Interum manual push
This commit is contained in:
@@ -180,7 +180,10 @@ public static class GameEngine
|
||||
/// Tri=3). Each subsequent tile must be orthogonally adjacent to the previous.
|
||||
/// The card's affinity is pushed to each tile; the card then goes to Discard.
|
||||
///
|
||||
/// Repentance / Instinct / Ruin: targetTiles may be null. The card goes to Discard after
|
||||
/// Ruin: placed on a random tile matching the card's affinity (ignores occupancy).
|
||||
/// Abilities fire at TurnStart if a Spirit/ArchSpirit occupies the tile.
|
||||
///
|
||||
/// Repentance / Instinct: targetTiles may be null. The card goes to Discard after
|
||||
/// cost payment — full effect resolution is deferred to AbilitySystem (future).
|
||||
/// </summary>
|
||||
public static GameState ChannelCard(
|
||||
@@ -196,6 +199,27 @@ public static class GameEngine
|
||||
if (player.CurrentSp < card.SpCost) throw new GameException("INSUFFICIENT_SP");
|
||||
if (player.CurrentSt < card.StCost) throw new GameException("INSUFFICIENT_ST");
|
||||
|
||||
// Ability lock-out checks.
|
||||
if (card.CardType == "Spirit" && !player.CanChannelSpirit)
|
||||
throw new GameException("CANNOT_CHANNEL_SPIRIT");
|
||||
if (card.CardType == "Repentance" && !player.CanChannelRepentance)
|
||||
throw new GameException("CANNOT_CHANNEL_REPENTANCE");
|
||||
if (card.CardType == "Instinct" && !player.CanChannelInstinct)
|
||||
throw new GameException("CANNOT_CHANNEL_INSTINCT");
|
||||
if (card.CardType == "Ruin" && !player.CanChannelRuin)
|
||||
throw new GameException("CANNOT_CHANNEL_RUIN");
|
||||
if (card.CardType == "Terramorpha")
|
||||
{
|
||||
var allowed = card.TerramorphaMode switch
|
||||
{
|
||||
TerramorphaMode.Mono => player.CanChannelTerramorphaMono,
|
||||
TerramorphaMode.Di => player.CanChannelTerramorphaDi,
|
||||
TerramorphaMode.Tri => player.CanChannelTerramorphaTri,
|
||||
_ => true,
|
||||
};
|
||||
if (!allowed) throw new GameException("CANNOT_CHANNEL_TERRAMORPHA");
|
||||
}
|
||||
|
||||
var board = state.Board ?? throw new GameException("BOARD_NOT_INITIALIZED");
|
||||
|
||||
if (card.CardType == "Spirit")
|
||||
@@ -289,9 +313,36 @@ public static class GameEngine
|
||||
CardType = "Terramorpha",
|
||||
});
|
||||
}
|
||||
else if (card.CardType == "Ruin")
|
||||
{
|
||||
// Place on a random tile matching the Ruin's affinity (may already be occupied).
|
||||
var hasAffinity = Enum.TryParse<Affinity>(card.Affinity, out var ruinAffinity);
|
||||
var validTiles = board.Tiles.Values
|
||||
.Where(t => !hasAffinity || AffinitySystem.IsAffinityValid(t, ruinAffinity))
|
||||
.ToList();
|
||||
if (validTiles.Count == 0) throw new GameException("NO_VALID_TILE");
|
||||
|
||||
var ruinCoord = validTiles[Random.Shared.Next(validTiles.Count)].Coord;
|
||||
|
||||
player.Hand.Remove(card);
|
||||
player.CurrentSp -= card.SpCost;
|
||||
player.CurrentSt -= card.StCost;
|
||||
|
||||
var ruinField = ToFieldCard(card, ruinCoord);
|
||||
player.Field.Add(ruinField);
|
||||
board.PlaceRuin(ruinCoord, ruinField.InstanceId, actorId);
|
||||
|
||||
AbilitySystem.FireTrigger(state, new TriggerOccurrence
|
||||
{
|
||||
Kind = TriggerEventKind.Channeled,
|
||||
ActorId = actorId,
|
||||
CardType = "Ruin",
|
||||
Data = new TriggerEventData { SourceId = ruinField.InstanceId },
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
// Repentance, Instinct, Ruin — pay cost, fire EffectsJson actions, then discard.
|
||||
// Repentance, Instinct — pay cost, fire EffectsJson actions, then discard.
|
||||
player.Hand.Remove(card);
|
||||
player.CurrentSp -= card.SpCost;
|
||||
player.CurrentSt -= card.StCost;
|
||||
@@ -405,6 +456,9 @@ public static class GameEngine
|
||||
if ((incoming.Tier ?? 1) != 1)
|
||||
throw new GameException("NOT_TIER_1");
|
||||
|
||||
if (!player.CanTransitionArchSpirit)
|
||||
throw new GameException("CANNOT_TRANSITION");
|
||||
|
||||
// Pay the incoming ArchSpirit's cost.
|
||||
if (player.CurrentSp < incoming.SpCost) throw new GameException("INSUFFICIENT_SP");
|
||||
if (player.CurrentSt < incoming.StCost) throw new GameException("INSUFFICIENT_ST");
|
||||
@@ -417,13 +471,15 @@ public static class GameEngine
|
||||
var coord = current.Position.Value;
|
||||
var newArchSpirit = ToFieldCard(incoming, coord, isLeader: true);
|
||||
|
||||
// Remove current from board; move to discard.
|
||||
// Remove current from board; fire aura leave before removal.
|
||||
AbilitySystem.EvaluateAurasOnLeave(state, current.InstanceId);
|
||||
board.RemoveUnit(current.InstanceId);
|
||||
player.Discard.Add(current);
|
||||
|
||||
// Seat the new ArchSpirit.
|
||||
// Seat the new ArchSpirit; fire aura enter after placement.
|
||||
player.ArchSpirit = newArchSpirit;
|
||||
board.PlaceUnit(coord, newArchSpirit.InstanceId, actorId);
|
||||
AbilitySystem.EvaluateAurasOnEnter(state, newArchSpirit.InstanceId);
|
||||
|
||||
AbilitySystem.FireTrigger(state, new TriggerOccurrence
|
||||
{
|
||||
@@ -507,6 +563,18 @@ public static class GameEngine
|
||||
Data = new TriggerEventData { SourceId = unitInstanceId },
|
||||
});
|
||||
|
||||
// Fire UnitOccupyRuin if the destination tile has a Ruin.
|
||||
var destTileAfterMove = board.GetTile(targetPos);
|
||||
if (destTileAfterMove?.RuinId is not null)
|
||||
{
|
||||
AbilitySystem.FireTrigger(state, new TriggerOccurrence
|
||||
{
|
||||
Kind = TriggerEventKind.UnitOccupyRuin,
|
||||
ActorId = actorId,
|
||||
Data = new TriggerEventData { SourceId = unitInstanceId, TargetId = destTileAfterMove.RuinId },
|
||||
});
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
@@ -731,6 +799,8 @@ public static class GameEngine
|
||||
ActorId = state.ActivePlayerAccountId,
|
||||
});
|
||||
|
||||
AbilitySystem.FireRuinAbilities(state);
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
@@ -1083,7 +1153,9 @@ public static class GameEngine
|
||||
Base2 : t.Base2.ToString(),
|
||||
ResolvedAffinity : AffinitySystem.Resolve(t.Base1, t.Base2).ToString(),
|
||||
OccupantId : t.OccupantId,
|
||||
OccupantOwner : t.OccupantOwner));
|
||||
OccupantOwner : t.OccupantOwner,
|
||||
RuinId : t.RuinId,
|
||||
RuinOwner : t.RuinOwner));
|
||||
|
||||
return new BoardDto(board.Width, board.Height, tiles);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user