Compare commits
2 Commits
renovate/s
...
addingBuil
| Author | SHA1 | Date | |
|---|---|---|---|
| c2b9d0b3c2 | |||
| 5ef3be8cc8 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -16,4 +16,5 @@ bin
|
|||||||
obj
|
obj
|
||||||
report
|
report
|
||||||
tools/
|
tools/
|
||||||
TestResults
|
TestResults
|
||||||
|
/src/.vs
|
||||||
|
|||||||
6
src/LittleTown.Api/LittleTown.Api.csproj.user
Normal file
6
src/LittleTown.Api/LittleTown.Api.csproj.user
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<ActiveDebugProfile>https</ActiveDebugProfile>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
||||||
@@ -23,4 +23,4 @@ app.MapGet("/helloWorld", () =>
|
|||||||
.WithName("HelloWorld")
|
.WithName("HelloWorld")
|
||||||
.WithOpenApi();
|
.WithOpenApi();
|
||||||
|
|
||||||
app.Run();
|
await app.RunAsync();
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
<div class="rootTile">
|
||||||
|
@Building.Name
|
||||||
|
</div>
|
||||||
@@ -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; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
root {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
<div class="board">
|
||||||
|
<div class="terrain">
|
||||||
|
@for(int y = Board.Height-1; y >= 0; y--)
|
||||||
|
{
|
||||||
|
<div class="terrain-row">
|
||||||
|
@for (int x = 0; x < Board.Width; x++)
|
||||||
|
{
|
||||||
|
<span class="terrain-cell">
|
||||||
|
<TerrainCell Tile="Board.GetTile(x,y)" />
|
||||||
|
</span>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
<div class="footer">
|
||||||
|
<div class="topScore">
|
||||||
|
@for(int i = 0; i < 25; i++)
|
||||||
|
{
|
||||||
|
<div class="scoreItem">@i</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
<div class="centerFooter">
|
||||||
|
<div class="leftScore">
|
||||||
|
@for (int i = 59; i >= 55; i--)
|
||||||
|
{
|
||||||
|
<div class="scoreItem">@i</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
<div class="infos">
|
||||||
|
<div class="infos-row">
|
||||||
|
<div class="turns">
|
||||||
|
@for(int i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
<div class="turn">@i</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
@for (int i = 0; i < 6; i++)
|
||||||
|
{
|
||||||
|
<div class="building">
|
||||||
|
@if (!Match.BuildingInfos.ElementAt(i).IsBuilt)
|
||||||
|
{
|
||||||
|
<AvailibleBuildingTile Building="Match.BuildingInfos.ElementAt(i).Building"></AvailibleBuildingTile>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
<div class="infos-row">
|
||||||
|
<div class="construction">constructions</div>
|
||||||
|
<div class="fields">fields</div>
|
||||||
|
@for (int i = 0; i < 6; i++)
|
||||||
|
{
|
||||||
|
<div class="building">
|
||||||
|
@if (!Match.BuildingInfos.ElementAt(i+6).IsBuilt)
|
||||||
|
{
|
||||||
|
<AvailibleBuildingTile Building="Match.BuildingInfos.ElementAt(i+6).Building"></AvailibleBuildingTile>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="rightScore">
|
||||||
|
@for (int i = 25; i < 30; i++)
|
||||||
|
{
|
||||||
|
<div class="scoreItem">@i</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="bottomScore">
|
||||||
|
@for (int i = 54; i >= 30; i--)
|
||||||
|
{
|
||||||
|
<div class="scoreItem">@i</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
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 Core.Match Match { get; init; }
|
||||||
|
|
||||||
|
public Board Board { get; private set; }
|
||||||
|
|
||||||
|
protected override void OnParametersSet()
|
||||||
|
{
|
||||||
|
Board = StaticDataGetter.GetBoard(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,110 @@
|
|||||||
|
.board {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
.terrain {
|
||||||
|
width: 100%;
|
||||||
|
background-color: red;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.terrain-row {
|
||||||
|
display: grid;
|
||||||
|
grid-auto-flow: column;
|
||||||
|
grid-auto-columns: 1fr; /* toutes les cellules même largeur */
|
||||||
|
}
|
||||||
|
|
||||||
|
.terrain-cell {
|
||||||
|
aspect-ratio: 1 / 1; /* largeur = hauteur */
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
border: 1px solid black;
|
||||||
|
}
|
||||||
|
.footer {
|
||||||
|
width: 100%;
|
||||||
|
background-color: gray;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.topScore {
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bottomScore {
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
}
|
||||||
|
|
||||||
|
.centerFooter{
|
||||||
|
flex:5;
|
||||||
|
display: flex;
|
||||||
|
flex-direction:row;
|
||||||
|
}
|
||||||
|
.scoreItem {
|
||||||
|
flex: 1;
|
||||||
|
border: 1px solid;
|
||||||
|
aspect-ratio: 1 / 1;
|
||||||
|
}
|
||||||
|
.leftScore {
|
||||||
|
flex:1;
|
||||||
|
display:flex;
|
||||||
|
flex-direction:column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rightScore {
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.infos {
|
||||||
|
flex:23;
|
||||||
|
display: flex;
|
||||||
|
flex-wrap:wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.building {
|
||||||
|
height: 100%;
|
||||||
|
aspect-ratio: 1 / 1;
|
||||||
|
flex: 0 0 auto;
|
||||||
|
background: lightblue;
|
||||||
|
border: 1px solid black;
|
||||||
|
}
|
||||||
|
|
||||||
|
.turns {
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
}
|
||||||
|
|
||||||
|
.turn {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.infos-row{
|
||||||
|
height:50%;
|
||||||
|
width:100%;
|
||||||
|
background-color:blue;
|
||||||
|
display:flex;
|
||||||
|
flex-direction:row;
|
||||||
|
}
|
||||||
|
|
||||||
|
.construction {
|
||||||
|
flex:1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fields {
|
||||||
|
height: 100%;
|
||||||
|
aspect-ratio: 1 / 1; /* largeur = hauteur */
|
||||||
|
flex: 0 0 auto;
|
||||||
|
background: lightblue;
|
||||||
|
border: 1px solid black;
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<div class="cell-root @CssTileType">
|
||||||
|
<h3>@Tile.ResourceType</h3>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
@@ -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
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
.cell-root {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rock {
|
||||||
|
background-color: gray;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lake {
|
||||||
|
background-color: blue;
|
||||||
|
}
|
||||||
|
|
||||||
|
.forest
|
||||||
|
{
|
||||||
|
background-color: green;
|
||||||
|
}
|
||||||
@@ -13,4 +13,9 @@
|
|||||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="10.0.2" />
|
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="10.0.2" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\LittleTown.Core\LittleTown.Core.csproj" />
|
||||||
|
<ProjectReference Include="..\..\LittleTown.StaticDataAccess\LittleTown.StaticDataAccess.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
@page "/match"
|
||||||
|
@rendermode InteractiveAuto
|
||||||
|
|
||||||
|
<PageTitle>Match</PageTitle>
|
||||||
|
<div class="board">
|
||||||
|
<MatchBoard Match="match"/>
|
||||||
|
</div>
|
||||||
|
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
using LittleTown.Blazor.Client.Services;
|
||||||
|
using Microsoft.AspNetCore.Components;
|
||||||
|
|
||||||
|
namespace LittleTown.Blazor.Client.Pages;
|
||||||
|
|
||||||
|
public partial class Match(IMatchService matchServices)
|
||||||
|
{
|
||||||
|
Core.Match match;
|
||||||
|
|
||||||
|
public async override Task SetParametersAsync(ParameterView parameters)
|
||||||
|
{
|
||||||
|
match = matchServices.GetMatch();
|
||||||
|
match.AddPlayer("Andre");
|
||||||
|
match.AddPlayer("Maelie");
|
||||||
|
match.AddPlayer("Liam");
|
||||||
|
|
||||||
|
await match.Init();
|
||||||
|
|
||||||
|
await base.SetParametersAsync(parameters);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
.board {
|
||||||
|
width: 100%;
|
||||||
|
height: 50vh;
|
||||||
|
}
|
||||||
@@ -1,5 +1,12 @@
|
|||||||
|
using LittleTown.Blazor.Client.Services;
|
||||||
|
using LittleTown.Core.Ports;
|
||||||
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
|
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
|
||||||
|
|
||||||
var builder = WebAssemblyHostBuilder.CreateDefault(args);
|
var builder = WebAssemblyHostBuilder.CreateDefault(args);
|
||||||
|
|
||||||
|
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
|
||||||
|
|
||||||
|
builder.Services.AddScoped<IStaticDataGetter, WasmStaticDataGetter>();
|
||||||
|
builder.Services.AddScoped<IMatchService, MatchService>();
|
||||||
|
|
||||||
await builder.Build().RunAsync();
|
await builder.Build().RunAsync();
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
using LittleTown.Core;
|
||||||
|
|
||||||
|
namespace LittleTown.Blazor.Client.Services
|
||||||
|
{
|
||||||
|
public interface IMatchService
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Temporaire, recupere l'instance d'un match par défaut
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
Match GetMatch();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
using LittleTown.Core;
|
||||||
|
using LittleTown.Core.Ports;
|
||||||
|
|
||||||
|
namespace LittleTown.Blazor.Client.Services
|
||||||
|
{
|
||||||
|
public class MatchService : IMatchService
|
||||||
|
{
|
||||||
|
private readonly IStaticDataGetter _staticDataGetter;
|
||||||
|
private Match? _currentMatch;
|
||||||
|
|
||||||
|
public MatchService(IStaticDataGetter staticDataGetter)
|
||||||
|
{
|
||||||
|
_staticDataGetter = staticDataGetter;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>>
|
||||||
|
public Match GetMatch()
|
||||||
|
{
|
||||||
|
if (null == _currentMatch)
|
||||||
|
{
|
||||||
|
_currentMatch = new Match(_staticDataGetter);
|
||||||
|
}
|
||||||
|
return _currentMatch;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
using System.Text.Json;
|
||||||
|
using LittleTown.Core;
|
||||||
|
using LittleTown.Core.Ports;
|
||||||
|
|
||||||
|
namespace LittleTown.Blazor.Client.Services;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Implementation du getter de données static pour WebAssembly via HttpClient
|
||||||
|
/// </summary>
|
||||||
|
public class WasmStaticDataGetter : IStaticDataGetter
|
||||||
|
{
|
||||||
|
private readonly HttpClient _httpClient;
|
||||||
|
private string _boardData = "";
|
||||||
|
private string _buildingData = "";
|
||||||
|
private string _objectivesData = "";
|
||||||
|
private bool _isInitialized = false;
|
||||||
|
|
||||||
|
public WasmStaticDataGetter(HttpClient httpClient)
|
||||||
|
{
|
||||||
|
_httpClient = httpClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task InitializeAsync()
|
||||||
|
{
|
||||||
|
if (_isInitialized) return;
|
||||||
|
|
||||||
|
_boardData = await _httpClient.GetStringAsync("data/Board1.json");
|
||||||
|
_buildingData = await _httpClient.GetStringAsync("data/Buildings.json");
|
||||||
|
_objectivesData = await _httpClient.GetStringAsync("data/Objectives.json");
|
||||||
|
|
||||||
|
_isInitialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public async Task<Board> GetBoardAsync(int version)
|
||||||
|
{
|
||||||
|
// Synchronous wrapper - not ideal but matches interface
|
||||||
|
await InitializeAsync();
|
||||||
|
|
||||||
|
Board board = JsonSerializer.Deserialize<Board>(_boardData)
|
||||||
|
?? throw new JsonException("Cannot deserialize Board");
|
||||||
|
return board;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Board GetBoard(int version)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException("Use the asynchronous version of GetBoard for WebAssembly.");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public async Task<ICollection<Building>> GetBuildingsAsync()
|
||||||
|
{
|
||||||
|
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()
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
@using System.Net.Http
|
@using System.Net.Http
|
||||||
@using System.Net.Http.Json
|
@using System.Net.Http.Json
|
||||||
@using Microsoft.AspNetCore.Components.Forms
|
@using Microsoft.AspNetCore.Components.Forms
|
||||||
@using Microsoft.AspNetCore.Components.Routing
|
@using Microsoft.AspNetCore.Components.Routing
|
||||||
@@ -7,3 +7,5 @@
|
|||||||
@using Microsoft.AspNetCore.Components.Web.Virtualization
|
@using Microsoft.AspNetCore.Components.Web.Virtualization
|
||||||
@using Microsoft.JSInterop
|
@using Microsoft.JSInterop
|
||||||
@using LittleTown.Blazor.Client
|
@using LittleTown.Blazor.Client
|
||||||
|
@using LittleTown.Blazor.Client.Components
|
||||||
|
@using LittleTown.StaticDataAcces;
|
||||||
|
|||||||
@@ -0,0 +1,276 @@
|
|||||||
|
{
|
||||||
|
"Width": 9,
|
||||||
|
"Height": 6,
|
||||||
|
"Tiles": [
|
||||||
|
{
|
||||||
|
"ResourceType": "None",
|
||||||
|
"PosX": 0,
|
||||||
|
"PosY": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ResourceType": "Wood",
|
||||||
|
"PosX": 1,
|
||||||
|
"PosY": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ResourceType": "Wood",
|
||||||
|
"PosX": 2,
|
||||||
|
"PosY": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ResourceType": "None",
|
||||||
|
"PosX": 3,
|
||||||
|
"PosY": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ResourceType": "Fish",
|
||||||
|
"PosX": 4,
|
||||||
|
"PosY": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ResourceType": "Fish",
|
||||||
|
"PosX": 5,
|
||||||
|
"PosY": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ResourceType": "None",
|
||||||
|
"PosX": 6,
|
||||||
|
"PosY": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ResourceType": "None",
|
||||||
|
"PosX": 7,
|
||||||
|
"PosY": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ResourceType": "Wood",
|
||||||
|
"PosX": 8,
|
||||||
|
"PosY": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ResourceType": "None",
|
||||||
|
"PosX": 0,
|
||||||
|
"PosY": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ResourceType": "None",
|
||||||
|
"PosX": 1,
|
||||||
|
"PosY": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ResourceType": "None",
|
||||||
|
"PosX": 2,
|
||||||
|
"PosY": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ResourceType": "None",
|
||||||
|
"PosX": 3,
|
||||||
|
"PosY": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ResourceType": "None",
|
||||||
|
"PosX": 4,
|
||||||
|
"PosY": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ResourceType": "None",
|
||||||
|
"PosX": 5,
|
||||||
|
"PosY": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ResourceType": "Wood",
|
||||||
|
"PosX": 6,
|
||||||
|
"PosY": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ResourceType": "None",
|
||||||
|
"PosX": 7,
|
||||||
|
"PosY": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ResourceType": "None",
|
||||||
|
"PosX": 8,
|
||||||
|
"PosY": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ResourceType": "Wood",
|
||||||
|
"PosX": 0,
|
||||||
|
"PosY": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ResourceType": "None",
|
||||||
|
"PosX": 1,
|
||||||
|
"PosY": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ResourceType": "None",
|
||||||
|
"PosX": 2,
|
||||||
|
"PosY": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ResourceType": "None",
|
||||||
|
"PosX": 3,
|
||||||
|
"PosY": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ResourceType": "None",
|
||||||
|
"PosX": 4,
|
||||||
|
"PosY": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ResourceType": "None",
|
||||||
|
"PosX": 5,
|
||||||
|
"PosY": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ResourceType": "None",
|
||||||
|
"PosX": 6,
|
||||||
|
"PosY": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ResourceType": "None",
|
||||||
|
"PosX": 7,
|
||||||
|
"PosY": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ResourceType": "Fish",
|
||||||
|
"PosX": 8,
|
||||||
|
"PosY": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ResourceType": "Fish",
|
||||||
|
"PosX": 0,
|
||||||
|
"PosY": 3
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ResourceType": "None",
|
||||||
|
"PosX": 1,
|
||||||
|
"PosY": 3
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ResourceType": "None",
|
||||||
|
"PosX": 2,
|
||||||
|
"PosY": 3
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ResourceType": "None",
|
||||||
|
"PosX": 3,
|
||||||
|
"PosY": 3
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ResourceType": "None",
|
||||||
|
"PosX": 4,
|
||||||
|
"PosY": 3
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ResourceType": "None",
|
||||||
|
"PosX": 5,
|
||||||
|
"PosY": 3
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ResourceType": "None",
|
||||||
|
"PosX": 6,
|
||||||
|
"PosY": 3
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ResourceType": "None",
|
||||||
|
"PosX": 7,
|
||||||
|
"PosY": 3
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ResourceType": "None",
|
||||||
|
"PosX": 8,
|
||||||
|
"PosY": 3
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ResourceType": "None",
|
||||||
|
"PosX": 0,
|
||||||
|
"PosY": 4
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ResourceType": "None",
|
||||||
|
"PosX": 1,
|
||||||
|
"PosY": 4
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ResourceType": "None",
|
||||||
|
"PosX": 2,
|
||||||
|
"PosY": 4
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ResourceType": "None",
|
||||||
|
"PosX": 3,
|
||||||
|
"PosY": 4
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ResourceType": "None",
|
||||||
|
"PosX": 4,
|
||||||
|
"PosY": 4
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ResourceType": "None",
|
||||||
|
"PosX": 5,
|
||||||
|
"PosY": 4
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ResourceType": "None",
|
||||||
|
"PosX": 6,
|
||||||
|
"PosY": 4
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ResourceType": "None",
|
||||||
|
"PosX": 7,
|
||||||
|
"PosY": 4
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ResourceType": "None",
|
||||||
|
"PosX": 8,
|
||||||
|
"PosY": 4
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ResourceType": "Rock",
|
||||||
|
"PosX": 0,
|
||||||
|
"PosY": 5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ResourceType": "None",
|
||||||
|
"PosX": 1,
|
||||||
|
"PosY": 5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ResourceType": "Wood",
|
||||||
|
"PosX": 2,
|
||||||
|
"PosY": 5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ResourceType": "Rock",
|
||||||
|
"PosX": 3,
|
||||||
|
"PosY": 5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ResourceType": "None",
|
||||||
|
"PosX": 4,
|
||||||
|
"PosY": 5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ResourceType": "Fish",
|
||||||
|
"PosX": 5,
|
||||||
|
"PosY": 5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ResourceType": "None",
|
||||||
|
"PosX": 6,
|
||||||
|
"PosY": 5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ResourceType": "Rock",
|
||||||
|
"PosX": 7,
|
||||||
|
"PosY": 5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ResourceType": "Rock",
|
||||||
|
"PosX": 8,
|
||||||
|
"PosY": 5
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,183 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"Name": "Atelier",
|
||||||
|
"Price": {
|
||||||
|
"Rock": 2
|
||||||
|
},
|
||||||
|
"BeginnerBuilding": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "Bar",
|
||||||
|
"Price": {
|
||||||
|
"Rock": 2,
|
||||||
|
"Cereal": 2
|
||||||
|
},
|
||||||
|
"BeginnerBuilding": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "Boulangerie",
|
||||||
|
"Price": {
|
||||||
|
"Wood": 2
|
||||||
|
},
|
||||||
|
"BeginnerBuilding": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "Brasserie",
|
||||||
|
"Price": {
|
||||||
|
"Wood": 2
|
||||||
|
},
|
||||||
|
"BeginnerBuilding": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "Carriere",
|
||||||
|
"Price": {
|
||||||
|
"Wood": 3
|
||||||
|
},
|
||||||
|
"BeginnerBuilding": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "Champsdeble",
|
||||||
|
"Price": {
|
||||||
|
"Wood": 1
|
||||||
|
},
|
||||||
|
"BeginnerBuilding": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "Charpentier",
|
||||||
|
"Price": {
|
||||||
|
"Wood": 2
|
||||||
|
},
|
||||||
|
"BeginnerBuilding": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "Epicerie",
|
||||||
|
"Price": {
|
||||||
|
"Wood": 2
|
||||||
|
},
|
||||||
|
"BeginnerBuilding": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "Entrepot",
|
||||||
|
"Price": {
|
||||||
|
"Rock": 4
|
||||||
|
},
|
||||||
|
"BeginnerBuilding": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "Eglise",
|
||||||
|
"Price": {
|
||||||
|
"Rock": 4
|
||||||
|
},
|
||||||
|
"BeginnerBuilding": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "Foire",
|
||||||
|
"Price": {
|
||||||
|
"Wood": 4
|
||||||
|
},
|
||||||
|
"BeginnerBuilding": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "Fontaine",
|
||||||
|
"Price": {
|
||||||
|
"Rock": 2
|
||||||
|
},
|
||||||
|
"BeginnerBuilding": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "Grenier",
|
||||||
|
"Price": {
|
||||||
|
"Wood": 4
|
||||||
|
},
|
||||||
|
"BeginnerBuilding": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "Librairie",
|
||||||
|
"Price": {
|
||||||
|
"Rock": 4
|
||||||
|
},
|
||||||
|
"BeginnerBuilding": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "minedor",
|
||||||
|
"Price": {
|
||||||
|
"Wood": 1,
|
||||||
|
"Rock": 1
|
||||||
|
},
|
||||||
|
"BeginnerBuilding": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "poissonnier",
|
||||||
|
"Price": {
|
||||||
|
"Wood": 1,
|
||||||
|
"Rock": 1
|
||||||
|
},
|
||||||
|
"BeginnerBuilding": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "Ponton",
|
||||||
|
"Price": {
|
||||||
|
"Wood": 3
|
||||||
|
},
|
||||||
|
"BeginnerBuilding": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "Preteursurgage",
|
||||||
|
"Price": {
|
||||||
|
"Wood": 3
|
||||||
|
},
|
||||||
|
"BeginnerBuilding": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "puits",
|
||||||
|
"Price": {
|
||||||
|
"Wood": 1,
|
||||||
|
"Rock": 1
|
||||||
|
},
|
||||||
|
"BeginnerBuilding": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "Restaurant",
|
||||||
|
"Price": {
|
||||||
|
"Wood": 2,
|
||||||
|
"Rock": 2
|
||||||
|
},
|
||||||
|
"BeginnerBuilding": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "Statue",
|
||||||
|
"Price": {
|
||||||
|
"Rock": 4
|
||||||
|
},
|
||||||
|
"BeginnerBuilding": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "Cathedrale",
|
||||||
|
"Price": {
|
||||||
|
"Rock": 6
|
||||||
|
},
|
||||||
|
"BeginnerBuilding": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "Residence",
|
||||||
|
"Price": {
|
||||||
|
"Piece": 6
|
||||||
|
},
|
||||||
|
"BeginnerBuilding": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "Chateau",
|
||||||
|
"Price": {
|
||||||
|
"Rock": 6
|
||||||
|
},
|
||||||
|
"BeginnerBuilding": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "Tourdegarde",
|
||||||
|
"Price": {
|
||||||
|
"Wood": 3,
|
||||||
|
"Rock": 3
|
||||||
|
},
|
||||||
|
"BeginnerBuilding": false
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"Description": "desc",
|
||||||
|
"Formula": "formula",
|
||||||
|
"Points": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Description": "desc",
|
||||||
|
"Formula": "formula",
|
||||||
|
"Points": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Description": "desc",
|
||||||
|
"Formula": "formula",
|
||||||
|
"Points": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Description": "desc",
|
||||||
|
"Formula": "formula",
|
||||||
|
"Points": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Description": "desc",
|
||||||
|
"Formula": "formula",
|
||||||
|
"Points": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Description": "desc",
|
||||||
|
"Formula": "formula",
|
||||||
|
"Points": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Description": "desc",
|
||||||
|
"Formula": "formula",
|
||||||
|
"Points": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Description": "desc",
|
||||||
|
"Formula": "formula",
|
||||||
|
"Points": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Description": "desc",
|
||||||
|
"Formula": "formula",
|
||||||
|
"Points": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Description": "desc",
|
||||||
|
"Formula": "formula",
|
||||||
|
"Points": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Description": "desc",
|
||||||
|
"Formula": "formula",
|
||||||
|
"Points": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Description": "desc",
|
||||||
|
"Formula": "formula",
|
||||||
|
"Points": 3
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Description": "desc",
|
||||||
|
"Formula": "formula",
|
||||||
|
"Points": 3
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Description": "desc",
|
||||||
|
"Formula": "formula",
|
||||||
|
"Points": 3
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Description": "desc",
|
||||||
|
"Formula": "formula",
|
||||||
|
"Points": 3
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Description": "desc",
|
||||||
|
"Formula": "formula",
|
||||||
|
"Points": 3
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Description": "desc",
|
||||||
|
"Formula": "formula",
|
||||||
|
"Points": 3
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Description": "desc",
|
||||||
|
"Formula": "formula",
|
||||||
|
"Points": 3
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
@inherits LayoutComponentBase
|
@inherits LayoutComponentBase
|
||||||
|
|
||||||
<div class="page">
|
<div class="page">
|
||||||
<div class="sidebar">
|
<div class="sidebar">
|
||||||
@@ -6,13 +6,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<main>
|
<main>
|
||||||
<div class="top-row px-4">
|
@Body
|
||||||
<a href="https://learn.microsoft.com/aspnet/core/" target="_blank">About</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<article class="content px-4">
|
|
||||||
@Body
|
|
||||||
</article>
|
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -19,5 +19,10 @@
|
|||||||
<span class="bi bi-plus-square-fill-nav-menu" aria-hidden="true"></span> Counter
|
<span class="bi bi-plus-square-fill-nav-menu" aria-hidden="true"></span> Counter
|
||||||
</NavLink>
|
</NavLink>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="nav-item px-3">
|
||||||
|
<NavLink class="nav-link" href="match">
|
||||||
|
<span class="bi bi-plus-square-fill-nav-menu" aria-hidden="true"></span> Match
|
||||||
|
</NavLink>
|
||||||
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
@@ -12,4 +12,9 @@
|
|||||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="10.0.2" />
|
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="10.0.2" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\..\LittleTown.Core\LittleTown.Core.csproj" />
|
||||||
|
<ProjectReference Include="..\..\LittleTown.StaticDataAccess\LittleTown.StaticDataAccess.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<ActiveDebugProfile>https</ActiveDebugProfile>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
using LittleTown.Blazor.Client.Pages;
|
using LittleTown.Blazor.Client.Services;
|
||||||
using LittleTown.Blazor.Components;
|
using LittleTown.Blazor.Components;
|
||||||
|
using LittleTown.Core.Ports;
|
||||||
|
using LittleTown.StaticDataAcces;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
@@ -8,6 +10,9 @@ builder.Services.AddRazorComponents()
|
|||||||
.AddInteractiveServerComponents()
|
.AddInteractiveServerComponents()
|
||||||
.AddInteractiveWebAssemblyComponents();
|
.AddInteractiveWebAssemblyComponents();
|
||||||
|
|
||||||
|
builder.Services.AddScoped<IStaticDataGetter, StaticDataGetter>();
|
||||||
|
builder.Services.AddScoped<IMatchService, MatchService>();
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
// Configure the HTTP request pipeline.
|
// Configure the HTTP request pipeline.
|
||||||
@@ -32,4 +37,4 @@ app.MapRazorComponents<App>()
|
|||||||
.AddInteractiveWebAssemblyRenderMode()
|
.AddInteractiveWebAssemblyRenderMode()
|
||||||
.AddAdditionalAssemblies(typeof(LittleTown.Blazor.Client._Imports).Assembly);
|
.AddAdditionalAssemblies(typeof(LittleTown.Blazor.Client._Imports).Assembly);
|
||||||
|
|
||||||
app.Run();
|
await app.RunAsync();
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public class BoardTesting
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void BoardGetTile()
|
public void BoardGetTile()
|
||||||
{
|
{
|
||||||
Assert.Equal(ResourceType.Fish, _board.GetTile(0, 3)?.ResourceType);
|
Assert.Equal(ResourceType.Fish, _board.GetTile(0, 3).ResourceType);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|||||||
@@ -7,31 +7,31 @@ namespace LittleTown.Core.Tests;
|
|||||||
public class MatchTesting
|
public class MatchTesting
|
||||||
{
|
{
|
||||||
[Fact]
|
[Fact]
|
||||||
public void EnforcePlayerCountInMatchCreation()
|
public async Task EnforcePlayerCountInMatchCreation()
|
||||||
{
|
{
|
||||||
StaticDataGetter getter = new();
|
StaticDataGetter getter = new();
|
||||||
var match = new Match(getter);
|
var match = new Match(getter);
|
||||||
match.AddPlayer("Player1");
|
match.AddPlayer("Player1");
|
||||||
Assert.Throws<ArgumentOutOfRangeException>(() => { match.Init(); });
|
await Assert.ThrowsAsync<ArgumentOutOfRangeException>(() => match.Init() );
|
||||||
|
|
||||||
Match match2 = new Match(getter);
|
Match match2 = new Match(getter);
|
||||||
match2.AddPlayer("Player1");
|
match2.AddPlayer("Player1");
|
||||||
match2.AddPlayer("Player2");
|
match2.AddPlayer("Player2");
|
||||||
Assert.Throws<MatchConfigException>(() => match2.AddPlayer("Player2"));
|
Assert.Throws<MatchConfigException>(() => match2.AddPlayer("Player2"));
|
||||||
match2.Init();
|
await match2.Init();
|
||||||
|
|
||||||
Match match3 = new Match(getter);
|
Match match3 = new Match(getter);
|
||||||
match3.AddPlayer("Player1");
|
match3.AddPlayer("Player1");
|
||||||
match3.AddPlayer("Player2");
|
match3.AddPlayer("Player2");
|
||||||
match3.AddPlayer("Player3");
|
match3.AddPlayer("Player3");
|
||||||
match3.Init();
|
await match3.Init();
|
||||||
|
|
||||||
Match match4 = new Match(getter);
|
Match match4 = new Match(getter);
|
||||||
match4.AddPlayer("Player1");
|
match4.AddPlayer("Player1");
|
||||||
match4.AddPlayer("Player2");
|
match4.AddPlayer("Player2");
|
||||||
match4.AddPlayer("Player3");
|
match4.AddPlayer("Player3");
|
||||||
match4.AddPlayer("Player4");
|
match4.AddPlayer("Player4");
|
||||||
match4.Init();
|
await match4.Init();
|
||||||
|
|
||||||
Match match5 = new Match(getter);
|
Match match5 = new Match(getter);
|
||||||
match5.AddPlayer("Player1");
|
match5.AddPlayer("Player1");
|
||||||
@@ -42,13 +42,13 @@ public class MatchTesting
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void TwoPlayerInitMatchTest()
|
public async Task TwoPlayerInitMatchTest()
|
||||||
{
|
{
|
||||||
StaticDataGetter getter = new();
|
StaticDataGetter getter = new();
|
||||||
Match match = new Match(getter);
|
Match match = new Match(getter);
|
||||||
match.AddPlayer("Player1");
|
match.AddPlayer("Player1");
|
||||||
match.AddPlayer("Player2");
|
match.AddPlayer("Player2");
|
||||||
match.Init();
|
await match.Init();
|
||||||
|
|
||||||
PlayerZone player1 = match.GetPlayerZone("Player1");
|
PlayerZone player1 = match.GetPlayerZone("Player1");
|
||||||
PlayerZone player1_3 = match.GetPlayerZone("Player2");
|
PlayerZone player1_3 = match.GetPlayerZone("Player2");
|
||||||
|
|||||||
@@ -24,10 +24,10 @@ public class Board
|
|||||||
/// <param name="x">la colonne de la tile partant de la gauche a 0</param>
|
/// <param name="x">la colonne de la tile partant de la gauche a 0</param>
|
||||||
/// <param name="y">ligne de la tile partant du bas a 0</param>
|
/// <param name="y">ligne de la tile partant du bas a 0</param>
|
||||||
/// <returns>la tile</returns>
|
/// <returns>la tile</returns>
|
||||||
public Tile? GetTile(int x, int y)
|
public Tile GetTile(int x, int y)
|
||||||
{
|
{
|
||||||
if (x < 0 || x >= Width || y < 0 || y >= Height)
|
if (x < 0 || x >= Width || y < 0 || y >= Height)
|
||||||
return null;
|
throw new ArgumentException($"Cannot get the cell at {x},{y}");
|
||||||
|
|
||||||
return Tiles[x + y * Width];
|
return Tiles[x + y * Width];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
namespace LittleTown.Core.Aggregates.MatchAggregate
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Classe indiquant l'etat d'un batiment sélectionné pour une partie.
|
||||||
|
/// Au debut d'un match, 12 batiments sont sélectionnés aléatoirement parmi les 24 batiments du jeu, et sont disponibles pour tous les joueurs.
|
||||||
|
/// Cette classe indique l'etat de ces batiments (si ils sont encore disponibles ou si ils ont été construit par un joueur) et d'autres informations utiles pour le match.
|
||||||
|
/// </summary>
|
||||||
|
public class BuildingInfos
|
||||||
|
{
|
||||||
|
/// <summary> Le building concerné /// </summary>
|
||||||
|
required public Building Building { get; init; }
|
||||||
|
|
||||||
|
/// <summary> Indique si le batiment est dans la zone a construire ou sur le terrain construit </summary>
|
||||||
|
public bool IsBuilt { get; set; }
|
||||||
|
/// <summary> Le owner du batiment, null si le batiment n'est pas encore construit </summary>
|
||||||
|
public string? Owner { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using LittleTown.Core.Actions;
|
using LittleTown.Core.Actions;
|
||||||
|
using LittleTown.Core.Aggregates.MatchAggregate;
|
||||||
using LittleTown.Core.Exceptions;
|
using LittleTown.Core.Exceptions;
|
||||||
using LittleTown.Core.Ports;
|
using LittleTown.Core.Ports;
|
||||||
|
|
||||||
@@ -9,6 +10,8 @@ namespace LittleTown.Core;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class Match
|
public class Match
|
||||||
{
|
{
|
||||||
|
private IStaticDataGetter StaticData { get; set; }
|
||||||
|
|
||||||
/// <summary> LE numero du tour en cours (Partant de 1) </summary>
|
/// <summary> LE numero du tour en cours (Partant de 1) </summary>
|
||||||
public int CurrentTurn { get; private set; } = 1;
|
public int CurrentTurn { get; private set; } = 1;
|
||||||
|
|
||||||
@@ -19,7 +22,7 @@ public class Match
|
|||||||
public bool IsDone { get; private set; }
|
public bool IsDone { get; private set; }
|
||||||
|
|
||||||
/// <summary>la liste indiquant l'ordre des joueurs, _playerTurnsOrder[0] donne l'index du 1er joueur, _playerTurnsOrder[1] du second..... </summary>
|
/// <summary>la liste indiquant l'ordre des joueurs, _playerTurnsOrder[0] donne l'index du 1er joueur, _playerTurnsOrder[1] du second..... </summary>
|
||||||
private List<int> _playerTurnsOrder = new List<int>();
|
private readonly List<int> _playerTurnsOrder = new List<int>();
|
||||||
|
|
||||||
private const int _minPlayerCount = 2;
|
private const int _minPlayerCount = 2;
|
||||||
private const int _maxPlayerCount = 4;
|
private const int _maxPlayerCount = 4;
|
||||||
@@ -27,11 +30,18 @@ public class Match
|
|||||||
private int _maxWorkerPerPlayer;
|
private int _maxWorkerPerPlayer;
|
||||||
private int _maxBuidingPerPlayer;
|
private int _maxBuidingPerPlayer;
|
||||||
|
|
||||||
private readonly Board _board;
|
private Board _board;
|
||||||
private ICollection<Building> _buildings;
|
private ICollection<Building> _buildings;
|
||||||
private ICollection<Objective> _objectives;
|
private ICollection<Objective> _objectives;
|
||||||
|
|
||||||
private Random _random = new Random();
|
List<BuildingInfos> _buildingInfos = new List<BuildingInfos>();
|
||||||
|
public IList<BuildingInfos> BuildingInfos { get
|
||||||
|
{
|
||||||
|
return new List<BuildingInfos>(_buildingInfos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Random _random = new Random(10);
|
||||||
|
|
||||||
private List<PlayerZone> _players = new();
|
private List<PlayerZone> _players = new();
|
||||||
private int _currentPlayerIndex;
|
private int _currentPlayerIndex;
|
||||||
@@ -43,10 +53,7 @@ public class Match
|
|||||||
public Match(IStaticDataGetter staticData)
|
public Match(IStaticDataGetter staticData)
|
||||||
{
|
{
|
||||||
ArgumentNullException.ThrowIfNull(staticData);
|
ArgumentNullException.ThrowIfNull(staticData);
|
||||||
|
StaticData = staticData;
|
||||||
_board = staticData.GetBoard(1);
|
|
||||||
_buildings = staticData.GetBuildings();
|
|
||||||
_objectives = staticData.GetObjectives();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Ajouter un nouveau joueur a la partie </summary>
|
/// <summary> Ajouter un nouveau joueur a la partie </summary>
|
||||||
@@ -91,8 +98,12 @@ public class Match
|
|||||||
|
|
||||||
/// <summary> Initialiser la partie, il faut avoir ajouté les joueurs au préalable </summary>
|
/// <summary> Initialiser la partie, il faut avoir ajouté les joueurs au préalable </summary>
|
||||||
/// <exception cref="MatchConfigException"></exception>
|
/// <exception cref="MatchConfigException"></exception>
|
||||||
public void Init()
|
public async Task Init()
|
||||||
{
|
{
|
||||||
|
_board = await StaticData.GetBoardAsync(1).ConfigureAwait(true);
|
||||||
|
_buildings = await StaticData.GetBuildingsAsync().ConfigureAwait(true); ;
|
||||||
|
_objectives = await StaticData.GetObjectivesAsync().ConfigureAwait(true); ;
|
||||||
|
|
||||||
int nbPlayer = _players.Count;
|
int nbPlayer = _players.Count;
|
||||||
|
|
||||||
ArgumentOutOfRangeException.ThrowIfLessThan(nbPlayer, _minPlayerCount);
|
ArgumentOutOfRangeException.ThrowIfLessThan(nbPlayer, _minPlayerCount);
|
||||||
@@ -136,6 +147,9 @@ public class Match
|
|||||||
index = 0;
|
index = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// selectionner les batiments qui seront disponibles pour la partie
|
||||||
|
SelectBuildings();
|
||||||
|
|
||||||
_currentPlayerIndex = 0;
|
_currentPlayerIndex = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -166,6 +180,42 @@ public class Match
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SelectBuildings(bool beginerMode = false)
|
||||||
|
{
|
||||||
|
|
||||||
|
List<Building>? filteredBuildings = null;
|
||||||
|
if (beginerMode)
|
||||||
|
{
|
||||||
|
filteredBuildings = _buildings.Where(b => b.Name != "Champsdeble" && b.BeginnerBuilding).ToList();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
filteredBuildings = _buildings.Where(b => b.Name != "Champsdeble").ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(null == filteredBuildings)
|
||||||
|
{
|
||||||
|
throw new MatchConfigException("Aucun batiment trouvé pour la partie");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
List<int> freeIndex = filteredBuildings. Select((b, i) => i).ToList();
|
||||||
|
for (int i = 0; i < 12; ++i)
|
||||||
|
{
|
||||||
|
int randomIndex = _random.Next(freeIndex.Count);
|
||||||
|
int itemIndex = freeIndex[randomIndex];
|
||||||
|
freeIndex.RemoveAt(randomIndex);
|
||||||
|
BuildingInfos infos = new BuildingInfos()
|
||||||
|
{
|
||||||
|
Building = filteredBuildings.ElementAt(itemIndex),
|
||||||
|
IsBuilt = false,
|
||||||
|
Owner = null
|
||||||
|
};
|
||||||
|
_buildingInfos.Add(infos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary> Changer le joueur en cours pour passer au suivant </summary>
|
/// <summary> Changer le joueur en cours pour passer au suivant </summary>
|
||||||
public void NextPlayer()
|
public void NextPlayer()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,6 +5,11 @@ namespace LittleTown.Core.Ports;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IStaticDataGetter
|
public interface IStaticDataGetter
|
||||||
{
|
{
|
||||||
|
/// <summary> Recuperer un plateau de jeu </summary>
|
||||||
|
/// <param name="version">la version du plateau (1 ou 2)</param>
|
||||||
|
/// <returns> une instance du plateau avec les données statique</returns>
|
||||||
|
public Task<Board> GetBoardAsync(int version);
|
||||||
|
|
||||||
/// <summary> Recuperer un plateau de jeu </summary>
|
/// <summary> Recuperer un plateau de jeu </summary>
|
||||||
/// <param name="version">la version du plateau (1 ou 2)</param>
|
/// <param name="version">la version du plateau (1 ou 2)</param>
|
||||||
/// <returns> une instance du plateau avec les données statique</returns>
|
/// <returns> une instance du plateau avec les données statique</returns>
|
||||||
@@ -14,8 +19,16 @@ public interface IStaticDataGetter
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public ICollection<Building> GetBuildings();
|
public ICollection<Building> GetBuildings();
|
||||||
|
|
||||||
|
/// <summary> Recupérer la liste des batiments et leurs données statiques </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Task<ICollection<Building>> GetBuildingsAsync();
|
||||||
|
|
||||||
/// <summary> Récupérer la liste des objectifs du jeu </summary>
|
/// <summary> Récupérer la liste des objectifs du jeu </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public ICollection<Objective> GetObjectives();
|
public ICollection<Objective> GetObjectives();
|
||||||
|
|
||||||
|
/// <summary> Récupérer la liste des objectifs du jeu </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Task<ICollection<Objective>> GetObjectivesAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net10.0</TargetFramework>
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
@@ -15,4 +15,11 @@
|
|||||||
<ProjectReference Include="..\LittleTown.Core\LittleTown.Core.csproj" />
|
<ProjectReference Include="..\LittleTown.Core\LittleTown.Core.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<!-- Copier les fichiers JSON dans le dossier de build -->
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="Data\*.json">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -26,12 +26,16 @@ public class StaticDataGetter : IStaticDataGetter
|
|||||||
_buildingData = buildingData;
|
_buildingData = buildingData;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Constructeur avec les chemins par défaut, à utiliser pour les tests seulement </summary>
|
/// <summary> Constructeur avec les chemins par défaut </summary>
|
||||||
public StaticDataGetter()
|
public StaticDataGetter()
|
||||||
{
|
{
|
||||||
string boardPath = Path.Combine(Environment.CurrentDirectory, "../../../../LittleTown.StaticDataAccess/Data/Board1.json");
|
// Les fichiers JSON sont copiés dans le dossier de build via le .csproj
|
||||||
string buildingPath = Path.Combine(Environment.CurrentDirectory, "../../../../LittleTown.StaticDataAccess/Data/Buildings.json");
|
// Ils sont donc toujours relatifs à l'exécutable
|
||||||
string objectivesPath = Path.Combine(Environment.CurrentDirectory, "../../../../LittleTown.StaticDataAccess/Data/Objectives.json");
|
var baseDirectory = AppContext.BaseDirectory;
|
||||||
|
string boardPath = Path.Combine(baseDirectory, "Data", "Board1.json");
|
||||||
|
string buildingPath = Path.Combine(baseDirectory, "Data", "Buildings.json");
|
||||||
|
string objectivesPath = Path.Combine(baseDirectory, "Data", "Objectives.json");
|
||||||
|
|
||||||
ReadFiles(boardPath, buildingPath, objectivesPath);
|
ReadFiles(boardPath, buildingPath, objectivesPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,6 +53,12 @@ public class StaticDataGetter : IStaticDataGetter
|
|||||||
return board;
|
return board;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public async Task<Board> GetBoardAsync(int version)
|
||||||
|
{
|
||||||
|
return GetBoard(version);
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public ICollection<Building> GetBuildings()
|
public ICollection<Building> GetBuildings()
|
||||||
{
|
{
|
||||||
@@ -57,6 +67,12 @@ public class StaticDataGetter : IStaticDataGetter
|
|||||||
return buildings;
|
return buildings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public async Task<ICollection<Building>> GetBuildingsAsync()
|
||||||
|
{
|
||||||
|
return GetBuildings();
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public ICollection<Objective> GetObjectives()
|
public ICollection<Objective> GetObjectives()
|
||||||
{
|
{
|
||||||
@@ -64,4 +80,10 @@ public class StaticDataGetter : IStaticDataGetter
|
|||||||
|
|
||||||
return objectives;
|
return objectives;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public async Task<ICollection<Objective>> GetObjectivesAsync()
|
||||||
|
{
|
||||||
|
return GetObjectives();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio Version 17
|
# Visual Studio Version 18
|
||||||
VisualStudioVersion = 17.0.31903.59
|
VisualStudioVersion = 18.3.11512.155 d18.3
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LittleTown.Core", "LittleTown.Core\LittleTown.Core.csproj", "{E1A228C7-E008-47F4-9EBC-148D4A9071E0}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LittleTown.Core", "LittleTown.Core\LittleTown.Core.csproj", "{E1A228C7-E008-47F4-9EBC-148D4A9071E0}"
|
||||||
EndProject
|
EndProject
|
||||||
@@ -14,8 +14,14 @@ EndProject
|
|||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "LittleTown.Blazor", "LittleTown.Blazor", "{5142DF7A-0B25-DAC6-14FF-F9CE4E6A354A}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "LittleTown.Blazor", "LittleTown.Blazor", "{5142DF7A-0B25-DAC6-14FF-F9CE4E6A354A}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LittleTown.Blazor", "LittleTown.Blazor\LittleTown.Blazor\LittleTown.Blazor.csproj", "{12579937-5A8E-44F9-AC45-B742B311102E}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LittleTown.Blazor", "LittleTown.Blazor\LittleTown.Blazor\LittleTown.Blazor.csproj", "{12579937-5A8E-44F9-AC45-B742B311102E}"
|
||||||
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
{FA0DE9D0-F788-4734-BDA3-F89F71D757BA} = {FA0DE9D0-F788-4734-BDA3-F89F71D757BA}
|
||||||
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LittleTown.Blazor.Client", "LittleTown.Blazor\LittleTown.Blazor.Client\LittleTown.Blazor.Client.csproj", "{83375A45-793A-462B-BAB8-AD432FA49350}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LittleTown.Blazor.Client", "LittleTown.Blazor\LittleTown.Blazor.Client\LittleTown.Blazor.Client.csproj", "{83375A45-793A-462B-BAB8-AD432FA49350}"
|
||||||
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
{FA0DE9D0-F788-4734-BDA3-F89F71D757BA} = {FA0DE9D0-F788-4734-BDA3-F89F71D757BA}
|
||||||
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@@ -107,4 +113,7 @@ Global
|
|||||||
{12579937-5A8E-44F9-AC45-B742B311102E} = {5142DF7A-0B25-DAC6-14FF-F9CE4E6A354A}
|
{12579937-5A8E-44F9-AC45-B742B311102E} = {5142DF7A-0B25-DAC6-14FF-F9CE4E6A354A}
|
||||||
{83375A45-793A-462B-BAB8-AD432FA49350} = {5142DF7A-0B25-DAC6-14FF-F9CE4E6A354A}
|
{83375A45-793A-462B-BAB8-AD432FA49350} = {5142DF7A-0B25-DAC6-14FF-F9CE4E6A354A}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {35A15B53-B50E-40B5-A9F7-F47132A2EEE3}
|
||||||
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|||||||
Reference in New Issue
Block a user