Esempio n. 1
0
 public HumanPlayer(String name, BoardGameMidlet frame, int side) {
   super(name, frame.getGame(), side);
   this.frame = frame;
   BoardGame game = (BoardGame) getGame();
   game.addStateListener(this);
   frame.getBoard().addActionListener(this);
   it = new MoveIterator(game);
   moves = new Vector(game.getBoard().size);
   moveIndex = -1;
 }
Esempio n. 2
0
 public void stateChanged(State state) {
   BoardGame game = (BoardGame) getGame();
   if ((state == game.STATE_THINKING) && (game.getCurrentPlayer() == this)) {
     it.reset(this, game.getBoard());
     while (it.hasMoreElements()) {
       moves.addElement(it.nextElement());
     }
     if (isMoveAvailable()) {
       setCursor(0);
     }
   }
 }
Esempio n. 3
0
 public void gameAction(int action) {
   BoardGame game = (BoardGame) getGame();
   if ((game.getCurrentPlayer() == this)
       && (game.getState() == game.STATE_THINKING)
       && (getSelectedMove() != null)) {
     switch (action) {
       case Canvas.FIRE:
         game.queueMove(getSelectedMove());
         moves.removeAllElements();
         break;
       case Canvas.LEFT:
       case Canvas.UP:
         moveCursor(-1);
         break;
       case Canvas.DOWN:
       case Canvas.RIGHT:
         moveCursor(1);
         break;
     }
   }
 }