61 lines
1.4 KiB
Java
61 lines
1.4 KiB
Java
package pp.mdga.game;
|
|
|
|
import java.util.Map;
|
|
|
|
/**
|
|
* This class will be used to hold all Board relevant data.
|
|
*/
|
|
public class Board {
|
|
private Map<Color, PlayerData> playerData;
|
|
private Node[] infield;
|
|
|
|
/**
|
|
* This constructor is used to create a new board
|
|
*/
|
|
public Board() {
|
|
infield = new Node[40];
|
|
for (int i = 0; i < 40; i++) {
|
|
if (i % 10 == 0) {
|
|
infield[i] = new StartNode(
|
|
i == 0 ? Color.AIRFORCE :
|
|
i == 10 ? Color.CYBER :
|
|
i == 20 ? Color.NAVY :
|
|
Color.ARMY
|
|
);
|
|
} else if (i == 4 || i == 14 || i == 24 || i == 34) {
|
|
infield[i] = new BonusNode();
|
|
} else {
|
|
infield[i] = new Node();
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* This method returns the playerData
|
|
*
|
|
* @return the playerData
|
|
*/
|
|
public Map<Color, PlayerData> getPlayerData() {
|
|
return playerData;
|
|
}
|
|
|
|
/**
|
|
* This method returns the infield
|
|
*
|
|
* @return the infield
|
|
*/
|
|
public Node[] getInfield() {
|
|
return infield;
|
|
}
|
|
|
|
/**
|
|
* This method sets a piece on a specific Node in the infield
|
|
*
|
|
* @param index the index of the node
|
|
* @param piece the piece to be set
|
|
*/
|
|
public void setPieceOnBoard(int index, Piece piece) {
|
|
infield[index].setOccupant(piece);
|
|
}
|
|
}
|