blob: e83ac8c542f4d64014764b81ab9825a3a3682c83 (
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
|
package esieequest.model.items;
import esieequest.controller.Callback;
import esieequest.model.Game;
import esieequest.model.events.Scene;
import esieequest.model.map.Direction;
import esieequest.model.map.Room;
import esieequest.view.Viewable;
/**
* A Disk that can be used in conjunction with an installed PortableConsole.
*
* @author Pacien TRAN-GIRARD
*/
public class Disk extends SimpleItem {
public Disk() {
super("Bootloader disk");
}
@Override
public void use(final Game game, final Viewable view) {
final boolean onRoundabout = game.getPlayer().getCurrentRoom().equals(
Room.ENTRANCE_ROUNDABOUT);
final boolean pointingSouth = game.getPlayer().getCurrentDirection()
.equals(Direction.SOUTH);
final boolean deviceInstalled = game.getPlayer().getCurrentSide().getInventory().hasItem(
Item.PORTABLE_CONSOLE);
if (onRoundabout && pointingSouth && deviceInstalled) {
game.getPlayer().getInventory().removeItem(Item.DISK);
game.getPlayer().getCurrentSide().getInventory().putItem(Item.DISK);
view.disable();
Scene.RUN_CONSOLE.setCallback(new Callback() {
@Override
public void call() {
Scene.END.setCallback(new Callback() {
@Override
public void call() {
view.echo("Congratulations. The simple fact that you are standing here reading this sentence means you made a glorious contribution to science!");
}
});
view.playScene(Scene.END);
}
});
view.playScene(Scene.RUN_CONSOLE);
} else {
view.echo("Can't use this item here.");
}
}
}
|