From e300e2325c7cb65d42f85f21ea09a64726c165b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Ple=C3=9F?= Date: Fri, 22 Jun 2012 01:54:07 +0200 Subject: [PATCH] - small fixes in the game - rokets will be switched off, if not solved in time --- src/de/ctdo/crashtest/game/IStatemachine.java | 1 + src/de/ctdo/crashtest/game/Statemachine.java | 7 +++++++ src/de/ctdo/crashtest/game/TheGame.java | 14 +++++++++----- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/de/ctdo/crashtest/game/IStatemachine.java b/src/de/ctdo/crashtest/game/IStatemachine.java index 83b0d75..13abfc5 100644 --- a/src/de/ctdo/crashtest/game/IStatemachine.java +++ b/src/de/ctdo/crashtest/game/IStatemachine.java @@ -4,6 +4,7 @@ public interface IStatemachine { void addListener(StatemachineListener listener); void reset(); Statemachine.state getCurrentState(); + Statemachine.state getLastState(); void setNewState(Statemachine.state newState); int getStateChangeCounter(); void handleInput(char input); diff --git a/src/de/ctdo/crashtest/game/Statemachine.java b/src/de/ctdo/crashtest/game/Statemachine.java index 04a2076..5830a7f 100644 --- a/src/de/ctdo/crashtest/game/Statemachine.java +++ b/src/de/ctdo/crashtest/game/Statemachine.java @@ -34,6 +34,7 @@ public class Statemachine implements IStatemachine { private long lastHandleInput; private int stateChangeCounter; + private state lastState; private state currentState; private int timertSecondsLeft; private int timertSeconds; @@ -53,6 +54,11 @@ public class Statemachine implements IStatemachine { return currentState; } + @Override + public state getLastState() { + return lastState; + } + @Override public void setNewState(state newState) { currentState = newState; @@ -80,6 +86,7 @@ public class Statemachine implements IStatemachine { state newState = getNewState(input); if( newState != currentState ) { + lastState = currentState; stateChangeCounter++; currentState = newState; onStateChanged(); diff --git a/src/de/ctdo/crashtest/game/TheGame.java b/src/de/ctdo/crashtest/game/TheGame.java index f214d39..9c10fd3 100644 --- a/src/de/ctdo/crashtest/game/TheGame.java +++ b/src/de/ctdo/crashtest/game/TheGame.java @@ -98,7 +98,10 @@ public class TheGame implements StatemachineListener, GuiEventListener, IRCEvent relaisboard.setRelais(6, true); // enable third green circle extraSoundControl.playJingle("jump"); - //mpdController.playSong("crashtest", "table_game_one"); + + if(machine.getLastState() != Statemachine.state.TABLE_GAME_WRONG) { + mpdController.playSong("crashtest", "table_game_one"); + } bunti.setLampel(false, true, false); bunti.setPar56(20,0,100); @@ -247,6 +250,7 @@ public class TheGame implements StatemachineListener, GuiEventListener, IRCEvent mpdController.playSong("crashtest","timeouted"); if(state == Statemachine.state.ROKET_STARTED) { + relaisboard.toggleRelais(0, 300); // r0kets toogle (so there will probably be switched off) ircClient.say("if ready, use >reset"); } else { ircClient.say("if ready, set state with >state TABLE_GAME_DONE"); @@ -263,7 +267,7 @@ public class TheGame implements StatemachineListener, GuiEventListener, IRCEvent sayScore(); } - if(tsecondsLeft <= 627 && !startedHurrySound) { + if(tsecondsLeft <= 630 && !startedHurrySound) { Statemachine.state state = machine.getCurrentState(); if( state != Statemachine.state.TABLE_GAME_DONE && state != Statemachine.state.ROKET_DONE ) { @@ -495,10 +499,10 @@ public class TheGame implements StatemachineListener, GuiEventListener, IRCEvent private void sayScore() { StringBuilder sb = new StringBuilder(); - sb.append("stateChangeCounter: "); + sb.append("st.ch.: "); sb.append(machine.getStateChangeCounter()); - sb.append(" gamerRating: "); + sb.append(" rating: "); sb.append(gamerRating); int secondsLeft = machine.getTimerSecondsLeft(); @@ -509,7 +513,7 @@ public class TheGame implements StatemachineListener, GuiEventListener, IRCEvent int minsUsed = secondsUsed / 60; int minsLeft = secondsLeft / 60; - sb.append(String.format(" time: %d:%02d used: %d:%02d left: %d:%02d", + sb.append(String.format(" time:%d:%02d u:%d:%02d l:%d:%02d", mins, seconds % 60, minsUsed, secondsUsed % 60, minsLeft, secondsLeft % 60)); ircClient.say(sb.toString());