namespace YGOLegacy.Protocol.Contracts { public readonly struct ErrorMsg { public byte Msg { get; } public int Code { get; } public ErrorMsg(byte msg, int code) { Msg = msg; Code = code; } } public readonly struct HandResultAnnounce { public byte First { get; } public byte Second { get; } public HandResultAnnounce(byte first, byte second) { First = first; Second = second; } } // STOC 0x5B (patch 0017), to every seat and spectator before SELECT_TP: who chooses the turn order and how the coin landed. public readonly struct CoinTossAnnounce { public const byte CurrentVersion = 1; public const byte Heads = 0; public const byte Tails = 1; // No toss: game 2+ of a match, the loser chooses. public const byte NoFace = 0xFF; public byte Version { get; } public byte ChooserSeat { get; } public byte Face { get; } public byte ChooseSeconds { get; } public CoinTossAnnounce(byte chooserSeat, byte face, byte chooseSeconds) : this(CurrentVersion, chooserSeat, face, chooseSeconds) { } public CoinTossAnnounce(byte version, byte chooserSeat, byte face, byte chooseSeconds) { Version = version; ChooserSeat = chooserSeat; Face = face; ChooseSeconds = chooseSeconds; } public bool Tossed => Face != NoFace; } public readonly struct HostInfo { public uint Lflist { get; } public byte Rule { get; } public byte Mode { get; } public byte DuelRule { get; } public bool NoCheckDeck { get; } public bool NoShuffleDeck { get; } public int StartLp { get; } public byte StartHand { get; } public byte DrawCount { get; } public ushort TimeLimit { get; } public HostInfo(uint lflist, byte rule, byte mode, byte duelRule, bool noCheckDeck, bool noShuffleDeck, int startLp, byte startHand, byte drawCount, ushort timeLimit) { Lflist = lflist; Rule = rule; Mode = mode; DuelRule = duelRule; NoCheckDeck = noCheckDeck; NoShuffleDeck = noShuffleDeck; StartLp = startLp; StartHand = startHand; DrawCount = drawCount; TimeLimit = timeLimit; } } public readonly struct TypeChange { public byte Position { get; } public bool IsHost { get; } public TypeChange(byte position, bool isHost) { Position = (byte)(position & 0xF); IsHost = isHost; } } public readonly struct TimeLimit { public byte Player { get; } public ushort LeftTime { get; } public TimeLimit(byte player, ushort leftTime) { Player = player; LeftTime = leftTime; } } public readonly struct ServerChat { public ushort Player { get; } public string Text { get; } public ServerChat(ushort player, string text) { Player = player; Text = text ?? string.Empty; } } public readonly struct PlayerEnter { public string Name { get; } public byte Position { get; } public PlayerEnter(string name, byte position) { Name = name ?? string.Empty; Position = position; } } public enum PlayerChangeKind { MoveTo, Observe, Ready, NotReady, Leave, Unknown } public readonly struct PlayerChange { public const byte ObserveState = 0x8; public const byte ReadyState = 0x9; public const byte NotReadyState = 0xA; public const byte LeaveState = 0xB; public byte Position { get; } public byte State { get; } public PlayerChangeKind Kind { get; } public byte TargetSeat { get; } public PlayerChange(byte position, byte state) { Position = (byte)(position & 0xF); State = (byte)(state & 0xF); Kind = KindOf(State); TargetSeat = Kind == PlayerChangeKind.MoveTo ? State : (byte)0; } public static PlayerChangeKind KindOf(byte state) { if (state < ObserveState) return PlayerChangeKind.MoveTo; switch (state) { case ObserveState: return PlayerChangeKind.Observe; case ReadyState: return PlayerChangeKind.Ready; case NotReadyState: return PlayerChangeKind.NotReady; case LeaveState: return PlayerChangeKind.Leave; default: return PlayerChangeKind.Unknown; } } } public readonly struct WatchChange { public ushort Count { get; } public WatchChange(ushort count) { Count = count; } } public readonly struct DeckCount { public short Main0 { get; } public short Extra0 { get; } public short Side0 { get; } public short Main1 { get; } public short Extra1 { get; } public short Side1 { get; } public DeckCount(short main0, short extra0, short side0, short main1, short extra1, short side1) { Main0 = main0; Extra0 = extra0; Side0 = side0; Main1 = main1; Extra1 = extra1; Side1 = side1; } } }