Compare commits
3 Commits
d4db36c418
...
62830e92a6
Author | SHA1 | Date | |
---|---|---|---|
![]() |
62830e92a6 | ||
![]() |
80e9ec9dbc | ||
![]() |
5996c744a2 |
@ -998,11 +998,17 @@ exists or setup the property manually. For example like this:
|
|||||||
<target depends="init,compile,compile-jsps,-pre-dist,-do-dist-with-manifest,-do-dist-without-manifest" name="do-dist"/>
|
<target depends="init,compile,compile-jsps,-pre-dist,-do-dist-with-manifest,-do-dist-without-manifest" name="do-dist"/>
|
||||||
<target depends="init" if="dist.ear.dir" name="library-inclusion-in-manifest">
|
<target depends="init" if="dist.ear.dir" name="library-inclusion-in-manifest">
|
||||||
<copyfiles files="${libs.javaee-web-api-7.0.classpath}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
|
<copyfiles files="${libs.javaee-web-api-7.0.classpath}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
|
||||||
|
<copyfiles files="${file.reference.jackson-annotations-2.9.0.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
|
||||||
|
<copyfiles files="${file.reference.jackson-core-2.9.9.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
|
||||||
|
<copyfiles files="${file.reference.jackson-databind-2.9.9.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
|
||||||
<mkdir dir="${build.web.dir}/META-INF"/>
|
<mkdir dir="${build.web.dir}/META-INF"/>
|
||||||
<manifest file="${build.web.dir}/META-INF/MANIFEST.MF" mode="update"/>
|
<manifest file="${build.web.dir}/META-INF/MANIFEST.MF" mode="update"/>
|
||||||
</target>
|
</target>
|
||||||
<target depends="init" name="library-inclusion-in-archive" unless="dist.ear.dir">
|
<target depends="init" name="library-inclusion-in-archive" unless="dist.ear.dir">
|
||||||
<copyfiles files="${libs.javaee-web-api-7.0.classpath}" todir="${build.web.dir}/WEB-INF/lib"/>
|
<copyfiles files="${libs.javaee-web-api-7.0.classpath}" todir="${build.web.dir}/WEB-INF/lib"/>
|
||||||
|
<copyfiles files="${file.reference.jackson-annotations-2.9.0.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
|
||||||
|
<copyfiles files="${file.reference.jackson-core-2.9.9.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
|
||||||
|
<copyfiles files="${file.reference.jackson-databind-2.9.9.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
|
||||||
</target>
|
</target>
|
||||||
<target depends="init" if="dist.ear.dir" name="-clean-webinf-lib">
|
<target depends="init" if="dist.ear.dir" name="-clean-webinf-lib">
|
||||||
<delete dir="${build.web.dir}/WEB-INF/lib"/>
|
<delete dir="${build.web.dir}/WEB-INF/lib"/>
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
build.xml.data.CRC32=b50c735c
|
build.xml.data.CRC32=20a1ec55
|
||||||
build.xml.script.CRC32=2d64e8d1
|
build.xml.script.CRC32=2d64e8d1
|
||||||
build.xml.stylesheet.CRC32=651128d4@1.77.1.1
|
build.xml.stylesheet.CRC32=651128d4@1.77.1.1
|
||||||
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
|
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
|
||||||
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
|
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
|
||||||
nbproject/build-impl.xml.data.CRC32=b50c735c
|
nbproject/build-impl.xml.data.CRC32=20a1ec55
|
||||||
nbproject/build-impl.xml.script.CRC32=74e621b3
|
nbproject/build-impl.xml.script.CRC32=b4f5594b
|
||||||
nbproject/build-impl.xml.stylesheet.CRC32=99ea4b56@1.77.1.1
|
nbproject/build-impl.xml.stylesheet.CRC32=99ea4b56@1.77.1.1
|
||||||
|
@ -28,6 +28,9 @@ dist.war=${dist.dir}/${war.name}
|
|||||||
endorsed.classpath=\
|
endorsed.classpath=\
|
||||||
${libs.javaee-endorsed-api-7.0.classpath}
|
${libs.javaee-endorsed-api-7.0.classpath}
|
||||||
excludes=
|
excludes=
|
||||||
|
file.reference.jackson-annotations-2.9.0.jar=C:\\Users\\Edi\\Desktop\\jackson-annotations-2.9.0.jar
|
||||||
|
file.reference.jackson-core-2.9.9.jar=C:\\Users\\Edi\\Desktop\\jackson-core-2.9.9.jar
|
||||||
|
file.reference.jackson-databind-2.9.9.jar=C:\\Users\\Edi\\Desktop\\jackson-databind-2.9.9.jar
|
||||||
includes=**
|
includes=**
|
||||||
j2ee.compile.on.save=true
|
j2ee.compile.on.save=true
|
||||||
j2ee.copy.static.files.on.save=true
|
j2ee.copy.static.files.on.save=true
|
||||||
@ -42,7 +45,10 @@ j2ee.platform.wsit.classpath=
|
|||||||
j2ee.server.type=gfv3ee6
|
j2ee.server.type=gfv3ee6
|
||||||
jar.compress=false
|
jar.compress=false
|
||||||
javac.classpath=\
|
javac.classpath=\
|
||||||
${libs.javaee-web-api-7.0.classpath}
|
${libs.javaee-web-api-7.0.classpath}:\
|
||||||
|
${file.reference.jackson-annotations-2.9.0.jar}:\
|
||||||
|
${file.reference.jackson-core-2.9.9.jar}:\
|
||||||
|
${file.reference.jackson-databind-2.9.9.jar}
|
||||||
# Space-separated list of extra javac options
|
# Space-separated list of extra javac options
|
||||||
javac.compilerargs=
|
javac.compilerargs=
|
||||||
javac.debug=true
|
javac.debug=true
|
||||||
|
@ -10,6 +10,18 @@
|
|||||||
<file>${libs.javaee-web-api-7.0.classpath}</file>
|
<file>${libs.javaee-web-api-7.0.classpath}</file>
|
||||||
<path-in-war>WEB-INF/lib</path-in-war>
|
<path-in-war>WEB-INF/lib</path-in-war>
|
||||||
</library>
|
</library>
|
||||||
|
<library dirs="200">
|
||||||
|
<file>${file.reference.jackson-annotations-2.9.0.jar}</file>
|
||||||
|
<path-in-war>WEB-INF/lib</path-in-war>
|
||||||
|
</library>
|
||||||
|
<library dirs="200">
|
||||||
|
<file>${file.reference.jackson-core-2.9.9.jar}</file>
|
||||||
|
<path-in-war>WEB-INF/lib</path-in-war>
|
||||||
|
</library>
|
||||||
|
<library dirs="200">
|
||||||
|
<file>${file.reference.jackson-databind-2.9.9.jar}</file>
|
||||||
|
<path-in-war>WEB-INF/lib</path-in-war>
|
||||||
|
</library>
|
||||||
</web-module-libraries>
|
</web-module-libraries>
|
||||||
<web-module-additional-libraries/>
|
<web-module-additional-libraries/>
|
||||||
<source-roots>
|
<source-roots>
|
||||||
|
@ -1,36 +1,49 @@
|
|||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonEncoding;
|
||||||
|
import com.fasterxml.jackson.core.JsonGenerator;
|
||||||
|
import com.fasterxml.jackson.core.JsonParseException;
|
||||||
|
import com.fasterxml.jackson.core.JsonParser;
|
||||||
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
|
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
import java.io.PrintWriter;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import javax.json.stream.JsonGenerationException;
|
||||||
|
|
||||||
public class Game {
|
public class Game {
|
||||||
|
|
||||||
private static ArrayList<Room> rooms = new ArrayList<Room>();
|
private static ArrayList<Room> rooms = new ArrayList<Room>();
|
||||||
private static ArrayList<Item> inventory = new ArrayList<Item>();
|
private static ArrayList<Item> inventory = new ArrayList<Item>();
|
||||||
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<Puzzle> puzzles = new ArrayList<Puzzle>();
|
||||||
|
|
||||||
|
|
||||||
private boolean stoppFlag = false;
|
private boolean stoppFlag = false;
|
||||||
|
private Map<String, Object> jsonMap = null;
|
||||||
|
private String[] inputArray = null;
|
||||||
|
|
||||||
String[] inputArray = null;
|
private String itemName = null;
|
||||||
String itemName = null;
|
private String intentName = null;
|
||||||
String intentName = null;
|
private String puzzleName = null;
|
||||||
String puzzleName = null;
|
private String input = null;
|
||||||
String input = null;
|
private Room currentRoom = null;
|
||||||
Room currentRoom = null;
|
|
||||||
|
|
||||||
Room intro;
|
|
||||||
Room keller;
|
|
||||||
Puzzle durchgang;
|
|
||||||
Puzzle schloss;
|
|
||||||
Puzzle door;
|
|
||||||
Item schluessel;
|
|
||||||
Item stahlschluessel;
|
|
||||||
|
|
||||||
public Game() {
|
public Game() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
startGame();
|
startGame();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
@ -38,73 +51,176 @@ public class Game {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVariables() {
|
public Map<String, Object> readJSON() throws IOException, Exception {
|
||||||
|
|
||||||
// Intro Raum
|
//TODO: Define path!
|
||||||
intro = new Room("Intro");
|
File file = new File("game.JSON");
|
||||||
intro.setDescription("Hier ist das Intro von Kidnappd");
|
if(!file.exists())
|
||||||
durchgang = new Puzzle("Durchgang");
|
{
|
||||||
durchgang.setSolvedText("Hurra, du hast das Intro Level beendet");
|
PrintWriter writer = new PrintWriter("game.JSON", "UTF-8");
|
||||||
intro.puzzles.add(durchgang);
|
writer.println("{\\nroom\\n:[{\\nid\\n:0,\\nname\\n:\\nIntro\\n,\\ndescription\\n:\\nHier ist das Intro von Kidnappd\\n,\\ngameoverFlag\\n:false,\\nitems\\n:[],\\npuzzles\\n:[0]},{\\nid\\n:1,\\nname\\n:\\nKeller\\n,\\ndescription\\n:\\nder 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\\n,\\ngameoverFlag\\n:false,\\nitems\\n:[0,1],\\npuzzles\\n:[1,2]}],\\npuzzle\\n:[{\\nid\\n:0,\\nname\\n:\\nDurchgang\\n,\\nitems\\n:[],\\ndescription\\n:\\nAusgang Intro Level\\n,\\nsolved\\n:false,\\nsolvedText\\n:\\nHurra, du hast es geschafft\\n,\\ngameOverFlag\\n:false,\\nnextRoom\\n:null,\\ndependencyText\\n:null,\\ndependency\\n:null},{\\nid\\n:1,\\nname\\n:\\nTuer\\n,\\nitems\\n:[1],\\ndescription\\n:\\nAusgang aus dem Keller\\n,\\nsolved\\n:false,\\nsolvedText\\n:\\nGeschafft! Die Tuer ist offen. Das Intro ist nun beendet\\n,\\ngameOverFlag\\n:true,\\nnextRoom\\n:null,\\ndependencyText\\n:null,\\ndependency\\n:null},{\\nid\\n:2,\\nname\\n:\\nSchloss\\n,\\nitems\\n:[0],\\ndescription\\n:\\nEs ist ein altes Schloss aus Metall, dass eine Einkerbung f�r einen Schl�ssel hat\\n,\\nsolved\\n:false,\\nsolvedText\\n:\\nJa, es hat funktioniert! Mit einem Knacksen geht das Schloss auf und du kannst dich von deiner Beinfessel befreien. \\n,\\ngameOverFlag\\n:false,\\nnextRoom\\n:null,\\ndependencyText\\n:null,\\ndependency\\n:null}],\\nitem\\n:[{\\nid\\n:1,\\nname\\n:\\nStahlschluessel\\n,\\nportableFlag\\n:true,\\nhiddenFlag\\n:false,\\ndescription\\n:\\nEin Stahlschlüssel\\n},{\\nid\\n:0,\\nname\\n:\\nSchluessel\\n,\\nportableFlag\\n:true,\\nhiddenFlag\\n:false,\\ndescription\\n:\\nDer Schlüssel ist kalt und klein. Vielleicht hast du Glück und er passt ins Schloss. Versuche es zu öffnen!\\n}],\\nstory\\n:[\\nDein 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\\n]}");
|
||||||
|
writer.close();
|
||||||
|
}
|
||||||
|
|
||||||
//Raum Object
|
|
||||||
keller = new Room("Keller");
|
|
||||||
|
|
||||||
durchgang.setNextRoom(keller);
|
try {
|
||||||
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. "
|
FileReader fr = new FileReader(file);
|
||||||
+ "überall h�ngen Spinnennetze und Staub sammelt sich am Betonboden. Du erkennst am anderen Ende des Raumes eine T�r");
|
BufferedReader br = new BufferedReader(fr);
|
||||||
|
String jsonObject = br.readLine();
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
|
||||||
//Puzzle Object
|
try {
|
||||||
schloss = new Puzzle("Schloss");
|
jsonMap = objectMapper.readValue(jsonObject,
|
||||||
schloss.setDescription("Es ist ein altes Schloss aus Metall, dass eine Einkerbung f�r einen Schl�ssel hat");
|
new TypeReference<Map<String, Object>>() {
|
||||||
schloss.setSolvedText("Ja, es hat funktioniert! Mit einem Knacksen geht das Schloss auf und du kannst dich von deiner Beinfessel befreien. ");
|
});
|
||||||
|
} catch (JsonParseException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (JsonMappingException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IOException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
log("Keyset:" + jsonMap.keySet().toString());
|
||||||
|
return jsonMap;
|
||||||
|
|
||||||
keller.puzzles.add(schloss);
|
} catch (FileNotFoundException e1) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
//Ausgang
|
return null;
|
||||||
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);
|
|
||||||
|
|
||||||
//Item Object
|
public static String writeJSON(File f) throws IOException {
|
||||||
schluessel = new Item("Schluessel");
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
schluessel.setHiddenFlag(false);
|
String s = "";
|
||||||
schluessel.setPortableFlag(true);
|
try (
|
||||||
schluessel.setDescription("Der Schl�ssel ist kalt und klein. Vielleicht hast du Gl�ck und er passt ins Schloss. Versuche es zu �ffnen!");
|
JsonGenerator jGenerator
|
||||||
schloss.addItem(schluessel);
|
= mapper.getFactory().createGenerator(f,JsonEncoding.UTF8)) {
|
||||||
keller.items.add(schluessel);
|
|
||||||
|
|
||||||
door.setDependency(schloss);
|
jGenerator.writeStartObject();
|
||||||
door.setDependencyText("Du musst erst das Schloss der Kette knacken um die Tür öffnen zu können");
|
jGenerator.writeObjectField("room", rooms);
|
||||||
|
jGenerator.writeObjectField("puzzle", puzzles);
|
||||||
|
jGenerator.writeObjectField("item", items);
|
||||||
|
jGenerator.writeObjectField("story", story);
|
||||||
|
jGenerator.writeEndObject();
|
||||||
|
jGenerator.close();
|
||||||
|
|
||||||
//Item Object
|
} catch (JsonGenerationException e) {
|
||||||
stahlschluessel = new Item("Stahlschluessel");
|
e.printStackTrace();
|
||||||
stahlschluessel.setHiddenFlag(false);
|
} catch (JsonMappingException e) {
|
||||||
stahlschluessel.setPortableFlag(false);
|
e.printStackTrace();
|
||||||
stahlschluessel.setDescription("Ein Stahlschlüssel");
|
} catch (IOException e) {
|
||||||
intro.items.add(stahlschluessel);
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
rooms.add(intro);
|
BufferedReader reader = null;
|
||||||
rooms.add(keller);
|
try {
|
||||||
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, "
|
reader = new BufferedReader(new FileReader("game.JSON"));
|
||||||
+ "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... "
|
} catch (FileNotFoundException ex) {
|
||||||
+ "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! "
|
Logger.getLogger(Game.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
+ "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."
|
StringBuilder sb = new StringBuilder();
|
||||||
+ "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. "
|
String line;
|
||||||
+ "Pl�tzlich st��t du auf einen kleinen Gegenstand, der sich tats�chlich anf�hlt wie ein Schl�ssel. Du solltest ihn aufheben");
|
|
||||||
|
while ((line = reader.readLine()) != null) {
|
||||||
|
s = s + (line + "\n");
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
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 void setVariables() throws Exception {
|
||||||
|
|
||||||
|
readJSON();
|
||||||
|
log(readJSON().toString());
|
||||||
|
log("Readjson fertig");
|
||||||
|
|
||||||
|
currentRoom = rooms.get(0);
|
||||||
|
|
||||||
currentRoom = intro;
|
|
||||||
stoppFlag = false;
|
stoppFlag = false;
|
||||||
inventory = new ArrayList<Item>();
|
inventory = new ArrayList<>();
|
||||||
|
|
||||||
|
//log("JSON: " + writeJSON());
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
objectMapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
|
||||||
|
|
||||||
|
String jsonStringRoom = objectMapper.writeValueAsString(jsonMap.get("room"));
|
||||||
|
String jsonStringItem = objectMapper.writeValueAsString(jsonMap.get("item"));
|
||||||
|
String jsonStringPuzzle = objectMapper.writeValueAsString(jsonMap.get("puzzle"));
|
||||||
|
String jsonStringStory = objectMapper.writeValueAsString(jsonMap.get("story"));
|
||||||
|
|
||||||
|
log("Item: " + jsonStringItem);
|
||||||
|
log("Room: " + jsonStringRoom);
|
||||||
|
log("Story: " + jsonStringStory);
|
||||||
|
log("Puzzle: " + jsonStringPuzzle);
|
||||||
|
|
||||||
|
String[] st = objectMapper.readValue(jsonStringStory, String[].class);
|
||||||
|
log("Story Array OK");
|
||||||
|
Item[] it = objectMapper.readValue(jsonStringItem, Item[].class);
|
||||||
|
log("Item Array OK");
|
||||||
|
Puzzle[] pu = objectMapper.readValue(jsonStringPuzzle, Puzzle[].class);
|
||||||
|
log("Puzzle Array OK");
|
||||||
|
Room[] ro = objectMapper.readValue(jsonStringRoom, Room[].class);
|
||||||
|
log("Room Array OK");
|
||||||
|
|
||||||
|
for (Room ro1 : ro) {
|
||||||
|
log("Room: " + ro1.getName());
|
||||||
|
log("Description: " + ro1.getDescription());
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Item it1 : it) {
|
||||||
|
log("Item: " + it1.getName());
|
||||||
|
log("Description: " + it1.getDescription());
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Puzzle pu1 : pu) {
|
||||||
|
log("Puzzle: " + pu1.getName());
|
||||||
|
log("Description: " + pu1.getDescription());
|
||||||
|
log("DependencyText: " + pu1.getDependencyText());
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String st1 : st) {
|
||||||
|
log("Story: " + st1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void play() throws Exception {
|
public void play() throws Exception {
|
||||||
log("play()");
|
log("play()");
|
||||||
log("Input: " + input);
|
log("Input: " + input);
|
||||||
|
log("currentRoom: " + currentRoom.getName());
|
||||||
|
|
||||||
|
for (int i = 0; i < currentRoom.getPuzzles().size(); i++) {
|
||||||
|
log("Puzzle im Raum: " + currentRoom.getPuzzles().get(i)); //getPuzzles().get(i).getName());
|
||||||
|
}
|
||||||
|
for (int i = 0; i < currentRoom.getItems().size(); i++) {
|
||||||
|
log("Item im Raum: " + currentRoom.getItems().get(i)); //getItems().get(i).getName());
|
||||||
|
}
|
||||||
|
|
||||||
input = input.replace("ä", "ae");
|
input = input.replace("ä", "ae");
|
||||||
input = input.replace("ü", "ue");
|
input = input.replace("ü", "ue");
|
||||||
@ -115,11 +231,11 @@ public class Game {
|
|||||||
inputArray = input.split(" ");
|
inputArray = input.split(" ");
|
||||||
|
|
||||||
for (String s : inputArray) {
|
for (String s : inputArray) {
|
||||||
if (currentRoom.getItem(s) != null) {
|
if (getItem(s) != null) {
|
||||||
itemName = currentRoom.getItem(s).getName();
|
itemName = getItem(s).getName();
|
||||||
log("itemName: " + itemName);
|
log("itemName: " + itemName);
|
||||||
} else if (currentRoom.getPuzzle(s) != null) {
|
} else if (getPuzzle(s) != null) {
|
||||||
puzzleName = currentRoom.getPuzzle(s).getName();
|
puzzleName = getPuzzle(s).getName();
|
||||||
log("PuzzleName: " + puzzleName);
|
log("PuzzleName: " + puzzleName);
|
||||||
} else {
|
} else {
|
||||||
intentName = s;
|
intentName = s;
|
||||||
@ -134,22 +250,22 @@ public class Game {
|
|||||||
switch (intentName.toLowerCase()) {
|
switch (intentName.toLowerCase()) {
|
||||||
//intent
|
//intent
|
||||||
case "lookaroundintent":
|
case "lookaroundintent":
|
||||||
log("Switch: lookAroundIntent");
|
log("Switch: LookAroundIntent");
|
||||||
if (itemName == null && puzzleName == null) {
|
if (itemName == null && puzzleName == null) {
|
||||||
lookaround();
|
lookaround();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
//intent
|
//intent
|
||||||
case "inspectintent":
|
case "inspectintent":
|
||||||
log("Switch: inspectintent");
|
log("Switch: InspectIntent");
|
||||||
if (itemName != null) {
|
if (getItem(itemName) != null) {
|
||||||
inspect(itemName);
|
inspect(getItem(itemName));
|
||||||
} else if (puzzleName != null) {
|
} else if (getPuzzle(puzzleName) != null) {
|
||||||
inspect(puzzleName);
|
inspect(getPuzzle(puzzleName));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
//intent
|
|
||||||
|
|
||||||
|
//intent
|
||||||
case "examineintent":
|
case "examineintent":
|
||||||
log("Switch: ExamineIntent");
|
log("Switch: ExamineIntent");
|
||||||
if (itemName == null && puzzleName == null) {
|
if (itemName == null && puzzleName == null) {
|
||||||
@ -160,15 +276,15 @@ public class Game {
|
|||||||
//intent
|
//intent
|
||||||
case "takeintent":
|
case "takeintent":
|
||||||
log("Switch: TakeIntent");
|
log("Switch: TakeIntent");
|
||||||
if (itemName != null) {
|
if (getItem(itemName) != null) {
|
||||||
take(currentRoom.getItem(itemName));
|
take(getItem(itemName));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
//intent
|
//intent
|
||||||
case "openintent":
|
case "openintent":
|
||||||
log("Switch: OpenIntent");
|
log("Switch: OpenIntent");
|
||||||
if (puzzleName != null) {
|
if (getPuzzle(puzzleName) != null) {
|
||||||
open(currentRoom.getPuzzle(puzzleName));
|
open(getPuzzle(puzzleName));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
//intent
|
//intent
|
||||||
@ -185,14 +301,18 @@ public class Game {
|
|||||||
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) {
|
if (getPuzzleById(currentRoom.puzzles.get(i)).getNextRoom() != null) {
|
||||||
setRoom(currentRoom.puzzles.get(i).getNextRoom());
|
setRoom(getRoomById(getPuzzleById(currentRoom.puzzles.get(i)).getNextRoom()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "resumeintent":
|
||||||
|
log("Switch: ResumeIntent");
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
itemName = null;
|
itemName = null;
|
||||||
@ -206,8 +326,35 @@ public class Game {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void log(String s) throws Exception
|
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 {
|
||||||
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);
|
||||||
HttpURLConnection httpConn = (HttpURLConnection) obj.openConnection();
|
HttpURLConnection httpConn = (HttpURLConnection) obj.openConnection();
|
||||||
@ -219,11 +366,11 @@ public class Game {
|
|||||||
|
|
||||||
// Send post request
|
// Send post request
|
||||||
httpConn.setDoOutput(true);
|
httpConn.setDoOutput(true);
|
||||||
DataOutputStream wr = new DataOutputStream(httpConn.getOutputStream());
|
try (DataOutputStream wr = new DataOutputStream(httpConn.getOutputStream())) {
|
||||||
String urlParameters = "log=" + s;
|
String urlParameters = "log=" + s;
|
||||||
wr.writeBytes(urlParameters);
|
wr.writeBytes(urlParameters);
|
||||||
wr.flush();
|
wr.flush();
|
||||||
wr.close();
|
}
|
||||||
|
|
||||||
BufferedReader in = new BufferedReader(
|
BufferedReader in = new BufferedReader(
|
||||||
new InputStreamReader(httpConn.getInputStream()));
|
new InputStreamReader(httpConn.getInputStream()));
|
||||||
@ -253,22 +400,23 @@ public class Game {
|
|||||||
startGame();
|
startGame();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void inspect(String s) throws Exception {
|
public void inspect(Puzzle currentPuzzle) throws Exception {
|
||||||
log("inspect(" + s + ") ");
|
log("inspect(" + currentPuzzle.getName() + ")");
|
||||||
Item currentItem=null;
|
|
||||||
if(currentRoom.getItem(s) != null)
|
for (int i = 0; i < currentRoom.getItems().size(); i++) {
|
||||||
{
|
if (Objects.equals(currentRoom.getPuzzles().get(i), currentPuzzle.getId())) {
|
||||||
currentItem= currentRoom.getItem(s);
|
say(currentPuzzle.getDescription());
|
||||||
log("currentItem: " + currentItem.getName());
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void inspect(Item currentItem) throws Exception {
|
||||||
|
log("inspect(" + currentItem.getName() + ")");
|
||||||
|
|
||||||
|
for (int i = 0; i < currentRoom.getItems().size(); i++) {
|
||||||
|
if (Objects.equals(currentRoom.getItems().get(i), currentItem.getId())) {
|
||||||
say(currentItem.getDescription());
|
say(currentItem.getDescription());
|
||||||
}
|
}
|
||||||
Puzzle currentPuzzle=null;
|
|
||||||
|
|
||||||
if(currentRoom.getPuzzle(s) != null)
|
|
||||||
{
|
|
||||||
currentPuzzle = currentRoom.getPuzzle(s);
|
|
||||||
log("currentPuzzle " + currentPuzzle.getName());
|
|
||||||
say(currentPuzzle.getDescription());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -354,13 +502,13 @@ public class Game {
|
|||||||
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
|
||||||
@ -372,7 +520,7 @@ public class Game {
|
|||||||
|
|
||||||
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
|
||||||
{
|
{
|
||||||
@ -380,7 +528,7 @@ public class Game {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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());
|
||||||
}
|
}
|
||||||
@ -400,16 +548,19 @@ public class Game {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<Room> getRooms() {
|
public boolean checkPuzzleItemsInInventory(int puzzleId) {
|
||||||
return rooms;
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,24 @@
|
|||||||
|
|
||||||
public class Item
|
public class Item
|
||||||
{
|
{
|
||||||
|
private Integer id;
|
||||||
private String name;
|
private String name;
|
||||||
private boolean portableFlag;
|
private boolean portableFlag;
|
||||||
private boolean hiddenFlag;
|
private boolean hiddenFlag;
|
||||||
private String description;
|
private String description;
|
||||||
public Item(String name)
|
|
||||||
|
public Item(Integer i, String n, boolean portable, boolean hidden, String desc)
|
||||||
{
|
{
|
||||||
this.name = name;
|
id = i;
|
||||||
|
name = n;
|
||||||
|
portableFlag = portable;
|
||||||
|
hiddenFlag = hidden;
|
||||||
|
description = desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Item()
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription()
|
public String getDescription()
|
||||||
@ -15,32 +26,21 @@ public class Item
|
|||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDescription(String description)
|
|
||||||
{
|
|
||||||
this.description = description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isPortableFlag() {
|
public boolean isPortableFlag() {
|
||||||
return portableFlag;
|
return portableFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPortableFlag(boolean portableFlag) {
|
|
||||||
this.portableFlag = portableFlag;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isHiddenFlag() {
|
public boolean isHiddenFlag() {
|
||||||
return hiddenFlag;
|
return hiddenFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHiddenFlag(boolean hiddenFlag) {
|
public Integer getId()
|
||||||
this.hiddenFlag = hiddenFlag;
|
{
|
||||||
|
return id;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -61,7 +61,7 @@ public class Log extends HttpServlet {
|
|||||||
@Override
|
@Override
|
||||||
protected void doGet(HttpServletRequest request, HttpServletResponse response)
|
protected void doGet(HttpServletRequest request, HttpServletResponse response)
|
||||||
throws ServletException, IOException {
|
throws ServletException, IOException {
|
||||||
response.setIntHeader("Refresh", 2);
|
response.setIntHeader("Refresh", 10);
|
||||||
try {
|
try {
|
||||||
processRequest(request, response);
|
processRequest(request, response);
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ public class Log extends HttpServlet {
|
|||||||
@Override
|
@Override
|
||||||
protected void doPost(HttpServletRequest request, HttpServletResponse response)
|
protected void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||||
throws ServletException, IOException {
|
throws ServletException, IOException {
|
||||||
response.setIntHeader("Refresh", 2);
|
response.setIntHeader("Refresh", 10);
|
||||||
try {
|
try {
|
||||||
processRequest(request, response);
|
processRequest(request, response);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
@ -21,6 +22,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||||||
*/
|
*/
|
||||||
@WebServlet(urlPatterns = {"/IO"})
|
@WebServlet(urlPatterns = {"/IO"})
|
||||||
public class Logic extends HttpServlet {
|
public class Logic extends HttpServlet {
|
||||||
|
private ArrayList<Game> games = new ArrayList<Game>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
|
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
|
||||||
@ -35,8 +37,14 @@ public class Logic extends HttpServlet {
|
|||||||
String context = "";
|
String context = "";
|
||||||
|
|
||||||
public void init() {
|
public void init() {
|
||||||
|
try {
|
||||||
g.setVariables();
|
g.setVariables();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
Logger.getLogger(Logic.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
|
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
|
||||||
throws ServletException, IOException, Exception {
|
throws ServletException, IOException, Exception {
|
||||||
@ -50,7 +58,7 @@ public class Logic extends HttpServlet {
|
|||||||
|
|
||||||
out.println(context);
|
out.println(context);
|
||||||
|
|
||||||
|
//String deviceId = request.getParameter("deviceId"); // einzigartige DeviceID des Alexa Geräts
|
||||||
|
|
||||||
String input = request.getParameter("intent");
|
String input = request.getParameter("intent");
|
||||||
if (request.getParameter("slot") != null) {
|
if (request.getParameter("slot") != null) {
|
||||||
@ -63,6 +71,17 @@ public class Logic extends HttpServlet {
|
|||||||
g.play();
|
g.play();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Mehrere Spieler auf einem Server
|
||||||
|
for(int i = 0; i < games.size(); i++)
|
||||||
|
{
|
||||||
|
if(games.get(i).getId().equals(deviceId))
|
||||||
|
{
|
||||||
|
games.get(i).setInput(input);
|
||||||
|
games.get(i).play();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,19 +2,34 @@ import java.util.ArrayList;
|
|||||||
|
|
||||||
public class Puzzle
|
public class Puzzle
|
||||||
{
|
{
|
||||||
|
private Integer id;
|
||||||
private String name;
|
private String name;
|
||||||
private ArrayList<Item> items = new ArrayList<Item>();
|
private ArrayList<Integer> items = new ArrayList<>();
|
||||||
private String description="";
|
private String description="";
|
||||||
private boolean solved = false;
|
private boolean solved = false;
|
||||||
private String solvedText = "";
|
private String solvedText = "";
|
||||||
private boolean gameOverFlag=false;
|
private boolean gameOverFlag=false;
|
||||||
private Room nextRoom = null;
|
private Integer nextRoom = null;
|
||||||
private String dependencyText = null;
|
private String dependencyText = null;
|
||||||
private Puzzle dependency= null;
|
private Integer dependency= null;
|
||||||
|
|
||||||
public Puzzle(String name)
|
public Puzzle()
|
||||||
{
|
{
|
||||||
this.name = name;
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Puzzle(Integer i, String n, ArrayList<Integer> itemList, String desc, boolean solvedFlag, String solvedTxt, boolean gameOver, Integer next, String dependencytxt, Integer dependentFrom)
|
||||||
|
{
|
||||||
|
id = i;
|
||||||
|
name = n;
|
||||||
|
items = itemList;
|
||||||
|
description = desc;
|
||||||
|
solved = solvedFlag;
|
||||||
|
solvedText = solvedTxt;
|
||||||
|
gameOverFlag = gameOver;
|
||||||
|
nextRoom = next;
|
||||||
|
dependencyText = dependencytxt;
|
||||||
|
dependency = dependentFrom;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasDependency()
|
public boolean hasDependency()
|
||||||
@ -22,17 +37,8 @@ public class Puzzle
|
|||||||
return dependency != null;
|
return dependency != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDependency(Puzzle p)
|
|
||||||
{
|
|
||||||
dependency = p;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDependencyText(String s)
|
public Integer getDependency()
|
||||||
{
|
|
||||||
dependencyText = s;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Puzzle getDependency()
|
|
||||||
{
|
{
|
||||||
return dependency;
|
return dependency;
|
||||||
}
|
}
|
||||||
@ -42,60 +48,38 @@ public class Puzzle
|
|||||||
return dependencyText;
|
return dependencyText;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Room getNextRoom()
|
public Integer getNextRoom()
|
||||||
{
|
{
|
||||||
return nextRoom;
|
return nextRoom;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addItem(Item i)
|
|
||||||
{
|
|
||||||
items.add(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArrayList<Item> getItems() {
|
public ArrayList<Integer> getItems() {
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setItems(ArrayList<Item> items) {
|
|
||||||
this.items = items;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDescription(String description) {
|
|
||||||
this.description = description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSolvedText() {
|
public String getSolvedText() {
|
||||||
return solvedText;
|
return solvedText;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSolvedText(String solvedText) {
|
|
||||||
this.solvedText = solvedText;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSolved() {
|
public boolean isSolved() {
|
||||||
return solved;
|
return solved;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSolved(boolean solved) {
|
public void setSolved(boolean s)
|
||||||
this.solved = solved;
|
{
|
||||||
}
|
solved = s;
|
||||||
|
|
||||||
public void setGameOverFlag(boolean b) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
gameOverFlag = b;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getGameOverFlag() {
|
public boolean getGameOverFlag() {
|
||||||
@ -103,8 +87,8 @@ public class Puzzle
|
|||||||
return gameOverFlag;
|
return gameOverFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNextRoom(Room r)
|
public Integer getId()
|
||||||
{
|
{
|
||||||
nextRoom = r;
|
return id;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -3,60 +3,51 @@ import java.util.ArrayList;
|
|||||||
|
|
||||||
public class Room
|
public class Room
|
||||||
{
|
{
|
||||||
|
private Integer id;
|
||||||
private String name;
|
private String name;
|
||||||
private String description;
|
private String description;
|
||||||
private boolean gameoverFlag;
|
private boolean gameoverFlag;
|
||||||
ArrayList<Item> items = new ArrayList<>();
|
ArrayList<Integer> items = new ArrayList<>();
|
||||||
ArrayList<Puzzle> puzzles = new ArrayList<>();
|
ArrayList<Integer> puzzles = new ArrayList<>();
|
||||||
public Room(String name)
|
|
||||||
|
public Room()
|
||||||
{
|
{
|
||||||
this.name = name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Item getItem(String s)
|
public Room(Integer i, String n, String desc, boolean gameover, ArrayList<Integer> itemList, ArrayList<Integer> puzzleList)
|
||||||
{
|
{
|
||||||
for(Item i: items)
|
id = i;
|
||||||
{
|
name = n;
|
||||||
if(i.getName().equalsIgnoreCase(s))
|
description = desc;
|
||||||
return i;
|
gameoverFlag = gameover;
|
||||||
}
|
items = itemList;
|
||||||
return null;
|
puzzles = puzzleList;
|
||||||
}
|
|
||||||
|
|
||||||
public Puzzle getPuzzle(String s)
|
|
||||||
{
|
|
||||||
for(Puzzle p: puzzles)
|
|
||||||
{
|
|
||||||
if(p.getName().equalsIgnoreCase(s))
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
public void setName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
public void setDescription(String description) {
|
|
||||||
this.description = description;
|
|
||||||
}
|
|
||||||
public boolean getGameoverFlag() {
|
public boolean getGameoverFlag() {
|
||||||
return gameoverFlag;
|
return gameoverFlag;
|
||||||
}
|
}
|
||||||
public void setGameoverFlag(boolean gameOverFlag) {
|
|
||||||
gameoverFlag = gameOverFlag;
|
public ArrayList<Integer> getItems() {
|
||||||
}
|
|
||||||
public ArrayList<Item> getItems() {
|
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<Puzzle> getPuzzles() {
|
public ArrayList<Integer> getPuzzles() {
|
||||||
return puzzles;
|
return puzzles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getId()
|
||||||
|
{
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
1
src/java/original.json
Normal file
1
src/java/original.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"room":[{"id":0,"name":"Intro","description":"Hier ist das Intro von Kidnappd","gameoverFlag":false,"items":[],"puzzles":[0]},{"id":1,"name":"Keller","description":"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","gameoverFlag":false,"items":[0,1],"puzzles":[1,2]}],"puzzle":[{"id":0,"name":"Durchgang","items":[],"description":"Ausgang Intro Level","solved":false,"solvedText":"Hurra, du hast es geschafft","gameOverFlag":false,"nextRoom":null,"dependencyText":null,"dependency":null},{"id":1,"name":"Tuer","items":[1],"description":"Ausgang aus dem Keller","solved":false,"solvedText":"Geschafft! Die Tuer ist offen. Das Intro ist nun beendet","gameOverFlag":true,"nextRoom":null,"dependencyText":null,"dependency":null},{"id":2,"name":"Schloss","items":[0],"description":"Es ist ein altes Schloss aus Metall, dass eine Einkerbung f�r einen Schl�ssel hat","solved":false,"solvedText":"Ja, es hat funktioniert! Mit einem Knacksen geht das Schloss auf und du kannst dich von deiner Beinfessel befreien. ","gameOverFlag":false,"nextRoom":null,"dependencyText":null,"dependency":null}],"item":[{"id":1,"name":"Stahlschluessel","portableFlag":true,"hiddenFlag":false,"description":"Ein Stahlschlüssel"},{"id":0,"name":"Schluessel","portableFlag":true,"hiddenFlag":false,"description":"Der Schlüssel ist kalt und klein. Vielleicht hast du Glück und er passt ins Schloss. Versuche es zu öffnen!"}],"story":["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"]}
|
Loading…
x
Reference in New Issue
Block a user