Пример #1
0
        //////////
        //// HANDLERS FOR BOARD, PIECES, LOGIC AND HIGHLIGHTING LOCATED BELOW HERE
        //////////
        public static void MakeMove(int boardX, int boardY)
        {
            if (wait_for_timer || !player_turn || wait_for_computer || !canMove())
            {
                return;
            }
            if (MainPage.game_state == GameState.OUT_OF_GAME || MainPage.game_state == GameState.END_GAME || (checkerX == -1 && checkerY == -1))
            {
                return;
            }

            if (game_type == GameState.SINGLE_PLAYER)
            {
                player_turn = false;
            }
            wait_for_timer = true;
            Move m;

            try
            {
                PieceColor whoseTurn = logic.whoseMove();
                int        locX      = checkerX;
                int        locY      = checkerY;
                // Unhighlight the selected piece
                handleHighlighting(checkerX, checkerY);
                m = logic.makeMove(locY, locX, boardY, boardX);

                handleMove(m);
                if (whoseTurn.Equals(logic.whoseMove()))
                {
                    checkerX   = boardX;
                    checkerY   = boardY;
                    multi_jump = true;
                }

                TURN_TIMER.Start();
            }
            catch (PlayerMustJumpException)
            {
                MessageBox.Show("You must take an available jump!");
                wait_for_timer = false;
                player_turn    = true;
            }
            catch (WrongMultiJumpPieceException)
            {
                MessageBox.Show("You must finish the multijump!");
                wait_for_timer = false;
                player_turn    = true;
            }
            catch (InvalidMoveException)
            {
                System.Diagnostics.Debug.WriteLine("invalid move");
                wait_for_timer = false;
                player_turn    = true;
            }
        }
Пример #2
0
        public static List <List <MoveAttempt> > getFullTurns(List <MoveAttempt> possibility, GameLogic g)
        {
            List <List <MoveAttempt> > fullturns = new List <List <MoveAttempt> >();

            g.makeMove(possibility[possibility.Count - 1]);
            if (g.multiJumpLoc == null)
            {
                fullturns.Add(possibility);
            }
            else
            {
                foreach (Vector v in g.getDoableJumps(g.board.getCellContents(g.multiJumpLoc)))
                {
                    MoveAttempt        move = new MoveAttempt(v, g.board.getCellContents(g.multiJumpLoc));
                    List <MoveAttempt> p    = new List <MoveAttempt>();
                    p.AddRange(possibility);
                    p.Add(move);
                    GameLogic newG = new GameLogic(g);
                    g.makeMove(move);
                    fullturns.AddRange(getFullTurns(p, newG));
                }
            }
            return(fullturns);
        }
Пример #3
0
 public static List<List<MoveAttempt>> getFullTurns(List<MoveAttempt> possibility, GameLogic g)
 {
     List<List<MoveAttempt>> fullturns = new List<List<MoveAttempt>>();
     g.makeMove(possibility[possibility.Count-1]);
     if(g.multiJumpLoc == null) {
         fullturns.Add(possibility);
     } else {
         foreach(Vector v in g.getDoableJumps(g.board.getCellContents(g.multiJumpLoc))) {
             MoveAttempt move = new MoveAttempt(v, g.board.getCellContents(g.multiJumpLoc));
             List<MoveAttempt> p = new List<MoveAttempt>();
             p.AddRange(possibility);
             p.Add(move);
             GameLogic newG = new GameLogic(g);
             g.makeMove(move);
             fullturns.AddRange(getFullTurns(p, newG));
         }
     }
     return fullturns;
 }