aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPacien TRAN-GIRARD2014-05-20 19:51:11 +0200
committerPacien TRAN-GIRARD2014-05-20 19:51:11 +0200
commit614965104e47724f55c17dd88cb97eb109e477f4 (patch)
tree61d625fe4cc29b4a72f37ab5d6434adfe6febc0b
parentbf54f0fe13964f41bcd4cfd9450b98e952bafaf2 (diff)
downloadesieequest-614965104e47724f55c17dd88cb97eb109e477f4.tar.gz
Implement playable scenario
-rw-r--r--src/esieequest/controller/commands/TalkCommand.java2
-rw-r--r--src/esieequest/model/Game.java2
-rw-r--r--src/esieequest/model/characters/Athanase.java76
-rw-r--r--src/esieequest/model/characters/Character.java6
-rw-r--r--src/esieequest/model/characters/SimpleCharacter.java4
-rw-r--r--src/esieequest/model/characters/Sumobot.java6
-rw-r--r--src/esieequest/model/events/Quest.java4
-rw-r--r--src/esieequest/model/events/Scene.java4
-rw-r--r--src/esieequest/model/items/Banana.java (renamed from src/esieequest/model/items/Transponder.java)12
-rw-r--r--src/esieequest/model/items/Beamer.java2
-rw-r--r--src/esieequest/model/items/Disk.java55
-rw-r--r--src/esieequest/model/items/Item.java6
-rw-r--r--src/esieequest/model/items/Note.java2
-rw-r--r--src/esieequest/model/items/PortableConsole.java42
-rw-r--r--src/esieequest/model/items/SimpleItem.java14
15 files changed, 197 insertions, 40 deletions
diff --git a/src/esieequest/controller/commands/TalkCommand.java b/src/esieequest/controller/commands/TalkCommand.java
index 228f954..39c4932 100644
--- a/src/esieequest/controller/commands/TalkCommand.java
+++ b/src/esieequest/controller/commands/TalkCommand.java
@@ -19,7 +19,7 @@ public class TalkCommand implements Executable {
19 return; 19 return;
20 } 20 }
21 21
22 view.echo(game.getPlayer().getCurrentSide().getCharacter().talk()); 22 game.getPlayer().getCurrentSide().getCharacter().talk(game, view);
23 23
24 } 24 }
25 25
diff --git a/src/esieequest/model/Game.java b/src/esieequest/model/Game.java
index 27237bf..2a6a31b 100644
--- a/src/esieequest/model/Game.java
+++ b/src/esieequest/model/Game.java
@@ -176,7 +176,7 @@ public class Game implements SerialisableObject {
176 // scenario 176 // scenario
177 this.i(Room.AMPHITHEATER_STAGE, Direction.SOUTH, Item.NOTE); 177 this.i(Room.AMPHITHEATER_STAGE, Direction.SOUTH, Item.NOTE);
178 this.i(Room.CAFETERIA, Direction.WEST, Item.BANANA); 178 this.i(Room.CAFETERIA, Direction.WEST, Item.BANANA);
179 this.i(Room.ESIEESPACE, Direction.NORTH, Item.TRANSPONDER); 179 this.i(Room.ESIEESPACE, Direction.NORTH, Item.PORTABLE_CONSOLE);
180 this.i(Room.CLUBNIX, Direction.NORTH, Item.DISK); 180 this.i(Room.CLUBNIX, Direction.NORTH, Item.DISK);
181 181
182 } 182 }
diff --git a/src/esieequest/model/characters/Athanase.java b/src/esieequest/model/characters/Athanase.java
index b4527c8..698b7ae 100644
--- a/src/esieequest/model/characters/Athanase.java
+++ b/src/esieequest/model/characters/Athanase.java
@@ -1,8 +1,10 @@
1package esieequest.model.characters; 1package esieequest.model.characters;
2 2
3import net.pacien.util.CleanJSONObject; 3import esieequest.model.Game;
4 4import esieequest.model.events.Quest;
5import org.json.simple.JSONObject; 5import esieequest.model.items.Inventory;
6import esieequest.model.items.Item;
7import esieequest.view.Viewable;
6 8
7/** 9/**
8 * Athanase the mathgorilla. 10 * Athanase the mathgorilla.
@@ -12,27 +14,69 @@ import org.json.simple.JSONObject;
12public class Athanase extends SimpleCharacter { 14public class Athanase extends SimpleCharacter {
13 15
14 /** 16 /**
15 * Creates Athanase. 17 * Instantiates Athanase.
16 */ 18 */
17 public Athanase() { 19 public Athanase() {
18 super("Athanase"); 20 super("Athanase");
19 } 21 }
20 22
21 @Override 23 @Override
22 public String talk() { 24 public void talk(final Game game, final Viewable view) {
23 // TODO: require items 25 final Quest currentQuest = game.getPlayer().getCurrentQuest();
24 return "Who are you? Where did Leila go? I'm so hungry..."; 26 final Inventory playersInventory = game.getPlayer().getInventory();
25 } 27 switch (currentQuest) {
26 28
27 @Override 29 case WHAT_HAPPENED:
28 public JSONObject serialise() { 30 view.echo("Who are you? Where did Leila go? Somethin happened... But... Can't think... I'm hungry... So hungry...");
29 // TODO: save state (received items) 31 game.getPlayer().setCurrentQuest(Quest.FEED_ATHANASE);
30 return new CleanJSONObject(); 32 view.updateQuest(Quest.FEED_ATHANASE);
31 } 33 break;
34
35 case FEED_ATHANASE:
36 if (playersInventory.hasItem(Item.BANANA)) {
37 playersInventory.removeItem(Item.BANANA);
38 view.updateInventory(playersInventory);
39 view.echo("Ooooh! You have a banana! *nomz* WAIT!... It tastes like... an EMERGENCY BANANA! That means... Hmmm..."
40 + "\n"
41 + "They turned it ON... Their stupid machine... It was not ready. It was a beta... Obviously it crashed... WITH THE ENTIRE UNIVERSE"
42 + "\n" + "I think we have to restart everything...");
43 game.getPlayer().setCurrentQuest(Quest.FIND_DISK);
44 view.updateQuest(Quest.FIND_DISK);
45 } else {
46 view.echo("ME=HUNGRY => ¬(ME CAN HELP YOU)");
47 }
48 break;
49
50 case FIND_DISK:
51 if (playersInventory.hasItem(Item.DISK)) {
52 view.echo("Fantastic! You have the bootloader disk! Now we need a remote console to connect to the Universe... They have a portable one at the Esieespace...");
53 game.getPlayer().setCurrentQuest(Quest.FIND_CONSOLE);
54 view.updateQuest(Quest.FIND_CONSOLE);
55 } else {
56 view.echo("Hopefully the Club*nix guys made an emergency boot disk, just in case... FIND IT and bring it!");
57 }
58 break;
59
60 case FIND_CONSOLE:
61 if (playersInventory.hasItem(Item.PORTABLE_CONSOLE)) {
62 view.echo("Yaaaay! You found it! We have the software, we have the hardware... I think we are ready for the complete reboot.");
63 game.getPlayer().setCurrentQuest(Quest.INSTALL_CONSOLE);
64 view.updateQuest(Quest.INSTALL_CONSOLE);
65 } else {
66 view.echo("We need the Portable Remote Console to connect to the Universe... Find it at the Esieespace HQ.");
67 }
68 break;
69
70 case INSTALL_CONSOLE:
71 if (playersInventory.hasItem(Item.PORTABLE_CONSOLE)) {
72 view.echo("The Universe is far away... Well... Not exactly... Sort of... Complicated. Find an antenna or something that may act as an amplifier and connect the Portable Console to contact the Universe.");
73 } else {
74 view.echo("Well... You have installed the console? Have you turned it ON and inserted the disk? Because you should.");
75 }
76 break;
77
78 }
32 79
33 @Override
34 public void deserialise(final JSONObject o) {
35 return;
36 } 80 }
37 81
38} 82}
diff --git a/src/esieequest/model/characters/Character.java b/src/esieequest/model/characters/Character.java
index c46c5bf..452226d 100644
--- a/src/esieequest/model/characters/Character.java
+++ b/src/esieequest/model/characters/Character.java
@@ -5,8 +5,10 @@ import org.json.simple.JSONObject;
5 5
6import esieequest.controller.utils.EnumUtils; 6import esieequest.controller.utils.EnumUtils;
7import esieequest.controller.utils.SerialisableObject; 7import esieequest.controller.utils.SerialisableObject;
8import esieequest.model.Game;
8import esieequest.model.map.Direction; 9import esieequest.model.map.Direction;
9import esieequest.model.map.Room; 10import esieequest.model.map.Room;
11import esieequest.view.Viewable;
10 12
11public enum Character implements SerialisableObject { 13public enum Character implements SerialisableObject {
12 14
@@ -32,8 +34,8 @@ public enum Character implements SerialisableObject {
32 return this.character.getName(); 34 return this.character.getName();
33 } 35 }
34 36
35 public String talk() { 37 public void talk(final Game game, final Viewable view) {
36 return this.character.talk(); 38 this.character.talk(game, view);
37 } 39 }
38 40
39 /** 41 /**
diff --git a/src/esieequest/model/characters/SimpleCharacter.java b/src/esieequest/model/characters/SimpleCharacter.java
index b855089..baaf650 100644
--- a/src/esieequest/model/characters/SimpleCharacter.java
+++ b/src/esieequest/model/characters/SimpleCharacter.java
@@ -6,6 +6,8 @@ import net.pacien.util.CleanJSONObject;
6import org.json.simple.JSONObject; 6import org.json.simple.JSONObject;
7 7
8import esieequest.controller.utils.SerialisableObject; 8import esieequest.controller.utils.SerialisableObject;
9import esieequest.model.Game;
10import esieequest.view.Viewable;
9 11
10/** 12/**
11 * A character that can talk with the player. 13 * A character that can talk with the player.
@@ -32,7 +34,7 @@ public abstract class SimpleCharacter implements SerialisableObject {
32 * 34 *
33 * @return what the Character says 35 * @return what the Character says
34 */ 36 */
35 public abstract String talk(); 37 public abstract void talk(final Game game, final Viewable view);
36 38
37 @Override 39 @Override
38 public JSONObject serialise() { 40 public JSONObject serialise() {
diff --git a/src/esieequest/model/characters/Sumobot.java b/src/esieequest/model/characters/Sumobot.java
index c779ad8..fb4e7b3 100644
--- a/src/esieequest/model/characters/Sumobot.java
+++ b/