Exemplo n.º 1
0
 public static APIMsgConclusion makeClientMove(Connect4Command command)
 {
     return(new APIMsgConclusion()
     {
         msg = command.move.ToString(), target = MsgTarget.Server, status = ResponseStatus.Success
     });
 }
Exemplo n.º 2
0
        private APIMsgConclusion handleMakeClientMove(JSONObject jObj)
        {
            Connect4Command command = new Connect4Command();

            command.move = (int)jObj.GetField(Consts.Fields.move).i;
            return(APIGameLogic.makeClientMove(command));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Returns a list of possible available moves, depening on the specified current board.
        /// </summary>
        /// <param name="command"></param>
        /// <returns>APIMsgConclusion</returns>
        public static APIMsgConclusion evaluateBoard(Connect4Command command)
        {
            string boardMsg = command.board.encodeBoard(false, false, true);

            return(new APIMsgConclusion()
            {
                msg = boardMsg, status = ResponseStatus.Success, target = MsgTarget.Player
            });
        }
Exemplo n.º 4
0
        private APIMsgConclusion handleSimulateMove(JSONObject jObj)
        {
            Connect4Command command = parseAPICommand(jObj, Consts.Actions.simMove);

            command.player           = (int)jObj.GetField(Consts.Fields.player).i;
            command.getPossibleMoves = jObj.HasField(Consts.Fields.possibleMoves);
            command.move             = (int)jObj.GetField(Consts.Fields.move).i;

            return(APIGameLogic.simulateMove(command));
        }
Exemplo n.º 5
0
        /// <summary>
        /// Returns a list of possible available moves, depening on the specified current board.
        /// </summary>
        /// <param name="command"></param>
        /// <returns>APIMsgConclusion</returns>
        public static APIMsgConclusion aquirePossibleMoves(Connect4Command command)
        {
            getPossibleMoves(command.board);
            string boardMsg = command.board.encodeBoard(false, true, command.evaluate);

            return(new APIMsgConclusion()
            {
                msg = boardMsg, status = ResponseStatus.Success, target = MsgTarget.Player
            });
        }
Exemplo n.º 6
0
        private Connect4Command parseAPICommand(JSONObject jObj, string action)
        {
            Connect4Command command = new Connect4Command()
            {
                action = action
            };

            command.evaluate = action == Consts.Actions.evalBoard || jObj.HasField(Consts.Fields.evaluate);
            command.board    = command.board = new Board(jObj.GetField(Consts.Fields.board), command.evaluate);

            return(command);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Simulates the future board, depending on the specified current board and move.
        /// </summary>
        /// <param name="command"></param>
        /// <returns>APIMsgConclusion</returns>
        public static APIMsgConclusion simulateMove(Connect4Command command)
        {
            playMove(command.board, command.move, command.player);
            if (command.getPossibleMoves)
            {
                getPossibleMoves(command.board);
            }

            string boardMsg = command.board.encodeBoard(true, command.getPossibleMoves, command.evaluate);

            return(new APIMsgConclusion()
            {
                msg = boardMsg, status = ResponseStatus.Success, target = MsgTarget.Player
            });
        }
Exemplo n.º 8
0
        private APIMsgConclusion handleEvalBoard(JSONObject jObj)
        {
            Connect4Command command = parseAPICommand(jObj, Consts.Actions.evalBoard);

            return(APIGameLogic.evaluateBoard(command));
        }
Exemplo n.º 9
0
        private APIMsgConclusion handleGetPossibleMoves(JSONObject jObj)
        {
            Connect4Command command = parseAPICommand(jObj, Consts.Actions.simMove);

            return(APIGameLogic.aquirePossibleMoves(command));
        }