Skip to content

Commit

Permalink
Added equipment management system; Changes to how items work
Browse files Browse the repository at this point in the history
  • Loading branch information
qkmaxware committed Apr 28, 2021
1 parent e5c0076 commit fbe8150
Show file tree
Hide file tree
Showing 25 changed files with 302 additions and 39 deletions.
5 changes: 4 additions & 1 deletion TrekSharp.AdventureTools/Data/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ public UserCustomSpecies() {

public class UserCustomData {
public UserCustomSpecies Species {get; set;}
public List<NpcCharacter> NpcCharacterTypes {get; set;} = new List<NpcCharacter>();
public List<NpcCharacter> NpcCharacterTypes {get; set;}
public List<Item> Items {get; set;}

public UserCustomData() {
Species = new UserCustomSpecies();
NpcCharacterTypes = new List<NpcCharacter>();
Items = new List<Item>();
}
}

Expand Down
16 changes: 16 additions & 0 deletions TrekSharp.AdventureTools/Pages/CreateCustomData.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@page "/new/custom"

<LCARS Title="CUSTOM DATA">
<div class="w3-panel typeface">
Create custom resources for use within your own campaigns where the species, items, or npc types provided in the official rulebooks do not provide what you require.
</div>
<NavLink class="w3-button w3-block" href="new/custom/species" Match="NavLinkMatch.All">
Custom Species
</NavLink>
<NavLink class="w3-button w3-block" href="new/custom/npc" Match="NavLinkMatch.All">
Custom NPC Type
</NavLink>
<NavLink class="w3-button w3-block" href="new/custom/item" Match="NavLinkMatch.All">
Custom Item
</NavLink>
</LCARS>
110 changes: 110 additions & 0 deletions TrekSharp.AdventureTools/Pages/CreateItem.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
@page "/new/custom/item"
@inherits AppComponentBase

<LCARS Title="NEW ITEM">
<div class="w3-panel typeface">
This tool will allow you to create custom items which players can collect and use throughout a campaign.
</div>
<div class="row">
<div class="hbar elbow-left knee-left" style="width: 32px;"></div>
<span class="spacer typeface text-secondary w3-large">
DETAILS
</span>
<div class="hbar row-fill elbow-right knee-right"></div>
</div>
<div>
<div class="w3-row w3-padding">
<button class="w3-col s4 w3-button @(IsClothing ? "w3-blue" : "w3-black")" style="border-radius: 0;" @onclick=@(() => makeClothing())>Clothing</button>
<button class="w3-col s4 w3-button @(IsTool ? "w3-blue" : "w3-black")" style="border-radius: 0;" @onclick=@(() => makeTool())>Tool</button>
<button class="w3-col s4 w3-button @(IsWeapon ? "w3-blue" : "w3-black")" style="border-radius: 0;" @onclick=@(() => makeWeapon())>Weapon</button>
</div>
<div class="row w3-padding">
<span class="hbar elbow-left knee-left w3-padding">Name</span>
<span class="hbar row-fill row" style="margin-left: 10px;">
<input type="text" class="w3-padding w3-input" @bind="item.Name"/>
</span>
</div>
@if (!IsClothing) {
<div class="row w3-padding">
<span class="hbar elbow-left knee-left w3-padding">Size</span>
<span class="hbar row-fill row" style="margin-left: 10px;">
<select class="w3-padding w3-input lcars-border-primary" style="background-color:black;" @bind=size>
@foreach (var item in Enum.GetValues(typeof(ItemSize))) {
<option>@item?.ToString()</option>
}
</select>
</span>
</div>
}
@if (IsWeapon) {
<div class="row w3-padding">
<span class="hbar elbow-left knee-left w3-padding">Damage Rating</span>
<span class="hbar row-fill row" style="margin-left: 10px;">
<input type="text" class="w3-padding w3-input" @bind="item.DamageDice"/>
</span>
</div>
}
</div>
<div class="row">
<div class="hbar elbow-left knee-left" style="width: 32px;"></div>
<span class="spacer typeface text-secondary w3-large">
QUALITIES
</span>
<div class="hbar row-fill elbow-right knee-right" style="margin-right: 10px;"></div>
</div>
<div>
<StringEditor Items=item.Qualities></StringEditor>
<div class="w3-row w3-padding">
<div class="w3-half w3-left-align">
<button class="w3-red" @onclick=@(() => { if (item.Qualities.Count > 0) { item.Qualities.RemoveAt(item.Qualities.Count - 1); } })>-</button>
</div>
<div class="w3-half w3-right-align">
<button class="w3-blue" @onclick=@(() => item.Qualities.Add(string.Empty))>+</button>
</div>
</div>
</div>
<div class="w3-padding w3-right-align">
<button class="w3-blue" @onclick=save>Save</button>
</div>
</LCARS>

@code {
private Item item = new Item{};

private string size {
get => item.Size.ToString();
set {
item.Size = Enum.Parse<ItemSize>(value);
}
}
private bool IsClothing => item.Size == ItemSize.Worn && !IsWeapon;
private bool IsTool => item.Size != ItemSize.Worn && !IsWeapon;
private bool IsWeapon => item.DamageDice.HasValue;


private void makeClothing() {
item.DamageDice = null;
item.Size = ItemSize.Worn;
}

private void makeTool() {
item.DamageDice = null;
item.Size = ItemSize.OneHanded;
}

private void makeWeapon() {
item.DamageDice = 0;
item.Size = ItemSize.OneHanded;
}

private void save() {
if (Data.Custom == null)
Data.Custom = new UserCustomData();
if (Data.Custom.Items == null)
Data.Custom.Items = new List<Item>();

Data.Custom.Items.Add(item);
item = new Item();
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
@@ -1,4 +1,4 @@
@page "/new/npc"
@page "/new/custom/npc"
@using Data
@inherits AppComponentBase

Expand Down
2 changes: 1 addition & 1 deletion TrekSharp.AdventureTools/Pages/CreateSpecies.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@page "/new/species"
@page "/new/custom/species"
@inherits AppComponentBase

<LCARS Title="NEW SPECIES">
Expand Down
30 changes: 30 additions & 0 deletions TrekSharp.AdventureTools/Pages/ManageCustom.razor
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,25 @@
}
</LCARS>

<LCARS Title="CUSTOM ITEMS">
@if (Data.Custom != null && Data.Custom.Items != null) {
<Col3Layout Items="Data.Custom.Items">
<Template>
<div>
<div class="row">
<div class="hbar elbow-left knee-left" style="width: 32px;"></div>
<div class="typeface" style="margin-left: 10px; margin-right: 10px;">
@context.Name
<button class="w3-red" @onclick=@(() => confirmDeleteItem(context))>&times;</button>
</div>
<div class="hbar row-fill elbow-right knee-right"></div>
</div>
</div>
</Template>
</Col3Layout>
}
</LCARS>

<ConfirmationDialog @ref="confirm">
</ConfirmationDialog>

Expand Down Expand Up @@ -80,5 +99,16 @@
StateHasChanged();
}

private void confirmDeleteItem(Item character) {
confirm.Open($"Are you sure you want to delete the item '{character.Name}'?", () => deleteItem(character));
}

private void deleteItem(Item character) {
if (Data.Custom != null && Data.Custom.Items != null) {
Data.Custom.Items.Remove(character);
}
StateHasChanged();
}


}
12 changes: 6 additions & 6 deletions TrekSharp.AdventureTools/Pages/ManageEncounter.razor
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
</div>
<div class="hbar row-fill elbow-right knee-right"></div>
</div>
<div class="w3-right-align">
<div class="w3-right-align w3-padding">
<button class="w3-small" @onclick=@(() => NavigateToPlayerVessel(capture))>view</button>
</div>
</div>
Expand All @@ -143,7 +143,7 @@
</div>
<div class="hbar row-fill elbow-right knee-right"></div>
</div>
<div class="w3-right-align">
<div class="w3-right-align w3-padding">
<button class="w3-small" @onclick=@(() => NavigateToAlliedNpcVessel(encounter, capture))>view</button>
<button class="w3-small w3-red" @onclick=@(() => deleteAllyShip(capture))>x</button>
</div>
Expand All @@ -170,7 +170,7 @@
</div>
<div class="hbar row-fill elbow-right knee-right"></div>
</div>
<div class="w3-right-align">
<div class="w3-right-align w3-padding">
<button class="w3-small" @onclick=@(() => NavigateToEnemyNpcVessel(encounter, capture))>view</button>
<button class="w3-small w3-red" @onclick=@(() => deleteEnemyShip(capture))>x</button>
</div>
Expand Down Expand Up @@ -210,7 +210,7 @@
<div class="w3-padding">
Stress <input type="number" style="width: 32%;" @bind=capture.UsedStress/> / @capture.TotalStress
</div>
<div class="w3-right-align">
<div class="w3-right-align w3-padding">
<button class="w3-small" @onclick=@(() => NavigateToPlayerCharacter(capture))>view</button>
</div>
</div>
Expand All @@ -237,7 +237,7 @@
<div class="w3-padding">
Stress <input type="number" style="width: 32%;" @bind=capture.UsedStress/> / @capture.TotalStress
</div>
<div class="w3-right-align">
<div class="w3-right-align w3-padding">
<button class="w3-small" @onclick=@(() => NavigateToAlliedNpc(encounter, capture))>view</button>
<button class="w3-small w3-red" @onclick=@(() => deleteAlly(capture))>x</button>
</div>
Expand Down Expand Up @@ -267,7 +267,7 @@
<div class="w3-padding">
Stress <input type="number" style="width: 32%;" @bind=capture.UsedStress/> / @capture.TotalStress
</div>
<div class="w3-right-align">
<div class="w3-right-align w3-padding">
<button class="w3-small" @onclick=@(() => NavigateToEnemyNpc(encounter, capture))>view</button>
<button class="w3-small w3-red" @onclick=@(() => deleteEnemy(capture))>x</button>
</div>
Expand Down
2 changes: 1 addition & 1 deletion TrekSharp.AdventureTools/Pages/ManageShips.razor
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
OnLoad="onShipLoaded"
/>

