use of main.entity.type.ObjType in project Eidolons by IDemiurge.
the class LocationBuilder method buildDungeonPlan.
// static use and save as templates...
public DungeonPlan buildDungeonPlan(Location location) {
if (helper == null) {
helper = new BuildHelper(location, params);
helper.setPlan(plan);
}
if (StringMaster.isEmpty(helper.getParams().getValue(BUILD_PARAMS.FILLER_TYPE))) {
{
if (!location.isUnderground()) {
// return;
}
plan = new DungeonPlan(testTemplate, location);
int x1 = 0;
int x2 = params.getIntValue(BUILD_PARAMS.WIDTH);
if (x2 <= 0) {
x2 = location.getCellsX();
} else {
location.setParam(PARAMS.BF_WIDTH, x2);
}
int y1 = 0;
int y2 = params.getIntValue(BUILD_PARAMS.HEIGHT);
if (y2 <= 0) {
y2 = location.getCellsY();
} else {
location.setParam(PARAMS.BF_HEIGHT, y2);
}
MapZone zone = new MapZone(location.getDungeon(), 0, x1, x2, y1, y2);
List<Coordinates> coordinates = CoordinatesMaster.getCoordinatesWithin(x1 - 1, x2 - 1, y1 - 1, y2 - 1);
new MapBlock(0, BLOCK_TYPE.ROOM, zone, plan, coordinates);
plan.getZones().add(zone);
return plan;
}
}
if (TestDungeonInitializer.PRESET_PLAN != null) {
File file = FileManager.getFile(PathFinder.getDungeonLevelFolder() + TestDungeonInitializer.PRESET_PLAN);
if (file.isFile()) {
String data = FileManager.readFile(file);
DungeonPlan plan = null;
try {
plan = loadDungeonMap(data);
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
return plan;
}
}
// preset in location-mission, based
// on Level?
// yes, any dungeon could have any template more or less,
template = location.getTemplate();
if (testMode) {
template = testTemplate;
}
if (template == null) {
template = DUNGEON_TEMPLATES.CLASSIC;
}
List<MapBlock> blocks = null;
Map<ObjType, Coordinates> objMap = null;
plan = new DungeonPlan(template, location);
location.setPlan(plan);
plan.setBlocks(blocks);
plan.setObjMap(objMap);
plan.setZones(createMapZones());
// Entrance exit = dungeon.getMainExit();
// Entrance entrance = dungeon.getMainEntrance();
// plan.setBaseAnchor(
// entrance.getCoordinates()
// );
// plan.setEndAnchor(exit.getCoordinates());
// if (!dungeon.isIgnoreRotate())
plan.setRotated(location.isRotated());
plan.setFlippedX(location.isFlippedX());
plan.setFlippedY(location.isFlippedY());
placeMainRooms();
if (!location.isSurface()) {
placeCulDeSacs();
}
if (!location.isSurface() && !helper.getParams().isNoRandomRooms()) {
placeAdditionalRooms();
}
if (!location.isSurface() && !helper.getParams().isNoCorridors()) {
linkWithCorridors();
}
return plan;
}
use of main.entity.type.ObjType in project Eidolons by IDemiurge.
the class LocationSpawner method getCreepGroupForBlock.
private Wave getCreepGroupForBlock(int preferredPower, Dungeon dungeon, MapBlock block, int min, int max) {
// alt? vielleicht fur einige spezielle orte...
String property = dungeon.getProperty(PROPS.ENCOUNTERS);
int mod = block.getSpawningPriority();
if (mod == 0) {
mod = 100;
}
Wave wave;
List<ObjType> list = DataManager.toTypeList(property, DC_TYPE.ENCOUNTERS);
Collections.shuffle(list);
ObjType type = null;
for (ObjType t : list) {
type = t;
if (EncounterMaster.getPower(type, false) < min * mod / 100) {
continue;
}
if (EncounterMaster.getPower(type, false) > max * mod / 100) {
continue;
}
break;
}
if (type == null) {
type = new RandomWizard<ObjType>().getObjectByWeight(property, ObjType.class);
}
wave = new Wave(type, game, new Ref(game), game.getPlayer(false));
wave.setPreferredPower(preferredPower * mod / 100);
wave.setBlock(block);
return wave;
}
use of main.entity.type.ObjType 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 main.entity.type.ObjType in project Eidolons by IDemiurge.
the class DC_MapGenerator method getGatewayObjType.
public static ObjType getGatewayObjType(BF_OBJ_OWNER TYPE) {
if (!initialized) {
init();
}
ObjType type;
type = gatewaysMap.get(TYPE);
if (TYPE == BF_OBJ_OWNER.NEUTRAL) {
type = DataManager.getType(GenericEnums.ASPECT.NEUTRAL.getGateway());
}
if (TYPE == BF_OBJ_OWNER.RANDOM) {
type = DataManager.getType(GenericEnums.ASPECT.getAspectByCode(new Random().nextInt(GenericEnums.ASPECT.values().length)).getGateway());
}
return type;
}
use of main.entity.type.ObjType in project Eidolons by IDemiurge.
the class DC_MapGenerator method getCrystalObjType.
public static ObjType getCrystalObjType(BF_OBJ_OWNER TYPE) {
if (!initialized) {
init();
}
ObjType type;
type = crystalsMap.get(TYPE);
if (TYPE == BF_OBJ_OWNER.NEUTRAL) {
type = DataManager.getType(GenericEnums.ASPECT.NEUTRAL.getCrystalName());
}
if (TYPE == BF_OBJ_OWNER.RANDOM) {
type = DataManager.getType(GenericEnums.ASPECT.getAspectByCode(new Random().nextInt(GenericEnums.ASPECT.values().length)).getCrystalName());
}
return type;
}
Aggregations