state: Added addPlayer function
This commit is contained in:
@@ -13,6 +13,12 @@ import java.util.Random;
|
|||||||
*/
|
*/
|
||||||
public class State {
|
public class State {
|
||||||
|
|
||||||
|
// region Constants
|
||||||
|
// Constants for the game. Changing these could create errors
|
||||||
|
final int maxPlayers = 4;
|
||||||
|
|
||||||
|
// endregion
|
||||||
|
|
||||||
// region Variables
|
// region Variables
|
||||||
final int boardHeight;
|
final int boardHeight;
|
||||||
private int numPlayers;
|
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() {
|
public void distributeResources() {
|
||||||
if (stonesCoords.length != 32) return; // There are not enough stones to distribute resources
|
if (stonesCoords.length != 32) return; // There are not enough stones to distribute resources
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user