Compare commits
3 Commits
61bfb188f6
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 74840d32c1 | |||
| d6ee42b66d | |||
| 404ad03d0d |
@@ -0,0 +1,51 @@
|
||||
@page "/gear"
|
||||
@inject DocsService DocsService
|
||||
|
||||
<PageTitle>Gear & Equipment</PageTitle>
|
||||
|
||||
<div class="section-header d-flex align-items-center mb-4">
|
||||
<h1 class="mb-0">Gear & Equipment</h1>
|
||||
<div class="ms-3 flex-grow-1 border-bottom opacity-25"></div>
|
||||
</div>
|
||||
|
||||
@if (gearNotes == null)
|
||||
{
|
||||
<div class="d-flex justify-content-center py-5">
|
||||
<div class="spinner-border text-success" role="status">
|
||||
<span class="visually-hidden">Loading...</span>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="grid-container">
|
||||
<TelerikGrid Data="@gearNotes" Pageable="true" PageSize="50" Sortable="true" FilterMode="@GridFilterMode.FilterRow"
|
||||
Height="calc(100vh - 250px)">
|
||||
<GridColumns>
|
||||
<GridColumn Field="@(nameof(NoteInfo.Title))" Title="Item Name" Width="200px">
|
||||
<Template>
|
||||
<NavLink href="@($"docs/{(context as NoteInfo)!.Slug}")" class="fw-bold">@((context as NoteInfo)!.Title)</NavLink>
|
||||
</Template>
|
||||
</GridColumn>
|
||||
<GridColumn Field="@(nameof(NoteInfo.Cost))" Title="Cost" Width="90px" />
|
||||
<GridColumn Field="@(nameof(NoteInfo.GearCategory))" Title="Category" Width="140px"/>
|
||||
<GridColumn Field="@(nameof(NoteInfo.Effect))" Title="Effect"/>
|
||||
<GridColumn Field="@(nameof(NoteInfo.Location))" Title="Acquisition" Width="150px"/>
|
||||
</GridColumns>
|
||||
</TelerikGrid>
|
||||
</div>
|
||||
}
|
||||
|
||||
@code {
|
||||
private List<NoteInfo>? gearNotes;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
var index = await DocsService.GetIndexAsync();
|
||||
gearNotes = index.Notes
|
||||
.Where(n => string.Equals(n.Category, "Gear", StringComparison.OrdinalIgnoreCase))
|
||||
.OrderBy(n => n.Title)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="simulation-layout">
|
||||
<div class="simulation-layout" tabindex="0" @onkeydown="HandleKeyDown" @ref="layoutDiv">
|
||||
<div class="sim-controls d-flex align-items-center justify-content-between mb-3 flex-wrap gap-2">
|
||||
<div class="d-flex align-items-center gap-2">
|
||||
<button class="btn btn-outline-light btn-sm" @onclick="PrevTurn" disabled="@(SimService.Data.CurrentTurn <= 0)">
|
||||
@@ -109,12 +109,57 @@ else
|
||||
var dr = prev != null ? region.PreyMeeples - prev.PreyMeeples : 0;
|
||||
var df = prev != null ? region.FloraMeeples - prev.FloraMeeples : 0;
|
||||
var hasDelta = dp != 0 || dr != 0 || df != 0;
|
||||
|
||||
// Meeple dot counts (max 3 visible per type)
|
||||
var pdots = Math.Min(region.PredatorMeeples, 3);
|
||||
var rdots = Math.Min(region.PreyMeeples, 3);
|
||||
var fdots = Math.Min(region.FloraMeeples, 3);
|
||||
var dotR = 3;
|
||||
var dotGap = 7;
|
||||
|
||||
<g class="sim-region @(isActivated ? "sim-active" : "")">
|
||||
<circle cx="@region.X" cy="@region.Y" r="34" fill="url(#sg-@region.Terrain)"/>
|
||||
<circle cx="@region.X" cy="@region.Y" r="18"
|
||||
fill="@(terrainColor)cc"
|
||||
stroke="@(isActivated ? "#ffd700" : "rgba(255,255,255,0.5)")"
|
||||
stroke-width="@(isActivated ? 3 : 2)"/>
|
||||
|
||||
@* Predator dots (red, top row) *@
|
||||
@for (int d = 0; d < pdots; d++)
|
||||
{
|
||||
var dx = region.X + (d - (pdots - 1) * 0.5) * dotGap;
|
||||
var dy = region.Y - 7;
|
||||
<circle cx="@dx" cy="@dy" r="@dotR" fill="#e76f51" stroke="rgba(0,0,0,0.4)" stroke-width="0.5"/>
|
||||
}
|
||||
@if (region.PredatorMeeples > 3)
|
||||
{
|
||||
@((MarkupString)$"<text x=\"{region.X + 2 * dotGap + 2}\" y=\"{region.Y - 4}\" fill=\"#e76f51\" font-size=\"7\" font-weight=\"600\">+{region.PredatorMeeples - 3}</text>")
|
||||
}
|
||||
|
||||
@* Prey dots (yellow, middle row) *@
|
||||
@for (int d = 0; d < rdots; d++)
|
||||
{
|
||||
var dx = region.X + (d - (rdots - 1) * 0.5) * dotGap;
|
||||
var dy = region.Y;
|
||||
<circle cx="@dx" cy="@dy" r="@dotR" fill="#e9c46a" stroke="rgba(0,0,0,0.4)" stroke-width="0.5"/>
|
||||
}
|
||||
@if (region.PreyMeeples > 3)
|
||||
{
|
||||
@((MarkupString)$"<text x=\"{region.X + 2 * dotGap + 2}\" y=\"{region.Y + 3}\" fill=\"#e9c46a\" font-size=\"7\" font-weight=\"600\">+{region.PreyMeeples - 3}</text>")
|
||||
}
|
||||
|
||||
@* Flora dots (green, bottom row) *@
|
||||
@for (int d = 0; d < fdots; d++)
|
||||
{
|
||||
var dx = region.X + (d - (fdots - 1) * 0.5) * dotGap;
|
||||
var dy = region.Y + 7;
|
||||
<circle cx="@dx" cy="@dy" r="@dotR" fill="#4caf50" stroke="rgba(0,0,0,0.4)" stroke-width="0.5"/>
|
||||
}
|
||||
@if (region.FloraMeeples > 3)
|
||||
{
|
||||
@((MarkupString)$"<text x=\"{region.X + 2 * dotGap + 2}\" y=\"{region.Y + 10}\" fill=\"#4caf50\" font-size=\"7\" font-weight=\"600\">+{region.FloraMeeples - 3}</text>")
|
||||
}
|
||||
|
||||
<text x="@labelX" y="@(region.Y + 4)" fill="rgba(255,255,255,0.9)"
|
||||
font-family="system-ui,sans-serif" font-size="11" font-weight="600">
|
||||
@region.Name
|
||||
@@ -218,6 +263,7 @@ else
|
||||
|
||||
|
||||
@code {
|
||||
private ElementReference layoutDiv;
|
||||
private TurnEvent? CurrentEvent => SimService.Data.CurrentTurn > 0 && SimService.Data.CurrentTurn <= SimService.Data.Events.Count
|
||||
? SimService.Data.Events[SimService.Data.CurrentTurn - 1]
|
||||
: null;
|
||||
@@ -252,6 +298,18 @@ else
|
||||
SimService.Data.CurrentTurn++;
|
||||
}
|
||||
|
||||
private void HandleKeyDown(KeyboardEventArgs e)
|
||||
{
|
||||
if (e.Key == "ArrowLeft") PrevTurn();
|
||||
else if (e.Key == "ArrowRight") NextTurn();
|
||||
}
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
if (firstRender)
|
||||
await layoutDiv.FocusAsync();
|
||||
}
|
||||
|
||||
private void RandomizeEvents()
|
||||
{
|
||||
SimService.RandomizeEvents();
|
||||
|
||||
+1
-1
@@ -11,6 +11,6 @@ builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.
|
||||
builder.Services.AddScoped<DocsService>();
|
||||
builder.Services.AddSingleton<GameSimulationService>();
|
||||
|
||||
//builder.Services.AddTelerikBlazor();
|
||||
builder.Services.AddTelerikBlazor();
|
||||
|
||||
await builder.Build().RunAsync();
|
||||
@@ -76,12 +76,7 @@ public class GameSimulationService
|
||||
|
||||
public void RandomizeEvents()
|
||||
{
|
||||
var initialRegions = Data.InitialRegions;
|
||||
Data = new SimulationData();
|
||||
Data.Regions = initialRegions.Select(r => r.Clone()).ToList();
|
||||
Data.InitialRegions = initialRegions;
|
||||
GenerateAndApplyEvents();
|
||||
Data.IsInitialized = true;
|
||||
RunSimulation();
|
||||
}
|
||||
|
||||
public List<RegionState> GetCurrentState()
|
||||
@@ -181,22 +176,25 @@ public class GameSimulationService
|
||||
if (region.PredatorMeeples <= 0)
|
||||
return;
|
||||
|
||||
if (region.PreyMeeples > 0)
|
||||
int total = region.PredatorMeeples;
|
||||
int canEat = Math.Min(total, region.PreyMeeples);
|
||||
int mustTravel = total - canEat;
|
||||
|
||||
if (canEat > 0)
|
||||
{
|
||||
int eaten = Math.Min(region.PredatorMeeples, region.PreyMeeples);
|
||||
region.PreyMeeples -= eaten;
|
||||
region.PredatorMeeples += eaten;
|
||||
details.Add($"{region.Name}: Predators ate {eaten} prey, now {region.PredatorMeeples}P / {region.PreyMeeples}R");
|
||||
region.PreyMeeples -= canEat;
|
||||
region.PredatorMeeples += canEat;
|
||||
details.Add($"{region.Name}: {canEat} predators ate prey, +{canEat} new predators");
|
||||
}
|
||||
else
|
||||
|
||||
if (mustTravel > 0)
|
||||
{
|
||||
var target = FindBestTravelTarget(region, r => r.PreyMeeples);
|
||||
if (target != null)
|
||||
{
|
||||
int traveling = region.PredatorMeeples;
|
||||
target.PredatorMeeples += traveling;
|
||||
region.PredatorMeeples = 0;
|
||||
details.Add($"{region.Name}: {traveling} predators traveled to {target.Name}");
|
||||
region.PredatorMeeples -= mustTravel;
|
||||
target.PredatorMeeples += mustTravel;
|
||||
details.Add($"{region.Name}: {mustTravel} predators traveled to {target.Name}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -206,22 +204,25 @@ public class GameSimulationService
|
||||
if (region.PreyMeeples <= 0)
|
||||
return;
|
||||
|
||||
if (region.FloraMeeples > 0)
|
||||
int total = region.PreyMeeples;
|
||||
int canEat = Math.Min(total, region.FloraMeeples);
|
||||
int mustTravel = total - canEat;
|
||||
|
||||
if (canEat > 0)
|
||||
{
|
||||
int consumed = Math.Min(region.PreyMeeples, region.FloraMeeples);
|
||||
region.FloraMeeples -= consumed;
|
||||
region.PreyMeeples += consumed;
|
||||
details.Add($"{region.Name}: Prey consumed {consumed} flora, now {region.PreyMeeples}R / {region.FloraMeeples}F");
|
||||
region.FloraMeeples -= canEat;
|
||||
region.PreyMeeples += canEat;
|
||||
details.Add($"{region.Name}: {canEat} prey ate flora, +{canEat} new prey");
|
||||
}
|
||||
else
|
||||
|
||||
if (mustTravel > 0)
|
||||
{
|
||||
var target = FindBestTravelTarget(region, r => r.FloraMeeples);
|
||||
if (target != null)
|
||||
{
|
||||
int traveling = region.PreyMeeples;
|
||||
target.PreyMeeples += traveling;
|
||||
region.PreyMeeples = 0;
|
||||
details.Add($"{region.Name}: {traveling} prey traveled to {target.Name}");
|
||||
region.PreyMeeples -= mustTravel;
|
||||
target.PreyMeeples += mustTravel;
|
||||
details.Add($"{region.Name}: {mustTravel} prey traveled to {target.Name}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -315,13 +316,22 @@ public class GameSimulationService
|
||||
}
|
||||
}
|
||||
|
||||
var excluded = new HashSet<string>
|
||||
{
|
||||
"Grass 1", "Grass 2", "Wasteland 1",
|
||||
"Mountain 1", "Mountain 2", "Mountain 3", "Mountain 4", "Mountain 5"
|
||||
};
|
||||
|
||||
var shuffled = combos.OrderBy(_ => _rng.Next()).ToList();
|
||||
for (int i = 0; i < Data.Regions.Count; i++)
|
||||
{
|
||||
if (!excluded.Contains(Data.Regions[i].Name))
|
||||
{
|
||||
var (p, r, f) = shuffled[i % shuffled.Count];
|
||||
Data.Regions[i].PredatorMeeples = p;
|
||||
Data.Regions[i].PreyMeeples = r;
|
||||
Data.Regions[i].FloraMeeples = f;
|
||||
Data.Regions[i].FloraMeeples += f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
<PackageReference Include="Markdig" Version="0.40.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="10.0.9" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="10.0.9" PrivateAssets="all" />
|
||||
<PackageReference Include="Telerik.UI.for.Blazor" Version="14.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="SyncDocsNotes" BeforeTargets="BeforeBuild">
|
||||
|
||||
@@ -9,4 +9,6 @@
|
||||
@using Web
|
||||
@using Web.Layout
|
||||
@using Web.Models
|
||||
@using Telerik.Blazor
|
||||
@using Telerik.Blazor.Components
|
||||
@using Web.Services
|
||||
Reference in New Issue
Block a user