From 5278dc13e60a171aa27c7efcfbfaa2af2fa3cee1 Mon Sep 17 00:00:00 2001 From: Christian Kroll Date: Thu, 14 Jun 2012 06:06:35 +0200 Subject: [PATCH] make gem feature more battle.net like and adapted it to xleave's code style --- src/de/ctdo/crashtest/game/TheGame.java | 35 ++++++++++++++++--------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/src/de/ctdo/crashtest/game/TheGame.java b/src/de/ctdo/crashtest/game/TheGame.java index 3eeec3f..ca534dc 100644 --- a/src/de/ctdo/crashtest/game/TheGame.java +++ b/src/de/ctdo/crashtest/game/TheGame.java @@ -16,6 +16,7 @@ public class TheGame implements StatemachineListener, GuiEventListener, IRCEvent private int gamerRating = 3; private Thread discoThread; private boolean shouldStopDisco; + private boolean gemActivated = false; public TheGame(IGuiControl guiControl) { this.guiControl = guiControl; @@ -274,18 +275,8 @@ public class TheGame implements StatemachineListener, GuiEventListener, IRCEvent disco(); } else if(message.startsWith("disco stop")) { discoStop(); - } else if(message.startsWith("gem activate")) { - java.util.Random random = new java.util.Random(); - int scry = random.nextInt(100); - if (scry >= 98) { - ircClient.say("Perfect Gem Activated"); - } else if (scry >= 90) { - ircClient.say("Moooooooo!"); - } else { - ircClient.say("Gem Activated"); - } - } else if(message.startsWith("gem deactivate")) { - ircClient.say("Gem Deactivated"); + } else if(message.startsWith("gem")) { + handleGem(); } else { ircClient.say("y u no use valid command?"); } @@ -319,6 +310,8 @@ public class TheGame implements StatemachineListener, GuiEventListener, IRCEvent machine.pauseTimer(true); } else if(params.startsWith("resume")) { machine.pauseTimer(false); + } else if(params.startsWith("gem")) { + ircClient.say("You don't say?"); } } @@ -342,6 +335,24 @@ public class TheGame implements StatemachineListener, GuiEventListener, IRCEvent } } + // Yes, it makes no sense, but I want have it anyway. For more Spass am Geraet! + private void handleGem() { + if (!gemActivated) { + java.util.Random random = new java.util.Random(); + int scry = random.nextInt(100); + if (scry >= 99) { + ircClient.say("Perfect Gem Activated"); + } else if (scry >= 90) { + ircClient.say("Moooooooo!"); + } else { + ircClient.say("Gem Activated"); + } + } else { + ircClient.say("Gem Deactivated"); + } + gemActivated = !gemActivated; + } + private void handleRelaisCommand(final String message) { String params = message.substring("relais".length()).trim().toLowerCase();