Skip to content

Commit

Permalink
More NPC types; Can export and import entire homebrew sources
Browse files Browse the repository at this point in the history
  • Loading branch information
qkmaxware committed May 18, 2021
1 parent c6b3ff8 commit 7b37e8b
Show file tree
Hide file tree
Showing 14 changed files with 2,137 additions and 24 deletions.
21 changes: 21 additions & 0 deletions TrekSharp.AdventureTools/Data/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,27 @@ public UserCustomData() {
Items = new List<Item>();
Spaceframes = new List<Spaceframe>();
}

public void Concat(UserCustomData data) {
if (data == null)
return;

this.Species = this.Species ?? new UserCustomSpecies();
this.NpcCharacterTypes = this.NpcCharacterTypes ?? new List<NpcCharacter>();
this.Items = this.Items ?? new List<Item>();
this.Spaceframes = this.Spaceframes ?? new List<Spaceframe>();

if (data.Species != null && data.Species.Definitions != null)
this.Species.Definitions.AddRange(data.Species.Definitions);
if (data.Species != null && data.Species.Talents != null)
this.Species.Talents.AddRange(data.Species.Talents);
if (data.NpcCharacterTypes != null)
this.NpcCharacterTypes.AddRange(data.NpcCharacterTypes);
if (data.Items != null)
this.Items.AddRange(data.Items);
if (data.Spaceframes != null)
this.Spaceframes.AddRange(data.Spaceframes);
}
}

