Merge origin/master
This commit is contained in:
parent
d4db36c418
commit
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,34 +1,50 @@
|
|||||||
|
|
||||||
|
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.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 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;
|
private Room intro;
|
||||||
Room keller;
|
private Room keller;
|
||||||
Puzzle durchgang;
|
private Puzzle durchgang;
|
||||||
Puzzle schloss;
|
private Puzzle schloss;
|
||||||
Puzzle door;
|
private Puzzle door;
|
||||||
Item schluessel;
|
private Item schluessel;
|
||||||
Item stahlschluessel;
|
private Item stahlschluessel;
|
||||||
|
|
||||||
public Game() {
|
public Game() {
|
||||||
try {
|
try {
|
||||||
@ -38,7 +54,83 @@ public class Game {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVariables() {
|
public Map<String, Object> readJSON() throws IOException, Exception {
|
||||||
|
|
||||||
|
//TODO: Define path!
|
||||||
|
File file = new File("game.JSON");
|
||||||
|
try {
|
||||||
|
FileReader fr = new FileReader(file);
|
||||||
|
BufferedReader br = new BufferedReader(fr);
|
||||||
|
String jsonObject = br.readLine();
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
|
||||||
|
try {
|
||||||
|
jsonMap = objectMapper.readValue(jsonObject,
|
||||||
|
new TypeReference<Map<String, Object>>() {
|
||||||
|
});
|
||||||
|
} 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();
|
||||||
|
}
|
||||||
|
|
||||||
|
return jsonMap;
|
||||||
|
|
||||||
|
} catch (FileNotFoundException e1) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String generateJSON() throws IOException {
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
String s = "";
|
||||||
|
try (
|
||||||
|
JsonGenerator jGenerator
|
||||||
|
= mapper.getFactory().createGenerator(
|
||||||
|
new File("game.JSON"),
|
||||||
|
JsonEncoding.UTF8)) {
|
||||||
|
|
||||||
|
jGenerator.writeStartObject();
|
||||||
|
jGenerator.writeObjectField("room", rooms);
|
||||||
|
jGenerator.writeObjectField("puzzle", puzzles);
|
||||||
|
jGenerator.writeObjectField("item", items);
|
||||||
|
jGenerator.writeObjectField("story", story);
|
||||||
|
|
||||||
|
jGenerator.writeEndObject();
|
||||||
|
jGenerator.close();
|
||||||
|
|
||||||
|
} catch (JsonGenerationException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (JsonMappingException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
BufferedReader reader = null;
|
||||||
|
try {
|
||||||
|
reader = new BufferedReader(new FileReader("game.JSON"));
|
||||||
|
} catch (FileNotFoundException ex) {
|
||||||
|
Logger.getLogger(Game.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
|
}
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
String line;
|
||||||
|
|
||||||
|
while ((line = reader.readLine()) != null) {
|
||||||
|
s = s + (line + "\n");
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVariables() throws Exception {
|
||||||
|
|
||||||
// Intro Raum
|
// Intro Raum
|
||||||
intro = new Room("Intro");
|
intro = new Room("Intro");
|
||||||
@ -58,7 +150,7 @@ public class Game {
|
|||||||
schloss = new Puzzle("Schloss");
|
schloss = new Puzzle("Schloss");
|
||||||
schloss.setDescription("Es ist ein altes Schloss aus Metall, dass eine Einkerbung f�r einen Schl�ssel hat");
|
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. ");
|
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);
|
keller.puzzles.add(schloss);
|
||||||
|
|
||||||
//Ausgang
|
//Ausgang
|
||||||
@ -67,6 +159,7 @@ public class Game {
|
|||||||
door.setGameOverFlag(true);
|
door.setGameOverFlag(true);
|
||||||
door.setSolvedText("Geschafft! Die Tuer ist offen. Das Intro ist nun beendet");
|
door.setSolvedText("Geschafft! Die Tuer ist offen. Das Intro ist nun beendet");
|
||||||
keller.puzzles.add(door);
|
keller.puzzles.add(door);
|
||||||
|
puzzles.add(door);
|
||||||
|
|
||||||
//Item Object
|
//Item Object
|
||||||
schluessel = new Item("Schluessel");
|
schluessel = new Item("Schluessel");
|
||||||
@ -75,6 +168,7 @@ public class Game {
|
|||||||
schluessel.setDescription("Der Schl�ssel ist kalt und klein. Vielleicht hast du Gl�ck und er passt ins Schloss. Versuche es zu �ffnen!");
|
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);
|
schloss.addItem(schluessel);
|
||||||
keller.items.add(schluessel);
|
keller.items.add(schluessel);
|
||||||
|
items.add(schluessel);
|
||||||
|
|
||||||
door.setDependency(schloss);
|
door.setDependency(schloss);
|
||||||
door.setDependencyText("Du musst erst das Schloss der Kette knacken um die Tür öffnen zu können");
|
door.setDependencyText("Du musst erst das Schloss der Kette knacken um die Tür öffnen zu können");
|
||||||
@ -85,6 +179,7 @@ public class Game {
|
|||||||
stahlschluessel.setPortableFlag(false);
|
stahlschluessel.setPortableFlag(false);
|
||||||
stahlschluessel.setDescription("Ein Stahlschlüssel");
|
stahlschluessel.setDescription("Ein Stahlschlüssel");
|
||||||
intro.items.add(stahlschluessel);
|
intro.items.add(stahlschluessel);
|
||||||
|
items.add(stahlschluessel);
|
||||||
|
|
||||||
rooms.add(intro);
|
rooms.add(intro);
|
||||||
rooms.add(keller);
|
rooms.add(keller);
|
||||||
@ -99,12 +194,76 @@ public class Game {
|
|||||||
currentRoom = intro;
|
currentRoom = intro;
|
||||||
stoppFlag = false;
|
stoppFlag = false;
|
||||||
inventory = new ArrayList<Item>();
|
inventory = new ArrayList<Item>();
|
||||||
|
log("JSON: " + generateJSON());
|
||||||
|
|
||||||
|
readJSON();
|
||||||
|
|
||||||
|
log("Readjson fertig");
|
||||||
|
|
||||||
|
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(int i=0; i < ro.length; i++)
|
||||||
|
{
|
||||||
|
log("Room: " + ro[i].getName());
|
||||||
|
log("Description: " + ro[i].getDescription());
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int i=0; i < it.length; i++)
|
||||||
|
{
|
||||||
|
log("Item: " + it[i].getName());
|
||||||
|
log("Description: " + it[i].getDescription());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
for(int i=0; i < pu.length; i++)
|
||||||
|
{
|
||||||
|
log("Puzzle: " + pu[i].getName());
|
||||||
|
log("Description: " + pu[i].getDescription());
|
||||||
|
log("DependencyText: " + pu[i].getDependencyText());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
for(int i=0; i < st.length; i++)
|
||||||
|
{
|
||||||
|
log("Story: " + st[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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).getName());
|
||||||
|
}
|
||||||
|
for (int i = 0; i < currentRoom.getItems().size(); i++) {
|
||||||
|
log("Item im Raum: " + currentRoom.getItems().get(i).getName());
|
||||||
|
}
|
||||||
|
|
||||||
input = input.replace("ä", "ae");
|
input = input.replace("ä", "ae");
|
||||||
input = input.replace("ü", "ue");
|
input = input.replace("ü", "ue");
|
||||||
@ -134,22 +293,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 (currentRoom.getItem(itemName) != null) {
|
||||||
inspect(itemName);
|
inspect(currentRoom.getItem(itemName));
|
||||||
} else if (puzzleName != null) {
|
} else if (currentRoom.getPuzzle(puzzleName) != null) {
|
||||||
inspect(puzzleName);
|
inspect(currentRoom.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,14 +319,14 @@ public class Game {
|
|||||||
//intent
|
//intent
|
||||||
case "takeintent":
|
case "takeintent":
|
||||||
log("Switch: TakeIntent");
|
log("Switch: TakeIntent");
|
||||||
if (itemName != null) {
|
if (currentRoom.getItem(itemName) != null) {
|
||||||
take(currentRoom.getItem(itemName));
|
take(currentRoom.getItem(itemName));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
//intent
|
//intent
|
||||||
case "openintent":
|
case "openintent":
|
||||||
log("Switch: OpenIntent");
|
log("Switch: OpenIntent");
|
||||||
if (puzzleName != null) {
|
if (currentRoom.getPuzzle(puzzleName) != null) {
|
||||||
open(currentRoom.getPuzzle(puzzleName));
|
open(currentRoom.getPuzzle(puzzleName));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -190,7 +349,6 @@ public class Game {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -206,8 +364,7 @@ public class Game {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
HttpURLConnection httpConn = (HttpURLConnection) obj.openConnection();
|
HttpURLConnection httpConn = (HttpURLConnection) obj.openConnection();
|
||||||
@ -237,43 +394,44 @@ public class Game {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void lookaround() throws Exception {
|
public void lookaround() throws Exception {
|
||||||
log("lookaround() ");
|
log("lookaround()");
|
||||||
say(currentRoom.getDescription());
|
say(currentRoom.getDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startGame() throws Exception {
|
public void startGame() throws Exception {
|
||||||
log("startGame() ");
|
log("startGame()");
|
||||||
for (int i = 0; i < story.size(); i++) {
|
for (int i = 0; i < story.size(); i++) {
|
||||||
say(story.get(i));
|
say(story.get(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetGame() throws Exception {
|
public void resetGame() throws Exception {
|
||||||
log("resetGame() ");
|
log("resetGame()");
|
||||||
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 (currentRoom.getPuzzles().get(i) == currentPuzzle) {
|
||||||
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 (currentRoom.getItems().get(i) == currentItem) {
|
||||||
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());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void endGame() throws Exception {
|
public void endGame() throws Exception {
|
||||||
log("endGame() ");
|
log("endGame()");
|
||||||
say("Glückwunsch das Spiel ist beendet!");
|
say("Glückwunsch das Spiel ist beendet!");
|
||||||
setVariables();
|
setVariables();
|
||||||
}
|
}
|
||||||
@ -309,7 +467,7 @@ public class Game {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void say(String s) throws Exception {
|
public void say(String s) throws Exception {
|
||||||
log("say(" + s + ") ");
|
log("say(" + s + ")");
|
||||||
try {
|
try {
|
||||||
sendPost(s);
|
sendPost(s);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
@ -318,12 +476,12 @@ public class Game {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setInput(String s) throws Exception {
|
public void setInput(String s) throws Exception {
|
||||||
log("setInput(" + s + ") ");
|
log("setInput(" + s + ")");
|
||||||
input = s;
|
input = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRoom(Room nextRoom) throws Exception {
|
public void setRoom(Room nextRoom) throws Exception {
|
||||||
log("setRoom(" + nextRoom.getName() + ") " );
|
log("setRoom(" + nextRoom.getName() + ")");
|
||||||
currentRoom = nextRoom;
|
currentRoom = nextRoom;
|
||||||
say(currentRoom.getDescription());
|
say(currentRoom.getDescription());
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,20 @@ public class Item
|
|||||||
private boolean portableFlag;
|
private boolean portableFlag;
|
||||||
private boolean hiddenFlag;
|
private boolean hiddenFlag;
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
|
public Item(String n, boolean p, boolean h, String d)
|
||||||
|
{
|
||||||
|
name = n;
|
||||||
|
portableFlag = p;
|
||||||
|
hiddenFlag = h;
|
||||||
|
description = d;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Item()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public Item(String name)
|
public Item(String name)
|
||||||
{
|
{
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
@ -35,8 +35,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 {
|
||||||
|
@ -17,6 +17,24 @@ public class Puzzle
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Puzzle()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Puzzle(String n, ArrayList<Item> i, String d, boolean s, String st, boolean g, Room nx, String dt, Puzzle p)
|
||||||
|
{
|
||||||
|
name = n;
|
||||||
|
items = i;
|
||||||
|
description = d;
|
||||||
|
solved = s;
|
||||||
|
solvedText = st;
|
||||||
|
gameOverFlag = g;
|
||||||
|
nextRoom = nx;
|
||||||
|
dependencyText = dt;
|
||||||
|
dependency = p;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean hasDependency()
|
public boolean hasDependency()
|
||||||
{
|
{
|
||||||
return dependency != null;
|
return dependency != null;
|
||||||
|
@ -13,6 +13,20 @@ public class Room
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Room()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Room(String n, String d, boolean g, ArrayList<Item> i, ArrayList<Puzzle> p)
|
||||||
|
{
|
||||||
|
name = n;
|
||||||
|
description = d;
|
||||||
|
gameoverFlag = g;
|
||||||
|
items = i;
|
||||||
|
puzzles = p;
|
||||||
|
}
|
||||||
|
|
||||||
public Item getItem(String s)
|
public Item getItem(String s)
|
||||||
{
|
{
|
||||||
for(Item i: items)
|
for(Item i: items)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user