mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-02-01 07:39:35 +01:00
Legger til funksjonalitet for å dele ut kort til aktive spillere
Parprogrammering med Torbjørn
This commit is contained in:
parent
4bcadf106e
commit
7312347615
@ -26,6 +26,7 @@ public class RoboRallyGame implements IDrawableGame {
|
|||||||
private List<BoardElementContainer<Tile>> fastConveyorBelts;
|
private List<BoardElementContainer<Tile>> fastConveyorBelts;
|
||||||
private List<Player> playerList;
|
private List<Player> playerList;
|
||||||
private final boolean host;
|
private final boolean host;
|
||||||
|
private Deck<ProgrammingCard> mainDeck;
|
||||||
/**
|
/**
|
||||||
* Instantiates a new robo rally game
|
* Instantiates a new robo rally game
|
||||||
* @param debug Whether to start the game in debugging mode
|
* @param debug Whether to start the game in debugging mode
|
||||||
@ -123,6 +124,7 @@ public class RoboRallyGame implements IDrawableGame {
|
|||||||
initializePlayers();
|
initializePlayers();
|
||||||
gameBoard = BoardLoaderUtil.loadBoard("boards/Checkmate.txt", robots);
|
gameBoard = BoardLoaderUtil.loadBoard("boards/Checkmate.txt", robots);
|
||||||
generateTileLists();
|
generateTileLists();
|
||||||
|
mainDeck = DeckLoaderUtil.loadProgrammingCardsDeck();
|
||||||
|
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
@ -227,6 +229,7 @@ public class RoboRallyGame implements IDrawableGame {
|
|||||||
gameBoard.executePowerdown();
|
gameBoard.executePowerdown();
|
||||||
if (host) {
|
if (host) {
|
||||||
// TODO: Distribute programming cards to players not in power down
|
// TODO: Distribute programming cards to players not in power down
|
||||||
|
distributeProgrammingCardsToPlayers();
|
||||||
}
|
}
|
||||||
// TODO: Make program for this player, if not in power down
|
// TODO: Make program for this player, if not in power down
|
||||||
// TODO: Ask player for new power down
|
// TODO: Ask player for new power down
|
||||||
@ -239,12 +242,34 @@ public class RoboRallyGame implements IDrawableGame {
|
|||||||
|
|
||||||
// Repair robots on repair tiles
|
// Repair robots on repair tiles
|
||||||
repairAllRobotsOnRepairTiles();
|
repairAllRobotsOnRepairTiles();
|
||||||
|
// TODO: Update locked cards deck
|
||||||
// TODO: Remove non-locked programming cards
|
// TODO: Remove non-locked programming cards
|
||||||
// TODO: If this player is in power down, ask if it shall continue
|
// TODO: If this player is in power down, ask if it shall continue
|
||||||
// Respawn dead robots, as long as they have more lives left
|
// Respawn dead robots, as long as they have more lives left
|
||||||
respawnRobots();
|
respawnRobots();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void distributeProgrammingCardsToPlayers() {
|
||||||
|
int robotDamage;
|
||||||
|
ProgrammingCardDeck playerDeck;
|
||||||
|
mainDeck.shuffle();
|
||||||
|
|
||||||
|
for (Player player : playerList) {
|
||||||
|
RobotID robot = player.getRobotID();
|
||||||
|
playerDeck = player.getPlayerDeck();
|
||||||
|
if (gameBoard.getPowerDown(robot)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
robotDamage = gameBoard.getRobotDamage(robot);
|
||||||
|
if (robotDamage >= 9) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (playerDeck.isEmpty()) {
|
||||||
|
playerDeck.draw(mainDeck,9-robotDamage);
|
||||||
|
} else throw new IllegalStateException("Player deck must be empty!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs one phase as defined in the Robo Rally rulebook
|
* Runs one phase as defined in the Robo Rally rulebook
|
||||||
* @param phaseNumber The number of the phase to run
|
* @param phaseNumber The number of the phase to run
|
||||||
|
Loading…
x
Reference in New Issue
Block a user