public class Mission {
Expand Down
4 changes: 2 additions & 2 deletions TrekSharp.AdventureTools/Data/UserCreatedSpeciesRulebook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

namespace TrekSharp.AdventureTools {

public class UserCreatedSpeciesRulebook : IRulebook {
public class HomebrewRulebook : IRulebook {
private AppData data;
public UserCreatedSpeciesRulebook(AppData data) {
public HomebrewRulebook(AppData data) {
this.data = data;
}
public IEnumerable<CharacterTalent> Talents => data?.Custom?.Species?.Talents?.Cast<CharacterTalent>() ?? Enumerable.Empty<CharacterTalent>();
Expand Down
32 changes: 31 additions & 1 deletion TrekSharp.AdventureTools/Pages/CreateCustomData.razor
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,34 @@
<NavLink class="w3-button w3-block" href="new/custom/item" Match="NavLinkMatch.All">
Create Custom Item
</NavLink>
</LCARS>
<a class="w3-button w3-block" @onclick=openRawImporter>
Import Homebrew Sourcebook
</a>
</LCARS>

<AssetImporter
@ref="importer"
TItem="UserCustomData"
Title="Import Sourcebook"
OnLoad="onSourceLoaded"
/>

@code {

private AssetImporter<UserCustomData> importer;

private void openRawImporter() {
importer.Open();
}

private void onSourceLoaded(UserCustomData source) {
if (this.Data.Custom == null) {
this.Data.Custom = source;
return;
} else {
this.Data.Custom.Concat(source);
}
this.NavigationManager.NavigateTo("manage/custom");
}

}
2 changes: 1 addition & 1 deletion TrekSharp.AdventureTools/Pages/CreateNpcType.razor
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
private List<NpcCharacter> ExistingCharacters;

protected override void OnInitialized() {
books.AddRulebook("Homebrew", new UserCreatedSpeciesRulebook(Data));
books.AddRulebook("Homebrew", new HomebrewRulebook(Data));
ExistingCharacters = books.AllRulebooks.SelectMany(book => book.Value.NpcCharacters).ToList();
}

Expand Down
2 changes: 1 addition & 1 deletion TrekSharp.AdventureTools/Pages/EditCustomNpcType.razor
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
private IEnumerable<Species> AllSpeciesOptions => books.AllRulebooks.SelectMany(book => book.Value.Species);

protected override void OnInitialized() {
books.AddRulebook("Homebrew", new UserCreatedSpeciesRulebook(Data));
books.AddRulebook("Homebrew", new HomebrewRulebook(Data));
}

[Parameter] public string Id { get; set; }
Expand Down
16 changes: 16 additions & 0 deletions TrekSharp.AdventureTools/Pages/ManageCustom.razor
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
@page "/manage/custom"
@inherits Page

<PopoutTab Name="Actions" TabPosition=80>
<div class="lcars">
<div class="typeface text-secondary w3-border-bottom w3-large">
<b>Other</b>
</div>
<div class="w3-bar-block w3-padding">
<button class="w3-bar-item w3-margin-bottom" style="font-size: medium;" @onclick=exportAll>Export Sourcebook</button>
</div>
</div>
</PopoutTab>

<LCARS Title="CUSTOM SPECIES">
@if (Data.Custom != null && Data.Custom.Species != null && Data.Custom.Species.Definitions != null) {
<Col3Layout Items="Data.Custom.Species.Definitions">
Expand Down Expand Up @@ -124,6 +135,11 @@

@code {

private async Task exportAll() {
var source = this.Data.Custom;
await this.DownloadJson("homebrew.sourcebook", source);
}

ConfirmationDialog confirm;

private void confirmDeleteSpecies(CustomSpecies species) {
Expand Down
2 changes: 1 addition & 1 deletion TrekSharp.AdventureTools/Pages/ManageEncounter.razor
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@

@code {
protected override void OnInitialized() {
books.AddRulebook("Homebrew", new UserCreatedSpeciesRulebook(Data));
books.AddRulebook("Homebrew", new HomebrewRulebook(Data));
// Load last loaded guid automatically
if (!string.IsNullOrEmpty(lastGuid)) {
var guid_encounter = Data.Encounters.Where(enc => enc.GUID == lastGuid).FirstOrDefault();
Expand Down
2 changes: 1 addition & 1 deletion TrekSharp.AdventureTools/Shared/EquipmentDrawer.razor
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@

protected override void OnInitialized() {
RulebookContainer books = new RulebookContainer();
books.AddRulebook("Homebrew", new UserCreatedSpeciesRulebook(Data));
books.AddRulebook("Homebrew", new HomebrewRulebook(Data));
items = books.AllRulebooks.SelectMany(book => book.Value.Items).OrderBy((item) => item.Name).ToList();
}

Expand Down
2 changes: 1 addition & 1 deletion TrekSharp.AdventureTools/Shared/RulebookPicker.razor
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

protected override void OnInitialized() {
// Add the user created data to the rulebook picker
Rulebooks.AddRulebook("Homebrew", new UserCreatedSpeciesRulebook(data));
Rulebooks.AddRulebook("Homebrew", new HomebrewRulebook(data));
}

private void Toggle(string name) {
Expand Down
33 changes: 17 additions & 16 deletions TrekSharp/src/Rulebooks/Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1333,7 +1333,7 @@ List<Item> items
},
new List<NpcCharacter>() {
new NpcCharacter {
Name = "Minor Starfleet Conn Officer",
Name = "Human Starfleet Conn Officer",
BaseStress = 9,
Species = new Species{ Name="Human" },
Attributes = new Attributes {
Expand All @@ -1358,7 +1358,7 @@ List<Item> items
}
},
new NpcCharacter {
Name = "Minor Starfleet Security Officer",
Name = "Human Starfleet Security Officer",
BaseStress = 11,
Species = new Species{ Name="Human" },
Attributes = new Attributes {
Expand All @@ -1383,7 +1383,7 @@ List<Item> items
}
},
new NpcCharacter {
Name = "Minor Starfleet Engineer",
Name = "Human Starfleet Engineer",
BaseStress = 10,
Species = new Species{ Name="Human" },
Attributes = new Attributes {
Expand All @@ -1408,7 +1408,7 @@ List<Item> items
}
},
new NpcCharacter {
Name = "Minor Starfleet Science Officer",
Name = "Human Starfleet Science Officer",
BaseStress = 9,
Species = new Species{ Name="Human" },
Attributes = new Attributes {
Expand All @@ -1433,7 +1433,7 @@ List<Item> items
}
},
new NpcCharacter {
Name = "Notable Section 31 Operative",
Name = "Human Section 31 Operative",
BaseStress = 11,
Species = new Species{ Name="Human" },
Values = new List<string> {
Expand Down Expand Up @@ -1469,7 +1469,7 @@ List<Item> items
}
},
new NpcCharacter {
Name = "Minor Klingon Warrior",
Name = "Klingon Warrior",
BaseStress = 13,
Resistance = 1,
Species = new Species{ Name="Klingon" },
Expand Down Expand Up @@ -1500,7 +1500,7 @@ List<Item> items
}
},
new NpcCharacter {
Name = "Notable Klingon Warrior",
Name = "Veteran Klingon Warrior",
BaseStress = 14,
Resistance = 1,
Values = new List<string> {
Expand Down Expand Up @@ -1539,7 +1539,7 @@ List<Item> items
}
},
new NpcCharacter {
Name = "Minor Romulan Uhlan",
Name = "Romulan Uhlan",
BaseStress = 11,
Resistance = 0,
Species = new Species{ Name="Romulan" },
Expand Down Expand Up @@ -1570,7 +1570,7 @@ List<Item> items
}
},
new NpcCharacter {
Name = "Notable Romulan Centurion",
Name = "Romulan Centurion",
BaseStress = 11,
Resistance = 0,
Species = new Species{ Name="Romulan" },
Expand Down Expand Up @@ -1609,7 +1609,7 @@ List<Item> items
}
},
new NpcCharacter {
Name = "Minor Ferengi Menial",
Name = "Ferengi Menial",
BaseStress = 9,
Resistance = 0,
Species = new Species{ Name="Ferengi" },
Expand Down Expand Up @@ -1644,7 +1644,7 @@ List<Item> items
}
},
new NpcCharacter {
Name = "Minor Ferengi Salesman",
Name = "Ferengi Salesman",
BaseStress = 9,
Resistance = 0,
Species = new Species{ Name="Ferengi" },
Expand Down Expand Up @@ -1680,7 +1680,7 @@ List<Item> items
}
},
new NpcCharacter {
Name = "Minor Cardassian Soldier",
Name = "Cardassian Soldier",
BaseStress = 11,
Resistance = 1,
Species = new Species{ Name="Cardassian" },
Expand Down Expand Up @@ -1716,7 +1716,7 @@ List<Item> items
}
},
new NpcCharacter {
Name = "Notable Cardassian Glinn",
Name = "Cardassian Glinn",
BaseStress = 12,
Resistance = 1,
Species = new Species{ Name="Cardassian" },
Expand Down Expand Up @@ -1864,7 +1864,7 @@ List<Item> items
}
},
new NpcCharacter {
Name = "Minor Jem'Hadar Warrior",
Name = "Jem'Hadar Warrior",
BaseStress = 14,
Resistance = 2,
Species = new Species{ Name="Jem'Hadar" },
Expand Down Expand Up @@ -1899,7 +1899,7 @@ List<Item> items
}
},
new NpcCharacter {
Name = "Notable Jem'Hadar First",
Name = "Jem'Hadar First",
BaseStress = 14,
Resistance = 2,
Species = new Species{ Name="Jem'Hadar" },
Expand Down Expand Up @@ -1940,7 +1940,7 @@ List<Item> items
}
},
new NpcCharacter {
Name = "Notable Vorta Overseer",
Name = "Vorta Overseer",
BaseStress = 14,
Resistance = 2,
Species = new Species{ Name="Vorta" },
Expand Down Expand Up @@ -2559,6 +2559,7 @@ List<Item> items
new Item { Name = "Tricorder", Size = ItemSize.OneHanded },
new Item { Name = "Phaser Type 1", Size = ItemSize.OneHanded, DamageDice = 2, Qualities = new List<string>{ "Charge", "Hidden 1" } },
new Item { Name = "Unarmed Strike",Size = ItemSize.OneHanded, DamageDice = 1, Qualities = new List<string>{ "Knockdown", "Non-lethal" } },
new Item { Name = "Bludgeon", Size = ItemSize.OneHanded, DamageDice = 2, Qualities = new List<string>{ "Knockdown" } },
new Item { Name = "Knife", Size = ItemSize.OneHanded, DamageDice = 1, Qualities = new List<string>{ "Vicious 1", "Deadly", "Hidden 1" } },
new Item { Name = "Dagger", Size = ItemSize.OneHanded, DamageDice = 1, Qualities = new List<string>{ "Vicious 1", "Deadly", "Hidden 1" } },
new Item { Name = "D'k tahg Dagger", Size = ItemSize.OneHanded, DamageDice = 3, Qualities = new List<string>{ "Vicious 1" } },
Expand Down
Loading

0 comments on commit 7b37e8b

Please sign in to comment.