#nullable enable using System; using System.Collections.Generic; namespace ReplacedPerson.Core { public enum ReplacedEffectType { Attack = 0, Dodge = 1, Counter = 2 } public enum ReplacedMatchPhase { AwaitingLead = 0, AwaitingResponse = 1, Resolving = 2, Completed = 3 } public enum ReplacedWinner { None = -1, PlayerOne = 0, PlayerTwo = 1, Draw = 2 } [Serializable] public sealed class ReplacedCardDefinition { public string Id { get; set; } = string.Empty; public string Name { get; set; } = string.Empty; public string Description { get; set; } = string.Empty; public ReplacedEffectType EffectType { get; set; } public int Cost { get; set; } public int BaseValue { get; set; } public int Factor { get; set; } public string SpecialEffectId { get; set; } = string.Empty; } [Serializable] public sealed class ReplacedEndCardDefinition { public string Id { get; set; } = string.Empty; public string Name { get; set; } = string.Empty; public string Description { get; set; } = string.Empty; public int Cost { get; set; } public int[] SlotBase { get; set; } = new int[3]; public int[] SlotFactor { get; set; } = new int[3]; } [Serializable] public sealed class ReplacedEnemyDefinition { public string Id { get; set; } = string.Empty; public string Name { get; set; } = string.Empty; public int MaxHealth { get; set; } = 30; public List NormalDeck { get; set; } = new(); public List EndDeck { get; set; } = new(); public List RewardIds { get; set; } = new(); } [Serializable] public sealed class ReplacedDeck { public List NormalCards { get; set; } = new(); public List EndCards { get; set; } = new(); public ReplacedDeck Clone() => new() { NormalCards = new List(NormalCards), EndCards = new List(EndCards) }; } [Serializable] public sealed class ReplacedTurnSubmission { public bool Pass { get; set; } public bool DiscardEndOnPass { get; set; } public List NormalCardIds { get; set; } = new(); public List EndCardIds { get; set; } = new(); public int RerollSlot { get; set; } = -1; public ReplacedTurnSubmission Clone() => new() { Pass = Pass, DiscardEndOnPass = DiscardEndOnPass, NormalCardIds = new List(NormalCardIds), EndCardIds = new List(EndCardIds), RerollSlot = RerollSlot }; } [Serializable] public sealed class ReplacedMatchCommand { public long Sequence { get; set; } public string IdempotencyToken { get; set; } = string.Empty; public int PlayerIndex { get; set; } public ReplacedTurnSubmission Submission { get; set; } = new(); public ReplacedMatchCommand Clone() => new() { Sequence = Sequence, IdempotencyToken = IdempotencyToken, PlayerIndex = PlayerIndex, Submission = Submission.Clone() }; } [Serializable] public sealed class ReplacedPlayerState { public string PlayerId { get; set; } = string.Empty; public string DisplayName { get; set; } = string.Empty; public int Health { get; set; } = 30; public int MaxHealth { get; set; } = 30; public int Cost { get; set; } = 10; public int Defense { get; set; } public int BonusNormalDraw { get; set; } public bool GuaranteedDodge { get; set; } public bool SkipNextEndDraw { get; set; } public int SpentThisRound { get; set; } public int EffectiveEffectsThisRound { get; set; } public int DamageThisRound { get; set; } public List NormalDrawPile { get; set; } = new(); public List NormalDiscard { get; set; } = new(); public List NormalHand { get; set; } = new(); public List EndDrawPile { get; set; } = new(); public List EndDiscard { get; set; } = new(); public List EndHand { get; set; } = new(); public ReplacedPlayerState Clone() => new() { PlayerId = PlayerId, DisplayName = DisplayName, Health = Health, MaxHealth = MaxHealth, Cost = Cost, Defense = Defense, BonusNormalDraw = BonusNormalDraw, GuaranteedDodge = GuaranteedDodge, SkipNextEndDraw = SkipNextEndDraw, SpentThisRound = SpentThisRound, EffectiveEffectsThisRound = EffectiveEffectsThisRound, DamageThisRound = DamageThisRound, NormalDrawPile = new List(NormalDrawPile), NormalDiscard = new List(NormalDiscard), NormalHand = new List(NormalHand), EndDrawPile = new List(EndDrawPile), EndDiscard = new List(EndDiscard), EndHand = new List(EndHand) }; } [Serializable] public sealed class ReplacedSlotResolution { public int SlotIndex { get; set; } public ReplacedEffectType PlayerOneType { get; set; } public ReplacedEffectType PlayerTwoType { get; set; } public int PlayerOneRoll { get; set; } public int PlayerTwoRoll { get; set; } public int PlayerOneValue { get; set; } public int PlayerTwoValue { get; set; } public int DamageToPlayerOne { get; set; } public int DamageToPlayerTwo { get; set; } public bool PlayerOneRerolled { get; set; } public bool PlayerTwoRerolled { get; set; } public string Summary { get; set; } = string.Empty; } [Serializable] public sealed class ReplacedMatchState { public int Round { get; set; } public int LeadPlayer { get; set; } public int InitiativeRoll { get; set; } public ReplacedMatchPhase Phase { get; set; } public ReplacedWinner Winner { get; set; } = ReplacedWinner.None; public bool IsLastStand { get; set; } public bool LastStandUsed { get; set; } public ReplacedPlayerState[] Players { get; set; } = Array.Empty(); public ReplacedTurnSubmission?[] Submissions { get; set; } = new ReplacedTurnSubmission?[2]; public List LastResolution { get; set; } = new(); public List Log { get; set; } = new(); public long[] LastAcceptedSequence { get; set; } = new long[2]; public string ContentHash { get; set; } = string.Empty; public ReplacedMatchState Clone() => new() { Round = Round, LeadPlayer = LeadPlayer, InitiativeRoll = InitiativeRoll, Phase = Phase, Winner = Winner, IsLastStand = IsLastStand, LastStandUsed = LastStandUsed, Players = new[] { Players[0].Clone(), Players[1].Clone() }, Submissions = new ReplacedTurnSubmission?[] { Submissions[0]?.Clone(), Submissions[1]?.Clone() }, LastResolution = new List(LastResolution), Log = new List(Log), LastAcceptedSequence = (long[])LastAcceptedSequence.Clone(), ContentHash = ContentHash }; } public sealed class ReplacedCommandResult { public bool Accepted { get; set; } public bool Duplicate { get; set; } public string ErrorCode { get; set; } = string.Empty; public string Message { get; set; } = string.Empty; public string StateHash { get; set; } = string.Empty; } }