aboutsummaryrefslogtreecommitdiff
path: root/src/esieequest/controller/commands/DoCommand.java
blob: 646ac2a4685d5146f8ca369ad8e90ec26cc54e0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package esieequest.controller.commands;

import esieequest.model.Game;
import esieequest.model.Text;
import esieequest.model.map.Side;
import esieequest.view.Viewable;

/**
 * A shortcut Command that executes a TALK or a TAKE Command accordingly to the
 * context.
 * 
 * @author Pacien TRAN-GIRARD
 */
public class DoCommand implements Executable {

	@Override
	public void execute(final String argument, final Game game, final Viewable view) {

		final Side currentSide = game.getPlayer().getCurrentSide();

		if (currentSide.hasCharacter()) {
			Command.TALK.execute(argument, game, view);
			return;
		}

		if (currentSide.getInventory().getSize() == 1) {
			Command.TAKE.execute(argument, game, view);
			return;
		}

		view.echo(Text.NOTHING_TO_DO.toString());

	}

}