- small fixes in the game
- rokets will be switched off, if not solved in time
This commit is contained in:
parent
1b69470d9c
commit
e300e2325c
|
@ -4,6 +4,7 @@ public interface IStatemachine {
|
||||||
void addListener(StatemachineListener listener);
|
void addListener(StatemachineListener listener);
|
||||||
void reset();
|
void reset();
|
||||||
Statemachine.state getCurrentState();
|
Statemachine.state getCurrentState();
|
||||||
|
Statemachine.state getLastState();
|
||||||
void setNewState(Statemachine.state newState);
|
void setNewState(Statemachine.state newState);
|
||||||
int getStateChangeCounter();
|
int getStateChangeCounter();
|
||||||
void handleInput(char input);
|
void handleInput(char input);
|
||||||
|
|
|
@ -34,6 +34,7 @@ public class Statemachine implements IStatemachine {
|
||||||
|
|
||||||
private long lastHandleInput;
|
private long lastHandleInput;
|
||||||
private int stateChangeCounter;
|
private int stateChangeCounter;
|
||||||
|
private state lastState;
|
||||||
private state currentState;
|
private state currentState;
|
||||||
private int timertSecondsLeft;
|
private int timertSecondsLeft;
|
||||||
private int timertSeconds;
|
private int timertSeconds;
|
||||||
|
@ -53,6 +54,11 @@ public class Statemachine implements IStatemachine {
|
||||||
return currentState;
|
return currentState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public state getLastState() {
|
||||||
|
return lastState;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setNewState(state newState) {
|
public void setNewState(state newState) {
|
||||||
currentState = newState;
|
currentState = newState;
|
||||||
|
@ -80,6 +86,7 @@ public class Statemachine implements IStatemachine {
|
||||||
state newState = getNewState(input);
|
state newState = getNewState(input);
|
||||||
|
|
||||||
if( newState != currentState ) {
|
if( newState != currentState ) {
|
||||||
|
lastState = currentState;
|
||||||
stateChangeCounter++;
|
stateChangeCounter++;
|
||||||
currentState = newState;
|
currentState = newState;
|
||||||
onStateChanged();
|
onStateChanged();
|
||||||
|
|
|
@ -98,7 +98,10 @@ public class TheGame implements StatemachineListener, GuiEventListener, IRCEvent
|
||||||
relaisboard.setRelais(6, true); // enable third green circle
|
relaisboard.setRelais(6, true); // enable third green circle
|
||||||
|
|
||||||
extraSoundControl.playJingle("jump");
|
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.setLampel(false, true, false);
|
||||||
bunti.setPar56(20,0,100);
|
bunti.setPar56(20,0,100);
|
||||||
|
@ -247,6 +250,7 @@ public class TheGame implements StatemachineListener, GuiEventListener, IRCEvent
|
||||||
mpdController.playSong("crashtest","timeouted");
|
mpdController.playSong("crashtest","timeouted");
|
||||||
|
|
||||||
if(state == Statemachine.state.ROKET_STARTED) {
|
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");
|
ircClient.say("if ready, use >reset");
|
||||||
} else {
|
} else {
|
||||||
ircClient.say("if ready, set state with >state TABLE_GAME_DONE");
|
ircClient.say("if ready, set state with >state TABLE_GAME_DONE");
|
||||||
|
@ -263,7 +267,7 @@ public class TheGame implements StatemachineListener, GuiEventListener, IRCEvent
|
||||||
sayScore();
|
sayScore();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tsecondsLeft <= 627 && !startedHurrySound) {
|
if(tsecondsLeft <= 630 && !startedHurrySound) {
|
||||||
Statemachine.state state = machine.getCurrentState();
|
Statemachine.state state = machine.getCurrentState();
|
||||||
if( state != Statemachine.state.TABLE_GAME_DONE &&
|
if( state != Statemachine.state.TABLE_GAME_DONE &&
|
||||||
state != Statemachine.state.ROKET_DONE ) {
|
state != Statemachine.state.ROKET_DONE ) {
|
||||||
|
@ -495,10 +499,10 @@ public class TheGame implements StatemachineListener, GuiEventListener, IRCEvent
|
||||||
|
|
||||||
private void sayScore() {
|
private void sayScore() {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append("stateChangeCounter: ");
|
sb.append("st.ch.: ");
|
||||||
sb.append(machine.getStateChangeCounter());
|
sb.append(machine.getStateChangeCounter());
|
||||||
|
|
||||||
sb.append(" gamerRating: ");
|
sb.append(" rating: ");
|
||||||
sb.append(gamerRating);
|
sb.append(gamerRating);
|
||||||
|
|
||||||
int secondsLeft = machine.getTimerSecondsLeft();
|
int secondsLeft = machine.getTimerSecondsLeft();
|
||||||
|
@ -509,7 +513,7 @@ public class TheGame implements StatemachineListener, GuiEventListener, IRCEvent
|
||||||
int minsUsed = secondsUsed / 60;
|
int minsUsed = secondsUsed / 60;
|
||||||
int minsLeft = secondsLeft / 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));
|
mins, seconds % 60, minsUsed, secondsUsed % 60, minsLeft, secondsLeft % 60));
|
||||||
|
|
||||||
ircClient.say(sb.toString());
|
ircClient.say(sb.toString());
|
||||||
|
|
Loading…
Reference in New Issue