Skip to content
Snippets Groups Projects
Commit efdeb779 authored by Chris Kearney's avatar Chris Kearney
Browse files

enter functionality is working

parent 8f251432
No related branches found
No related tags found
No related merge requests found
...@@ -42,6 +42,9 @@ public class Main { ...@@ -42,6 +42,9 @@ public class Main {
public static CreeperCommandRegistry creeperCommandRegistry; public static CreeperCommandRegistry creeperCommandRegistry;
private static final Logger log = Logger.getLogger(Main.class); private static final Logger log = Logger.getLogger(Main.class);
private static final int PORT = 8081;
public static final String MUD_NAME = "creeperBETA";
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
checkAndCreateWorld(); checkAndCreateWorld();
......
...@@ -224,20 +224,11 @@ public class GameManager { ...@@ -224,20 +224,11 @@ public class GameManager {
} }
numExits++; numExits++;
} }
if (room.getDownId().isPresent()) {
if (player.getReturnDirection().get().equalsIgnoreCase("down")) {
sb.append(BOLD_OFF);
sb.append("Down ");
sb.append(BOLD_ON);
} else {
sb.append("Down ");
}
numExits++;
}
if (room.getEnterExits() != null && room.getEnterExits().size() > 0) { if (room.getEnterExits() != null && room.getEnterExits().size() > 0) {
List<RemoteExit> enters = room.getEnterExits(); List<RemoteExit> enters = room.getEnterExits();
for (RemoteExit enter: enters) { for (RemoteExit enter: enters) {
sb.append("e-" + enter.getExitDetail() + " "); sb.append("e-" + enter.getExitDetail() + " ");
numExits++;
} }
} }
String fin = null; String fin = null;
......
package com.comandante.creeper.player; package com.comandante.creeper.player;
import com.comandante.creeper.Main;
import com.comandante.creeper.fight.FightManager; import com.comandante.creeper.fight.FightManager;
import com.comandante.creeper.managers.SessionManager; import com.comandante.creeper.managers.SessionManager;
import com.comandante.creeper.server.Color; import com.comandante.creeper.server.Color;
...@@ -166,7 +167,9 @@ public class PlayerManager { ...@@ -166,7 +167,9 @@ public class PlayerManager {
StringBuilder sb = new StringBuilder() StringBuilder sb = new StringBuilder()
.append("[") .append("[")
.append(player.getPlayerName()) .append(player.getPlayerName())
.append("@creeper ") .append("@")
.append(Main.MUD_NAME)
.append(" ")
.append(currentHealth).append("/").append(maxHealth); .append(currentHealth).append("/").append(maxHealth);
if (isFight) { if (isFight) {
sb.append(Color.RED + " ! " + Color.RESET); sb.append(Color.RED + " ! " + Color.RESET);
......
...@@ -65,8 +65,9 @@ public class BuildCommand extends Command { ...@@ -65,8 +65,9 @@ public class BuildCommand extends Command {
Integer newRoomId = findUnusedRoomId(); Integer newRoomId = findUnusedRoomId();
Integer newFloorId = findUnusedFloorId(); Integer newFloorId = findUnusedFloorId();
RemoteExit remoteExit = new RemoteExit(RemoteExit.Direction.UP, newRoomId, ""); RemoteExit remoteExit = new RemoteExit(RemoteExit.Direction.UP, newRoomId, "");
RemoteExit returnRemoteExit = new RemoteExit(RemoteExit.Direction.DOWN, currentRoom.getRoomId(), "");
mapMatrix.addRemote(currentRoom.getRoomId(), remoteExit); mapMatrix.addRemote(currentRoom.getRoomId(), remoteExit);
FloorModel newFloorModel = newFloorModel(newFloorId, newRoomId, currentRoom.getRoomId(), remoteExit); FloorModel newFloorModel = newFloorModel(newFloorId, newRoomId, currentRoom.getRoomId(), returnRemoteExit);
BasicRoom basicRoom = newBasic() BasicRoom basicRoom = newBasic()
.setRoomId(newRoomId) .setRoomId(newRoomId)
.setFloorId(newFloorId) .setFloorId(newFloorId)
...@@ -87,8 +88,9 @@ public class BuildCommand extends Command { ...@@ -87,8 +88,9 @@ public class BuildCommand extends Command {
Integer newRoomId = findUnusedRoomId(); Integer newRoomId = findUnusedRoomId();
Integer newFloorId = findUnusedFloorId(); Integer newFloorId = findUnusedFloorId();
RemoteExit remoteExit = new RemoteExit(RemoteExit.Direction.DOWN, newRoomId, ""); RemoteExit remoteExit = new RemoteExit(RemoteExit.Direction.DOWN, newRoomId, "");
RemoteExit returnRemoteExit = new RemoteExit(RemoteExit.Direction.UP, currentRoom.getRoomId(), "");
mapMatrix.addRemote(currentRoom.getRoomId(), remoteExit); mapMatrix.addRemote(currentRoom.getRoomId(), remoteExit);
FloorModel newFloorModel = newFloorModel(newFloorId, newRoomId, currentRoom.getRoomId(), remoteExit); FloorModel newFloorModel = newFloorModel(newFloorId, newRoomId, currentRoom.getRoomId(), returnRemoteExit);
BasicRoom basicRoom = newBasic() BasicRoom basicRoom = newBasic()
.setRoomId(newRoomId) .setRoomId(newRoomId)
.setFloorId(newFloorId) .setFloorId(newFloorId)
...@@ -109,12 +111,13 @@ public class BuildCommand extends Command { ...@@ -109,12 +111,13 @@ public class BuildCommand extends Command {
Integer newRoomId = findUnusedRoomId(); Integer newRoomId = findUnusedRoomId();
Integer newFloorId = findUnusedFloorId(); Integer newFloorId = findUnusedFloorId();
RemoteExit remoteExit = new RemoteExit(RemoteExit.Direction.ENTER, newRoomId, enterName); RemoteExit remoteExit = new RemoteExit(RemoteExit.Direction.ENTER, newRoomId, enterName);
RemoteExit returnRemoteExit = new RemoteExit(RemoteExit.Direction.ENTER, currentRoom.getRoomId(), "Leave");
mapMatrix.addRemote(currentRoom.getRoomId(),remoteExit ); mapMatrix.addRemote(currentRoom.getRoomId(),remoteExit );
FloorModel newFloorModel = newFloorModel(newFloorId, newRoomId, currentRoom.getRoomId(), remoteExit); FloorModel newFloorModel = newFloorModel(newFloorId, newRoomId, currentRoom.getRoomId(), returnRemoteExit);
BasicRoom basicRoom = newBasic() BasicRoom basicRoom = newBasic()
.setRoomId(newRoomId) .setRoomId(newRoomId)
.setFloorId(newFloorId) .setFloorId(newFloorId)
.addEnterExit(new RemoteExit(RemoteExit.Direction.ENTER, currentRoom.getRoomId(), "Leave")) .addEnterExit(returnRemoteExit)
.createBasicRoom(); .createBasicRoom();
currentRoom.addEnterExit(remoteExit); currentRoom.addEnterExit(remoteExit);
entityManager.addEntity(basicRoom); entityManager.addEntity(basicRoom);
...@@ -138,11 +141,11 @@ public class BuildCommand extends Command { ...@@ -138,11 +141,11 @@ public class BuildCommand extends Command {
RemoteExit.Direction returnDirection = remoteExit.getDirection(); RemoteExit.Direction returnDirection = remoteExit.getDirection();
newFloorModel.setId(floorId); newFloorModel.setId(floorId);
if (returnDirection.equals(RemoteExit.Direction.DOWN)) { if (returnDirection.equals(RemoteExit.Direction.DOWN)) {
newFloorModel.setRawMatrixCsv(Integer.toString(newRoomId) + "d" + currentRoomId); newFloorModel.setRawMatrixCsv(Integer.toString(newRoomId) + "d|" + currentRoomId);
} else if (returnDirection.equals(RemoteExit.Direction.UP)) { } else if (returnDirection.equals(RemoteExit.Direction.UP)) {
newFloorModel.setRawMatrixCsv(Integer.toString(newRoomId) + "u" + currentRoomId); newFloorModel.setRawMatrixCsv(Integer.toString(newRoomId) + "u|" + currentRoomId);
} else if (returnDirection.equals(RemoteExit.Direction.ENTER)) { } else if (returnDirection.equals(RemoteExit.Direction.ENTER)) {
newFloorModel.setRawMatrixCsv(Integer.toString(newRoomId) + "e" + currentRoomId + "ee" + remoteExit.getExitDetail()); newFloorModel.setRawMatrixCsv(Integer.toString(newRoomId) + "e|" + currentRoomId + "ee" + remoteExit.getExitDetail());
} }
newFloorModel.setName(UUID.randomUUID().toString()); newFloorModel.setName(UUID.randomUUID().toString());
return newFloorModel; return newFloorModel;
......
...@@ -208,7 +208,7 @@ public class MapMatrix { ...@@ -208,7 +208,7 @@ public class MapMatrix {
} }
private static Integer getUp(String csvInputCell) { private static Integer getUp(String csvInputCell) {
String[] us = csvInputCell.split("u|"); String[] us = csvInputCell.split("u\\|");
if (us[1].matches(".*[a-zA-Z]+.*")) { if (us[1].matches(".*[a-zA-Z]+.*")) {
return Integer.valueOf(us[1].split("[a-zA-Z]")[0]); return Integer.valueOf(us[1].split("[a-zA-Z]")[0]);
} }
...@@ -216,7 +216,7 @@ public class MapMatrix { ...@@ -216,7 +216,7 @@ public class MapMatrix {
} }
private static Integer getDown(String csvInputCell) { private static Integer getDown(String csvInputCell) {
String[] us = csvInputCell.split("d|"); String[] us = csvInputCell.split("d\\|");
if (us[1].matches(".*[a-zA-Z]+.*")) { if (us[1].matches(".*[a-zA-Z]+.*")) {
return Integer.valueOf(us[1].split("[a-zA-Z]")[0]); return Integer.valueOf(us[1].split("[a-zA-Z]")[0]);
} }
...@@ -224,7 +224,7 @@ public class MapMatrix { ...@@ -224,7 +224,7 @@ public class MapMatrix {
} }
private static Integer getEnter(String csvInputCell) { private static Integer getEnter(String csvInputCell) {
String[] us = csvInputCell.split("e|"); String[] us = csvInputCell.split("e\\|");
if (us[1].matches(".*[a-zA-Z]+.*")) { if (us[1].matches(".*[a-zA-Z]+.*")) {
return Integer.valueOf(us[1].split("[a-zA-Z]")[0]); return Integer.valueOf(us[1].split("[a-zA-Z]")[0]);
} }
......
...@@ -3,36 +3,6 @@ ...@@ -3,36 +3,6 @@
{ {
"name": "main", "name": "main",
"id": 0, "id": 0,
"rawMatrixCsv": ",1u|2,\n", "rawMatrixCsv": "0,1"
"roomModels": [ }]
{ }
"roomId": 1,
"floorId": 0,
"roomDescription": "This is a blank Description.\nWords should go here, ideally.",
"roomTitle": "This is a blank title.",
"roomTags": [],
"areaNames": [
"newbie_zone"
]
}
]
},
{
"name": "785c3189-93d9-45e1-97b8-38dda8b1745a",
"id": 1,
"rawMatrixCsv": "2,\n",
"roomModels": [
{
"roomId": 2,
"floorId": 1,
"roomDescription": "Newly created room. Set a new description with the desc command.",
"roomTitle": "Default Title, change with title command",
"roomTags": [],
"areaNames": [
"default"
]
}
]
}
]
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment