예제 #1
0
 public MakeMove(ulong playerID, byte[] move, byte[] newBoardState, MatchStates newMatchState)
     : base(Types.MakeMove)
 {
     PlayerID      = playerID;
     Move          = move;
     NewBoardState = newBoardState;
     NewMatchState = newMatchState;
 }
예제 #2
0
 public override void Deserialize(BinaryReader reader)
 {
     base.Deserialize(reader);
     PlayerID      = reader.ReadUInt64();
     Move          = ReadBytes(reader);
     NewBoardState = ReadBytes(reader);
     NewMatchState = (MatchStates)reader.ReadByte();
 }
예제 #3
0
 public GameState(byte[] boardState, byte[][] recentMoves, MatchStates matchState,
                  ulong player1ID, ulong player2ID)
     : base(Types.GameState)
 {
     BoardState  = boardState;
     RecentMoves = recentMoves;
     MatchState  = matchState;
     Player1ID   = player1ID;
     Player2ID   = player2ID;
 }
예제 #4
0
        public static bool IsGameOver(this MatchStates state)
        {
            switch (state)
            {
            case MatchStates.Player1Turn:
            case MatchStates.Player2Turn:
                return(false);

            case MatchStates.Player1Won:
            case MatchStates.Player2Won:
            case MatchStates.Tie:
                return(true);

            default: throw new NotImplementedException(state.ToString());
            }
        }
예제 #5
0
        public override void Deserialize(BinaryReader reader)
        {
            base.Deserialize(reader);

            BoardState = ReadBytes(reader);

            RecentMoves = new byte[reader.ReadInt32()][];
            for (int i = 0; i < RecentMoves.Length; ++i)
            {
                RecentMoves[i] = ReadBytes(reader);
            }

            MatchState = (MatchStates)reader.ReadByte();

            Player1ID = reader.ReadUInt64();
            Player2ID = reader.ReadUInt64();
        }
예제 #6
0
 public override void Deserialize(BinaryReader reader)
 {
     base.Deserialize(reader);
     BoardState = ReadBytes(reader);
     MatchState = (MatchStates)reader.ReadByte();
 }
예제 #7
0
 public NewBoard(byte[] boardState, MatchStates matchState)
     : base(Types.NewBoard)
 {
     BoardState = boardState;
     MatchState = matchState;
 }