Exemple #1
0
 private void addTokens() {
   tokens = new MonopolyToken[gameScreen.getNumPlayers()];
   for (int i = 0; i < tokens.length; i++) {
     MonopolyToken token = createToken(gameScreen.getTokenName(i), i);
     tokens[i] = token;
     add(token);
   }
   addKeyListener(new TokenMoveListener(this));
 }
Exemple #2
0
 public void moveToken(int nextTile) {
   if (nextTile > MAX_TILE_INDEX) gameScreen.giveSalary(playerTurn);
   int circularIndex = nextTile % 40;
   gameScreen.setPlayerLocation(playerTurn, circularIndex);
   tokens[playerTurn].setLocation(
       tileLocations[circularIndex][0], tileLocations[circularIndex][1]);
   repaint();
   revalidate();
   gameScreen.exacuteTileAction(playerTurn, circularIndex);
 }
Exemple #3
0
 public int getRolledDiceResult() {
   Random random = new Random();
   int dice1 = random.nextInt(5) + 1;
   int dice2 = random.nextInt(5) + 1;
   gameScreen.setDices(dice1, dice2);
   return dice1 + dice2;
 }
Exemple #4
0
 public int getPlayerLocation() {
   return gameScreen.getPlayerLocation(getTurn());
 }
Exemple #5
0
 public void changeTurn() {
   playerTurn = (++playerTurn) % tokens.length;
   gameScreen.setPlayerTurn(playerTurn);
 }