Skip to content

Commit

Permalink
Added breach management to ship sheets
Browse files Browse the repository at this point in the history
  • Loading branch information
qkmaxware committed May 20, 2021
1 parent c0327a7 commit 04d984c
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ This fan site is intended for personal and non-profit use only and is not sponso
The code in this project is licensed under the following [LICENSE](LICENSE).

## Usage
For usage information check out the [wiki](https://github.com/qkmaxware/TrekSharp/wiki).
For usage information check out the [wiki](https://github.com/qkmaxware/TrekSharp/wiki).
For browser compatibility check out the [compatibility matrix](https://github.com/qkmaxware/TrekSharp/wiki/Compatibility).
48 changes: 48 additions & 0 deletions TrekSharp.AdventureTools/Shared/SystemsDrawer.razor
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,59 @@
<div class="w3-col s4 w3-white border-secondary w3-right-align elbow-right knee-right print-small">
@context?.Value
</div>
<div class="w3-small print-small">
<div class="no-print" style="display: inline-block">
<span class="typeface text-secondary">Breaches:</span>
<button class="no-lcars w3-button" style="padding: 4px;" @onclick=@(() => decrementBreaches(context))>-</button>
<button class="no-lcars w3-button" style="padding: 4px;" @onclick=@(() => incrementBreaches(context))>+</button>
</div>
<div style="display: inline-block">
@if(context.Breaches > 0) {
<span>&#9635;</span>
} else {
<span>&#9634;</span>
}
@if(context.Breaches > 1) {
<span>&#9635;</span>
} else {
<span>&#9634;</span>
}
@if(context.Breaches > 2) {
<span>&#9635;</span>
} else {
<span>&#9634;</span>
}
@if(context.Breaches > 3) {
<span>&#9635;</span>
} else {
<span>&#9634;</span>
}
@if(context.Breaches > 4) {
<span>&#9635;</span>
} else {
<span>&#9634;</span>
}
@if(context.Breaches > 5) {
<span>&#9635;</span>
} else {
<span>&#9634;</span>
}
</div>
</div>
</Template>
</Grid3x2Layout>

@code {

[Parameter]
public Systems Systems {get; set;}

private void decrementBreaches(SystemReference r) {
if (r.Breaches > 0) {
r.Breaches --;
}
}
private void incrementBreaches(SystemReference r) {
r.Breaches++;
}
}
2 changes: 1 addition & 1 deletion TrekSharp.AdventureTools/wwwroot/css/pdf.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
}

.print-small {
font-size: x-small;
font-size: x-small !important;
}

.print {
Expand Down
29 changes: 29 additions & 0 deletions TrekSharp/src/Ships.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,29 @@ public class SystemReference {
5 => "Weapons",
_ => null
};
public int Breaches {
get {
return Index switch {
0 => source.CommsBreaches,
1 => source.EnginesBreaches,
2 => source.StructureBreaches,
3 => source.ComputersBreaches,
4 => source.SensorsBreaches,
5 => source.WeaponsBreaches,
_ => 0
};
}
set {
switch (Index) {
case 0: source.CommsBreaches = value; break;
case 1: source.EnginesBreaches = value; break;
case 2: source.StructureBreaches = value; break;
case 3: source.ComputersBreaches = value; break;
case 4: source.SensorsBreaches = value; break;
case 5: source.WeaponsBreaches = value; break;
}
}
}
public int Index {get; private set;}
public int Value {
get => source[Index];
Expand Down Expand Up @@ -49,16 +72,22 @@ IEnumerator IEnumerable.GetEnumerator() {

public class Systems {
public int Comms {get; set;}
public int CommsBreaches {get; set;}
public SystemReference CommsReference => new SystemReference(this, 0);
public int Engines {get; set;}
public int EnginesBreaches {get; set;}
public SystemReference EnginesReference => new SystemReference(this, 1);
public int Structure {get; set;}
public int StructureBreaches {get; set;}
public SystemReference StructureReference => new SystemReference(this, 2);
public int Computers {get; set;}
public int ComputersBreaches {get; set;}
public SystemReference ComputersReference => new SystemReference(this, 3);
public int Sensors {get; set;}
public int SensorsBreaches {get; set;}
public SystemReference SensorsReference => new SystemReference(this, 4);
public int Weapons {get; set;}
public int WeaponsBreaches {get; set;}
public SystemReference WeaponsReference => new SystemReference(this, 5);

public int this[int index] {
Expand Down

0 comments on commit 04d984c

Please sign in to comment.