mirror of
				https://github.com/inf112-v20/Fiasko.git
				synced 2025-10-26 23:33:44 +01:00 
			
		
		
		
	Legger til en sjekk for ugylding spillstatus når power down velges
This commit is contained in:
		| @@ -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){ | ||||
|             roboRallyWrapper.roboRallyGame.setGameState(GameState.TURN_CLEANUP); | ||||
|             roboRallyWrapper.client.sendElement(bool); | ||||
|     /** | ||||
|      * 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); | ||||
|                 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."); | ||||
|         } | ||||
|         else if (roboRallyWrapper.roboRallyGame.getGameState()==GameState.CHOOSING_POWER_DOWN){ | ||||
|  | ||||
|             roboRallyWrapper.roboRallyGame.setGameState(GameState.LOADING); | ||||
|  | ||||
|             roboRallyWrapper.client.sendElement(new ProgramAndPowerdownRequest(bool, | ||||
|                     roboRallyWrapper.roboRallyGame.getProgram())); | ||||
|  | ||||
|         } | ||||
|  | ||||
|  | ||||
|         roboRallyWrapper.setScreen(roboRallyWrapper.screenManager.getLoadingScreen(this.roboRallyWrapper)); | ||||
|  | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|   | ||||
		Reference in New Issue
	
	Block a user