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

return path bold

parent c2a22965
No related branches found
No related tags found
No related merge requests found
...@@ -55,7 +55,7 @@ public class MovementCommand extends Command { ...@@ -55,7 +55,7 @@ public class MovementCommand extends Command {
return; return;
} }
Room destinationRoom = gameManager.getRoomManager().getRoom(currentRoom.getNorthId().get()); Room destinationRoom = gameManager.getRoomManager().getRoom(currentRoom.getNorthId().get());
movement = new Movement(player, currentRoom.getRoomId(), destinationRoom.getRoomId(), this, "exited to the north."); movement = new Movement(player, currentRoom.getRoomId(), destinationRoom.getRoomId(), this, "exited to the north.", "south");
} }
if (southTriggers.contains(command.toLowerCase())) { if (southTriggers.contains(command.toLowerCase())) {
if (!currentRoom.getSouthId().isPresent()) { if (!currentRoom.getSouthId().isPresent()) {
...@@ -63,7 +63,7 @@ public class MovementCommand extends Command { ...@@ -63,7 +63,7 @@ public class MovementCommand extends Command {
return; return;
} }
Room destinationRoom = gameManager.getRoomManager().getRoom(currentRoom.getSouthId().get()); Room destinationRoom = gameManager.getRoomManager().getRoom(currentRoom.getSouthId().get());
movement = new Movement(player, currentRoom.getRoomId(), destinationRoom.getRoomId(), this, "exited to the south."); movement = new Movement(player, currentRoom.getRoomId(), destinationRoom.getRoomId(), this, "exited to the south.", "north");
} }
if (eastTriggers.contains(command.toLowerCase())) { if (eastTriggers.contains(command.toLowerCase())) {
if (!currentRoom.getEastId().isPresent()) { if (!currentRoom.getEastId().isPresent()) {
...@@ -71,7 +71,7 @@ public class MovementCommand extends Command { ...@@ -71,7 +71,7 @@ public class MovementCommand extends Command {
return; return;
} }
Room destinationRoom = gameManager.getRoomManager().getRoom(currentRoom.getEastId().get()); Room destinationRoom = gameManager.getRoomManager().getRoom(currentRoom.getEastId().get());
movement = new Movement(player, currentRoom.getRoomId(), destinationRoom.getRoomId(), this, "exited to the east."); movement = new Movement(player, currentRoom.getRoomId(), destinationRoom.getRoomId(), this, "exited to the east.", "west");
} }
if (westTriggers.contains(command.toLowerCase())) { if (westTriggers.contains(command.toLowerCase())) {
if (!currentRoom.getWestId().isPresent()) { if (!currentRoom.getWestId().isPresent()) {
...@@ -79,7 +79,7 @@ public class MovementCommand extends Command { ...@@ -79,7 +79,7 @@ public class MovementCommand extends Command {
return; return;
} }
Room destinationRoom = gameManager.getRoomManager().getRoom(currentRoom.getWestId().get()); Room destinationRoom = gameManager.getRoomManager().getRoom(currentRoom.getWestId().get());
movement = new Movement(player, currentRoom.getRoomId(), destinationRoom.getRoomId(), this, "exited to the west."); movement = new Movement(player, currentRoom.getRoomId(), destinationRoom.getRoomId(), this, "exited to the west.", "east");
} }
if (upTriggers.contains(command.toLowerCase())) { if (upTriggers.contains(command.toLowerCase())) {
if (!currentRoom.getUpId().isPresent()) { if (!currentRoom.getUpId().isPresent()) {
...@@ -87,7 +87,7 @@ public class MovementCommand extends Command { ...@@ -87,7 +87,7 @@ public class MovementCommand extends Command {
return; return;
} }
Room destinationRoom = gameManager.getRoomManager().getRoom(currentRoom.getUpId().get()); Room destinationRoom = gameManager.getRoomManager().getRoom(currentRoom.getUpId().get());
movement = new Movement(player, currentRoom.getRoomId(), destinationRoom.getRoomId(), this, "exited to the west."); movement = new Movement(player, currentRoom.getRoomId(), destinationRoom.getRoomId(), this, "exited to the west.", "down");
} }
if (downTriggers.contains(command.toLowerCase())) { if (downTriggers.contains(command.toLowerCase())) {
if (!currentRoom.getDownId().isPresent()) { if (!currentRoom.getDownId().isPresent()) {
...@@ -95,10 +95,11 @@ public class MovementCommand extends Command { ...@@ -95,10 +95,11 @@ public class MovementCommand extends Command {
return; return;
} }
Room destinationRoom = gameManager.getRoomManager().getRoom(currentRoom.getDownId().get()); Room destinationRoom = gameManager.getRoomManager().getRoom(currentRoom.getDownId().get());
movement = new Movement(player, currentRoom.getRoomId(), destinationRoom.getRoomId(), this, "exited to the west."); movement = new Movement(player, currentRoom.getRoomId(), destinationRoom.getRoomId(), this, "exited to the west.", "up");
} }
gameManager.movePlayer(movement); gameManager.movePlayer(movement);
if (movement != null) { if (movement != null) {
player.setReturnDirection(Optional.of(movement.getReturnDirection()));
gameManager.currentRoomLogic(movement.getPlayer().getPlayerId()); gameManager.currentRoomLogic(movement.getPlayer().getPlayerId());
} }
} }
......
...@@ -214,27 +214,66 @@ public class GameManager { ...@@ -214,27 +214,66 @@ public class GameManager {
} }
} }
private String getExits(Room room) { private String getExits(Room room, Player player) {
StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("[ Exits: "); stringBuilder.append("[ Exits: ");
stringBuilder.append(new Ansi().fg(Ansi.Color.GREEN).toString()); stringBuilder.append(new Ansi().fg(Ansi.Color.GREEN).toString());
if (!player.getReturnDirection().isPresent()) {
player.setReturnDirection(Optional.of("-"));
}
if (room.getNorthId().isPresent()) { if (room.getNorthId().isPresent()) {
stringBuilder.append("North "); if (player.getReturnDirection().get().equalsIgnoreCase("north")) {
stringBuilder.append(new Ansi().fgBright(Ansi.Color.GREEN).toString());
stringBuilder.append("North ");
stringBuilder.append(new Ansi().fg(Ansi.Color.GREEN).toString());
} else {
stringBuilder.append("North ");
}
} }
if (room.getSouthId().isPresent()) { if (room.getSouthId().isPresent()) {
stringBuilder.append("South "); if (player.getReturnDirection().get().equalsIgnoreCase("south")) {
stringBuilder.append(new Ansi().fgBright(Ansi.Color.GREEN).toString());
stringBuilder.append("South ");
stringBuilder.append(new Ansi().fg(Ansi.Color.GREEN).toString());
} else {
stringBuilder.append("South ");
}
} }
if (room.getEastId().isPresent()) { if (room.getEastId().isPresent()) {
stringBuilder.append("East "); if (player.getReturnDirection().get().equalsIgnoreCase("east")) {
stringBuilder.append(new Ansi().fgBright(Ansi.Color.GREEN).toString());
stringBuilder.append("East ");
stringBuilder.append(new Ansi().fg(Ansi.Color.GREEN).toString());
} else {
stringBuilder.append("East ");
}
} }
if (room.getWestId().isPresent()) { if (room.getWestId().isPresent()) {
stringBuilder.append("West "); if (player.getReturnDirection().get().equalsIgnoreCase("west")) {
stringBuilder.append(new Ansi().fgBright(Ansi.Color.GREEN).toString());
stringBuilder.append("West ");
stringBuilder.append(new Ansi().fg(Ansi.Color.GREEN).toString());
} else {
stringBuilder.append("West ");
}
} }
if (room.getUpId().isPresent()) { if (room.getUpId().isPresent()) {
stringBuilder.append("Up "); if (player.getReturnDirection().get().equalsIgnoreCase("up")) {
stringBuilder.append(new Ansi().fgBright(Ansi.Color.GREEN).toString());
stringBuilder.append("Up ");
stringBuilder.append(new Ansi().fg(Ansi.Color.GREEN).toString());
} else {
stringBuilder.append("Up ");
}
} }
if (room.getDownId().isPresent()) { if (room.getDownId().isPresent()) {
stringBuilder.append("Down "); if (player.getReturnDirection().get().equalsIgnoreCase("down")) {
stringBuilder.append(new Ansi().fgBright(Ansi.Color.GREEN).toString());
stringBuilder.append("Down ");
stringBuilder.append(new Ansi().fg(Ansi.Color.GREEN).toString());
} else {
stringBuilder.append("Down ");
}
} }
stringBuilder.append(new Ansi().reset().toString()).append("]\r\n"); stringBuilder.append(new Ansi().reset().toString()).append("]\r\n");
return stringBuilder.toString(); return stringBuilder.toString();
...@@ -249,7 +288,7 @@ public class GameManager { ...@@ -249,7 +288,7 @@ public class GameManager {
sb.append(playerCurrentRoom.getRoomTitle()).append("\r\n\r\n"); sb.append(playerCurrentRoom.getRoomTitle()).append("\r\n\r\n");
sb.append(new Ansi().reset().toString()); sb.append(new Ansi().reset().toString());
sb.append(playerCurrentRoom.getRoomDescription()).append("\r\n"); sb.append(playerCurrentRoom.getRoomDescription()).append("\r\n");
sb.append(getExits(playerCurrentRoom)); sb.append(getExits(playerCurrentRoom, player));
for (String searchPlayerId : playerCurrentRoom.getPresentPlayerIds()) { for (String searchPlayerId : playerCurrentRoom.getPresentPlayerIds()) {
if (searchPlayerId.equals(player.getPlayerId())) { if (searchPlayerId.equals(player.getPlayerId())) {
continue; continue;
...@@ -257,7 +296,7 @@ public class GameManager { ...@@ -257,7 +296,7 @@ public class GameManager {
Player searchPlayer = playerManager.getPlayer(searchPlayerId); Player searchPlayer = playerManager.getPlayer(searchPlayerId);
sb.append(searchPlayer.getPlayerName()).append(" is here.\r\n"); sb.append(searchPlayer.getPlayerName()).append(" is here.\r\n");
} }
for (String npcId: playerCurrentRoom.getNpcIds()) { for (String npcId : playerCurrentRoom.getNpcIds()) {
Npc npcEntity = entityManager.getNpcEntity(npcId); Npc npcEntity = entityManager.getNpcEntity(npcId);
sb.append("A ").append(npcEntity.getColorName()).append(" is here.\r\n"); sb.append("A ").append(npcEntity.getColorName()).append(" is here.\r\n");
} }
......
...@@ -9,17 +9,25 @@ public class Movement { ...@@ -9,17 +9,25 @@ public class Movement {
private final Integer destinationRoomId; private final Integer destinationRoomId;
private final MovementCommand command; private final MovementCommand command;
private final String roomExitMessage; private final String roomExitMessage;
private final String returnDirection;
public Movement(Player player, public Movement(Player player,
Integer sourceRoomId, Integer sourceRoomId,
Integer destinationRoomId, Integer destinationRoomId,
MovementCommand command, MovementCommand command,
String roomExitMessage) { String roomExitMessage,
String returnDirection) {
this.player = player; this.player = player;
this.sourceRoomId = sourceRoomId; this.sourceRoomId = sourceRoomId;
this.destinationRoomId = destinationRoomId; this.destinationRoomId = destinationRoomId;
this.command = command; this.command = command;
this.roomExitMessage = roomExitMessage; this.roomExitMessage = roomExitMessage;
this.returnDirection = returnDirection;
}
public String getReturnDirection() {
return returnDirection;
} }
public Integer getSourceRoomId() { public Integer getSourceRoomId() {
......
package com.comandante.creeper.model; package com.comandante.creeper.model;
import com.google.common.base.Optional;
import org.apache.commons.codec.binary.Base64; import org.apache.commons.codec.binary.Base64;
import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.Channel;
public class Player { public class Player extends CreeperEntity{
private String playerName; private String playerName;
private Channel channel; private Channel channel;
private Optional<String> returnDirection = Optional.absent();
public Player(String playerName) { public Player(String playerName) {
this.playerName = playerName; this.playerName = playerName;
...@@ -28,4 +30,21 @@ public class Player { ...@@ -28,4 +30,21 @@ public class Player {
public void setChannel(Channel channel) { public void setChannel(Channel channel) {
this.channel = channel; this.channel = channel;
} }
public void setPlayerName(String playerName) {
this.playerName = playerName;
}
public Optional<String> getReturnDirection() {
return returnDirection;
}
public void setReturnDirection(Optional<String> returnDirection) {
this.returnDirection = returnDirection;
}
@Override
public void run() {
}
} }
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