state: Added addPlayer function
This commit is contained in:
parent
8bab67bcba
commit
10b23e8a8c
@ -13,6 +13,12 @@ import java.util.Random;
|
||||
*/
|
||||
public class State {
|
||||
|
||||
// region Constants
|
||||
// Constants for the game. Changing these could create errors
|
||||
final int maxPlayers = 4;
|
||||
|
||||
// endregion
|
||||
|
||||
// region Variables
|
||||
final int boardHeight;
|
||||
private int numPlayers;
|
||||
@ -138,6 +144,19 @@ public class State {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void addPlayer(){
|
||||
if (numPlayers >= maxPlayers) return; // There are already the maximum number of players
|
||||
Player[] oldPlayers = players;
|
||||
players = new Player[numPlayers+1];
|
||||
for (int i=0; i<numPlayers; i++)
|
||||
{
|
||||
players[i] = oldPlayers[i];
|
||||
}
|
||||
players[numPlayers] = new Player(numPlayers);
|
||||
numPlayers++;
|
||||
}
|
||||
|
||||
public void distributeResources() {
|
||||
if (stonesCoords.length != 32) return; // There are not enough stones to distribute resources
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user