Compare commits
No commits in common. "d4db36c4183bd580d6c2577e35e368d6c31ac29f" and "1e14f0e2ad888118907c5434da811933bc78bca5" have entirely different histories.
d4db36c418
...
1e14f0e2ad
BIN
NetBeansExport/WebAdventure.zip
Normal file
BIN
NetBeansExport/WebAdventure.zip
Normal file
Binary file not shown.
@ -1,98 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.PrintWriter;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
import javax.servlet.ServletException;
|
|
||||||
import javax.servlet.annotation.WebServlet;
|
|
||||||
import javax.servlet.http.HttpServlet;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Edi
|
|
||||||
*/
|
|
||||||
@WebServlet(urlPatterns = {"/Editor"})
|
|
||||||
public class Editor extends HttpServlet {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
|
|
||||||
* methods.
|
|
||||||
*
|
|
||||||
* @param request servlet request
|
|
||||||
* @param response servlet response
|
|
||||||
* @throws ServletException if a servlet-specific error occurs
|
|
||||||
* @throws IOException if an I/O error occurs
|
|
||||||
*/
|
|
||||||
|
|
||||||
public void init() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
|
|
||||||
throws ServletException, IOException, Exception {
|
|
||||||
|
|
||||||
try (PrintWriter out = response.getWriter()) {
|
|
||||||
/* TODO output your page here. You may use following sample code. */
|
|
||||||
out.println("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
|
|
||||||
/**
|
|
||||||
* Handles the HTTP <code>GET</code> method.
|
|
||||||
*
|
|
||||||
* @param request servlet request
|
|
||||||
* @param response servlet response
|
|
||||||
* @throws ServletException if a servlet-specific error occurs
|
|
||||||
* @throws IOException if an I/O error occurs
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
protected void doGet(HttpServletRequest request, HttpServletResponse response)
|
|
||||||
throws ServletException, IOException {
|
|
||||||
response.setIntHeader("Refresh", 2);
|
|
||||||
try {
|
|
||||||
processRequest(request, response);
|
|
||||||
|
|
||||||
} catch (Exception ex) {
|
|
||||||
Logger.getLogger(Logic.class.getName()).log(Level.SEVERE, null, ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles the HTTP <code>POST</code> method.
|
|
||||||
*
|
|
||||||
* @param request servlet request
|
|
||||||
* @param response servlet response
|
|
||||||
* @throws ServletException if a servlet-specific error occurs
|
|
||||||
* @throws IOException if an I/O error occurs
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
protected void doPost(HttpServletRequest request, HttpServletResponse response)
|
|
||||||
throws ServletException, IOException {
|
|
||||||
response.setIntHeader("Refresh", 2);
|
|
||||||
try {
|
|
||||||
processRequest(request, response);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
Logger.getLogger(Logic.class.getName()).log(Level.SEVERE, null, ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a short description of the servlet.
|
|
||||||
*
|
|
||||||
* @return a String containing servlet description
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public String getServletInfo() {
|
|
||||||
return "Short description";
|
|
||||||
}// </editor-fold>
|
|
||||||
|
|
||||||
}
|
|
@ -28,7 +28,7 @@ public class Game {
|
|||||||
Puzzle schloss;
|
Puzzle schloss;
|
||||||
Puzzle door;
|
Puzzle door;
|
||||||
Item schluessel;
|
Item schluessel;
|
||||||
Item stahlschluessel;
|
Item tonne;
|
||||||
|
|
||||||
public Game() {
|
public Game() {
|
||||||
try {
|
try {
|
||||||
@ -80,11 +80,11 @@ public class Game {
|
|||||||
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");
|
||||||
|
|
||||||
//Item Object
|
//Item Object
|
||||||
stahlschluessel = new Item("Stahlschluessel");
|
tonne = new Item("Muelltonne");
|
||||||
stahlschluessel.setHiddenFlag(false);
|
tonne.setHiddenFlag(false);
|
||||||
stahlschluessel.setPortableFlag(false);
|
tonne.setPortableFlag(false);
|
||||||
stahlschluessel.setDescription("Ein Stahlschlüssel");
|
tonne.setDescription("Eine schwarze M�lltonne. Sie stinkt f�rchterlich");
|
||||||
intro.items.add(stahlschluessel);
|
keller.items.add(tonne);
|
||||||
|
|
||||||
rooms.add(intro);
|
rooms.add(intro);
|
||||||
rooms.add(keller);
|
rooms.add(keller);
|
||||||
@ -102,178 +102,96 @@ public class Game {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void play() throws Exception {
|
public void play() {
|
||||||
log("play()");
|
|
||||||
log("Input: " + input);
|
|
||||||
|
|
||||||
input = input.replace("ä", "ae");
|
|
||||||
input = input.replace("ü", "ue");
|
|
||||||
input = input.replace("ö", "oe");
|
|
||||||
input = input.replace("ß", "ss");
|
|
||||||
|
|
||||||
if (input.contains(" ")) {
|
if (input.contains(" ")) {
|
||||||
inputArray = input.split(" ");
|
inputArray = input.split(" ");
|
||||||
|
|
||||||
for (String s : inputArray) {
|
for (String s : inputArray) {
|
||||||
if (currentRoom.getItem(s) != null) {
|
if (currentRoom.getItem(s) != null) {
|
||||||
itemName = currentRoom.getItem(s).getName();
|
itemName = s;
|
||||||
log("itemName: " + itemName);
|
|
||||||
} else if (currentRoom.getPuzzle(s) != null) {
|
} else if (currentRoom.getPuzzle(s) != null) {
|
||||||
puzzleName = currentRoom.getPuzzle(s).getName();
|
puzzleName = s;
|
||||||
log("PuzzleName: " + puzzleName);
|
|
||||||
} else {
|
} else {
|
||||||
intentName = s;
|
intentName = s;
|
||||||
log("intentName: " + intentName);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
intentName = input;
|
intentName = input;
|
||||||
log("intentName: " + intentName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (intentName.toLowerCase()) {
|
switch (intentName.toLowerCase()) {
|
||||||
//intent
|
//intent
|
||||||
case "lookaroundintent":
|
case "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");
|
|
||||||
if (itemName != null) {
|
if (itemName != null) {
|
||||||
inspect(itemName);
|
inspect(itemName);
|
||||||
} else if (puzzleName != null) {
|
} else if (puzzleName != null) {
|
||||||
inspect(puzzleName);
|
inspect(puzzleName);
|
||||||
|
} else {
|
||||||
|
say("Das kann nicht untersucht werden");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
//intent
|
//intent
|
||||||
|
|
||||||
case "examineintent":
|
case "examineintent":
|
||||||
log("Switch: ExamineIntent");
|
|
||||||
if (itemName == null && puzzleName == null) {
|
if (itemName == null && puzzleName == null) {
|
||||||
examine();
|
examine();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
//intent
|
//intent
|
||||||
case "takeintent":
|
case "takeintent":
|
||||||
log("Switch: TakeIntent");
|
|
||||||
if (itemName != null) {
|
if (itemName != null) {
|
||||||
take(currentRoom.getItem(itemName));
|
take(currentRoom.getItem(itemName));
|
||||||
|
} else {
|
||||||
|
say("das kann nicht mitgenommen werden");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
//intent
|
//intent
|
||||||
case "openintent":
|
case "openintent":
|
||||||
log("Switch: OpenIntent");
|
|
||||||
if (puzzleName != null) {
|
if (puzzleName != null) {
|
||||||
open(currentRoom.getPuzzle(puzzleName));
|
open(currentRoom.getPuzzle(puzzleName));
|
||||||
}
|
} else {
|
||||||
break;
|
say("das kann nicht geöffnet werden");
|
||||||
//intent
|
|
||||||
case "resetintent":
|
|
||||||
log("Switch: ResetIntent");
|
|
||||||
if (itemName == null && puzzleName == null) {
|
|
||||||
resetGame();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
//intent
|
|
||||||
case "skipintent":
|
|
||||||
log("Switch: SkipIntent");
|
|
||||||
if (itemName == null && puzzleName == null) {
|
|
||||||
resetGame();
|
|
||||||
for (int i = 0; i < currentRoom.puzzles.size(); i++) {
|
|
||||||
if (currentRoom.puzzles.get(i).getNextRoom() != null) {
|
|
||||||
setRoom(currentRoom.puzzles.get(i).getNextRoom());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
itemName = null;
|
itemName = null;
|
||||||
intentName = null;
|
intentName = null;
|
||||||
puzzleName = null;
|
puzzleName = null;
|
||||||
|
|
||||||
log("stoppFlag: " + stoppFlag);
|
|
||||||
|
|
||||||
if (stoppFlag == true) {
|
if (stoppFlag == true) {
|
||||||
endGame();
|
endGame();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void log(String s) throws Exception
|
public void lookaround() {
|
||||||
{
|
|
||||||
String url = "https://medinf.efi.th-nuernberg.de/tomcat/WebAdventure/Log";
|
|
||||||
URL obj = new URL(url);
|
|
||||||
HttpURLConnection httpConn = (HttpURLConnection) obj.openConnection();
|
|
||||||
|
|
||||||
//add reuqest header
|
|
||||||
httpConn.setRequestMethod("POST");
|
|
||||||
httpConn.setRequestProperty("User-Agent", "Mozilla/5.0");
|
|
||||||
httpConn.setRequestProperty("Accept-Language", "en-US,en;q=0.5");
|
|
||||||
|
|
||||||
// Send post request
|
|
||||||
httpConn.setDoOutput(true);
|
|
||||||
DataOutputStream wr = new DataOutputStream(httpConn.getOutputStream());
|
|
||||||
String urlParameters = "log=" + s;
|
|
||||||
wr.writeBytes(urlParameters);
|
|
||||||
wr.flush();
|
|
||||||
wr.close();
|
|
||||||
|
|
||||||
BufferedReader in = new BufferedReader(
|
|
||||||
new InputStreamReader(httpConn.getInputStream()));
|
|
||||||
String inputLine;
|
|
||||||
StringBuffer response = new StringBuffer();
|
|
||||||
|
|
||||||
while ((inputLine = in.readLine()) != null) {
|
|
||||||
response.append(inputLine);
|
|
||||||
}
|
|
||||||
in.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void lookaround() throws Exception {
|
|
||||||
log("lookaround() ");
|
|
||||||
say(currentRoom.getDescription());
|
say(currentRoom.getDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startGame() throws Exception {
|
public void 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 inspect(String s) {
|
||||||
log("resetGame() ");
|
Item currentItem = currentRoom.getItem(s);
|
||||||
startGame();
|
Puzzle currentPuzzle = currentRoom.getPuzzle(s);
|
||||||
}
|
|
||||||
|
|
||||||
public void inspect(String s) throws Exception {
|
if (currentPuzzle != null) {
|
||||||
log("inspect(" + s + ") ");
|
say(currentPuzzle.getDescription());
|
||||||
Item currentItem=null;
|
|
||||||
if(currentRoom.getItem(s) != null)
|
} else if (currentItem != null) {
|
||||||
{
|
|
||||||
currentItem= currentRoom.getItem(s);
|
|
||||||
log("currentItem: " + currentItem.getName());
|
|
||||||
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() {
|
||||||
log("endGame() ");
|
|
||||||
say("Glückwunsch das Spiel ist beendet!");
|
say("Glückwunsch das Spiel ist beendet!");
|
||||||
setVariables();
|
setVariables();
|
||||||
}
|
}
|
||||||
@ -308,8 +226,7 @@ public class Game {
|
|||||||
in.close();
|
in.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void say(String s) throws Exception {
|
public void say(String s) {
|
||||||
log("say(" + s + ") ");
|
|
||||||
try {
|
try {
|
||||||
sendPost(s);
|
sendPost(s);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
@ -317,19 +234,16 @@ public class Game {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInput(String s) throws Exception {
|
public void setInput(String s) {
|
||||||
log("setInput(" + s + ") ");
|
|
||||||
input = s;
|
input = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRoom(Room nextRoom) throws Exception {
|
public void setRoom(Room nextRoom) {
|
||||||
log("setRoom(" + nextRoom.getName() + ") " );
|
|
||||||
currentRoom = nextRoom;
|
currentRoom = nextRoom;
|
||||||
say(currentRoom.getDescription());
|
say(currentRoom.getDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void examine() throws Exception {
|
public void examine() {
|
||||||
log("examine() : " + getInventory());
|
|
||||||
|
|
||||||
if (getInventory().isEmpty()) {
|
if (getInventory().isEmpty()) {
|
||||||
say("Deine Taschen sind leer");
|
say("Deine Taschen sind leer");
|
||||||
@ -338,17 +252,12 @@ public class Game {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inventory.forEach((bag) -> {
|
inventory.forEach((bag) -> {
|
||||||
try {
|
|
||||||
say(bag.getName());
|
say(bag.getName());
|
||||||
} catch (Exception ex) {
|
|
||||||
Logger.getLogger(Game.class.getName()).log(Level.SEVERE, null, ex);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void open(Puzzle currentPuzzle) throws Exception {
|
public void open(Puzzle currentPuzzle) {
|
||||||
log("open(" + currentPuzzle.getName() + ") ");
|
|
||||||
if (currentPuzzle.isSolved()) // bereits gelöst
|
if (currentPuzzle.isSolved()) // bereits gelöst
|
||||||
{
|
{
|
||||||
say("ist bereits geöffnet");
|
say("ist bereits geöffnet");
|
||||||
@ -387,8 +296,7 @@ public class Game {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void take(Item currentItem) throws Exception {
|
public void take(Item currentItem) {
|
||||||
log("take(" + currentItem.getName() + ") ");
|
|
||||||
if ((!inventory.contains(currentItem)) && (currentItem.isPortableFlag() == true)) {
|
if ((!inventory.contains(currentItem)) && (currentItem.isPortableFlag() == true)) {
|
||||||
inventory.add(currentItem);
|
inventory.add(currentItem);
|
||||||
currentRoom.items.remove(currentItem);
|
currentRoom.items.remove(currentItem);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
public class Item
|
public class Item
|
||||||
{
|
{
|
||||||
|
private int id;
|
||||||
private String name;
|
private String name;
|
||||||
private boolean portableFlag;
|
private boolean portableFlag;
|
||||||
private boolean hiddenFlag;
|
private boolean hiddenFlag;
|
||||||
@ -20,6 +21,14 @@ public class Item
|
|||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
@ -1,102 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.PrintWriter;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
import javax.servlet.ServletException;
|
|
||||||
import javax.servlet.annotation.WebServlet;
|
|
||||||
import javax.servlet.http.HttpServlet;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Edi
|
|
||||||
*/
|
|
||||||
@WebServlet(urlPatterns = {"/Log"})
|
|
||||||
public class Log extends HttpServlet {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
|
|
||||||
* methods.
|
|
||||||
*
|
|
||||||
* @param request servlet request
|
|
||||||
* @param response servlet response
|
|
||||||
* @throws ServletException if a servlet-specific error occurs
|
|
||||||
* @throws IOException if an I/O error occurs
|
|
||||||
*/
|
|
||||||
String context = "";
|
|
||||||
public void init() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
|
|
||||||
throws ServletException, IOException, Exception {
|
|
||||||
|
|
||||||
try (PrintWriter out = response.getWriter()) {
|
|
||||||
/* TODO output your page here. You may use following sample code. */
|
|
||||||
if(request.getParameter("log") != null) {
|
|
||||||
context = context + "\n" + request.getParameter("log");
|
|
||||||
}
|
|
||||||
|
|
||||||
out.println(context);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
|
|
||||||
/**
|
|
||||||
* Handles the HTTP <code>GET</code> method.
|
|
||||||
*
|
|
||||||
* @param request servlet request
|
|
||||||
* @param response servlet response
|
|
||||||
* @throws ServletException if a servlet-specific error occurs
|
|
||||||
* @throws IOException if an I/O error occurs
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
protected void doGet(HttpServletRequest request, HttpServletResponse response)
|
|
||||||
throws ServletException, IOException {
|
|
||||||
response.setIntHeader("Refresh", 2);
|
|
||||||
try {
|
|
||||||
processRequest(request, response);
|
|
||||||
|
|
||||||
} catch (Exception ex) {
|
|
||||||
Logger.getLogger(Logic.class.getName()).log(Level.SEVERE, null, ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles the HTTP <code>POST</code> method.
|
|
||||||
*
|
|
||||||
* @param request servlet request
|
|
||||||
* @param response servlet response
|
|
||||||
* @throws ServletException if a servlet-specific error occurs
|
|
||||||
* @throws IOException if an I/O error occurs
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
protected void doPost(HttpServletRequest request, HttpServletResponse response)
|
|
||||||
throws ServletException, IOException {
|
|
||||||
response.setIntHeader("Refresh", 2);
|
|
||||||
try {
|
|
||||||
processRequest(request, response);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
Logger.getLogger(Logic.class.getName()).log(Level.SEVERE, null, ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a short description of the servlet.
|
|
||||||
*
|
|
||||||
* @return a String containing servlet description
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public String getServletInfo() {
|
|
||||||
return "Short description";
|
|
||||||
}// </editor-fold>
|
|
||||||
|
|
||||||
}
|
|
@ -2,6 +2,7 @@ import java.util.ArrayList;
|
|||||||
|
|
||||||
public class Puzzle
|
public class Puzzle
|
||||||
{
|
{
|
||||||
|
private int id;
|
||||||
private String name;
|
private String name;
|
||||||
private ArrayList<Item> items = new ArrayList<Item>();
|
private ArrayList<Item> items = new ArrayList<Item>();
|
||||||
private String description="";
|
private String description="";
|
||||||
@ -42,11 +43,19 @@ public class Puzzle
|
|||||||
return dependencyText;
|
return dependencyText;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
public Room getNextRoom()
|
public Room getNextRoom()
|
||||||
{
|
{
|
||||||
return nextRoom;
|
return nextRoom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setId(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
public void addItem(Item i)
|
public void addItem(Item i)
|
||||||
{
|
{
|
||||||
items.add(i);
|
items.add(i);
|
||||||
|
@ -3,6 +3,7 @@ import java.util.ArrayList;
|
|||||||
|
|
||||||
public class Room
|
public class Room
|
||||||
{
|
{
|
||||||
|
private int id;
|
||||||
private String name;
|
private String name;
|
||||||
private String description;
|
private String description;
|
||||||
private boolean gameoverFlag;
|
private boolean gameoverFlag;
|
||||||
@ -17,7 +18,7 @@ public class Room
|
|||||||
{
|
{
|
||||||
for(Item i: items)
|
for(Item i: items)
|
||||||
{
|
{
|
||||||
if(i.getName().equalsIgnoreCase(s))
|
if(i.getName().equals(s))
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -27,12 +28,18 @@ public class Room
|
|||||||
{
|
{
|
||||||
for(Puzzle p: puzzles)
|
for(Puzzle p: puzzles)
|
||||||
{
|
{
|
||||||
if(p.getName().equalsIgnoreCase(s))
|
if(p.getName().equals(s))
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
public void setId(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user