added wall limit per time

This commit is contained in:
Lucas Pleß 2012-06-15 01:04:53 +02:00
parent 03abf212c1
commit 92f1a7282a
1 changed files with 17 additions and 5 deletions

View File

@ -14,6 +14,7 @@ public class TheGame implements StatemachineListener, GuiEventListener, IRCEvent
private final IMPDController mpdController;
private final IRelaisboard relaisboard;
private int gamerRating = 3;
private long lastHandleWall;
private Thread discoThread;
private boolean shouldStopDisco;
private boolean gemActivated = false;
@ -264,14 +265,14 @@ public class TheGame implements StatemachineListener, GuiEventListener, IRCEvent
} else if(message.startsWith("score")) {
sayScore();
} else if(message.startsWith("wall")) {
guiControl.setWall(message.substring("wall".length()).trim());
handleWallCommand(message);
} else if(message.startsWith("extra")) {
guiControl.setExtra(message.substring("extra".length()).trim());
} else if(message.startsWith("relais")) {
handleRelaisCommand(message);
} else if(message.startsWith("disco start")) {
} else if(message.startsWith("disco on")) {
discoStart();
} else if(message.startsWith("disco stop")) {
} else if(message.startsWith("disco off")) {
discoStop();
} else if(message.startsWith("gem")) {
handleGemCommand();
@ -280,6 +281,17 @@ public class TheGame implements StatemachineListener, GuiEventListener, IRCEvent
}
}
private void handleWallCommand(final String message) {
if(System.currentTimeMillis() - lastHandleWall < 7000 ) {
ircClient.say("not enough mana!");
return;
}
guiControl.setWall(message.substring("wall".length()).trim());
lastHandleWall = System.currentTimeMillis();
}
private void handleTimerCommand(final String message) {
String params = message.substring("timer".length()).trim().toLowerCase();
@ -369,7 +381,7 @@ public class TheGame implements StatemachineListener, GuiEventListener, IRCEvent
private void handleHelpCommand(final String message) {
if(message.equals("help")) {
ircClient.say("commands: help, reset, state, timer, wall, extra, score, relais, disco");
ircClient.say("commands: help, reset, state, timer, wall, extra, score, relais, disco, gem");
} else if(message.contains("reset")) {
ircClient.say("resets the game to IDLE");
} else if(message.contains("state")) {
@ -406,7 +418,7 @@ public class TheGame implements StatemachineListener, GuiEventListener, IRCEvent
ircClient.say("control the relais board");
ircClient.say("valid commands: lamp on, lamp off, lamp blink, lamp stop, oven on, oven off, rokets");
} else if(message.contains("disco")) {
ircClient.say("party! use: disco {start,stop}");
ircClient.say("party! use: disco {on,off}");
} else if(message.contains("gem")) {
ircClient.say("you don't say?");
} else {