<RawShipCreator @ref="raw"></RawShipCreator>
<RawShipCreator @ref="raw" OnImport=@(() => StateHasChanged())></RawShipCreator>

@code {
private RawShipCreator raw;
Expand Down
2 changes: 1 addition & 1 deletion TrekSharp.AdventureTools/Pages/ViewCharacterNpcSheet.razor
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<InjuryDrawer Player="Player"/>
<AttributeDrawer Attributes="Player.Attributes"/>
<DisciplineDrawer Disciplines="Player.Disciplines"/>
<EquipmentDrawer Player="Player"/>
<EquipmentDrawer Player="Player" AllowEdit=true/>
</Left>
<Right>
<ListDrawer Title="VALUES" List="Player.Values"/>
Expand Down
2 changes: 1 addition & 1 deletion TrekSharp.AdventureTools/Pages/ViewCharacterSheet.razor
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
<InjuryDrawer Player="Player"/>
<AttributeDrawer Attributes="Player.Attributes"/>
<DisciplineDrawer Disciplines="Player.Disciplines"/>
<EquipmentDrawer Player="Player"/>
<EquipmentDrawer Player="Player" AllowEdit=true/>
</Left>
<Right>
<ValueDrawer Values="Player.Values"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<InjuryDrawer Player="Player"/>
<AttributeDrawer Attributes="Player.Attributes"/>
<DisciplineDrawer Disciplines="Player.Disciplines"/>
<EquipmentDrawer Player="Player"/>
<EquipmentDrawer Player="Player" AllowEdit=true/>
</Left>
<Right>
<FocusDrawer Focuses="Player.Focuses"/>
Expand Down
2 changes: 1 addition & 1 deletion TrekSharp.AdventureTools/Shared/CrewSupportDrawer.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="w3-margin-bottom">
<div class="w3-margin-bottom no-split">
<div class="row w3-margin-bottom">
<div class="hbar elbow-left knee-left" style="width: 32px;"></div>
<div class="typeface" style="margin-left: 10px; margin-right: 10px;">
Expand Down
53 changes: 46 additions & 7 deletions TrekSharp.AdventureTools/Shared/EquipmentDrawer.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<div class="w3-margin-bottom">
@using Data
@inherits AppComponentBase

<div class="w3-margin-bottom no-split">
<div class="row w3-margin-bottom">
<div class="hbar elbow-left knee-left" style="width: 32px;"></div>
<div class="typeface" style="margin-left: 10px; margin-right: 10px;">
Expand All @@ -10,27 +13,63 @@
<ul class="w3-ul w3-small">
@if (Player != null && Player.Equipment != null) {
foreach (var item in Player.Equipment) {
var capture = item;
<li>
@item.Name
@if(item.Qualities != null) {
<span class="w3-button no-print" @onclick=@(() => removeItem(capture))>&times;</span>
@capture.Name
@if(capture.Qualities != null && capture.Qualities.Count > 0) {
<small>(@string.Join(',', item.Qualities))</small>
}
@if (item.UsageDice.HasValue) {
@if (item.DamageDice.HasValue && item.DamageDice.Value != 0) {
<span class="w3-right">
@(item.UsageDice.Value + Player.BonusDamageDice)
@(item.DamageDice.Value + Player.BonusDamageDice)
<img src="assets/challenge-effect.png" width=12 height=12 />
</span>
}
@if(AllowEdit) {

}
</li>
}
}
</ul>
@if(AllowEdit) {
<div class="no-print w3-right-align">
<button @onclick=@(() => itemList?.Open())>+</button>
</div>
}
</div>
</div>

<AssetAddList
@ref=itemList
Title="Give Item"
Store=items
OnAdd=onAddItem
>
</AssetAddList>

@code {

[Parameter]
public Character Player {get; set;}
private AssetAddList<Item> itemList;
private List<Item> items;

[Parameter] public Character Player {get; set;}
[Parameter] public bool AllowEdit {get; set;} = false;

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

private void removeItem(Item item) {
Player.Equipment.Remove(item);
StateHasChanged();
}
private void onAddItem(Item item) {
Player.Equipment.Add(item);
StateHasChanged();
}

}
2 changes: 1 addition & 1 deletion TrekSharp.AdventureTools/Shared/FocusDrawer.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="w3-margin-bottom">
<div class="w3-margin-bottom no-split">
<div class="row w3-margin-bottom">
<div class="hbar elbow-left knee-left" style="width: 32px;"></div>
<div class="typeface" style="margin-left: 10px; margin-right: 10px;">
Expand Down
2 changes: 1 addition & 1 deletion TrekSharp.AdventureTools/Shared/InjuryDrawer.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="w3-margin-bottom">
<div class="w3-margin-bottom no-split">
<div class="row w3-margin-bottom">
<div class="hbar elbow-left knee-left" style="width: 32px;"></div>
<div class="typeface" style="margin-left: 10px; margin-right: 10px;">
Expand Down
Loading

0 comments on commit fbe8150

Please sign in to comment.