Skip to content

Commit

Permalink
Merge pull request #69 from pollubnet/equipment-component
Browse files Browse the repository at this point in the history
Equipment component
  • Loading branch information
Barsol6 authored May 27, 2024
2 parents 39c4797 + 73f2750 commit b702f20
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 36 deletions.
1 change: 1 addition & 0 deletions Server/Components/Layout/GameLayout.razor
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<HeadContent>
<link rel="stylesheet" href="css/game.css">
<link rel="stylesheet" href="css/items.css">
</HeadContent>

@Body
Expand Down
35 changes: 1 addition & 34 deletions Server/Components/Pages/GamePage.razor
Original file line number Diff line number Diff line change
Expand Up @@ -40,40 +40,7 @@
</div>
</div>
</div>
<table class="equipmentTable">
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>

</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>

</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>

</tr>

</table>
<EquipmentTable Equipment="@_equipment" />
</div>

</div>
Expand Down
53 changes: 53 additions & 0 deletions Server/Components/UI/EquipmentTable.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
@using Fracture.Server.Components.UI
@using Fracture.Server.Modules.Items.Models
@using Fracture.Server.Modules.Items.Services
@using System.Collections.ObjectModel

@rendermode InteractiveServer

<table class="equipmentTable">
<tr>
@for (int i = 0; i < 3; i++)
{
if (i < Equipment.Count)
{
<td><div class="@ToCss(Equipment[i].Name)">@Equipment[i].Name</div></td>
}
else
{
<td></td>
}
}
</tr>

<tr>
@for (int i = 3; i < 6; i++)
{
if (i < Equipment.Count)
{
<td><div class="@ToCss(Equipment[i].Name)">@Equipment[i].Name</div></td>
}
else
{
<td></td>
}
}
</tr>


</table>

@code {
[Parameter] public required ObservableCollection<Item> Equipment { get; set; }

protected override void OnInitialized()
{
Equipment.CollectionChanged += (sender, e) => StateHasChanged();
}

private string ToCss(string name)
{
var css = name.Split(' ').Select(x => "item-" + x.ToLower());
return string.Join(" ", css);
}
}
3 changes: 3 additions & 0 deletions Server/Fracture.Server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>16f71bc9-60c6-466f-af95-a2818674e57c</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<_ContentIncludedByDefault Remove="wwwroot\css\items.css" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Markov" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.1" />
Expand Down
4 changes: 2 additions & 2 deletions Server/wwwroot/css/game.css
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,8 @@ body {

.equipmentTable tr td {
border: #000 3px solid;
width: 60px;
height: 60px;
width: 100px;
height: 100px;
background-color: rgb(222, 222, 255);
}

Expand Down
11 changes: 11 additions & 0 deletions Server/wwwroot/css/items.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.item-reliable {
filter: drop-shadow(16px 16px 20px red) invert(75%);
}

.item-toxic {
filter: drop-shadow(16px 16px 20px green);
}

.item-poisoned {
font-family: Webdings;
}

0 comments on commit b702f20

Please sign in to comment.