aboutsummaryrefslogtreecommitdiff
path: root/src/esieequest/engine/commands/DoCommand.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/esieequest/engine/commands/DoCommand.java')
-rw-r--r--src/esieequest/engine/commands/DoCommand.java40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/esieequest/engine/commands/DoCommand.java b/src/esieequest/engine/commands/DoCommand.java
new file mode 100644
index 0000000..e6b5936
--- /dev/null
+++ b/src/esieequest/engine/commands/DoCommand.java
@@ -0,0 +1,40 @@
1package esieequest.engine.commands;
2
3import esieequest.game.Game;
4import esieequest.game.Text;
5import esieequest.game.map.Side;
6import esieequest.ui.Viewable;
7
8/**
9 * A shortcut Command that executes a TALK or a TAKE Command accordingly to the
10 * context.
11 *
12 * @author Pacien TRAN-GIRARD
13 */
14public class DoCommand implements Executable {
15
16 @Override
17 public void execute(final String argument, final Game game, final Viewable view) {
18
19 if (!argument.isEmpty()) {
20 view.echo(Text.TOO_MANY_ARGUMENTS.toString());
21 return;
22 }
23
24 final Side currentSide = game.getPlayer().getCurrentSide();
25
26 if (currentSide.hasCharacter()) {
27 Command.TALK.execute(argument, game, view);
28 return;
29 }
30
31 if (currentSide.getInventory().getSize() == 1) {
32 Command.TAKE.execute(argument, game, view);
33 return;
34 }
35
36 view.echo(Text.NOTHING_TO_DO.toString());
37
38 }
39
40}