blob: f55895626522eb14cc3a81542f1bb2ecddf0d589 (
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.game.items;
import esieequest.engine.Callback;
import esieequest.game.Game;
import esieequest.game.map.Direction;
import esieequest.game.map.Room;
import esieequest.game.states.Scene;
import esieequest.ui.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.disableInput();
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.");
}
}
}
|