|
|
|
|
|
|
|
|
private static ArrayList<String> story = new ArrayList<String>();
|
|
|
private static ArrayList<String> story = new ArrayList<String>();
|
|
|
private static ArrayList<Item> items = new ArrayList<Item>();
|
|
|
private static ArrayList<Item> items = new ArrayList<Item>();
|
|
|
private static ArrayList<Puzzle> puzzles = new ArrayList<Puzzle>();
|
|
|
private static ArrayList<Puzzle> puzzles = new ArrayList<Puzzle>();
|
|
|
|
|
|
private String deviceId = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean stoppFlag = false;
|
|
|
private boolean stoppFlag = false;
|
|
|
private Map<String, Object> jsonMap = null;
|
|
|
private Map<String, Object> jsonMap = null;
|
|
|
private String[] inputArray = null;
|
|
|
private String[] inputArray = null;
|
|
|
|
|
|
|
|
|
private String input = null;
|
|
|
private String input = null;
|
|
|
private Room currentRoom = null;
|
|
|
private Room currentRoom = null;
|
|
|
|
|
|
|
|
|
private Room intro;
|
|
|
|
|
|
private Room keller;
|
|
|
|
|
|
private Puzzle durchgang;
|
|
|
|
|
|
private Puzzle schloss;
|
|
|
|
|
|
private Puzzle door;
|
|
|
|
|
|
private Item schluessel;
|
|
|
|
|
|
private Item stahlschluessel;
|
|
|
|
|
|
|
|
|
|
|
|
public Game() {
|
|
|
public Game() {
|
|
|
|
|
|
|
|
|
try {
|
|
|
try {
|
|
|
startGame();
|
|
|
startGame();
|
|
|
} catch (Exception ex) {
|
|
|
} catch (Exception ex) {
|
|
|
|
|
|
|
|
|
return null;
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
public static String generateJSON() throws IOException {
|
|
|
|
|
|
|
|
|
public static String writeJSON(File f) throws IOException {
|
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
|
String s = "";
|
|
|
String s = "";
|
|
|
try (
|
|
|
try (
|
|
|
JsonGenerator jGenerator
|
|
|
JsonGenerator jGenerator
|
|
|
= mapper.getFactory().createGenerator(
|
|
|
|
|
|
new File("game.JSON"),
|
|
|
|
|
|
JsonEncoding.UTF8)) {
|
|
|
|
|
|
|
|
|
= mapper.getFactory().createGenerator(f,JsonEncoding.UTF8)) {
|
|
|
|
|
|
|
|
|
jGenerator.writeStartObject();
|
|
|
jGenerator.writeStartObject();
|
|
|
jGenerator.writeObjectField("room", rooms);
|
|
|
jGenerator.writeObjectField("room", rooms);
|
|
|
jGenerator.writeObjectField("puzzle", puzzles);
|
|
|
jGenerator.writeObjectField("puzzle", puzzles);
|
|
|
jGenerator.writeObjectField("item", items);
|
|
|
jGenerator.writeObjectField("item", items);
|
|
|
jGenerator.writeObjectField("story", story);
|
|
|
jGenerator.writeObjectField("story", story);
|
|
|
|
|
|
|
|
|
jGenerator.writeEndObject();
|
|
|
jGenerator.writeEndObject();
|
|
|
jGenerator.close();
|
|
|
jGenerator.close();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return s;
|
|
|
return s;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
public void setVariables() throws Exception {
|
|
|
|
|
|
|
|
|
public Item getItem(String s) {
|
|
|
|
|
|
for (int i = 0; i < items.size(); i++) {
|
|
|
|
|
|
if (items.get(i).getName().toLowerCase().equals(s.toLowerCase())) {
|
|
|
|
|
|
if (currentRoom.getItems().contains(items.get(i).getId())) {
|
|
|
|
|
|
return items.get(i);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
// Intro Raum
|
|
|
|
|
|
intro = new Room("Intro");
|
|
|
|
|
|
intro.setDescription("Hier ist das Intro von Kidnappd");
|
|
|
|
|
|
durchgang = new Puzzle("Durchgang");
|
|
|
|
|
|
durchgang.setSolvedText("Hurra, du hast das Intro Level beendet");
|
|
|
|
|
|
intro.puzzles.add(durchgang);
|
|
|
|
|
|
|
|
|
|
|
|
//Raum Object
|
|
|
|
|
|
keller = new Room("Keller");
|
|
|
|
|
|
|
|
|
|
|
|
durchgang.setNextRoom(keller);
|
|
|
|
|
|
keller.setDescription("der kleine Mondschein, der zuvor den unbekannten Raum schwach beleuchtet hat, leuchtet viel gr��er und viel heller und du erkennst nun den gesamten Raum. Er ist klein und d�ster. "
|
|
|
|
|
|
+ "überall h�ngen Spinnennetze und Staub sammelt sich am Betonboden. Du erkennst am anderen Ende des Raumes eine T�r");
|
|
|
|
|
|
|
|
|
|
|
|
//Puzzle Object
|
|
|
|
|
|
schloss = new Puzzle("Schloss");
|
|
|
|
|
|
schloss.setDescription("Es ist ein altes Schloss aus Metall, dass eine Einkerbung f�r einen Schl�ssel hat");
|
|
|
|
|
|
schloss.setSolvedText("Ja, es hat funktioniert! Mit einem Knacksen geht das Schloss auf und du kannst dich von deiner Beinfessel befreien. ");
|
|
|
|
|
|
puzzles.add(schloss);
|
|
|
|
|
|
keller.puzzles.add(schloss);
|
|
|
|
|
|
|
|
|
|
|
|
//Ausgang
|
|
|
|
|
|
door = new Puzzle("Tuer");
|
|
|
|
|
|
door.setDescription("Ausgang aus dem Keller");
|
|
|
|
|
|
door.setGameOverFlag(true);
|
|
|
|
|
|
door.setSolvedText("Geschafft! Die Tuer ist offen. Das Intro ist nun beendet");
|
|
|
|
|
|
keller.puzzles.add(door);
|
|
|
|
|
|
puzzles.add(door);
|
|
|
|
|
|
|
|
|
|
|
|
//Item Object
|
|
|
|
|
|
schluessel = new Item("Schluessel");
|
|
|
|
|
|
schluessel.setHiddenFlag(false);
|
|
|
|
|
|
schluessel.setPortableFlag(true);
|
|
|
|
|
|
schluessel.setDescription("Der Schl�ssel ist kalt und klein. Vielleicht hast du Gl�ck und er passt ins Schloss. Versuche es zu �ffnen!");
|
|
|
|
|
|
schloss.addItem(schluessel);
|
|
|
|
|
|
keller.items.add(schluessel);
|
|
|
|
|
|
items.add(schluessel);
|
|
|
|
|
|
|
|
|
|
|
|
door.setDependency(schloss);
|
|
|
|
|
|
door.setDependencyText("Du musst erst das Schloss der Kette knacken um die Tür öffnen zu können");
|
|
|
|
|
|
|
|
|
|
|
|
//Item Object
|
|
|
|
|
|
stahlschluessel = new Item("Stahlschluessel");
|
|
|
|
|
|
stahlschluessel.setHiddenFlag(false);
|
|
|
|
|
|
stahlschluessel.setPortableFlag(false);
|
|
|
|
|
|
stahlschluessel.setDescription("Ein Stahlschlüssel");
|
|
|
|
|
|
intro.items.add(stahlschluessel);
|
|
|
|
|
|
items.add(stahlschluessel);
|
|
|
|
|
|
|
|
|
|
|
|
rooms.add(intro);
|
|
|
|
|
|
rooms.add(keller);
|
|
|
|
|
|
story.add("Dein ganzer K�rper schmerzt, du liegst auf Betonboden. Du f�ngst laut an zu husten und Staubklumpen fliegen aus deinem Mund. Du �ffnest langsam und nur schwer die Augen, "
|
|
|
|
|
|
+ "doch es ist fast gar nichts zu sehen. Die einzige Lichtquelle ist ein kleines Fenster �ber dir, durch die ein schwacher Mondschein f�llt. Es ist also Nachts... "
|
|
|
|
|
|
+ "Langsam versuchst du dich an die fast komplette Dunkelheit zu gew�hnen und erkennst, dass du dich in einem kleinen dir unbekannten Raum befindest. Dich packt die Angst! "
|
|
|
|
|
|
+ "Was ist passiert, wo bist du und wie bist du hier gelandet?"
|
|
|
|
|
|
+ "Du nimmst die Stahlkette in die Hand. Sie ist schwer und verrostet. Mit den H�nden tastest du dich voran bis an die Heizung, wo du ein Schloss an der Kette entdeckst."
|
|
|
|
|
|
+ "Das Mondlicht ist nur sehr schwach, um den Raum zu begutachten. Du gehst in die Knie und tastest mit deinem H�nden wild und in Panik am Betonboden. "
|
|
|
|
|
|
+ "Pl�tzlich st��t du auf einen kleinen Gegenstand, der sich tats�chlich anf�hlt wie ein Schl�ssel. Du solltest ihn aufheben");
|
|
|
|
|
|
|
|
|
|
|
|
currentRoom = intro;
|
|
|
|
|
|
stoppFlag = false;
|
|
|
|
|
|
inventory = new ArrayList<Item>();
|
|
|
|
|
|
log("JSON: " + generateJSON());
|
|
|
|
|
|
|
|
|
public Puzzle getPuzzle(String s) {
|
|
|
|
|
|
for (int i = 0; i < items.size(); i++) {
|
|
|
|
|
|
if (items.get(i).getName().toLowerCase().equals(s.toLowerCase())) {
|
|
|
|
|
|
if (currentRoom.getPuzzles().contains(puzzles.get(i).getId())) {
|
|
|
|
|
|
return puzzles.get(i);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public String getId()
|
|
|
|
|
|
{
|
|
|
|
|
|
return deviceId;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void setVariables() throws Exception {
|
|
|
|
|
|
|
|
|
readJSON();
|
|
|
readJSON();
|
|
|
|
|
|
|
|
|
log("Readjson fertig");
|
|
|
log("Readjson fertig");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
currentRoom = rooms.get(0);
|
|
|
|
|
|
stoppFlag = false;
|
|
|
|
|
|
inventory = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
//log("JSON: " + writeJSON());
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
objectMapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
|
|
|
objectMapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String jsonStringPuzzle = objectMapper.writeValueAsString(jsonMap.get("puzzle"));
|
|
|
String jsonStringPuzzle = objectMapper.writeValueAsString(jsonMap.get("puzzle"));
|
|
|
String jsonStringStory = objectMapper.writeValueAsString(jsonMap.get("story"));
|
|
|
String jsonStringStory = objectMapper.writeValueAsString(jsonMap.get("story"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log("Item: " + jsonStringItem);
|
|
|
log("Item: " + jsonStringItem);
|
|
|
log("Room: " + jsonStringRoom);
|
|
|
log("Room: " + jsonStringRoom);
|
|
|
log("Story: " + jsonStringStory);
|
|
|
log("Story: " + jsonStringStory);
|
|
|
log("Puzzle: " + jsonStringPuzzle);
|
|
|
log("Puzzle: " + jsonStringPuzzle);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String[] st = objectMapper.readValue(jsonStringStory, String[].class);
|
|
|
String[] st = objectMapper.readValue(jsonStringStory, String[].class);
|
|
|
log("Story Array OK");
|
|
|
log("Story Array OK");
|
|
|
Item[] it = objectMapper.readValue(jsonStringItem, Item[].class);
|
|
|
Item[] it = objectMapper.readValue(jsonStringItem, Item[].class);
|
|
|
|
|
|
|
|
|
log("Puzzle Array OK");
|
|
|
log("Puzzle Array OK");
|
|
|
Room[] ro = objectMapper.readValue(jsonStringRoom, Room[].class);
|
|
|
Room[] ro = objectMapper.readValue(jsonStringRoom, Room[].class);
|
|
|
log("Room Array OK");
|
|
|
log("Room Array OK");
|
|
|
|
|
|
|
|
|
for(int i=0; i < ro.length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < ro.length; i++) {
|
|
|
log("Room: " + ro[i].getName());
|
|
|
log("Room: " + ro[i].getName());
|
|
|
log("Description: " + ro[i].getDescription());
|
|
|
log("Description: " + ro[i].getDescription());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
for(int i=0; i < it.length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < it.length; i++) {
|
|
|
log("Item: " + it[i].getName());
|
|
|
log("Item: " + it[i].getName());
|
|
|
log("Description: " + it[i].getDescription());
|
|
|
log("Description: " + it[i].getDescription());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(int i=0; i < pu.length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < pu.length; i++) {
|
|
|
log("Puzzle: " + pu[i].getName());
|
|
|
log("Puzzle: " + pu[i].getName());
|
|
|
log("Description: " + pu[i].getDescription());
|
|
|
log("Description: " + pu[i].getDescription());
|
|
|
log("DependencyText: " + pu[i].getDependencyText());
|
|
|
log("DependencyText: " + pu[i].getDependencyText());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(int i=0; i < st.length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < st.length; i++) {
|
|
|
log("Story: " + st[i]);
|
|
|
log("Story: " + st[i]);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
log("currentRoom: " + currentRoom.getName());
|
|
|
log("currentRoom: " + currentRoom.getName());
|
|
|
|
|
|
|
|
|
for (int i = 0; i < currentRoom.getPuzzles().size(); i++) {
|
|
|
for (int i = 0; i < currentRoom.getPuzzles().size(); i++) {
|
|
|
log("Puzzle im Raum: " + currentRoom.getPuzzles().get(i).getName());
|
|
|
|
|
|
|
|
|
log("Puzzle im Raum: " + currentRoom.getPuzzles().get(i)); //getPuzzles().get(i).getName());
|
|
|
}
|
|
|
}
|
|
|
for (int i = 0; i < currentRoom.getItems().size(); i++) {
|
|
|
for (int i = 0; i < currentRoom.getItems().size(); i++) {
|
|
|
log("Item im Raum: " + currentRoom.getItems().get(i).getName());
|
|
|
|
|
|
|
|
|
log("Item im Raum: " + currentRoom.getItems().get(i)); //getItems().get(i).getName());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
input = input.replace("ä", "ae");
|
|
|
input = input.replace("ä", "ae");
|
|
|
|
|
|
|
|
|
inputArray = input.split(" ");
|
|
|
inputArray = input.split(" ");
|
|
|
|
|
|
|
|
|
for (String s : inputArray) {
|
|
|
for (String s : inputArray) {
|
|
|
if (currentRoom.getItem(s) != null) {
|
|
|
|
|
|
itemName = currentRoom.getItem(s).getName();
|
|
|
|
|
|
|
|
|
if (getItem(s) != null) {
|
|
|
|
|
|
itemName = getItem(s).getName();
|
|
|
log("itemName: " + itemName);
|
|
|
log("itemName: " + itemName);
|
|
|
} else if (currentRoom.getPuzzle(s) != null) {
|
|
|
|
|
|
puzzleName = currentRoom.getPuzzle(s).getName();
|
|
|
|
|
|
|
|
|
} else if (getPuzzle(s) != null) {
|
|
|
|
|
|
puzzleName = getPuzzle(s).getName();
|
|
|
log("PuzzleName: " + puzzleName);
|
|
|
log("PuzzleName: " + puzzleName);
|
|
|
} else {
|
|
|
} else {
|
|
|
intentName = s;
|
|
|
intentName = s;
|
|
|
|
|
|
|
|
|
//intent
|
|
|
//intent
|
|
|
case "inspectintent":
|
|
|
case "inspectintent":
|
|
|
log("Switch: InspectIntent");
|
|
|
log("Switch: InspectIntent");
|
|
|
if (currentRoom.getItem(itemName) != null) {
|
|
|
|
|
|
inspect(currentRoom.getItem(itemName));
|
|
|
|
|
|
} else if (currentRoom.getPuzzle(puzzleName) != null) {
|
|
|
|
|
|
inspect(currentRoom.getPuzzle(puzzleName));
|
|
|
|
|
|
|
|
|
if (getItem(itemName) != null) {
|
|
|
|
|
|
inspect(getItem(itemName));
|
|
|
|
|
|
} else if (getPuzzle(puzzleName) != null) {
|
|
|
|
|
|
inspect(getPuzzle(puzzleName));
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//intent
|
|
|
//intent
|
|
|
case "takeintent":
|
|
|
case "takeintent":
|
|
|
log("Switch: TakeIntent");
|
|
|
log("Switch: TakeIntent");
|
|
|
if (currentRoom.getItem(itemName) != null) {
|
|
|
|
|
|
take(currentRoom.getItem(itemName));
|
|
|
|
|
|
|
|
|
if (getItem(itemName) != null) {
|
|
|
|
|
|
take(getItem(itemName));
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
break;
|
|
|
//intent
|
|
|
//intent
|
|
|
case "openintent":
|
|
|
case "openintent":
|
|
|
log("Switch: OpenIntent");
|
|
|
log("Switch: OpenIntent");
|
|
|
if (currentRoom.getPuzzle(puzzleName) != null) {
|
|
|
|
|
|
open(currentRoom.getPuzzle(puzzleName));
|
|
|
|
|
|
|
|
|
if (getPuzzle(puzzleName) != null) {
|
|
|
|
|
|
open(getPuzzle(puzzleName));
|
|
|
}
|
|
|
}
|
|
|
break;
|
|
|
break;
|
|
|
//intent
|
|
|
//intent
|
|
|
|
|
|
|
|
|
if (itemName == null && puzzleName == null) {
|
|
|
if (itemName == null && puzzleName == null) {
|
|
|
resetGame();
|
|
|
resetGame();
|
|
|
for (int i = 0; i < currentRoom.puzzles.size(); i++) {
|
|
|
for (int i = 0; i < currentRoom.puzzles.size(); i++) {
|
|
|
if (currentRoom.puzzles.get(i).getNextRoom() != null) {
|
|
|
|
|
|
setRoom(currentRoom.puzzles.get(i).getNextRoom());
|
|
|
|
|
|
|
|
|
if (getPuzzleById(currentRoom.puzzles.get(i)).getNextRoom() != null) {
|
|
|
|
|
|
setRoom(getRoomById(getPuzzleById(currentRoom.puzzles.get(i)).getNextRoom()));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Room getRoomById(int i) {
|
|
|
|
|
|
for (int j = 0; j < rooms.size(); j++) {
|
|
|
|
|
|
if (rooms.get(j).getId() == i) {
|
|
|
|
|
|
return rooms.get(j);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Item getItemById(int i) {
|
|
|
|
|
|
for (int j = 0; j < items.size(); j++) {
|
|
|
|
|
|
if (items.get(j).getId() == i) {
|
|
|
|
|
|
return items.get(j);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Puzzle getPuzzleById(int i) {
|
|
|
|
|
|
for (int j = 0; j < puzzles.size(); j++) {
|
|
|
|
|
|
if (puzzles.get(j).getId() == i) {
|
|
|
|
|
|
return puzzles.get(j);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
public void log(String s) throws Exception {
|
|
|
public void log(String s) throws Exception {
|
|
|
String url = "https://medinf.efi.th-nuernberg.de/tomcat/WebAdventure/Log";
|
|
|
String url = "https://medinf.efi.th-nuernberg.de/tomcat/WebAdventure/Log";
|
|
|
URL obj = new URL(url);
|
|
|
URL obj = new URL(url);
|
|
|
|
|
|
|
|
|
log("inspect(" + currentPuzzle.getName() + ")");
|
|
|
log("inspect(" + currentPuzzle.getName() + ")");
|
|
|
|
|
|
|
|
|
for (int i = 0; i < currentRoom.getItems().size(); i++) {
|
|
|
for (int i = 0; i < currentRoom.getItems().size(); i++) {
|
|
|
if (currentRoom.getPuzzles().get(i) == currentPuzzle) {
|
|
|
|
|
|
|
|
|
if (currentRoom.getPuzzles().get(i) == currentPuzzle.getId()) {
|
|
|
say(currentPuzzle.getDescription());
|
|
|
say(currentPuzzle.getDescription());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
log("inspect(" + currentItem.getName() + ")");
|
|
|
log("inspect(" + currentItem.getName() + ")");
|
|
|
|
|
|
|
|
|
for (int i = 0; i < currentRoom.getItems().size(); i++) {
|
|
|
for (int i = 0; i < currentRoom.getItems().size(); i++) {
|
|
|
if (currentRoom.getItems().get(i) == currentItem) {
|
|
|
|
|
|
|
|
|
if (currentRoom.getItems().get(i) == currentItem.getId()) {
|
|
|
say(currentItem.getDescription());
|
|
|
say(currentItem.getDescription());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
say("ist bereits geöffnet");
|
|
|
say("ist bereits geöffnet");
|
|
|
if (currentPuzzle.getNextRoom() != null) // wenn es eine Tür ist die in den nächsten Raum führt
|
|
|
if (currentPuzzle.getNextRoom() != null) // wenn es eine Tür ist die in den nächsten Raum führt
|
|
|
{
|
|
|
{
|
|
|
setRoom(currentPuzzle.getNextRoom()); // wechselt in den nächsten Raum
|
|
|
|
|
|
|
|
|
setRoom(getRoomById(currentPuzzle.getNextRoom())); // wechselt in den nächsten Raum
|
|
|
}
|
|
|
}
|
|
|
return;
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
if (!currentPuzzle.hasDependency() || currentPuzzle.getDependency().isSolved()) // ist keine Abhängigkeit vorhanden oder aber die Abhängigkeit ist gelöst
|
|
|
|
|
|
|
|
|
if (!currentPuzzle.hasDependency() || getPuzzleById(currentPuzzle.getDependency()).isSolved()) // ist keine Abhängigkeit vorhanden oder aber die Abhängigkeit ist gelöst
|
|
|
{
|
|
|
{
|
|
|
if (currentPuzzle.getItems().isEmpty() || getInventory().containsAll(currentPuzzle.getItems())) // keine Items zum lösen notwendig oder alle Items zum lösen befinden sich im Inventar
|
|
|
|
|
|
|
|
|
if (currentPuzzle.getItems().isEmpty() || checkPuzzleItemsInInventory(currentPuzzle.getId())) // keine Items zum lösen notwendig oder alle Items zum lösen befinden sich im Inventar
|
|
|
{
|
|
|
{
|
|
|
currentPuzzle.setSolved(true); // auf gelöst setzen
|
|
|
currentPuzzle.setSolved(true); // auf gelöst setzen
|
|
|
say(currentPuzzle.getSolvedText()); // Lösungstext
|
|
|
say(currentPuzzle.getSolvedText()); // Lösungstext
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (currentPuzzle.getNextRoom() != null) // wenn es eine Tür ist die in den nächsten Raum führt
|
|
|
if (currentPuzzle.getNextRoom() != null) // wenn es eine Tür ist die in den nächsten Raum führt
|
|
|
{
|
|
|
{
|
|
|
setRoom(currentPuzzle.getNextRoom()); // wechselt in den nächsten Raum
|
|
|
|
|
|
|
|
|
setRoom(getRoomById(currentPuzzle.getNextRoom())); // wechselt in den nächsten Raum
|
|
|
}
|
|
|
}
|
|
|
} else // Item zum lösen fehlt
|
|
|
} else // Item zum lösen fehlt
|
|
|
{
|
|
|
{
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
if (!currentPuzzle.getDependency().isSolved()) // Abhängigkeit nicht gelöst
|
|
|
|
|
|
|
|
|
if (!getPuzzleById(currentPuzzle.getDependency()).isSolved()) // Abhängigkeit nicht gelöst
|
|
|
{
|
|
|
{
|
|
|
say(currentPuzzle.getDependencyText());
|
|
|
say(currentPuzzle.getDependencyText());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
public ArrayList<Room> getRooms() {
|
|
|
|
|
|
return rooms;
|
|
|
|
|
|
|
|
|
public boolean checkPuzzleItemsInInventory(int puzzleId) {
|
|
|
|
|
|
Puzzle p = getPuzzleById(puzzleId);
|
|
|
|
|
|
for (int i = 0; i < p.getItems().size(); i++) {
|
|
|
|
|
|
if (inventory.contains(getItemById(p.getItems().get(i)))) {
|
|
|
|
|
|
} else {
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
public ArrayList<Item> getInventory() {
|
|
|
public ArrayList<Item> getInventory() {
|
|
|
return inventory;
|
|
|
return inventory;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
public ArrayList<String> getStory() {
|
|
|
|
|
|
return story;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|