-Allow me to introduce the two of you to regular expressions:
- Spoiler:
if (command1.matches("n(orth)?|s(outh)?|e(ast)?|w(est)?"))
currentPlayer.exit(command1.substring(0,1));
Don't make a text based game without it.
-to clarify, those two lines of code replace Snail's entire fourth spoiler block.
-You could also just use .matches("w(est)?") directly instead of having Snail's subroutine
-And don't tell people to open cmd to use your game. :\ Instead, supply a .bat file. Simply make a text file, put
- Spoiler:
java -jar TextGame.jar
pause
and name the file something like "runtextgame.bat".
-Spelling mistake: "basicaly"
-Items you take should disappear from the "look" descriptions.
-I can't write "take armour" :[
-Trolls you kill should disappear from the "look" descriptions.
-Your approach to creating an area isn't very dynamic. You'll want the constructor for "Area" to take a description as well as a name, and then probably read area name/descriptions from there. If you want the game to be more dynamic so you can drop several items in an area and such, you'll probably want each room to contain a List<Item> of items rather than just a single one, too. In addition, descriptions of items should be in the items themselves so that the room doesn't have to describe the item every time you pass by there, even after you've picked something up.
That way, you could write showInfo() like this:
- Spoiler:
public void showInfo(){
System.out.println(description);
for (Item i : itemList)
System.out.println(i.getDescription());
-This should go without saying, but "boolean monsterDead" has no business being in the Area class. It should be in the Monster class.
-You can rewrite public String doorDirection() as simply:
return door;
If the room doesn't have a door won't it be null anyways? Subsequently, boolean hasDoor becomes obsolete.
-Rewrote public Area exit(String direction) for you:
- Spoiler:
Area exit = direction.matches("n(orth)?") ?
exits[0] : direction.matches("s(outh)?") ?
exits[1] : direction.matches("e(east)?") ?
exits[2] : direction.matches("w(est)?") ?
exits[3] : null;
if (exit != null)
System.out.printf("You are at the %s", exit.getAreaName());
else
System.out.println("Looks like you can't go that way. Try again...");
return exit;