From f64a72ae85720815d63692b7ec9c7322629ea86b Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Sat, 17 May 2014 21:37:05 +0200 Subject: Add scenario items and characters --- src/esieequest/model/Game.java | 15 ++++++++++ src/esieequest/model/Text.java | 10 ++++--- src/esieequest/model/characters/Athanase.java | 38 ++++++++++++++++++++++++++ src/esieequest/model/characters/Character.java | 4 +++ src/esieequest/model/items/Item.java | 8 ++++++ src/esieequest/model/items/Note.java | 34 +++++++++++++++++++++++ src/esieequest/model/items/Transponder.java | 25 +++++++++++++++++ 7 files changed, 130 insertions(+), 4 deletions(-) create mode 100644 src/esieequest/model/characters/Athanase.java create mode 100644 src/esieequest/model/items/Note.java create mode 100644 src/esieequest/model/items/Transponder.java diff --git a/src/esieequest/model/Game.java b/src/esieequest/model/Game.java index bdcc698..9b572e7 100644 --- a/src/esieequest/model/Game.java +++ b/src/esieequest/model/Game.java @@ -158,6 +158,8 @@ public class Game implements SerialisableObject { * Adds Item-s in the map. */ public void addItems() { + + // secret corridor this.i(Room.STORAGE_ROOM, Direction.WEST, Item.STORAGE_CUBE); this.i(Room.STORAGE_ROOM, Direction.EAST, Item.SAFETY_CUBE); this.i(Room.STORAGE_ROOM, Direction.NORTH, Item.BLACK_HOLE); @@ -165,6 +167,13 @@ public class Game implements SerialisableObject { this.i(Room.SECRET_LAB, Direction.SOUTH, Item.BEAMER); this.i(Room.DEAD_END, Direction.NORTH, Item.KEYCARD); + + // scenario + this.i(Room.AMPHITHEATER_STAGE, Direction.SOUTH, Item.NOTE); + this.i(Room.CAFETERIA, Direction.WEST, Item.BANANA); + this.i(Room.ESIEESPACE, Direction.NORTH, Item.TRANSPONDER); + this.i(Room.CLUBNIX, Direction.NORTH, Item.DISK); + } /** @@ -185,7 +194,13 @@ public class Game implements SerialisableObject { * Adds Character-s to the map. */ public void addCharacters() { + + // secret corridor this.c(Room.LOCKED_ROOM, Direction.SOUTH, Character.SUMOBOT); + + // scenario + this.c(Room.WING_OFFICE, Direction.EAST, Character.ATHANASE); + } /** diff --git a/src/esieequest/model/Text.java b/src/esieequest/model/Text.java index d46b4b1..84253b3 100644 --- a/src/esieequest/model/Text.java +++ b/src/esieequest/model/Text.java @@ -20,11 +20,15 @@ public enum Text { NO_DOOR("There is no door."), DOOR_LOCKED("This door is locked."), INVENTORY_FULL("Cannot pick up item: the maximum inventory weight has been reached."), - ROOM_INVENTORY_FULL("Cannot drop this item here: the room is full."), + INVENTORY_EMPTY("Your inventory is empty."), BEAMER_ROOM_MEMORISED("The coordinates of the current location have been memorised: "), BEAMER_TELEPORTED("Zap! You have reached your destination. The device's memory has been cleared."), + // objects + NOTE_PREFIX("It is written: "), + NOTE_ATHANASE("In case of logical trouble: find Athanase, office #3254."), + // lists HELP_PREFIX("Available commands: "), HELP_SUFFIX("."), @@ -52,9 +56,7 @@ public enum Text { INVENTORY_WEIGHT_PREFIX("Total inventory weight: "), INVENTORY_WEIGHT_SUFFIX("."), - - INVENTORY_EMPTY("Your inventory is empty."), - + // formatting LIST_SEPARATOR(", "), NEW_LINE("\n"), diff --git a/src/esieequest/model/characters/Athanase.java b/src/esieequest/model/characters/Athanase.java new file mode 100644 index 0000000..b4527c8 --- /dev/null +++ b/src/esieequest/model/characters/Athanase.java @@ -0,0 +1,38 @@ +package esieequest.model.characters; + +import net.pacien.util.CleanJSONObject; + +import org.json.simple.JSONObject; + +/** + * Athanase the mathgorilla. + * + * @author Pacien TRAN-GIRARD + */ +public class Athanase extends SimpleCharacter { + + /** + * Creates Athanase. + */ + public Athanase() { + super("Athanase"); + } + + @Override + public String talk() { + // TODO: require items + return "Who are you? Where did Leila go? I'm so hungry..."; + } + + @Override + public JSONObject serialise() { + // TODO: save state (received items) + return new CleanJSONObject(); + } + + @Override + public void deserialise(final JSONObject o) { + return; + } + +} diff --git a/src/esieequest/model/characters/Character.java b/src/esieequest/model/characters/Character.java index 9af68b0..c46c5bf 100644 --- a/src/esieequest/model/characters/Character.java +++ b/src/esieequest/model/characters/Character.java @@ -12,8 +12,12 @@ public enum Character implements SerialisableObject { // @formatter:off + // secret corridor SUMOBOT(new Sumobot(Room.LOCKED_ROOM, Direction.SOUTH)), + // scenario + ATHANASE(new Athanase()); + ; // @formatter:on diff --git a/src/esieequest/model/items/Item.java b/src/esieequest/model/items/Item.java index be70c2e..a3c4f8f 100644 --- a/src/esieequest/model/items/Item.java +++ b/src/esieequest/model/items/Item.java @@ -8,12 +8,14 @@ import org.json.simple.JSONObject; import esieequest.controller.utils.EnumUtils; import esieequest.controller.utils.SerialisableObject; import esieequest.model.Game; +import esieequest.model.Text; import esieequest.view.Viewable; public enum Item implements Mappable, SerialisableObject { // @formatter:off + // secret corridor STORAGE_CUBE(new SimpleItem("Weighted Storage Cube", 5, true)), SAFETY_CUBE(new SimpleItem("Edgeless Safety Cube", 5, true)), BLACK_HOLE(new SimpleItem("Portable black-hole", -10, false)), @@ -22,6 +24,12 @@ public enum Item implements Mappable, SerialisableObject { BEAMER(new Beamer("Beamer")), + // scenario + NOTE(new Note("Note", Text.NOTE_ATHANASE.getText())), + BANANA(new SimpleItem("Banana", 0, false)), + TRANSPONDER(new Transponder()), + DISK(new SimpleItem("Bootloader disk", 0, false)), + ; // @formatter:on diff --git a/src/esieequest/model/items/Note.java b/src/esieequest/model/items/Note.java new file mode 100644 index 0000000..aac5cea --- /dev/null +++ b/src/esieequest/model/items/Note.java @@ -0,0 +1,34 @@ +package esieequest.model.items; + +import esieequest.model.Game; +import esieequest.model.Text; +import esieequest.view.Viewable; + +/** + * A note. + * + * @author Pacien TRAN-GIRARD + */ +public class Note extends SimpleItem { + + private final String text; + + /** + * Creates a note with a name and a text. + * + * @param name + * the name + * @param text + * the content of the note + */ + public Note(final String name, final String text) { + super(name, 0, false); + this.text = text; + } + + @Override + public void use(final Game game, final Viewable view) { + view.echo(Text.NOTE_PREFIX.getText() + this.text); + } + +} diff --git a/src/esieequest/model/items/Transponder.java b/src/esieequest/model/items/Transponder.java new file mode 100644 index 0000000..7ed7ecc --- /dev/null +++ b/src/esieequest/model/items/Transponder.java @@ -0,0 +1,25 @@ +package esieequest.model.items; + +import esieequest.model.Game; +import esieequest.view.Viewable; + +/** + * The transponder. + * + * @author Pacien TRAN-GIRARD + */ +public class Transponder extends SimpleItem { + + /** + * Creates a Transponder. + */ + public Transponder() { + super("Transponder", 0, false); + } + + @Override + public void use(final Game game, final Viewable view) { + // TODO: only usable with the bootloader on the roundabout + } + +} -- cgit v1.2.3