Compare commits
1 Commits
addingBuil
...
renovate/d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0b1d9c452b |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -17,4 +17,3 @@ obj
|
|||||||
report
|
report
|
||||||
tools/
|
tools/
|
||||||
TestResults
|
TestResults
|
||||||
/src/.vs
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.2" />
|
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.3" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="10.1.2" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="10.1.2" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
<?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();
|
||||||
|
|
||||||
await app.RunAsync();
|
app.Run();
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
<div class="rootTile">
|
|
||||||
@Building.Name
|
|
||||||
</div>
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
using LittleTown.Core;
|
|
||||||
using Microsoft.AspNetCore.Components;
|
|
||||||
|
|
||||||
namespace LittleTown.Blazor.Client.Components
|
|
||||||
{
|
|
||||||
public partial class AvailibleBuildingTile
|
|
||||||
{
|
|
||||||
[Parameter, EditorRequired]
|
|
||||||
public Building Building { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
root {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
@@ -1,76 +0,0 @@
|
|||||||
<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>
|
|
||||||
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,110 +0,0 @@
|
|||||||
.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;
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
<div class="cell-root @CssTileType">
|
|
||||||
<h3>@Tile.ResourceType</h3>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
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
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
|
|
||||||
.cell-root {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.rock {
|
|
||||||
background-color: gray;
|
|
||||||
}
|
|
||||||
|
|
||||||
.lake {
|
|
||||||
background-color: blue;
|
|
||||||
}
|
|
||||||
|
|
||||||
.forest
|
|
||||||
{
|
|
||||||
background-color: green;
|
|
||||||
}
|
|
||||||
@@ -10,12 +10,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="10.0.2" />
|
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="10.0.3" />
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\..\LittleTown.Core\LittleTown.Core.csproj" />
|
|
||||||
<ProjectReference Include="..\..\LittleTown.StaticDataAccess\LittleTown.StaticDataAccess.csproj" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
@page "/match"
|
|
||||||
@rendermode InteractiveAuto
|
|
||||||
|
|
||||||
<PageTitle>Match</PageTitle>
|
|
||||||
<div class="board">
|
|
||||||
<MatchBoard Match="match"/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
.board {
|
|
||||||
width: 100%;
|
|
||||||
height: 50vh;
|
|
||||||
}
|
|
||||||
@@ -1,12 +1,5 @@
|
|||||||
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();
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,81 +0,0 @@
|
|||||||
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,5 +7,3 @@
|
|||||||
@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;
|
|
||||||
|
|||||||
@@ -1,276 +0,0 @@
|
|||||||
{
|
|
||||||
"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
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,183 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"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
|
|
||||||
}
|
|
||||||
]
|
|
||||||
@@ -1,92 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"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,7 +6,13 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<main>
|
<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
|
@Body
|
||||||
|
</article>
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -19,10 +19,5 @@
|
|||||||
<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>
|
||||||
@@ -9,12 +9,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\LittleTown.Blazor.Client\LittleTown.Blazor.Client.csproj" />
|
<ProjectReference Include="..\LittleTown.Blazor.Client\LittleTown.Blazor.Client.csproj" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="10.0.2" />
|
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="10.0.3" />
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\..\LittleTown.Core\LittleTown.Core.csproj" />
|
|
||||||
<ProjectReference Include="..\..\LittleTown.StaticDataAccess\LittleTown.StaticDataAccess.csproj" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
<?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,7 +1,5 @@
|
|||||||
using LittleTown.Blazor.Client.Services;
|
using LittleTown.Blazor.Client.Pages;
|
||||||
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);
|
||||||
|
|
||||||
@@ -10,9 +8,6 @@ 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.
|
||||||
@@ -37,4 +32,4 @@ app.MapRazorComponents<App>()
|
|||||||
.AddInteractiveWebAssemblyRenderMode()
|
.AddInteractiveWebAssemblyRenderMode()
|
||||||
.AddAdditionalAssemblies(typeof(LittleTown.Blazor.Client._Imports).Assembly);
|
.AddAdditionalAssemblies(typeof(LittleTown.Blazor.Client._Imports).Assembly);
|
||||||
|
|
||||||
await app.RunAsync();
|
app.Run();
|
||||||
|
|||||||
@@ -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 async Task EnforcePlayerCountInMatchCreation()
|
public void EnforcePlayerCountInMatchCreation()
|
||||||
{
|
{
|
||||||
StaticDataGetter getter = new();
|
StaticDataGetter getter = new();
|
||||||
var match = new Match(getter);
|
var match = new Match(getter);
|
||||||
match.AddPlayer("Player1");
|
match.AddPlayer("Player1");
|
||||||
await Assert.ThrowsAsync<ArgumentOutOfRangeException>(() => match.Init() );
|
Assert.Throws<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"));
|
||||||
await match2.Init();
|
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");
|
||||||
await match3.Init();
|
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");
|
||||||
await match4.Init();
|
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 async Task TwoPlayerInitMatchTest()
|
public void 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");
|
||||||
await match.Init();
|
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)
|
||||||
throw new ArgumentException($"Cannot get the cell at {x},{y}");
|
return null;
|
||||||
|
|
||||||
return Tiles[x + y * Width];
|
return Tiles[x + y * Width];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
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,5 +1,4 @@
|
|||||||
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;
|
||||||
|
|
||||||
@@ -10,8 +9,6 @@ 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;
|
||||||
|
|
||||||
@@ -22,7 +19,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 readonly List<int> _playerTurnsOrder = new List<int>();
|
private 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;
|
||||||
@@ -30,18 +27,11 @@ public class Match
|
|||||||
private int _maxWorkerPerPlayer;
|
private int _maxWorkerPerPlayer;
|
||||||
private int _maxBuidingPerPlayer;
|
private int _maxBuidingPerPlayer;
|
||||||
|
|
||||||
private Board _board;
|
private readonly Board _board;
|
||||||
private ICollection<Building> _buildings;
|
private ICollection<Building> _buildings;
|
||||||
private ICollection<Objective> _objectives;
|
private ICollection<Objective> _objectives;
|
||||||
|
|
||||||
List<BuildingInfos> _buildingInfos = new List<BuildingInfos>();
|
private Random _random = new Random();
|
||||||
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;
|
||||||
@@ -53,7 +43,10 @@ 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>
|
||||||
@@ -98,12 +91,8 @@ 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 async Task Init()
|
public void 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);
|
||||||
@@ -147,9 +136,6 @@ public class Match
|
|||||||
index = 0;
|
index = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// selectionner les batiments qui seront disponibles pour la partie
|
|
||||||
SelectBuildings();
|
|
||||||
|
|
||||||
_currentPlayerIndex = 0;
|
_currentPlayerIndex = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -180,42 +166,6 @@ 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,11 +5,6 @@ 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>
|
||||||
@@ -19,16 +14,8 @@ 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,11 +15,4 @@
|
|||||||
<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,16 +26,12 @@ public class StaticDataGetter : IStaticDataGetter
|
|||||||
_buildingData = buildingData;
|
_buildingData = buildingData;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Constructeur avec les chemins par défaut </summary>
|
/// <summary> Constructeur avec les chemins par défaut, à utiliser pour les tests seulement </summary>
|
||||||
public StaticDataGetter()
|
public StaticDataGetter()
|
||||||
{
|
{
|
||||||
// Les fichiers JSON sont copiés dans le dossier de build via le .csproj
|
string boardPath = Path.Combine(Environment.CurrentDirectory, "../../../../LittleTown.StaticDataAccess/Data/Board1.json");
|
||||||
// Ils sont donc toujours relatifs à l'exécutable
|
string buildingPath = Path.Combine(Environment.CurrentDirectory, "../../../../LittleTown.StaticDataAccess/Data/Buildings.json");
|
||||||
var baseDirectory = AppContext.BaseDirectory;
|
string objectivesPath = Path.Combine(Environment.CurrentDirectory, "../../../../LittleTown.StaticDataAccess/Data/Objectives.json");
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,12 +49,6 @@ 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()
|
||||||
{
|
{
|
||||||
@@ -67,12 +57,6 @@ 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()
|
||||||
{
|
{
|
||||||
@@ -80,10 +64,4 @@ 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 18
|
# Visual Studio Version 17
|
||||||
VisualStudioVersion = 18.3.11512.155 d18.3
|
VisualStudioVersion = 17.0.31903.59
|
||||||
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,14 +14,8 @@ 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
|
||||||
@@ -113,7 +107,4 @@ 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