Exemplo n.º 1
0
 private void LoadMoves()
 {
     if (!movesLoaded)
     {
         List <string> moveList = redis.GetAllItemsFromList(movesKey);
         moves = new List <AlgebraicMove>();
         for (int i = 0; i < moveList.Count; i++)
         {
             AlgebraicMove move = new AlgebraicMove();
             move.move = moveList[i];
             moves.Add(move);
         }
         movesLoaded = true;
     }
 }
Exemplo n.º 2
0
        private void RegisterMove(string move, int stateAfterMove)
        {
            AlgebraicMove algMove = new AlgebraicMove();

            algMove.move = move;
            //TODO: If it's a game ending move
            //Turn to another player
            //Enter the move first
            redis.AddItemToList(movesKey, algMove.move);
            if (movesLoaded)
            {
                moves.Add(algMove);
            }
            UpdateTimeAfterMove();
            SetDataEntry(gameStateKey, stateAfterMove.ToString());

            GameState newGameState = (GameState)stateAfterMove;

            if (newGameState == GameState.Tie || newGameState == GameState.WhiteWin || newGameState == GameState.BlackWin)
            {
                FinishGame();
            }
        }