From 92f1a7282a038b329ce4a399694ca9c7e363e718 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Ple=C3=9F?= Date: Fri, 15 Jun 2012 01:04:53 +0200 Subject: [PATCH] added wall limit per time --- src/de/ctdo/crashtest/game/TheGame.java | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/de/ctdo/crashtest/game/TheGame.java b/src/de/ctdo/crashtest/game/TheGame.java index 43f4009..76e74be 100644 --- a/src/de/ctdo/crashtest/game/TheGame.java +++ b/src/de/ctdo/crashtest/game/TheGame.java @@ -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 {