示例#1
0
 private void goAuto() {
   playerAuto.go();
   updateViews();
   while (!board.isAbleForGo(playerGamer.getId())) {
     if (!board.isAbleForGo(playerAuto.getId())) {
       int idWin = board.getIdWinCounterNotAbleForGo();
       sendWinMessage(idWin);
       this.setFinished();
       return;
     }
     sendWaitMessage(View.UserOrAuto.user);
     playerAuto.go();
     updateViews();
   }
 }
示例#2
0
  private void initialNewGame(int sizeBoard, int idAuto, int idUser, int cntThreads, int level) {

    board.clear();
    playerAuto.dispose();
    playerAuto = new PlayerAuto(idAuto, board, cntThreads, level);
    playerGamer = new PlayerGamer(idUser, board);
    this.isInGame = true;
  }
示例#3
0
 public void setNewGameDiagonal(int sizeBoard, int idAuto, int idUser, int cntThreads, int level) {
   this.initialNewGame(sizeBoard, idAuto, idUser, cntThreads, level);
   if (sizeBoard > 4) {
     int szDiv2 = sizeBoard / 2;
     board.setMwithCounter(idUser, szDiv2 - 1, szDiv2 - 1);
     board.setMwithCounter(idAuto, szDiv2, szDiv2 - 1);
     board.setMwithCounter(idAuto, szDiv2 - 1, szDiv2);
     board.setMwithCounter(idUser, szDiv2, szDiv2);
   }
   updateViews();
   if (board.BOARD_SECOND == playerGamer.getId()) {
     playerAuto.go();
   }
   updateViews();
 }
示例#4
0
 private void sendWinMessage(int idWin) {
   int idUser = playerGamer.getId();
   int idAuto = playerAuto.getId();
   int cntUser = board.getCountFromCounters(idUser);
   int cntAuto = board.getCountFromCounters(idAuto);
   for (View view : views) {
     if (idWin == Board.WIN_FIRST && idUser == Board.BOARD_FIRST)
       view.showWin(View.UserOrAutoOrNone.user, cntUser, cntAuto);
     if (idWin == Board.WIN_SECOND && idUser == Board.BOARD_SECOND)
       view.showWin(View.UserOrAutoOrNone.user, cntUser, cntAuto);
     if (idWin == Board.WIN_FIRST && idAuto == Board.BOARD_FIRST)
       view.showWin(View.UserOrAutoOrNone.auto, cntUser, cntAuto);
     if (idWin == Board.WIN_SECOND && idAuto == Board.BOARD_SECOND)
       view.showWin(View.UserOrAutoOrNone.auto, cntUser, cntAuto);
     if (idWin == Board.WIN_DRAW) view.showWin(View.UserOrAutoOrNone.none, cntUser, cntAuto);
   }
 }
示例#5
0
 public void goUser(Point purpose) // return id Win user
     {
   if (!isInGame) return;
   if (!board.isAbleForGo(playerGamer.getId(), purpose)) return;
   playerGamer.go(purpose);
   updateViews();
   if (!board.isAbleForGo(playerAuto.getId())) {
     if (!board.isAbleForGo(playerGamer.getId())) {
       int idWin = board.getIdWinCounterNotAbleForGo();
       sendWinMessage(idWin);
       this.setFinished();
       return;
     }
     sendWaitMessage(View.UserOrAuto.auto);
     return;
   } else {
     goAuto();
     return;
   }
 }
示例#6
0
 public void dispose() {
   playerAuto.dispose();
 }
示例#7
0
 public int getCountAuto() {
   return board.getCount(playerAuto.getId());
 }