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