mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-01-31 23:29:36 +01:00
Legger til en sjekk for ugylding spillstatus når power down velges
This commit is contained in:
parent
d24eb1aa64
commit
80075d5015
@ -9,15 +9,10 @@ import com.badlogic.gdx.scenes.scene2d.Stage;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
|
||||
import com.badlogic.gdx.utils.viewport.FitViewport;
|
||||
import com.badlogic.gdx.utils.viewport.Viewport;
|
||||
import inf112.fiasko.roborally.elementproperties.Action;
|
||||
import inf112.fiasko.roborally.elementproperties.GameState;
|
||||
import inf112.fiasko.roborally.gamewrapper.RoboRallyWrapper;
|
||||
import inf112.fiasko.roborally.gamewrapper.SimpleButton;
|
||||
import inf112.fiasko.roborally.networking.containers.ProgramAndPowerdownRequest;
|
||||
import inf112.fiasko.roborally.objects.ProgrammingCard;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This screen is used for asking players whether they want to power down
|
||||
@ -49,7 +44,7 @@ public class PowerDownScreen extends AbstractScreen {
|
||||
powerDownButton.addListener(new InputListener() {
|
||||
@Override
|
||||
public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
|
||||
sendPowerdownStatus(true);
|
||||
sendPowerDownStatus(true);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
@ -75,27 +70,29 @@ public class PowerDownScreen extends AbstractScreen {
|
||||
stage.draw();
|
||||
|
||||
if (elapsedTime > 10) {
|
||||
sendPowerdownStatus( false);
|
||||
sendPowerDownStatus( false);
|
||||
}
|
||||
}
|
||||
|
||||
public void sendPowerdownStatus (boolean bool){
|
||||
if(roboRallyWrapper.roboRallyGame.getGameState()== GameState.CHOOSING_STAY_IN_POWER_DOWN){
|
||||
/**
|
||||
* Sends power down status to the server
|
||||
* @param bool Whether the player wants to go/stay in power down
|
||||
*/
|
||||
private void sendPowerDownStatus(boolean bool) {
|
||||
switch (roboRallyWrapper.roboRallyGame.getGameState()) {
|
||||
case CHOOSING_STAY_IN_POWER_DOWN:
|
||||
roboRallyWrapper.roboRallyGame.setGameState(GameState.TURN_CLEANUP);
|
||||
roboRallyWrapper.client.sendElement(bool);
|
||||
}
|
||||
else if (roboRallyWrapper.roboRallyGame.getGameState()==GameState.CHOOSING_POWER_DOWN){
|
||||
|
||||
break;
|
||||
case CHOOSING_POWER_DOWN:
|
||||
roboRallyWrapper.roboRallyGame.setGameState(GameState.LOADING);
|
||||
|
||||
roboRallyWrapper.client.sendElement(new ProgramAndPowerdownRequest(bool,
|
||||
roboRallyWrapper.roboRallyGame.getProgram()));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("The game is in an unexpected state. Cannot continue.");
|
||||
}
|
||||
|
||||
|
||||
roboRallyWrapper.setScreen(roboRallyWrapper.screenManager.getLoadingScreen(this.roboRallyWrapper));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
x
Reference in New Issue
Block a user