Skip to content

Commit

Permalink
Condition tracker
Browse files Browse the repository at this point in the history
  • Loading branch information
qkmaxware committed May 16, 2021
1 parent 8d3b406 commit 205be98
Show file tree
Hide file tree
Showing 23 changed files with 1,296 additions and 17 deletions.
2 changes: 1 addition & 1 deletion TrekSharp.AdventureTools/Pages/ManageLogs.razor
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
@if (count > 1) {
<h4>supplemental</h4>
}
<div class="w3-padding">
<div class="w3-padding" style="white-space: pre-line;">
@capture.Content
</div>
</div>
Expand Down
18 changes: 6 additions & 12 deletions TrekSharp.AdventureTools/Pages/ViewCharacterNpcSheet.razor
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
@inherits Page

@if (HasCharacter) {
<CharacterEditorPopoutTab Character=Player OnDelete=onConfirmDelete OnChange=StateHasChanged></CharacterEditorPopoutTab>
<CharacterConditionPopoutTab Character=Player></CharacterConditionPopoutTab>
<PrintNotification/>

<div class="w3-container no-print lcars" style="text-align: right;">
<button @onclick="confirmDelete" class="w3-red">Delete</button>
</div>

<div id="character-sheet" class="lcars">
<!-- Header -->
<div id="player-info" class="container">
Expand Down Expand Up @@ -161,21 +159,17 @@

public override string PageTitle => Player?.Name;

private void confirmDelete() {
confirm.Open($"Are you sure you want to delete the character '{this.Player.Name}'?", () => Delete());
}

private void createOrEditAvatar() {
NavigateToMini(this.Player);
}

public void Delete() {
if (HasCharacter) {
public void onConfirmDelete(Character character) {
if (character != null && character is NpcCharacter npc) {
if (ListId == "ally") {
Encounter?.AlliedInfrantry.Remove(this.Player);
Encounter?.AlliedInfrantry.Remove(npc);
}
else if (ListId == "enemy") {
Encounter?.EnemyInfantry.Remove(this.Player);
Encounter?.EnemyInfantry.Remove(npc);
}
NavigationManager.NavigateTo("manage/encounters");
}
Expand Down
1 change: 1 addition & 0 deletions TrekSharp.AdventureTools/Pages/ViewCharacterSheet.razor
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

@if (HasCharacter) {
<CharacterEditorPopoutTab Character=Player OnDelete=onConfirmDelete OnChange=StateHasChanged></CharacterEditorPopoutTab>
<CharacterConditionPopoutTab Character=Player></CharacterConditionPopoutTab>
<PrintNotification/>

<div id="character-sheet" class="lcars">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

@if (HasCharacter) {
<CharacterEditorPopoutTab Character=Player OnDelete=onConfirmDelete OnChange=StateHasChanged></CharacterEditorPopoutTab>
<CharacterConditionPopoutTab Character=Player></CharacterConditionPopoutTab>
<PrintNotification/>

<div id="character-sheet" class="lcars">
Expand Down
157 changes: 157 additions & 0 deletions TrekSharp.AdventureTools/Shared/CharacterConditionPopoutTab.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
<PopoutTab Name="Condition" TabPosition=168>
@if (HasCharacter) {
<div class="w3-bar-block w3-padding">
<ConditionDrawer
Name="Dying" IconUrl="assets/artwork/status effects/dying.svg"
Getter=@(() => Character.Condition.Dying) Setter=@((v) => Character.Condition.Dying = v)>
The character has suffered a lethal injury, if the character is not stablized with a <b>Difficulty 1, Daring + Medicine</b> first aid task, then they will die at the end of the scene.
</ConditionDrawer>
<ConditionDrawer
Name="Incapacitated" IconUrl="assets/artwork/status effects/unconcious.svg"
Getter=@(() => Character.Condition.Incapacitated) Setter=@((v) => Character.Condition.Incapacitated = v)>
An incapacitated character is unable to perform any minor actions or tasks until the end of the scene. A character that has taken any injury in combat is automatically incapacitated.
</ConditionDrawer>

<ConditionDrawer
Name="Grappled" IconUrl="assets/artwork/status effects/grappled.svg"
Getter=@(() => Character.Condition.Grappled) Setter=@((v) => Character.Condition.Grappled = v)>
A grappled character is incapable of taking any action other than to attack the grappling character with increased difficulty or to try and break free which is a <b>Difficulty 2, Fitness + Security,</b> task.
</ConditionDrawer>
<ConditionDrawer
Name="Prone" IconUrl="assets/artwork/status effects/fall.svg"
Getter=@(() => Character.Condition.Prone) Setter=@((v) => Character.Condition.Prone = v)>
A character that has been knocked prone must use a minor action to stand up.
</ConditionDrawer>
<ConditionDrawer
Name="Exhausted" IconUrl="assets/artwork/status effects/tired.svg"
Getter=@(() => Character.Condition.Exhausted) Setter=@((v) => Character.Condition.Exhausted = v)>
A character suffering from exhaustion has impaired mobility, increasing the difficulty of <b>Fitness</b> tasks by 1.
</ConditionDrawer>

<ConditionDrawer
Name="Dazed" IconUrl="assets/artwork/status effects/stunned.svg"
Getter=@(() => Character.Condition.Dazed) Setter=@((v) => Character.Condition.Dazed = v)>
A character that has been dazed has impaired concentration, increasing the difficulty of <b>Reason</b> tasks by 1.
</ConditionDrawer>
<ConditionDrawer
Name="Confused" IconUrl="assets/artwork/status effects/confused.svg"
Getter=@(() => Character.Condition.Confused) Setter=@((v) => Character.Condition.Confused = v)>
A character suffering from temporary or permanent blindness has impaired concentration, increasing the difficulty of <b>Reason</b> tasks by 1.
</ConditionDrawer>

<ConditionDrawer
Name="Shaky" IconUrl="assets/artwork/status effects/shaky.svg"
Getter=@(() => Character.Condition.Shaky) Setter=@((v) => Character.Condition.Shaky = v)>
A character who is shaky has impaired motor control, increasing the difficulty of <b>Control</b> tasks by 1.
</ConditionDrawer>

<ConditionDrawer
Name="Frightened" IconUrl="assets/artwork/status effects/scared.svg"
Getter=@(() => Character.Condition.Frightened) Setter=@((v) => Character.Condition.Frightened = v)>
A frightened character has impaired decision making, increasing the difficulty of <b>Daring</b> tasks by 1.
</ConditionDrawer>

<ConditionDrawer
Name="Blinded" IconUrl="assets/artwork/status effects/blind.svg"
Getter=@(() => Character.Condition.Blinded) Setter=@((v) => Character.Condition.Blinded = v)>
A character suffering from temporary or permanent blindness has impaired perception, increasing the difficulty of <b>Insight</b> tasks by 1.
</ConditionDrawer>
<ConditionDrawer
Name="Deafened" IconUrl="assets/artwork/status effects/deaf.svg"
Getter=@(() => Character.Condition.Deafened) Setter=@((v) => Character.Condition.Deafened = v)>
A character suffering from temporary or permanent deafness has impaired perception, increasing the difficulty of <b>Insight</b> tasks by 1.
</ConditionDrawer>

<ConditionDrawer
Name="Invisible" IconUrl="assets/artwork/status effects/invisible.svg"
Getter=@(() => Character.Condition.Invisible) Setter=@((v) => Character.Condition.Invisible = v)>
A character that is invisible will cause all tasks to observe, locate, or target the character to increase in difficulty.
</ConditionDrawer>

@if (Character.Condition.CustomFlags != null) {
foreach (var flag in Character.Condition.CustomFlags) {
var capture = flag;
<ConditionDrawer
Name=@capture.Name IconUrl="assets/artwork/species/Unknown.png"
Getter=@(() => capture.Toggled) Setter=@((v) => capture.Toggled = v)>
@capture.Description
<div class="w3-right-align">
<button class="w3-button noselect w3-large" @onclick=@(() => deleteCustom(capture))>&times;</button>
</div>
</ConditionDrawer>
}
}
<div class="w3-margin-top w3-margin-bottom w3-padding">
&nbsp;
</div>
<div class="w3-bar-item w3-row">
<div class="w3-col w3-right" style="width: 45px;">
<button class="w3-button noselect w3-large" style="transform: rotate(@(rotation)deg);" @onclick=toggleExpand>&#8250;</button>
</div>
<div class="w3-rest">
<span class="lcars">
<b class="text-secondary">
+ Custom Condition
</b>
</span>
</div>
</div>
<div>
@if (showCustomEffectDialog) {
<div class="lcars w3-border-left w3-border-right w3-border-bottom">
<div class="w3-row w3-padding">
<div class="hbar elbow-left knee-left w3-padding typeface secondary w3-col" style="width: 120px;">
<span>Name</span>
</div>
<div class="w3-rest" style="padding-left: 10px">
<input type="text" class="w3-input" style="font-size: medium;" @bind=customName placeholder="Condition Name"/>
</div>
</div>
<div class="w3-margin-left w3-margin-right">
<textarea @bind=customDescription class="text-primary typeface lcars-border-primary" style="width: 100%; resize: vertical; background-color: black;"></textarea>
</div>
<div class="w3-right-align">
<button @onclick=addCustom style="font-size: medium;">+ Condition</button>
</div>
</div>
}
</div>
</div>
}
</PopoutTab>

@code {
[Parameter] public Character Character {get; set;}
public bool HasCharacter => Character != null;

protected override void OnInitialized() {
if (HasCharacter && Character.Condition == null) {
Character.Condition = new StatusFlags();
}
}

private bool showCustomEffectDialog = false;
private int rotation => showCustomEffectDialog ? -90 : 90;
private void toggleExpand() {
showCustomEffectDialog = !showCustomEffectDialog;
}

private string customName;
private string customDescription;
private void addCustom() {
CustomFlag flag = new CustomFlag {
Name = customName,
Description = customDescription,
};
if (Character.Condition.CustomFlags == null) {
Character.Condition.CustomFlags = new List<CustomFlag>();
}
Character.Condition.CustomFlags.Add(flag);

customName = string.Empty;
customDescription = string.Empty;
}
private void deleteCustom(CustomFlag flag) {
Character.Condition.CustomFlags.Remove(flag);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@inherits AppComponentBase

<PopoutTab Name="Modify" TabPosition=80>
<PopoutTab Name="Actions" TabPosition=80>
<div class="lcars">
<div class="typeface text-secondary w3-border-bottom w3-large">
<b>Experience</b>
Expand Down
43 changes: 43 additions & 0 deletions TrekSharp.AdventureTools/Shared/ConditionDrawer.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<div class="w3-bar-item w3-border-bottom">
<input class="w3-check" type="checkbox" @bind=value> <img src="@IconUrl" width=32 height=32 style="object-fit: cover;"> <span>@Name</span>
@if (hasDescription) {
<button class="w3-button w3-right noselect w3-large" style="transform: rotate(@(rotation)deg);" @onclick=toggleExpand>&#8250;</button>
}
@if (isExpanded && hasDescription) {
<div class="w3-margin-left w3-padding">
@ChildContent
</div>
}
</div>

@code {
private bool isExpanded = false;
private int rotation => isExpanded ? -90 : 90;
private void toggleExpand() {
isExpanded = !isExpanded;
}

[Parameter] public string Name {get; set;}
[Parameter] public string IconUrl {get; set;}
[Parameter] public RenderFragment ChildContent {get; set;}

public bool hasDescription => ChildContent != null;

[Parameter] public Func<bool> Getter {get; set;}
[Parameter] public Action<bool> Setter {get; set;}

private bool value {
get {
if (Getter != null) {
return Getter();
} else {
return false;
}
}
set {
if (Setter != null) {
Setter(value);
}
}
}
}
2 changes: 1 addition & 1 deletion TrekSharp.AdventureTools/Shared/VesselEditorPopupTab.razor
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@inherits AppComponentBase

<PopoutTab Name="Modify" TabPosition=80>
<PopoutTab Name="Actions" TabPosition=80>
<div class="lcars">
<div class="typeface text-secondary w3-border-bottom w3-large">
<b>Experience</b>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 205be98

Please sign in to comment.