use of eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock in project Eidolons by IDemiurge.
the class LocationBuilder method constructBlock.
@Refactor
public static // TODO the way it's done, we can't have Structures in non-Location dungeons!!!
MapBlock constructBlock(Node node, int id, MapZone zone, DungeonPlan map, Dungeon dungeon) {
List<Coordinates> coordinates = new ArrayList<>();
Map<Coordinates, ? extends Obj> objectMap = new HashMap<>();
MapBlock b = new MapBlock(id, null, zone, map, coordinates);
// TODO b-data, coordinates, objects
for (Node subNode : XML_Converter.getNodeList(node)) {
if (StringMaster.compareByChar(subNode.getNodeName(), COORDINATES_NODE)) {
coordinates = CoordinatesMaster.getCoordinatesFromString(subNode.getTextContent());
} else if (StringMaster.compareByChar(subNode.getNodeName(), OBJ_NODE)) {
// TODO BETTER IN TYPES?
objectMap = DC_ObjInitializer.initMapBlockObjects(dungeon, b, subNode.getTextContent());
// TODO encounters?
} else {
// BLOCK TYPE
if (StringMaster.compareByChar(subNode.getNodeName(), BLOCK_TYPE_NODE)) {
BLOCK_TYPE type = new EnumMaster<BLOCK_TYPE>().retrieveEnumConst(BLOCK_TYPE.class, subNode.getTextContent());
b.setType(type);
}
if (StringMaster.compareByChar(subNode.getNodeName(), ROOM_TYPE_NODE)) {
ROOM_TYPE type = new EnumMaster<ROOM_TYPE>().retrieveEnumConst(ROOM_TYPE.class, subNode.getTextContent());
b.setRoomType(type);
}
}
}
b.setCoordinates(coordinates);
if (objectMap == null) {
return b;
}
b.getMap().putAll(objectMap);
b.getObjects().addAll(objectMap.values());
return b;
}
use of eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock in project Eidolons by IDemiurge.
the class LocationBuilder method getRandomCoordinate.
private Coordinates getRandomCoordinate(ROOM_TYPE roomType) {
// TODO totally random? a fair start...
boolean corner = false;
boolean center = false;
ROOM_TYPE[] adjacentRoomRequired = null;
switch(roomType) {
case DEATH_ROOM:
case GUARD_ROOM:
adjacentRoomRequired = new ROOM_TYPE[] { ROOM_TYPE.TREASURE_ROOM, ROOM_TYPE.THRONE_ROOM, ROOM_TYPE.EXIT_ROOM };
break;
case SECRET_ROOM:
case TREASURE_ROOM:
corner = true;
break;
}
Coordinates c = null;
if (adjacentRoomRequired != null) {
Loop.startLoop(500);
while (!Loop.loopEnded()) {
MapBlock block = new RandomWizard<MapBlock>().getRandomListItem(plan.getBlocks());
if (Arrays.asList(adjacentRoomRequired).contains(block.getRoomType())) {
List<Coordinates> list = CoordinatesMaster.getAdjacentToSquare(block.getCoordinates());
c = new RandomWizard<Coordinates>().getRandomListItem(list);
if (c.isInvalid()) {
continue;
}
if (helper.getUsedCoordinates().contains(c)) {
continue;
}
return c;
}
}
return null;
}
Loop.startLoop(100);
while (!Loop.loopEnded()) {
c = CoordinatesMaster.getRandomCoordinate(getDungeon().getCellsX(), getDungeon().getCellsY());
if (helper.getUsedCoordinates().contains(c)) {
continue;
}
// add the outer walls to usedCoordinates?
if (corner) {
if (Math.min(plan.getBorderX() - c.x, c.x) + Math.min(plan.getBorderY() - c.y, c.y) > 6) {
continue;
}
}
break;
}
return c;
}
use of eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock in project Eidolons by IDemiurge.
the class LocationSpawner method spawnDungeonCreeps.
public void spawnDungeonCreeps(Location dungeon) {
String info = dungeon.getProperty(PROPS.ENCOUNTER_INFO);
Map<Coordinates, Integer> delayMap = new HashMap<>();
for (String substring : StringMaster.open(info)) {
Coordinates c = new Coordinates(substring.split("")[0]);
int round = StringMaster.getInteger(substring.split("=")[1]);
delayMap.put(c, round);
}
/*
* Assign block per creep group? So a dungeon has a repertoire and map template...
* then we calculate total power...
* First, spawn the 'must have' groups, around entrances and treasures
*/
if (dungeon.isSublevel()) {
} else {
// different alg?
}
// PartyManager.getParty().getTotalPower();
// int power = DungeonMaster.getDungeonPowerTotal(dungeon);
// int maxGroups = dungeon.getIntParam(PARAMS.MAX_GROUPS);
int power = 0;
int preferredPower = dungeon.getLevel() + // + PartyManager.getParty().getPower()
getBattleMaster().getOptionManager().getOptions().getBattleLevel();
int min = preferredPower * 2 / 3;
int max = preferredPower * 3 / 2;
for (MapBlock block : dungeon.getPlan().getBlocks()) {
Wave group;
if (specialEncounters.get(dungeon) != null) {
Map<Coordinates, ObjType> specEncounters = specialEncounters.get(dungeon).get(block);
for (Coordinates c : specEncounters.keySet()) {
ObjType waveType = specEncounters.get(c);
if (waveType.getGroup().equalsIgnoreCase("Substitute")) {
waveType = EncounterMaster.getSubstituteEncounterType(waveType, dungeon.getDungeon(), preferredPower);
}
group = new Wave(waveType, game, new Ref(), game.getPlayer(false));
group.setCoordinates(c);
Integer delay = delayMap.get(c);
// TODO getBattleMaster().getConstructor().scheduleEncounter(group, delay);
// spawnWave(group, true);
// initGroup(group);
power += group.getPower();
}
} else {
// TODO POWER PER BLOCK!
if (!autoSpawnOn) {
continue;
}
// break;
if (!checkSpawnBlock(block)) {
continue;
}
// sort blocks! by spawn priority...
// can be more than 1 group, right? maybe merge?
group = getCreepGroupForBlock(preferredPower, dungeon.getDungeon(), block, min, max);
group.setPreferredPower(preferredPower);
// spawnWave(group, true);
// initGroup(group);
// power -= group.getPower();
power += group.getPower();
}
}
if (power > min) {
// spawn wandering creeps - apart from groups? in max distance from
// them?
}
}
use of eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock in project Eidolons by IDemiurge.
the class LE_PlanPanel method edit.
private boolean edit() {
MapZone zone = getSelectedZone();
if (zone == null) {
return false;
}
// Boolean filler_size_position =
// DialogMaster.askAndWait("What to edit for ",
// "Filler", "Size",
// "Position");
// move?
String prevFiller = zone.getFillerType();
String filler = DialogMaster.inputText("Set new Filler Type for " + zone.getName() + "...", prevFiller);
if (filler != null) {
if (!Objects.equals(filler, prevFiller)) {
zone.setFillerType(filler);
}
}
// zone.setX1(x1);
// zone.setName(name)
// size -> re-fill spaces!
List<Coordinates> coordinates = zone.getCoordinates();
for (MapBlock b : zone.getBlocks()) {
coordinates.removeAll(b.getCoordinates());
}
LevelEditor.getMapMaster().replace(prevFiller, filler, coordinates);
return true;
}
use of eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock in project Eidolons by IDemiurge.
the class LE_PlanPanel method handleBlockControl.
public void handleBlockControl(BLOCK_CONTROLS c) {
MapBlock b = getSelectedBlock();
switch(c) {
case COPY:
LevelEditor.getMapMaster().copyBlock(b);
break;
case PASTE:
LevelEditor.getMapMaster().pasteBlock();
break;
case LOAD:
LevelEditor.getMapMaster().loadBlock();
break;
case SAVE:
String path = PathFinder.getMapBlockFolderPath();
String fileName = DialogMaster.inputText("Input name", b.getRoomType() + " - " + (getMission() == null ? "" : getMission().getName() + " - ") + getLevel().getName());
if (fileName.isEmpty()) {
return;
} else {
fileName += ".xml";
}
XML_Writer.write(b.getXml(), path, fileName);
break;
}
}
Aggregations