Ejemplo n.º 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();
   }
 }
Ejemplo n.º 2
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);
   }
 }
Ejemplo n.º 3
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;
   }
 }
Ejemplo n.º 4
0
 public int getCountAuto() {
   return board.getCount(playerAuto.getId());
 }