Esempio n. 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));
 }
Esempio n. 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);
 }
Esempio n. 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;
 }
Esempio n. 4
0
 public int getPlayerLocation() {
   return gameScreen.getPlayerLocation(getTurn());
 }
Esempio n. 5
0
 public void changeTurn() {
   playerTurn = (++playerTurn) % tokens.length;
   gameScreen.setPlayerTurn(playerTurn);
 }