VanguardReMaster/client/Assets/Vanguard/Runtime/Board3D/Logic/BoardPlacementRules.cs

58 lines
2.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

namespace Vanguard.Board3D
{
/// <summary>
/// Локальные правила раскладки для UX. Сервер остаётся авторитарным:
/// эти проверки нужны для подсветки и drag&amp;drop, а не для начисления
/// результата.
/// </summary>
public static class BoardPlacementRules
{
public static bool CanRide(BoardZone zone, int slot) =>
zone == BoardZone.Vanguard && slot == PlaymatLayout.VanguardSlot;
public static bool CanCall(int slot, bool occupied) =>
slot >= 0
&& slot < PlaymatLayout.RearGuardCount;
// Occupied circles are valid call targets: the previous unit is
// moved to the drop zone.
public static bool CanGuard(BoardZone zone) =>
zone == BoardZone.Guardian;
public static bool CanMove(int fromSlot, int toSlot) =>
fromSlot >= 0
&& fromSlot < PlaymatLayout.RearGuardCount
&& toSlot >= 0
&& toSlot < PlaymatLayout.RearGuardCount
&& fromSlot != toSlot
&& SameColumn(fromSlot, toSlot);
public static bool CanAttack(int attackerSlot, int targetSlot) =>
attackerSlot >= PlaymatLayout.VanguardSlot
&& attackerSlot < PlaymatLayout.RearGuardCount
&& targetSlot >= PlaymatLayout.VanguardSlot
&& targetSlot < PlaymatLayout.RearGuardCount;
/// <summary>Колонки Classic: левая 0↔3, правая 2↔4; у центра пары нет.</summary>
public static bool SameColumn(int fromSlot, int toSlot) =>
(fromSlot, toSlot) is (0, 3) or (3, 0) or (2, 4) or (4, 2);
/// <summary>Call и Ride входят стоя и открытыми.</summary>
public static CardState3D EnterFromHand(CircleAttribute circle) => circle switch
{
CircleAttribute.Vanguard => CardState3D.FaceUpStand,
CircleAttribute.RearGuard => CardState3D.FaceUpStand,
CircleAttribute.Guardian => CardState3D.FaceUpStand,
_ => CardState3D.FaceUpStand,
};
/// <summary>Перемещение RC→RC сохраняет Rest и открытость.</summary>
public static CardState3D PreserveOnMove(CardState3D state) => state;
public static BoardZone ZoneOfSlot(int slot) =>
slot == PlaymatLayout.VanguardSlot
? BoardZone.Vanguard
: BoardZone.RearGuard;
}
}