From 159b168b2618e4bf73130cba262570e70a374438 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Sun, 6 Apr 2014 23:24:11 +0200 Subject: Reimplement help command --- src/esieequest/controller/Parser.java | 2 +- src/esieequest/controller/Performer.java | 12 +++++++++--- src/esieequest/view/web/WebInterface.java | 8 ++++---- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/esieequest/controller/Parser.java b/src/esieequest/controller/Parser.java index cea2b78..7b07efb 100644 --- a/src/esieequest/controller/Parser.java +++ b/src/esieequest/controller/Parser.java @@ -32,7 +32,7 @@ class Parser { try { action = CommandWord.valueOf(elements[0].toUpperCase()); - } catch (Exception e) { + } catch (final Exception e) { action = CommandWord.UNKNOWN; } finally { if (elements.length > 1) { diff --git a/src/esieequest/controller/Performer.java b/src/esieequest/controller/Performer.java index 8f8afeb..7ba8c94 100644 --- a/src/esieequest/controller/Performer.java +++ b/src/esieequest/controller/Performer.java @@ -1,6 +1,10 @@ package esieequest.controller; +import java.util.HashSet; +import java.util.Set; + import esieequest.model.Game; +import esieequest.model.commands.CommandWord; import esieequest.model.items.Inventory; import esieequest.model.map.Room; import esieequest.view.View; @@ -88,9 +92,11 @@ class Performer { * Displays the help message and the available commands. */ public void showHelp() { - this.notImplemented(); - // this.echo(this.game.getHelpMessage()); - // TODO: list commands + final Set commands = new HashSet(); + for (final CommandWord command : CommandWord.values()) { + commands.add(command.name().toLowerCase()); + } + this.echo(Utils.list(commands, "Commands:", "No commands.")); } /** diff --git a/src/esieequest/view/web/WebInterface.java b/src/esieequest/view/web/WebInterface.java index 409414b..452284d 100644 --- a/src/esieequest/view/web/WebInterface.java +++ b/src/esieequest/view/web/WebInterface.java @@ -154,10 +154,10 @@ class WebInterface extends Composite implements View { this.loadButton.addClickHandler(this.makeClickHandler(CommandWord.LOAD.name())); this.saveButton.addClickHandler(this.makeClickHandler(CommandWord.SAVE.name())); this.actionButton.addClickHandler(this.makeClickHandler(CommandWord.DO.name())); - this.forwardButton.addClickHandler(this.makeClickHandler(CommandWord.GO.name()+" forward")); - this.backButton.addClickHandler(this.makeClickHandler(CommandWord.GO.name()+" back")); - this.leftButton.addClickHandler(this.makeClickHandler(CommandWord.TURN.name()+" left")); - this.rightButton.addClickHandler(this.makeClickHandler(CommandWord.TURN.name()+" right")); + this.forwardButton.addClickHandler(this.makeClickHandler(CommandWord.GO.name() + " forward")); + this.backButton.addClickHandler(this.makeClickHandler(CommandWord.GO.name() + " back")); + this.leftButton.addClickHandler(this.makeClickHandler(CommandWord.TURN.name() + " left")); + this.rightButton.addClickHandler(this.makeClickHandler(CommandWord.TURN.name() + " right")); this.soundButton.addClickHandler(new ClickHandler() { @Override -- cgit v1.2.3