-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a sidebar that displays ship information.
- Loading branch information
1 parent
66fa286
commit 61a8dfa
Showing
19 changed files
with
87 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
namespace BlazorBattleship.Shared | ||
{ | ||
public struct Ship | ||
{ | ||
public (int x, int y) shipCoords; | ||
public int length; | ||
public int hp; | ||
public string name; | ||
|
||
public Ship(int length, int hp, string name, (int x, int y) coords) | ||
{ | ||
this.length = length; | ||
this.hp = hp; | ||
this.name = name; | ||
this.shipCoords = coords; | ||
} | ||
|
||
public bool IsDestroyed() | ||
{ | ||
return hp <= 0; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
@using BlazorBattleship.Shared | ||
|
||
@code { | ||
[Parameter] | ||
public Ship[]? Ships { get; set; } // Receiving the ships array from the parent component | ||
} | ||
|
||
<div class="sidebar"> | ||
<h3>Your Ships</h3> | ||
<ul> | ||
@if(Ships != null) | ||
{ | ||
@foreach (var ship in Ships) | ||
{ | ||
<li>@ship.name: @ship.hp HP @if (ship.IsDestroyed()) | ||
{ | ||
<strong>(Destroyed)</strong> | ||
}</li> | ||
} | ||
} | ||
</ul> | ||
</div> |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
BlazorBattleship/obj/Debug/net6.0/BlazorBattleship.csproj.CoreCompileInputs.cache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
08879e2c620f8ba2848b93428aab9c6e21415272 | ||
b68e3f88d7f0de9d7f14c16fb8f73c37973e2b5a |
Binary file not shown.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file modified
BIN
+512 Bytes
(100%)
BlazorBattleship/obj/Debug/net6.0/ref/BlazorBattleship.dll
Binary file not shown.
Binary file modified
BIN
+512 Bytes
(100%)
BlazorBattleship/obj/Debug/net6.0/refint/BlazorBattleship.dll
Binary file not shown.