mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-01-31 23:29:36 +01:00
Merge branch 'master' of https://github.com/inf112-v20/Fiasko
This commit is contained in:
commit
e4e4f04d23
@ -44,6 +44,8 @@ public enum GameState {
|
||||
/**
|
||||
* Indicates that the game is no longer running
|
||||
*/
|
||||
EXITED
|
||||
EXITED,
|
||||
|
||||
SKIP_POWER_DOWN_SCREEN
|
||||
|
||||
}
|
||||
|
@ -92,7 +92,13 @@ public class CardChoiceScreen extends InputAdapter implements Screen {
|
||||
@Override
|
||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
|
||||
if (chosenCards.size() == maxCards) {
|
||||
roboRallyWrapper.roboRallyGame.setProgram(getCards());
|
||||
List<ProgrammingCard> oldProgram = roboRallyWrapper.roboRallyGame.getProgram();
|
||||
int lockedCardsInt = 5-maxCards;
|
||||
List<ProgrammingCard> newProgram = getCards();
|
||||
for(int i = 5; i>(5-lockedCardsInt);i--){
|
||||
newProgram.add(oldProgram.get(i));
|
||||
}
|
||||
roboRallyWrapper.roboRallyGame.setProgram(newProgram);
|
||||
roboRallyWrapper.roboRallyGame.setGameState(GameState.CHOOSING_POWER_DOWN);
|
||||
roboRallyWrapper.setScreen(roboRallyWrapper.screenManager.getPowerDownScreen(roboRallyWrapper));
|
||||
return true;
|
||||
|
@ -7,6 +7,9 @@ import com.badlogic.gdx.utils.viewport.ExtendViewport;
|
||||
import com.badlogic.gdx.utils.viewport.Viewport;
|
||||
import inf112.fiasko.roborally.elementproperties.GameState;
|
||||
import inf112.fiasko.roborally.gamewrapper.RoboRallyWrapper;
|
||||
import inf112.fiasko.roborally.networking.containers.ProgramAndPowerdownRequest;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* This screen is used to wait for something
|
||||
@ -68,6 +71,14 @@ public class LoadingScreen extends AbstractScreen {
|
||||
case EXITED:
|
||||
roboRallyWrapper.quit("All players died. Cannot continue playing.");
|
||||
break;
|
||||
case CHOOSING_POWER_DOWN:
|
||||
roboRallyWrapper.setScreen(roboRallyWrapper.screenManager.getPowerDownScreen(this.roboRallyWrapper));
|
||||
break;
|
||||
case SKIP_POWER_DOWN_SCREEN:
|
||||
roboRallyWrapper.roboRallyGame.setGameState(GameState.LOADING);
|
||||
roboRallyWrapper.setScreen(roboRallyWrapper.screenManager.getLoadingScreen(this.roboRallyWrapper));
|
||||
roboRallyWrapper.client.sendElement(new ProgramAndPowerdownRequest(false, new ArrayList<>()));
|
||||
break;
|
||||
default:
|
||||
System.out.println("The loading screen doesn't know what to do with " + gameState);
|
||||
break;
|
||||
|
@ -57,11 +57,18 @@ public class PowerDownScreen extends AbstractScreen {
|
||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||
camera.update();
|
||||
roboRallyWrapper.batch.setProjectionMatrix(camera.combined);
|
||||
|
||||
String descriptiontext;
|
||||
if(roboRallyWrapper.roboRallyGame.getGameState()==GameState.CHOOSING_POWER_DOWN){
|
||||
descriptiontext = "click the button to enter powerdown next round";
|
||||
}
|
||||
else{
|
||||
descriptiontext = "continue powerdown?";
|
||||
}
|
||||
int elapsedTime = (int) Math.floor((System.currentTimeMillis() - startTime) / 1000f);
|
||||
|
||||
roboRallyWrapper.batch.begin();
|
||||
roboRallyWrapper.font.draw(roboRallyWrapper.batch, "Click the button to enter Power Down next round",
|
||||
|
||||
roboRallyWrapper.font.draw(roboRallyWrapper.batch, descriptiontext,
|
||||
applicationWidth / 2f - 380 / 2f, applicationHeight / 2f + 100, 380, 1,
|
||||
true);
|
||||
roboRallyWrapper.font.draw(roboRallyWrapper.batch, String.valueOf(10 - elapsedTime),
|
||||
|
@ -11,6 +11,8 @@ import inf112.fiasko.roborally.networking.containers.ProgamsContainer;
|
||||
import inf112.fiasko.roborally.objects.ProgrammingCardDeck;
|
||||
import inf112.fiasko.roborally.objects.RoboRallyGame;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* This listener handles all receiving from the server
|
||||
*/
|
||||
@ -40,7 +42,16 @@ class RoboRallyClientListener extends Listener {
|
||||
wrapper.roboRallyGame = new RoboRallyGame(info.getPlayerList(), info.getBoardName(),
|
||||
wrapper.server != null, info.getPlayerName(), wrapper.server);
|
||||
} else if (object instanceof ProgrammingCardDeck) {
|
||||
wrapper.roboRallyGame.setGameState(GameState.CHOOSING_CARDS);
|
||||
if(((ProgrammingCardDeck) object).isEmpty()){
|
||||
if (wrapper.roboRallyGame.getRobotPowerdown()){
|
||||
wrapper.roboRallyGame.setGameState(GameState.SKIP_POWER_DOWN_SCREEN);
|
||||
}
|
||||
else {
|
||||
wrapper.roboRallyGame.setGameState(GameState.CHOOSING_POWER_DOWN);
|
||||
}
|
||||
wrapper.roboRallyGame.setProgram(new ArrayList<>());
|
||||
}
|
||||
else {wrapper.roboRallyGame.setGameState(GameState.CHOOSING_CARDS);}
|
||||
new Thread(() -> wrapper.roboRallyGame.setPlayerHand((ProgrammingCardDeck) object)).start();
|
||||
} else if (object instanceof ProgamsContainer) {
|
||||
new Thread(() -> {
|
||||
|
@ -77,7 +77,7 @@ public class Player {
|
||||
* @param cardList list the size of 5 with programing cards
|
||||
*/
|
||||
public void setProgram(List<ProgrammingCard> cardList) {
|
||||
if (cardList.size() != 5) {
|
||||
if (cardList.size() != 5 && !cardList.isEmpty()) {
|
||||
throw new IllegalArgumentException("The program must contain exactly 5 cards.");
|
||||
} else {
|
||||
program = new ArrayList<>(cardList);
|
||||
|
@ -15,6 +15,7 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* This class represent a game which is drawable using libgdx
|
||||
@ -33,6 +34,13 @@ public class RoboRallyGame implements DrawableGame, InteractableGame {
|
||||
private ProgrammingCardDeck playerHand;
|
||||
private Phase phase;
|
||||
|
||||
public Boolean getRobotPowerdown(){
|
||||
if(getPlayerFromName(this.playerName)!=null){
|
||||
return gameBoard.getPowerDown(Objects.requireNonNull(getPlayerFromName(this.playerName)).getRobotID());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new Robo Rally game
|
||||
*
|
||||
@ -173,19 +181,20 @@ public class RoboRallyGame implements DrawableGame, InteractableGame {
|
||||
removeNonLockedProgrammingCardsFromPlayers();
|
||||
}
|
||||
|
||||
if (gameBoard.getPowerDown(getPlayerFromName(this.playerName).getRobotID())) {
|
||||
if (gameBoard.getPowerDown(Objects.requireNonNull(getPlayerFromName(this.playerName)).getRobotID())) {
|
||||
setGameState(GameState.CHOOSING_STAY_IN_POWER_DOWN);
|
||||
} else {
|
||||
setGameState(GameState.LOADING);
|
||||
|
||||
}
|
||||
//updateRobotPowerDown(); Should this be here?
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receiveStayInPowerDown(PowerDownContainer powerDowns) {
|
||||
for (Player player : playerList) {
|
||||
player.setPowerDownNextRound(powerDowns.getPowerDown().get(player.getName()));
|
||||
if(gameBoard.getPowerDown(player.getRobotID())) {
|
||||
player.setPowerDownNextRound(powerDowns.getPowerDown().get(player.getName()));
|
||||
}
|
||||
}
|
||||
respawnRobots();
|
||||
sendAllDeadPlayersToServer();
|
||||
|
@ -1,15 +1,15 @@
|
||||
12 12
|
||||
01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01
|
||||
01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01
|
||||
01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01
|
||||
01;01 05;01 01;01 01;01 01;01 01;01 01;01 05;01 01;01 01;01 01;01 01;01
|
||||
01;01 05;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 02;01 01;01 01;01
|
||||
01;01 05;03 01;01 05;07 01;01 01;01 01;01 01;01 01;01 05;01 01;01 01;01
|
||||
01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01
|
||||
01;01 01;01 01;01 01;01 01;01 11;01 01;01 01;01 01;01 01;01 01;01 01;01
|
||||
01;01 01;01 01;01 01;01 01;01 12;07 11;07 01;01 01;01 01;01 01;01 01;01
|
||||
01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01
|
||||
01;01 01;01 01;01 01;01 01;01 01;01 01;01 02;01 01;01 01;01 01;01 01;01
|
||||
01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01
|
||||
01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01
|
||||
01;01 01;01 01;01 01;01 01;01 12;07 11;07 01;01 01;01 04;01 01;01 01;01
|
||||
01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01
|
||||
01;01 01;01 01;01 01;01 11;01 05;01 05;03 02;01 01;01 03;01 01;01 01;01
|
||||
01;01 07;05 07;07 01;01 11;01 05;01 01;01 05;01 01;01 01;01 01;01 01;01
|
||||
01;01 07;03 07;01 01;01 11;01 05;01 01;01 01;01 01;01 01;01 01;01 01;01
|
||||
01;01 01;01 01;01 01;01 11;01 05;01 01;01 01;01 01;01 01;01 01;01 01;01
|
||||
01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01 01;01
|
||||
0 1;1 0 0 0 0 0 0 0 0 0 0
|
||||
0 0 0 0 0 0 0 0 0 0 0 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user