tmp
Some checks failed
Main Build Process / Build & Test (pull_request) Failing after 1m15s

This commit is contained in:
2026-02-23 22:58:44 +01:00
parent 5ef3be8cc8
commit c2b9d0b3c2
22 changed files with 245 additions and 71 deletions

View File

@@ -0,0 +1,3 @@
<div class="rootTile">
@Building.Name
</div>

View File

@@ -0,0 +1,11 @@
using LittleTown.Core;
using Microsoft.AspNetCore.Components;
namespace LittleTown.Blazor.Client.Components
{
public partial class AvailibleBuildingTile
{
[Parameter, EditorRequired]
public Building Building { get; set; }
}
}

View File

@@ -0,0 +1,4 @@
root {
width: 100%;
height: 100%;
}

View File

@@ -1,11 +1,13 @@
<div class="board">
<div class="terrain">
@foreach (var row in MatchViewModel.Rows)
@for(int y = Board.Height-1; y >= 0; y--)
{
<div class="terrain-row">
@foreach (var cell in row)
{
<span class="terrain-cell">@cell</span>
@for (int x = 0; x < Board.Width; x++)
{
<span class="terrain-cell">
<TerrainCell Tile="Board.GetTile(x,y)" />
</span>
}
</div>
}
@@ -35,7 +37,10 @@
@for (int i = 0; i < 6; i++)
{
<div class="building">
<div>building @i</div>
@if (!Match.BuildingInfos.ElementAt(i).IsBuilt)
{
<AvailibleBuildingTile Building="Match.BuildingInfos.ElementAt(i).Building"></AvailibleBuildingTile>
}
</div>
}
</div>
@@ -45,7 +50,10 @@
@for (int i = 0; i < 6; i++)
{
<div class="building">
<div>building @(i+6)</div>
@if (!Match.BuildingInfos.ElementAt(i+6).IsBuilt)
{
<AvailibleBuildingTile Building="Match.BuildingInfos.ElementAt(i+6).Building"></AvailibleBuildingTile>
}
</div>
}
</div>

View File

@@ -1,11 +1,23 @@
using LittleTown.Blazor.Client.ViewModels;
using LittleTown.Core;
using LittleTown.Core.Ports;
using Microsoft.AspNetCore.Components;
namespace LittleTown.Blazor.Client.Components
{
public partial class MatchBoard
{
[Inject]
private IStaticDataGetter StaticDataGetter { get; set; } = default!;
[Parameter, EditorRequired]
public MatchViewModel MatchViewModel { get; init; }
public Core.Match Match { get; init; }
public Board Board { get; private set; }
protected override void OnParametersSet()
{
Board = StaticDataGetter.GetBoard(1);
}
}
}

View File

@@ -0,0 +1,5 @@
<div class="cell-root @CssTileType">
<h3>@Tile.ResourceType</h3>
</div>

View File

@@ -0,0 +1,28 @@
using LittleTown.Core;
using LittleTown.Core.Enums;
using Microsoft.AspNetCore.Components;
namespace LittleTown.Blazor.Client.Components
{
public partial class TerrainCell
{
[Parameter, EditorRequired]
public Tile Tile { get; init; }
private string CssTileType { get; set; } = string.Empty;
protected override void OnInitialized()
{
CssTileType = Tile.ResourceType switch
{
ResourceType.None => "",
ResourceType.Rock => "rock",
ResourceType.Wood => "forest",
ResourceType.Fish => "lake",
ResourceType.Cereal => "",
ResourceType.Piece => "",
_ => string.Empty
};
}
}
}

View File

@@ -0,0 +1,18 @@
.cell-root {
width: 100%;
height: 100%;
}
.rock {
background-color: gray;
}
.lake {
background-color: blue;
}
.forest
{
background-color: green;
}

View File

@@ -3,6 +3,6 @@
<PageTitle>Match</PageTitle>
<div class="board">
<MatchBoard MatchViewModel="MatchViewModel" />
<MatchBoard Match="match"/>
</div>

View File

@@ -1,16 +1,21 @@
using LittleTown.Blazor.Client.Services;
using LittleTown.Blazor.Client.ViewModels;
using Microsoft.AspNetCore.Components;
namespace LittleTown.Blazor.Client.Pages;
public partial class Match(IMatchService matchServices)
{
public MatchViewModel MatchViewModel { get; private set; }
Core.Match match;
public override Task SetParametersAsync(ParameterView parameters)
public async override Task SetParametersAsync(ParameterView parameters)
{
MatchViewModel = new MatchViewModel(matchServices.GetMatch());
return base.SetParametersAsync(parameters);
match = matchServices.GetMatch();
match.AddPlayer("Andre");
match.AddPlayer("Maelie");
match.AddPlayer("Liam");
await match.Init();
await base.SetParametersAsync(parameters);
}
}

View File

@@ -48,21 +48,33 @@ public class WasmStaticDataGetter : IStaticDataGetter
}
/// <inheritdoc/>
public ICollection<Building> GetBuildings()
public async Task<ICollection<Building>> GetBuildingsAsync()
{
InitializeAsync().GetAwaiter().GetResult();
List<Building> buildings = JsonSerializer.Deserialize<List<Building>>(_buildingData)
await InitializeAsync();
List<Building> buildings = JsonSerializer.Deserialize<List<Building>>(_buildingData)
?? throw new JsonException("Cannot deserialize Buildings");
return buildings;
}
/// <inheritdoc/>
public ICollection<Building> GetBuildings()
{
throw new NotImplementedException("Use the asynchronous version of GetBuildings for WebAssembly.");
}
/// <inheritdoc/>
public ICollection<Objective> GetObjectives()
{
InitializeAsync().GetAwaiter().GetResult();
List<Objective> objectives = JsonSerializer.Deserialize<List<Objective>>(_objectivesData)
throw new NotImplementedException("Use the asynchronous version of GetObjectives for WebAssembly.");
}
/// <inheritdoc/>
public async Task<ICollection<Objective>> GetObjectivesAsync()
{
await InitializeAsync();
List<Objective> objectives = JsonSerializer.Deserialize<List<Objective>>(_objectivesData)
?? throw new JsonException("Cannot deserialize Objectives");
return objectives;
}

View File

@@ -1,19 +0,0 @@
using LittleTown.Core;
namespace LittleTown.Blazor.Client.ViewModels;
public class MatchViewModel(Match match)
{
public List<List<int>> Rows
{
get
{
List<List<int>> rows = new List<List<int>>();
for(int i = 0; i < 6; i++)
{
rows.Add(Enumerable.Range(i * 6, 9).ToList());
}
return rows;
}
}
}

View File

@@ -1,4 +1,4 @@
@inherits LayoutComponentBase
@inherits LayoutComponentBase
<div class="page">
<div class="sidebar">
@@ -6,13 +6,7 @@
</div>
<main>
<div class="top-row px-4">
<a href="https://learn.microsoft.com/aspnet/core/" target="_blank">About</a>
</div>
<article class="content px-4">
@Body
</article>
@Body
</main>
</div>