mise en place de la structure de base du plateau (#40)
All checks were successful
Merging on main / Build & Test (push) Successful in 1m10s
All checks were successful
Merging on main / Build & Test (push) Successful in 1m10s
Co-authored-by: mcmuzzle <vezuvan@hotmail.com> Reviewed-on: #40
This commit was merged in pull request #40.
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -17,3 +17,4 @@ obj
|
||||
report
|
||||
tools/
|
||||
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>
|
||||
@@ -0,0 +1,68 @@
|
||||
<div class="board">
|
||||
<div class="terrain">
|
||||
@foreach (var row in MatchViewModel.Rows)
|
||||
{
|
||||
<div class="terrain-row">
|
||||
@foreach (var cell in row)
|
||||
{
|
||||
<span class="terrain-cell">@cell</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">
|
||||
<div>building @i</div>
|
||||
</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">
|
||||
<div>building @(i+6)</div>
|
||||
</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,11 @@
|
||||
using LittleTown.Blazor.Client.ViewModels;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace LittleTown.Blazor.Client.Components
|
||||
{
|
||||
public partial class MatchBoard
|
||||
{
|
||||
[Parameter, EditorRequired]
|
||||
public MatchViewModel MatchViewModel { get; init; }
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -13,4 +13,9 @@
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="10.0.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\LittleTown.Core\LittleTown.Core.csproj" />
|
||||
<ProjectReference Include="..\..\LittleTown.StaticDataAccess\LittleTown.StaticDataAccess.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
@page "/match"
|
||||
@rendermode InteractiveAuto
|
||||
|
||||
<PageTitle>Match</PageTitle>
|
||||
<div class="board">
|
||||
<MatchBoard MatchViewModel="MatchViewModel" />
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
using LittleTown.Blazor.Client.Services;
|
||||
using LittleTown.Blazor.Client.ViewModels;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace LittleTown.Blazor.Client.Pages;
|
||||
|
||||
public partial class Match(IMatchService matchServices)
|
||||
{
|
||||
public MatchViewModel MatchViewModel { get; private set; }
|
||||
|
||||
public override Task SetParametersAsync(ParameterView parameters)
|
||||
{
|
||||
MatchViewModel = new MatchViewModel(matchServices.GetMatch());
|
||||
return 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;
|
||||
|
||||
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();
|
||||
|
||||
@@ -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,69 @@
|
||||
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 ICollection<Building> GetBuildings()
|
||||
{
|
||||
InitializeAsync().GetAwaiter().GetResult();
|
||||
|
||||
List<Building> buildings = JsonSerializer.Deserialize<List<Building>>(_buildingData)
|
||||
?? throw new JsonException("Cannot deserialize Buildings");
|
||||
return buildings;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public ICollection<Objective> GetObjectives()
|
||||
{
|
||||
InitializeAsync().GetAwaiter().GetResult();
|
||||
|
||||
List<Objective> objectives = JsonSerializer.Deserialize<List<Objective>>(_objectivesData)
|
||||
?? throw new JsonException("Cannot deserialize Objectives");
|
||||
return objectives;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using LittleTown.Core;
|
||||
|
||||
namespace LittleTown.Blazor.Client.ViewModels;
|
||||
|
||||
public class MatchViewModel(Match match)
|
||||
{
|
||||
public List<List<int>> Rows
|
||||
{
|
||||
get
|
||||
{
|
||||
List<List<int>> rows = new List<List<int>>();
|
||||
for(int i = 0; i < 6; i++)
|
||||
{
|
||||
rows.Add(Enumerable.Range(i * 6, 9).ToList());
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
@using System.Net.Http
|
||||
@using System.Net.Http
|
||||
@using System.Net.Http.Json
|
||||
@using Microsoft.AspNetCore.Components.Forms
|
||||
@using Microsoft.AspNetCore.Components.Routing
|
||||
@@ -7,3 +7,5 @@
|
||||
@using Microsoft.AspNetCore.Components.Web.Virtualization
|
||||
@using Microsoft.JSInterop
|
||||
@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">
|
||||
|
||||
<head>
|
||||
|
||||
@@ -19,5 +19,10 @@
|
||||
<span class="bi bi-plus-square-fill-nav-menu" aria-hidden="true"></span> Counter
|
||||
</NavLink>
|
||||
</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>
|
||||
</div>
|
||||
@@ -12,4 +12,9 @@
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="10.0.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\LittleTown.Core\LittleTown.Core.csproj" />
|
||||
<ProjectReference Include="..\..\LittleTown.StaticDataAccess\LittleTown.StaticDataAccess.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</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.Core.Ports;
|
||||
using LittleTown.StaticDataAcces;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
@@ -8,6 +10,9 @@ builder.Services.AddRazorComponents()
|
||||
.AddInteractiveServerComponents()
|
||||
.AddInteractiveWebAssemblyComponents();
|
||||
|
||||
builder.Services.AddScoped<IStaticDataGetter, StaticDataGetter>();
|
||||
builder.Services.AddScoped<IMatchService, MatchService>();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
@@ -32,4 +37,4 @@ app.MapRazorComponents<App>()
|
||||
.AddInteractiveWebAssemblyRenderMode()
|
||||
.AddAdditionalAssemblies(typeof(LittleTown.Blazor.Client._Imports).Assembly);
|
||||
|
||||
app.Run();
|
||||
await app.RunAsync();
|
||||
|
||||
@@ -44,7 +44,7 @@ public class Match
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(staticData);
|
||||
|
||||
_board = staticData.GetBoard(1);
|
||||
_board = staticData.GetBoardAsync(1).GetAwaiter().GetResult();
|
||||
_buildings = staticData.GetBuildings();
|
||||
_objectives = staticData.GetObjectives();
|
||||
}
|
||||
|
||||
@@ -5,6 +5,11 @@ namespace LittleTown.Core.Ports;
|
||||
/// </summary>
|
||||
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>
|
||||
/// <param name="version">la version du plateau (1 ou 2)</param>
|
||||
/// <returns> une instance du plateau avec les données statique</returns>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
@@ -15,4 +15,11 @@
|
||||
<ProjectReference Include="..\LittleTown.Core\LittleTown.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Copier les fichiers JSON dans le dossier de build -->
|
||||
<ItemGroup>
|
||||
<Content Include="Data\*.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -26,12 +26,16 @@ public class StaticDataGetter : IStaticDataGetter
|
||||
_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()
|
||||
{
|
||||
string boardPath = Path.Combine(Environment.CurrentDirectory, "../../../../LittleTown.StaticDataAccess/Data/Board1.json");
|
||||
string buildingPath = Path.Combine(Environment.CurrentDirectory, "../../../../LittleTown.StaticDataAccess/Data/Buildings.json");
|
||||
string objectivesPath = Path.Combine(Environment.CurrentDirectory, "../../../../LittleTown.StaticDataAccess/Data/Objectives.json");
|
||||
// Les fichiers JSON sont copiés dans le dossier de build via le .csproj
|
||||
// Ils sont donc toujours relatifs à l'exécutable
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -49,6 +53,11 @@ public class StaticDataGetter : IStaticDataGetter
|
||||
return board;
|
||||
}
|
||||
|
||||
public Task<Board> GetBoardAsync(int version)
|
||||
{
|
||||
return Task.FromResult(GetBoard(version));
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public ICollection<Building> GetBuildings()
|
||||
{
|
||||
|
||||
@@ -14,8 +14,14 @@ EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "LittleTown.Blazor", "LittleTown.Blazor", "{5142DF7A-0B25-DAC6-14FF-F9CE4E6A354A}"
|
||||
EndProject
|
||||
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
|
||||
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
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
||||
Reference in New Issue
Block a user