added rating explanation to irc

This commit is contained in:
Lucas Pleß 2012-06-08 03:13:48 +02:00
parent b388cce5f0
commit 899cad5719
1 changed files with 37 additions and 12 deletions

View File

@ -18,7 +18,7 @@ public class TheGame implements StatemachineListener, GuiEventListener, IRCEvent
public TheGame(IGuiControl guiControl) {
this.guiControl = guiControl;
this.ircClient = new IrcClient("crashtest", "#crashtest","irc.hackint.eu");
this.ircClient = new IrcClient("crashtest", "#crashtest","irc.ctdo.de");
this.bunti = new BuntiClient("bunti.ctdo.de", 8080);
this.mpdController = new MPDController("dampfradio.raum.ctdo.de");
this.relaisboard = new Relaisboard("/dev/ttyUSB0");
@ -37,8 +37,9 @@ public class TheGame implements StatemachineListener, GuiEventListener, IRCEvent
relaisboard.toggleRelais(2, 2000);
}
private void rate(int rating) {
private void rate(int rating, String text) {
gamerRating += rating;
ircClient.say("rated: " + rating + " (" + gamerRating + ") " + text );
if(gamerRating > 5) gamerRating = 5;
if(gamerRating < 1) gamerRating = 1;
}
@ -137,12 +138,12 @@ public class TheGame implements StatemachineListener, GuiEventListener, IRCEvent
// spieler haben 8 Minuten, wenn sie es in weniger als 4 minuten schaffen
// gibts +1, in weniger als 2 minuten gibts +2
if(machine.getTimerSecondsLast() >= 6*60 ) {
rate(2);
rate(2, "table game faster than 2 minutes");
} else if(machine.getTimerSecondsLast() > 4*60) {
rate(1);
rate(1, "table game faster than 4 minutes");
}
if(machine.getStateChangeCounter() > 100) {
rate(-1);
rate(-1, "more than 100 tries");
}
sayScore();
@ -154,7 +155,7 @@ public class TheGame implements StatemachineListener, GuiEventListener, IRCEvent
mpdController.setVolume(50);
mpdController.playSong("The Underdog Project", "Summer Jam");
bunti.setLampel(false,false,true);
bunti.setLampel(false,true,false);
bunti.setPar56(0, 255, 0);
ircClient.say("table game complete, r0kets now");
@ -166,10 +167,10 @@ public class TheGame implements StatemachineListener, GuiEventListener, IRCEvent
break;
case ROKET_DONE:
mpdController.setVolume(50);
mpdController.playSong("Coldplay", "Amsterdam");
mpdController.playSong("CTDO", "finish");
bunti.setLampel(true,true,true);
bunti.setPar56(255, 196, 0);
bunti.setLampel(false,false,true);
bunti.setPar56(255, 255, 255);
guiControl.showCountDown(true);
machine.pauseTimer(true);
@ -177,9 +178,9 @@ public class TheGame implements StatemachineListener, GuiEventListener, IRCEvent
// spieler haben 7 Minuten, wenn sie es in weniger als 4 minuten schaffen
// gibts +1, in weniger als 2 minuten gibts +2
if(machine.getTimerSecondsLast() >= 5*60 ) {
rate(2);
rate(2, "r0kets faster than 2 minutes");
} else if(machine.getTimerSecondsLast() > 3*60) {
rate(1);
rate(1, "r0kets faster than 4 minutes");
}
sayScore();
@ -198,7 +199,7 @@ public class TheGame implements StatemachineListener, GuiEventListener, IRCEvent
if( bla != Statemachine.state.TABLE_GAME_DONE &&
bla != Statemachine.state.ROKET_DONE ) {
rate(-2);
rate(-2, "game not done in time");
sayScore();
}
}
@ -247,6 +248,8 @@ public class TheGame implements StatemachineListener, GuiEventListener, IRCEvent
guiControl.setWall(message.substring("wall".length()).trim());
} else if(message.startsWith("extra")) {
guiControl.setExtra(message.substring("extra".length()).trim());
} else if(message.startsWith("relais")) {
handleRelaisCommand(message);
} else {
ircClient.say("y u no use valid command?");
}
@ -304,6 +307,25 @@ public class TheGame implements StatemachineListener, GuiEventListener, IRCEvent
}
}
private void handleRelaisCommand(final String message) {
String params = message.substring("relais".length()).trim().toLowerCase();
if(params.startsWith("lamp on")) {
relaisboard.setRelais(2, true);
} else if(params.startsWith("lamp off")) {
relaisboard.setRelais(2, false);
} else if(params.startsWith("oven on")) {
relaisboard.setRelais(3, true);
} else if(params.startsWith("oven off")) {
relaisboard.setRelais(3, false);
} else if(params.startsWith("rokets")) {
relaisboard.toggleRelais(0, 300);
}
}
private void handleHelpCommand(final String message) {
if(message.equals("help")) {
ircClient.say("commands: help, reset, state, timer, wall, extra, score");
@ -339,6 +361,9 @@ public class TheGame implements StatemachineListener, GuiEventListener, IRCEvent
ircClient.say("set small extra message on the screen");
} else if(message.contains("score")) {
ircClient.say("i will tell you the current game score");
} else if(message.contains("relais")) {
ircClient.say("control the relais board");
ircClient.say("valid commands: lamp on, lamp off, oven on, oven off, rokets");
} else {
ircClient.say("dafuq?");
}