Black box sim engine (commands in, events out) with 3 piece types (Rook, Bishop, Knight), cargo transfer system with social status priority, collision detection, and victory/defeat conditions. 57 tests covering rules, simulation, loading, and solvability. Godot 4 presentation layer scaffolding.
61 lines
1.9 KiB
C#
61 lines
1.9 KiB
C#
using Godot;
|
|
using System.Collections.Generic;
|
|
using Chessistics.Engine.Model;
|
|
|
|
namespace Chessistics.Scripts.UI;
|
|
|
|
public partial class ObjectivePanel : VBoxContainer
|
|
{
|
|
private readonly Dictionary<Coords, (Label label, ProgressBar bar)> _entries = new();
|
|
|
|
public void Setup(IReadOnlyList<DemandDef> demands)
|
|
{
|
|
foreach (var child in GetChildren())
|
|
child.QueueFree();
|
|
_entries.Clear();
|
|
|
|
var title = new Label { Text = "OBJECTIFS" };
|
|
title.AddThemeFontSizeOverride("font_size", 16);
|
|
AddChild(title);
|
|
|
|
AddChild(new HSeparator());
|
|
|
|
foreach (var demand in demands)
|
|
{
|
|
var vbox = new VBoxContainer();
|
|
|
|
var label = new Label { Text = $"{demand.Name}: 0/{demand.Amount} {demand.Cargo}" };
|
|
label.AddThemeFontSizeOverride("font_size", 12);
|
|
vbox.AddChild(label);
|
|
|
|
var bar = new ProgressBar
|
|
{
|
|
MinValue = 0,
|
|
MaxValue = demand.Amount,
|
|
Value = 0,
|
|
CustomMinimumSize = new Vector2(180, 16),
|
|
ShowPercentage = false
|
|
};
|
|
vbox.AddChild(bar);
|
|
|
|
var deadline = new Label { Text = $"Deadline: {demand.Deadline} coups" };
|
|
deadline.AddThemeFontSizeOverride("font_size", 10);
|
|
deadline.AddThemeColorOverride("font_color", new Color("#AAAAAA"));
|
|
vbox.AddChild(deadline);
|
|
|
|
AddChild(vbox);
|
|
_entries[demand.Position] = (label, bar);
|
|
}
|
|
}
|
|
|
|
public void UpdateProgress(Coords demandCell, string name, int current, int required)
|
|
{
|
|
if (!_entries.TryGetValue(demandCell, out var entry)) return;
|
|
|
|
entry.label.Text = $"{name}: {current}/{required}";
|
|
entry.bar.Value = current;
|
|
|
|
if (current >= required)
|
|
entry.label.AddThemeColorOverride("font_color", new Color("#44CC44"));
|
|
}
|
|
}
|