aboutsummaryrefslogtreecommitdiff
path: root/src/esieequest/engine/commands/NewCommand.java
blob: 49c0225e784a08a6b3145be82c873989936cc799 (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
36
37
38
39
40
41
package esieequest.engine.commands;

import esieequest.engine.Callback;
import esieequest.game.Game;
import esieequest.game.Text;
import esieequest.game.states.Scene;
import esieequest.ui.Viewable;

/**
 * Creates a new game.
 * 
 * @author Pacien TRAN-GIRARD
 */
public class NewCommand implements Executable {

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

		final boolean challengeMode = argument.equals(Text.CHALLENGE_FLAG.toString());

		game.newGame(true, challengeMode);

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

		Scene.INTRO.setCallback(new Callback() {
			@Override
			public void call() {
				view.updateQuest(game.getPlayer().getCurrentQuest());
				view.updateInventory(game.getPlayer().getInventory());
				view.updateLocation(game.getPlayer().getCurrentRoom(), game.getPlayer()
						.getCurrentDirection(), game.getPlayer().getCurrentSide(), game.getPlayer()
						.canGoBack());

				view.enableInput();
			}
		});

		view.playScene(Scene.INTRO);

	}
}