Commit ae465474 authored by Jeffrey Phillips Freeman's avatar Jeffrey Phillips Freeman 💥
Browse files

feat: moved world persistance to graph DB.

parent 4cf2696c
...@@ -30,23 +30,15 @@ import com.syncleus.aethermud.player.PlayerManagementManager; ...@@ -30,23 +30,15 @@ import com.syncleus.aethermud.player.PlayerManagementManager;
import com.syncleus.aethermud.player.PlayerManager; import com.syncleus.aethermud.player.PlayerManager;
import com.syncleus.aethermud.server.communication.ChannelUtils; import com.syncleus.aethermud.server.communication.ChannelUtils;
import com.syncleus.aethermud.server.telnet.AetherMudServer; import com.syncleus.aethermud.server.telnet.AetherMudServer;
import com.syncleus.aethermud.storage.WorldStorage;
import com.syncleus.aethermud.storage.graphdb.*; import com.syncleus.aethermud.storage.graphdb.*;
import com.syncleus.aethermud.storage.graphdb.model.*;
import com.syncleus.aethermud.world.MapsManager; import com.syncleus.aethermud.world.MapsManager;
import com.syncleus.aethermud.world.RoomManager; import com.syncleus.aethermud.world.RoomManager;
import com.google.common.io.Files; import com.google.common.io.Files;
import com.syncleus.ferma.DelegatingFramedGraph;
import com.syncleus.ferma.WrappedFramedGraph;
import org.apache.commons.codec.binary.Base64; import org.apache.commons.codec.binary.Base64;
import org.apache.commons.configuration.*; import org.apache.commons.configuration.*;
import org.apache.http.impl.client.HttpClients; import org.apache.http.impl.client.HttpClients;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.io.IoCore;
import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
...@@ -103,8 +95,10 @@ public class Main { ...@@ -103,8 +95,10 @@ public class Main {
GameManager gameManager = new GameManager(graphStorageFactory, aetherMudConfiguration, roomManager, playerManager, entityManager, mapsManager, channelUtils, HttpClients.createDefault()); GameManager gameManager = new GameManager(graphStorageFactory, aetherMudConfiguration, roomManager, playerManager, entityManager, mapsManager, channelUtils, HttpClients.createDefault());
startUpMessage("Reading world from disk."); startUpMessage("Reading world from disk.");
WorldStorage worldExporter = new WorldStorage(roomManager, mapsManager, gameManager.getFloorManager(), entityManager, gameManager); try( GraphStorageFactory.AetherMudTx tx = gameManager.getGraphStorageFactory().beginTransaction() ) {
worldExporter.readWorldFromDisk(); tx.getStorage().loadWorld(mapsManager, entityManager, gameManager);
tx.success();
}
startUpMessage("Creating and registering Player Management MBeans."); startUpMessage("Creating and registering Player Management MBeans.");
PlayerManagementManager playerManagementManager = new PlayerManagementManager(gameManager); PlayerManagementManager playerManagementManager = new PlayerManagementManager(gameManager);
......
...@@ -24,7 +24,6 @@ import com.syncleus.aethermud.player.PlayerManager; ...@@ -24,7 +24,6 @@ import com.syncleus.aethermud.player.PlayerManager;
import com.syncleus.aethermud.player.PlayerRole; import com.syncleus.aethermud.player.PlayerRole;
import com.syncleus.aethermud.server.model.AetherMudSession; import com.syncleus.aethermud.server.model.AetherMudSession;
import com.syncleus.aethermud.server.communication.ChannelCommunicationUtils; import com.syncleus.aethermud.server.communication.ChannelCommunicationUtils;
import com.syncleus.aethermud.storage.WorldStorage;
import com.syncleus.aethermud.world.FloorManager; import com.syncleus.aethermud.world.FloorManager;
import com.syncleus.aethermud.world.MapMatrix; import com.syncleus.aethermud.world.MapMatrix;
import com.syncleus.aethermud.world.MapsManager; import com.syncleus.aethermud.world.MapsManager;
...@@ -63,7 +62,6 @@ public abstract class Command extends SimpleChannelUpstreamHandler { ...@@ -63,7 +62,6 @@ public abstract class Command extends SimpleChannelUpstreamHandler {
public Optional<MapMatrix> mapMatrix = Optional.empty(); public Optional<MapMatrix> mapMatrix = Optional.empty();
public Optional<Coords> currentRoomCoords = Optional.empty(); public Optional<Coords> currentRoomCoords = Optional.empty();
public List<String> originalMessageParts; public List<String> originalMessageParts;
public WorldStorage worldExporter;
public String rootCommand; public String rootCommand;
protected Command(GameManager gameManager, List<String> validTriggers, String description, String correctUsage) { protected Command(GameManager gameManager, List<String> validTriggers, String description, String correctUsage) {
...@@ -81,7 +79,6 @@ public abstract class Command extends SimpleChannelUpstreamHandler { ...@@ -81,7 +79,6 @@ public abstract class Command extends SimpleChannelUpstreamHandler {
this.entityManager = gameManager.getEntityManager(); this.entityManager = gameManager.getEntityManager();
this.playerManager = gameManager.getPlayerManager(); this.playerManager = gameManager.getPlayerManager();
this.channelUtils = gameManager.getChannelUtils(); this.channelUtils = gameManager.getChannelUtils();
this.worldExporter = new WorldStorage(roomManager, mapsManager, floorManager, entityManager, gameManager);
this.lootManager = gameManager.getLootManager(); this.lootManager = gameManager.getLootManager();
this.roles = roles; this.roles = roles;
} }
......
...@@ -19,7 +19,7 @@ import com.syncleus.aethermud.command.commands.Command; ...@@ -19,7 +19,7 @@ import com.syncleus.aethermud.command.commands.Command;
import com.syncleus.aethermud.core.GameManager; import com.syncleus.aethermud.core.GameManager;
import com.syncleus.aethermud.player.PlayerMovement; import com.syncleus.aethermud.player.PlayerMovement;
import com.syncleus.aethermud.player.PlayerRole; import com.syncleus.aethermud.player.PlayerRole;
import com.syncleus.aethermud.storage.WorldStorage; import com.syncleus.aethermud.storage.AetherMudStorage;
import com.syncleus.aethermud.world.MapMatrix; import com.syncleus.aethermud.world.MapMatrix;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
...@@ -225,7 +225,7 @@ public class BuildCommand extends Command { ...@@ -225,7 +225,7 @@ public class BuildCommand extends Command {
private void addNewRoomAndFloorAndMovePlayer(Room newRoom, FloorModel newFloorModel, Optional<RemoteExit> returnRemoteExit) { private void addNewRoomAndFloorAndMovePlayer(Room newRoom, FloorModel newFloorModel, Optional<RemoteExit> returnRemoteExit) {
entityManager.addEntity(newRoom); entityManager.addEntity(newRoom);
Set<RoomModel> roomModels = Sets.newHashSet(newRoom).stream().map(WorldStorage.buildRoomModelsFromRooms()).collect(Collectors.toSet()); Set<RoomModel> roomModels = Sets.newHashSet(newRoom).stream().map(AetherMudStorage.buildRoomModelsFromRooms()).collect(Collectors.toSet());
newFloorModel.setRoomModels(roomModels); newFloorModel.setRoomModels(roomModels);
floorManager.addFloor(newFloorModel.getId(), newFloorModel.getName()); floorManager.addFloor(newFloorModel.getId(), newFloorModel.getName());
MapMatrix matrixFromCsv = MapMatrix.createMatrixFromCsv(newFloorModel.getRawMatrixCsv()); MapMatrix matrixFromCsv = MapMatrix.createMatrixFromCsv(newFloorModel.getRawMatrixCsv());
......
/**
* Copyright 2017 - 2018 Syncleus, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.syncleus.aethermud.command.commands.admin;
import com.syncleus.aethermud.command.commands.Command;
import com.syncleus.aethermud.core.GameManager;
import com.syncleus.aethermud.npc.Npc;
import com.syncleus.aethermud.player.PlayerRole;
import com.syncleus.aethermud.spawner.SpawnRule;
import com.syncleus.aethermud.storage.AetherMudStorage;
import com.syncleus.aethermud.storage.graphdb.GraphStorageFactory;
import com.syncleus.aethermud.storage.graphdb.model.NpcData;
import com.google.common.collect.Sets;
import com.syncleus.aethermud.world.model.WorldModel;
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.util.EntityUtils;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.channel.MessageEvent;
import java.lang.reflect.InvocationTargetException;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.function.Consumer;
public class LoadWorldCommand extends Command {
final static List<String> validTriggers = Arrays.asList("loadworld");
final static String description = "Load a World using JSON over http";
final static String correctUsage = "loadworld <http url with json for world>";
final static Set<PlayerRole> roles = Sets.newHashSet(PlayerRole.ADMIN);
public LoadWorldCommand(GameManager gameManager) {
super(gameManager, validTriggers, description, correctUsage, roles);
}
@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
execCommand(ctx, e, () -> {
if (originalMessageParts.size() <= 1) {
write("Please specify a http url." + "\r\n");
return;
}
originalMessageParts.remove(0);
String worldJsonHttpUrl = originalMessageParts.get(0);
if (!isValidURL(worldJsonHttpUrl)) {
write("Invalid HTTP address." + "\r\n");
return;
}
HttpGet httpGet = new HttpGet(worldJsonHttpUrl);
HttpClient httpclient = gameManager.getHttpclient();
HttpResponse httpResponse = httpclient.execute(httpGet);
HttpEntity entity = httpResponse.getEntity();
if (entity == null) {
write("Error retrieving JSON url." + "\r\n");
return;
}
String worldJson = EntityUtils.toString(entity);
WorldModel world = null;
try {
world = gameManager.getGson().fromJson(worldJson, WorldModel.class);
} catch (Exception ex) {
write("Retrieved JSON file is malformed. " + ex.getLocalizedMessage() + "\r\n");
return;
}
httpGet.reset();
try( GraphStorageFactory.AetherMudTx tx = this.gameManager.getGraphStorageFactory().beginTransaction() ) {
AetherMudStorage storage = tx.getStorage();
storage.loadWorld( roomManager, mapsManager, entityManager, gameManager, world);
tx.success();
}
});
}
public boolean isValidURL(String url) {
URL u = null;
try {
u = new URL(url);
} catch (MalformedURLException e) {
return false;
}
try {
u.toURI();
} catch (URISyntaxException e) {
return false;
}
return true;
}
}
...@@ -19,6 +19,7 @@ import com.syncleus.aethermud.command.commands.Command; ...@@ -19,6 +19,7 @@ import com.syncleus.aethermud.command.commands.Command;
import com.syncleus.aethermud.core.GameManager; import com.syncleus.aethermud.core.GameManager;
import com.syncleus.aethermud.player.PlayerRole; import com.syncleus.aethermud.player.PlayerRole;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.syncleus.aethermud.storage.graphdb.GraphStorageFactory;
import org.jboss.netty.channel.ChannelHandlerContext; import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.channel.MessageEvent; import org.jboss.netty.channel.MessageEvent;
...@@ -40,7 +41,10 @@ public class SaveWorldCommand extends Command { ...@@ -40,7 +41,10 @@ public class SaveWorldCommand extends Command {
@Override @Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
execCommandThreadSafe(ctx, e, SaveWorldCommand.class, () -> { execCommandThreadSafe(ctx, e, SaveWorldCommand.class, () -> {
worldExporter.saveWorld(); try( GraphStorageFactory.AetherMudTx tx = this.gameManager.getGraphStorageFactory().beginTransaction() ) {
tx.getStorage().saveWorld(roomManager, mapsManager, floorManager);
tx.success();
}
write("World saved."); write("World saved.");
}); });
} }
......
...@@ -120,6 +120,7 @@ public class ConfigureCommands { ...@@ -120,6 +120,7 @@ public class ConfigureCommands {
commandRegistry.addCommand(new LoadNpcCommand(gameManager)); commandRegistry.addCommand(new LoadNpcCommand(gameManager));
commandRegistry.addCommand(new LoadItemCommand(gameManager)); commandRegistry.addCommand(new LoadItemCommand(gameManager));
commandRegistry.addCommand(new LoadMerchantCommand(gameManager)); commandRegistry.addCommand(new LoadMerchantCommand(gameManager));
commandRegistry.addCommand(new LoadWorldCommand(gameManager));
commandRegistry.addCommand(new RestartCommand(gameManager)); commandRegistry.addCommand(new RestartCommand(gameManager));
commandRegistry.addCommand(new GiveHealthCommand(gameManager)); commandRegistry.addCommand(new GiveHealthCommand(gameManager));
commandRegistry.addCommand(new GraphStatusCommand(gameManager)); commandRegistry.addCommand(new GraphStatusCommand(gameManager));
......
...@@ -17,15 +17,21 @@ package com.syncleus.aethermud.storage; ...@@ -17,15 +17,21 @@ package com.syncleus.aethermud.storage;
import com.syncleus.aethermud.core.GameManager; import com.syncleus.aethermud.core.GameManager;
import com.syncleus.aethermud.entity.EntityManager;
import com.syncleus.aethermud.items.Item; import com.syncleus.aethermud.items.Item;
import com.syncleus.aethermud.items.ItemInstance; import com.syncleus.aethermud.items.ItemInstance;
import com.syncleus.aethermud.merchant.Merchant; import com.syncleus.aethermud.merchant.Merchant;
import com.syncleus.aethermud.npc.NpcSpawn; import com.syncleus.aethermud.npc.NpcSpawn;
import com.syncleus.aethermud.storage.graphdb.model.*; import com.syncleus.aethermud.storage.graphdb.model.*;
import com.syncleus.aethermud.world.FloorManager;
import com.syncleus.aethermud.world.MapsManager;
import com.syncleus.aethermud.world.RoomManager;
import com.syncleus.aethermud.world.model.*;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.function.Function;
public interface AetherMudStorage { public interface AetherMudStorage {
...@@ -66,4 +72,31 @@ public interface AetherMudStorage { ...@@ -66,4 +72,31 @@ public interface AetherMudStorage {
Optional<MerchantData> getMerchantData(String internalName); Optional<MerchantData> getMerchantData(String internalName);
MerchantData newMerchantData(); MerchantData newMerchantData();
void saveWorld(RoomManager roomManager, MapsManager mapsManager, FloorManager floorManager);
void loadWorld(MapsManager mapsManager, EntityManager entityManager, GameManager gameManager);
void loadWorld(RoomManager roomManager, MapsManager mapsManager, EntityManager entityManager, GameManager gameManager, WorldModel worldModel);
static Function<Room, RoomModel> buildRoomModelsFromRooms() {
return room -> {
RoomModelBuilder roomModelBuilder = new RoomModelBuilder();
for (RemoteExit remoteExit : room.getEnterExits()) {
roomModelBuilder.addEnterExitName(remoteExit.getRoomId(), remoteExit.getExitDetail());
}
roomModelBuilder.setRoomDescription(room.getRoomDescription());
roomModelBuilder.setRoomTitle(room.getRoomTitle());
roomModelBuilder.setRoomId(room.getRoomId());
roomModelBuilder.setRoomTags(room.getRoomTags());
roomModelBuilder.setFloorId(room.getFloorId());
for (Area area : room.getAreas()) {
roomModelBuilder.addAreaName(area.getName());
}
for (Map.Entry<String, String> notable : room.getNotables().entrySet()) {
roomModelBuilder.addNotable(notable.getKey(), notable.getValue());
}
return roomModelBuilder.build();
};
}
} }
/**
* Copyright 2017 - 2018 Syncleus, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.syncleus.aethermud.storage;
import com.syncleus.aethermud.core.GameManager;
import com.syncleus.aethermud.core.SentryManager;
import com.syncleus.aethermud.entity.EntityManager;
import com.syncleus.aethermud.world.FloorManager;
import com.syncleus.aethermud.world.MapMatrix;
import com.syncleus.aethermud.world.MapsManager;
import com.syncleus.aethermud.world.RoomManager;
import com.google.common.collect.Sets;
import com.google.common.io.Files;
import com.google.gson.GsonBuilder;
import com.syncleus.aethermud.world.model.*;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.*;
import java.util.function.Function;
public class WorldStorage {
private final static String WORLD_DIR = "world/";
private final RoomManager roomManager;
private final MapsManager mapsManager;
private final FloorManager floorManager;
private final EntityManager entityManager;
private final GameManager gameManager;
public WorldStorage(RoomManager roomManager, MapsManager mapsManager, FloorManager floorManager, EntityManager entityManager, GameManager gameManager) {
this.roomManager = roomManager;
this.mapsManager = mapsManager;
this.floorManager = floorManager;
this.entityManager = entityManager;
this.gameManager = gameManager;
}
public void saveWorld() {
WorldModel worldModel = new WorldModel();
Set<FloorModel> floors = Sets.newHashSet();
Set<Integer> floorIds = floorManager.getFloorIds();
for (Integer floorId : floorIds) {
floors.add(generateFloorModel(floorId, mapsManager.getFloorMatrixMaps().get(floorId)));
}
worldModel.setFloorModelList(floors);
String worldJson = new GsonBuilder().setPrettyPrinting().create().toJson(worldModel, WorldModel.class);
try {
Files.write(worldJson.getBytes(), new File(WORLD_DIR + "world.json"));
} catch (IOException e) {
SentryManager.logSentry(this.getClass(), e, "Save world problem!");
e.printStackTrace();
}
}
private FloorModel generateFloorModel(Integer floorId, MapMatrix mapMatrix) {
Set<Room> rooms = roomManager.getRoomsByFloorId(floorId);
FloorModel floorModel = new FloorModel();
floorModel.setId(floorId);
floorModel.setRawMatrixCsv(mapMatrix.getCsv());
floorModel.setRoomModels((new HashSet<RoomModel>()));
floorModel.setName(floorManager.getName(floorId));
rooms.stream()
.map(buildRoomModelsFromRooms())
.forEach(roomModel -> floorModel.getRoomModels()
.add(roomModel));
return floorModel;
}
public static Function<Room, RoomModel> buildRoomModelsFromRooms() {
return room -> {
RoomModelBuilder roomModelBuilder = new RoomModelBuilder();
for (RemoteExit remoteExit : room.getEnterExits()) {
roomModelBuilder.addEnterExitName(remoteExit.getRoomId(), remoteExit.getExitDetail());
}
roomModelBuilder.setRoomDescription(room.getRoomDescription());
roomModelBuilder.setRoomTitle(room.getRoomTitle());
roomModelBuilder.setRoomId(room.getRoomId());
roomModelBuilder.setRoomTags(room.getRoomTags());
roomModelBuilder.setFloorId(room.getFloorId());
for (Area area : room.getAreas()) {
roomModelBuilder.addAreaName(area.getName());
}
for (Map.Entry<String, String> notable : room.getNotables().entrySet()) {
roomModelBuilder.addNotable(notable.getKey(), notable.getValue());
}
return roomModelBuilder.build();
};
}
public Function<RoomModel, BasicRoom> getBasicRoom(final MapMatrix mapMatrix) {
return roomModel -> {
BasicRoomBuilder basicRoomBuilder = new BasicRoomBuilder(gameManager)
.setRoomId(roomModel.getRoomId())
.setFloorId(roomModel.getFloorId())
.setRoomDescription(roomModel.getRoomDescription())
.setRoomTitle(roomModel.getRoomTitle());
for (String tag : roomModel.getRoomTags()) {
basicRoomBuilder.addTag(tag);
}
for (String areaName : roomModel.getAreaNames()) {
Area byName = Area.getByName(areaName);
if (byName != null) {
basicRoomBuilder.addArea(byName);
}
}
Map<String, String> enterExitNames = roomModel.getEnterExitNames();
if (enterExitNames != null) {
for (Map.Entry<String, String> next : enterExitNames.entrySet()) {
RemoteExit remoteExit = new RemoteExit(RemoteExit.Direction.ENTER, Integer.parseInt(next.getKey()), next.getValue());
basicRoomBuilder.addEnterExit(remoteExit);
mapMatrix.addRemote(roomModel.getRoomId(), remoteExit);
}
}
Map<String, String> notables = roomModel.getNotables();
if (notables != null) {
for (Map.Entry<String, String> next : notables.entrySet()) {
basicRoomBuilder.addNotable(next.getKey(), next.getValue());
}
}
configureExits(basicRoomBuilder, mapMatrix, roomModel.getRoomId());
return basicRoomBuilder.createBasicRoom();
};
}
private void configureExits(BasicRoomBuilder basicRoomBuilder, MapMatrix mapMatrix, int roomId) {
Integer north = mapMatrix.getNorthernExit(roomId);
if (north > 0) {
basicRoomBuilder.setNorthId(Optional.of(north));
}
Integer east = mapMatrix.getEasternExit(roomId);
if (east > 0) {
basicRoomBuilder.setEastId(Optional.of(east));
}
Integer south = mapMatrix.getSouthernExit(roomId);
if (south > 0) {
basicRoomBuilder.setSouthId(Optional.of(south));
}
Integer west = mapMatrix.getWesternExit(roomId);
if (west > 0) {
basicRoomBuilder.setWestId(Optional.of(west));
}
if (mapMatrix.getRemotes().containsKey(roomId)) {
for (RemoteExit exit : mapMatrix.getRemotes().get(roomId)) {
if (exit.getDirection().equals(RemoteExit.Direction.UP)) {
basicRoomBuilder.setUpId(Optional.of(exit.getRoomId()));
} else if (exit.getDirection().equals(RemoteExit.Direction.DOWN)) {
basicRoomBuilder.setDownId(Optional.of(exit.getRoomId()));
}
}
}
}
private void buildFloor(FloorModel floorModel) {
MapMatrix matrixFromCsv = MapMatrix.createMatrixFromCsv(floorModel.getRawMatrixCsv());
Set<Room> rooms = Sets.newHashSet();
if (floorModel.getRoomModels() == null || floorModel.getRoomModels().size() == 0) {
Iterator<List<Integer>> rows = matrixFromCsv.getRows();
while (rows.hasNext()) {
List<Integer> row = rows.next();
for (Integer roomId : row) {
if (roomId.equals(0)) {
continue;
}
BasicRoomBuilder basicRoomBuilder = new BasicRoomBuilder(gameManager);
basicRoomBuilder.setFloorId(floorModel.getId());
basicRoomBuilder.setRoomId(roomId);
basicRoomBuilder.setRoomTitle("This is a blank title.");
basicRoomBuilder.setRoomDescription("This is a blank Description.\nWords should go here, ideally.");
configureExits(basicRoomBuilder, matrixFromCsv, roomId);
rooms.add(basicRoomBuilder.createBasicRoom());
}
}
for (Room r : rooms) {
entityManager.addEntity(r);
}
floorManager.addFloor(floorModel.getId(), floorModel.getName());
mapsManager.addFloorMatrix(floorModel.getId(), matrixFromCsv);
return;
}
floorModel.getRoomModels().stream().map(getBasicRoom(matrixFromCsv)).forEach(entityManager::addEntity);
floorManager.addFloor(floorModel.getId(), floorModel.getName());
mapsManager.addFloorMatrix(floorModel.getId(), matrixFromCsv);
}
public void readWorldFromDisk() throws FileNotFoundException {
WorldModel worldModel = new GsonBuilder().create().fromJson(Files.newReader(new File(("world/world.json")), Charset.defaultCharset()), WorldModel.class);
worldModel.getFloorModelList()
.forEach(this::buildFloor);
}
public void buildTestworld() {
WorldModel worldModel = new GsonBuilder().create().fromJson("{\n" +
" \"floorModelList\": [\n" +