* chore: add battleground UI task tracker (2026-03-28) * feat(#142): add [NonSerialized] battleground runtime state to CardModel * feat(#143): add LoadArtCrop and LoadCardRaw (RawImage) to ImageCache * feat(#148): add GameStateManager singleton and GameState/SeatState POCOs * feat(#138): add BattlegroundController scene orchestrator * feat(#139): add LifeTrackerWidget, CommanderDamageRow, PoisonCounter * feat(#140): add PhaseTrackerWidget and PhaseStepButton * feat(#141): add TurnOrderBar and TurnOrderPill * feat(#142): add CardZone and CardView battlefield zone components * feat(#143): add CommanderZoneWidget with art crop, cast counter, and tax display * feat(#144): add TokenModel POCO, TokenPanelController, and TokenRowView * chore: mark issues 1-8 as complete in task tracker * feat(#146): add StackZoneController, StackItemView, and ManaPoolDisplay * feat(#147 #150 #151): add LobbySetupModal, ZoneViewerModal, EliminationHandler; add Play Live button to SimulationController * feat(#151): add Play Live button to SimulationController * feat(#149): add GameWebSocketClient with reconnect, ping, and main-thread dispatch * fix: add PostGameAction to ApiClient + update TODO.md all issues complete - ApiClient.cs: add PostGameAction() wrapper → POST /api/game/action (fixes compile error in HumanActionBar.cs) - TODO.md: mark issues #145, #146, #147, #149, #150, #151 as ✅ all 14 battleground issues now committed * feat(game): add routes/game.py + wire lab_api + fix GameWebSocketClient game_id URL - routes/game.py: POST /api/game/start, POST /api/game/action (new) - lab_api.py: import + register game_router - GameWebSocketClient.cs: read game_id from PlayerPrefs, build ws://{host}/ws/game/{game_id} — fixes URL mismatch with ws_game.py * fix(lobby): wire OnConfirm to POST /api/game/start, save game_id to PlayerPrefs - OnConfirm() now calls ApiClient.PostGameStart() with 4-seat config - On success: saves BattleSeats + GameId + WsUrl to PlayerPrefs, loads Battleground scene - On failure: shows inline error label (red), re-enables Confirm button - Added StartGameRequest/Response POCOs matching routes/game.py schema - Added _errorLabel [SerializeField] for user-facing error feedback
55 lines
1.9 KiB
C#
55 lines
1.9 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using TMPro;
|
|
|
|
namespace CommanderAILab.UI
|
|
{
|
|
/// <summary>
|
|
/// Visual row for a single item on the stack.
|
|
/// Shows card/ability name, caster seat color, stack position, and targets.
|
|
/// </summary>
|
|
public class StackItemView : MonoBehaviour
|
|
{
|
|
[SerializeField] private TMP_Text cardNameLabel;
|
|
[SerializeField] private TMP_Text casterLabel;
|
|
[SerializeField] private TMP_Text targetsLabel;
|
|
[SerializeField] private TMP_Text stackPositionLabel;
|
|
[SerializeField] private Image seatColorStrip;
|
|
|
|
private static readonly Color[] SeatColors =
|
|
{
|
|
new Color(0.2f, 0.6f, 1f), // seat 0 — blue (human)
|
|
new Color(1f, 0.4f, 0.4f), // seat 1 — red
|
|
new Color(0.4f, 1f, 0.4f), // seat 2 — green
|
|
new Color(1f, 0.85f, 0.2f) // seat 3 — gold
|
|
};
|
|
|
|
public void Bind(StackZoneController.StackItem item, int displayPosition)
|
|
{
|
|
if (cardNameLabel)
|
|
cardNameLabel.text = item.isAbility ? $"⚡ {item.cardName}" : item.cardName;
|
|
|
|
if (casterLabel)
|
|
casterLabel.text = item.casterSeat == 0 ? "You" : $"Seat {item.casterSeat}";
|
|
|
|
if (seatColorStrip)
|
|
{
|
|
int seat = Mathf.Clamp(item.casterSeat, 0, SeatColors.Length - 1);
|
|
seatColorStrip.color = SeatColors[seat];
|
|
}
|
|
|
|
if (stackPositionLabel)
|
|
stackPositionLabel.text = displayPosition == 0 ? "[TOP]" : $"[{displayPosition}]";
|
|
|
|
if (targetsLabel)
|
|
{
|
|
if (item.targets != null && item.targets.Count > 0)
|
|
targetsLabel.text = "\u2192 " + string.Join(", ", item.targets);
|
|
else
|
|
targetsLabel.text = "";
|
|
}
|
|
}
|
|
}
|
|
}
|