Add square grid system, positional combat, sacrifice, and Placement phase
Grid infrastructure (SOR.Game/Grid/): - Coord — immutable (X,Y) struct with Manhattan distance, adjacency, BFS helpers - Tile — mutable affinity slots (Base1/Base2) + occupancy tracking - Board — 8×8 (configurable) grid, PlaceUnit/RemoveUnit/MoveUnit/BuildOccupancyMap - Pathfinding — Walk/Flight BFS (GetReachableWithCost), Jump/Teleport range (GetJumpRange) - LineOfSight — supercover DDA; occupied intermediate tiles block LOS - AffinitySystem — full Resolve table for all 20+ affinities per affinity.md, PushAffinity, ApplyPlacementAffinity, IsAffinityValid (basic vs non-basic rules) Combat (SOR.Game/Combat/): - AttackSystem — Manhattan range + optional LOS validation (§6.10) - SacrificeSystem — exact ST return formula from gameplay.md §6.15 Abilities (SOR.Game/Abilities/): - AbilitySystem stub — future pass per abilities.md Game engine / state changes: - GamePhase: added Placement phase (before Draw) - GameRuleSet + GameRules: added BoardWidth/BoardHeight (default 8×8) - GameState: added Board, PlayerOneAccountId; CardInstance gains MovementType, MaxMp, MinAttackRange, MaxAttackRange, RequiresLos, MinChannelRange, MaxChannelRange, IsLeader (moved from FieldCard); FieldCard adds Position + CurrentMp - [JsonPolymorphic] on CardInstance so FieldCard survives JSONB round-trip - JsonStringEnumConverter added to GameEngine serializer options - GameEngine.Initialize: creates Board + sets Placement phase; no opening draw yet - GameEngine.PlaceArchSpirit: validates row, pushes affinity, triggers opening draw and SP gain when both players placed - GameEngine.ChannelCard (was PlayCard): validates channeling range + affinity for Spirits - GameEngine.MoveUnit: Walk/Flight BFS, Jump (1 MP/landing), Teleport (LOS + 1 MP) - GameEngine.Attack: adds range+LOS validation via AttackSystem - GameEngine.Sacrifice: adjacency + SacrificeSystem ST formula - GameEngine.EndTurn: now also restores MP (§6.0 step 1) for next player - ToDto: includes Board tiles with resolved affinities; CardInstanceDto gets Position, CurrentMp, MaxMp, MovementType New handlers: game.place_arch_spirit, game.move_unit, game.sacrifice Updated handlers: game.play_card (target tile), GameReadyHandler (new Initialize sig) Migration: AddBoardDimensions (board_width/board_height on game_rule_sets) Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
@@ -11,8 +11,20 @@ public sealed record GameGetStateRequest(Guid SessionId);
|
||||
/// <summary>Draw a card from the player's deck.</summary>
|
||||
public sealed record GameDrawRequest(Guid SessionId);
|
||||
|
||||
/// <summary>Play a card from hand onto the field.</summary>
|
||||
public sealed record GamePlayCardRequest(Guid SessionId, string CardInstanceId);
|
||||
/// <summary>
|
||||
/// Place the player's ArchSpirit on their starting row (Placement phase only).
|
||||
/// P1 must place in row y=0; P2 must place in row y=Height-1.
|
||||
/// </summary>
|
||||
public sealed record GamePlaceArchSpiritRequest(Guid SessionId, CoordDto Position);
|
||||
|
||||
/// <summary>
|
||||
/// Channel (play) a card from hand. Spirit cards require a TargetTile within
|
||||
/// the ArchSpirit's channeling range; other card types may omit it.
|
||||
/// </summary>
|
||||
public sealed record GamePlayCardRequest(Guid SessionId, string CardInstanceId, CoordDto? TargetTile = null);
|
||||
|
||||
/// <summary>Move a unit on the board to a new tile.</summary>
|
||||
public sealed record GameMoveUnitRequest(Guid SessionId, string UnitInstanceId, CoordDto TargetPosition);
|
||||
|
||||
/// <summary>Attack an opponent card (or their ArchSpirit) with one of your field cards.</summary>
|
||||
public sealed record GameAttackRequest(
|
||||
@@ -20,6 +32,12 @@ public sealed record GameAttackRequest(
|
||||
string AttackerInstanceId,
|
||||
string TargetInstanceId);
|
||||
|
||||
/// <summary>
|
||||
/// Sacrifice one of your Spirits adjacent to your ArchSpirit (§6.15).
|
||||
/// Sacrifice is a free action — does not consume an attack or ability use.
|
||||
/// </summary>
|
||||
public sealed record GameSacrificeRequest(Guid SessionId, string UnitInstanceId);
|
||||
|
||||
/// <summary>End the active player's turn.</summary>
|
||||
public sealed record GameEndTurnRequest(Guid SessionId);
|
||||
|
||||
@@ -44,7 +62,9 @@ public sealed record CustomRulesOverride(
|
||||
int? SpAccumulationPerTurn = null,
|
||||
int? DrawPerTurn = null,
|
||||
bool? SpHasCap = null,
|
||||
int? SpCap = null);
|
||||
int? SpCap = null,
|
||||
int? BoardWidth = null,
|
||||
int? BoardHeight = null);
|
||||
|
||||
/// <summary>Join an open custom lobby with the specified deck.</summary>
|
||||
public sealed record JoinCustomLobbyRequest(Guid LobbyId, Guid DeckId);
|
||||
@@ -64,10 +84,16 @@ public sealed record GameGetStateResponse(GameStateDto State);
|
||||
|
||||
public sealed record GameDrawResponse(GameStateDto State);
|
||||
|
||||
public sealed record GamePlaceArchSpiritResponse(GameStateDto State);
|
||||
|
||||
public sealed record GamePlayCardResponse(GameStateDto State);
|
||||
|
||||
public sealed record GameMoveUnitResponse(GameStateDto State);
|
||||
|
||||
public sealed record GameAttackResponse(GameStateDto State);
|
||||
|
||||
public sealed record GameSacrificeResponse(GameStateDto State);
|
||||
|
||||
public sealed record GameEndTurnResponse(GameStateDto State);
|
||||
|
||||
public sealed record GameConcedeResponse(GameStateDto State);
|
||||
@@ -130,11 +156,12 @@ public sealed record CustomLobbyGameStartedPush(
|
||||
/// </summary>
|
||||
public sealed record GameStateDto(
|
||||
Guid SessionId,
|
||||
string Phase, // Draw | Main | End | GameOver
|
||||
string Phase, // Placement | Draw | Main | End | GameOver
|
||||
string ActivePlayerAccountId,
|
||||
int TurnNumber,
|
||||
int StateVersion, // monotonic; use for client mismatch detection
|
||||
IEnumerable<PlayerStateDto> Players);
|
||||
IEnumerable<PlayerStateDto> Players,
|
||||
BoardDto? Board); // full board state including tile affinities
|
||||
|
||||
public sealed record PlayerStateDto(
|
||||
Guid AccountId,
|
||||
@@ -148,19 +175,39 @@ public sealed record PlayerStateDto(
|
||||
int CurrentSt);
|
||||
|
||||
public sealed record CardInstanceDto(
|
||||
string InstanceId,
|
||||
Guid CardDefinitionId,
|
||||
string Name,
|
||||
string CardType,
|
||||
string Affinity,
|
||||
string Rarity,
|
||||
int? CurrentHealth,
|
||||
int? MaxHealth,
|
||||
int? CurrentDefense,
|
||||
int? MaxDefense,
|
||||
int? Damage,
|
||||
bool IsExhausted,
|
||||
bool IsLeader); // true for the ArchSpirit
|
||||
string InstanceId,
|
||||
Guid CardDefinitionId,
|
||||
string Name,
|
||||
string CardType,
|
||||
string Affinity,
|
||||
string Rarity,
|
||||
int? CurrentHealth,
|
||||
int? MaxHealth,
|
||||
int? CurrentDefense,
|
||||
int? MaxDefense,
|
||||
int? Damage,
|
||||
bool IsExhausted,
|
||||
bool IsLeader,
|
||||
CoordDto? Position, // null when not on field or not yet placed
|
||||
int? CurrentMp,
|
||||
int? MaxMp,
|
||||
string? MovementType); // enum as string, null for non-unit cards
|
||||
|
||||
public sealed record BoardDto(
|
||||
int Width,
|
||||
int Height,
|
||||
IEnumerable<TileDto> Tiles);
|
||||
|
||||
public sealed record TileDto(
|
||||
CoordDto Coord,
|
||||
string Base1,
|
||||
string Base2,
|
||||
string ResolvedAffinity,
|
||||
string? OccupantId,
|
||||
string? OccupantOwner);
|
||||
|
||||
/// <summary>Client-facing 2D coordinate.</summary>
|
||||
public sealed record CoordDto(int X, int Y);
|
||||
|
||||
public sealed record CustomLobbyDto(
|
||||
Guid LobbyId,
|
||||
@@ -176,4 +223,6 @@ public sealed record CustomRulesDto(
|
||||
int SpAccumulationPerTurn,
|
||||
int DrawPerTurn,
|
||||
bool SpHasCap,
|
||||
int SpCap);
|
||||
int SpCap,
|
||||
int BoardWidth,
|
||||
int BoardHeight);
|
||||
|
||||
Reference in New Issue
Block a user