blob: c73564023bf8a864104cd486267af8c24bdba51d (
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
package esieequest.view.text;
import esieequest.controller.GameEngine;
import esieequest.controller.commands.Command;
import esieequest.model.Text;
import esieequest.model.events.Quest;
import esieequest.model.events.Scene;
import esieequest.model.items.Inventory;
import esieequest.model.map.Direction;
import esieequest.model.map.Room;
import esieequest.model.map.Side;
import esieequest.view.Viewable;
/**
* The textual view.
*
* @author Pacien TRAN-GIRARD
*/
abstract class TextInterface implements Viewable {
private GameEngine gameEngine;
private boolean running;
/**
* The default constructor.
*/
public TextInterface() {
this.running = false;
}
protected abstract void run();
/**
* @return the gameEngine
*/
public GameEngine getController() {
return this.gameEngine;
}
/**
* @return the running state
*/
public boolean isRunning() {
return this.running;
}
/**
* @param running
* the running to set
*/
public void setRunning(final boolean running) {
this.running = running;
}
@Override
public void setController(final GameEngine gameEngine) {
this.gameEngine = gameEngine;
}
@Override
public void show() {
this.gameEngine.interpret(Command.NEW.name());
}
@Override
public void enable() {
if (!this.running) {
this.running = true;
this.run();
}
}
@Override
public void disable() {
this.running = false;
}
@Override
public void echo(final String message) {
System.out.println(message);
}
@Override
public void updateQuest(final Quest quest) {
this.echo(Text.CURRENT_QUEST_PREFIX.toString() + quest.getTitle());
}
@Override
public void updateLocation(final Room room, final Direction direction, final Side side,
final boolean canGoBack) {
this.echo(room.getInformations());
}
@Override
public void updateInventory(final Inventory inventory) {
this.gameEngine.interpret(Command.INVENTORY.name());
}
@Override
public void playScene(final Scene scene) {
scene.getCallback().call();
}
}
|