use of main.game.bf.Coordinates 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 main.game.bf.Coordinates in project Eidolons by IDemiurge.
the class LocationSpawner method spawn.
@Override
public List<Unit> spawn(UnitData data, DC_Player player, SPAWN_MODE mode) {
if (data.getValue(PARTY_VALUE.MEMBERS) != null) {
String units = data.getValue(PARTY_VALUE.MEMBERS).replace(DataUnitFactory.getContainerSeparator(UnitData.FORMAT), "");
if (FileManager.isFile(units))
return spawnUnitGroup(player.isMe(), units);
}
if (player.isMe() && PresetMaster.getPreset() == null && getGame().getMetaMaster() != null) {
Party party = getGame().getMetaMaster().getPartyManager().getParty();
if (party == null) {
return new LinkedList<>();
}
List<String> list = ListMaster.toNameList(party.getMembers());
getPositioner().setMaxSpacePercentageTaken(50);
List<Coordinates> coords = getPositioner().getPlayerPartyCoordinates(list);
Iterator<Coordinates> iterator = coords.iterator();
for (Unit member : party.getMembers()) {
if (!iterator.hasNext()) {
main.system.auxiliary.log.LogMaster.log(1, "Spawn failed: Coordinates: " + coords + "; Units" + list);
break;
}
member.setCoordinates(iterator.next());
member.setConstructed(false);
getGame().getState().addObject(member);
member.setOriginalOwner(player);
member.setOwner(player);
member.setFacing(getFacingAdjuster().getPartyMemberFacing(member));
applyStartBonuses(member);
// what else should be done to *spawn*?
}
} else {
super.spawn(data, player, mode);
}
return null;
}
use of main.game.bf.Coordinates 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.game.bf.Coordinates in project Eidolons by IDemiurge.
the class BuildHelper method checkLinkOrReject.
private Boolean checkLinkOrReject(MapBlock baseBlock, Coordinates c, boolean culdesac) {
Coordinates adjacent = getAdjacentPassage(c, baseBlock.getCoordinates(), false);
if (adjacent != null) {
if (culdesac) {
return false;
}
// WILL BE IN LINK_COORDINATE
usedCoordinates.add(adjacent);
c = adjacent;
}
if (baseBlock.getType() == BLOCK_TYPE.CULDESAC) {
// or false?
return null;
}
MapBlock block = plan.getBlockByCoordinate(c);
if (block == null) {
return null;
}
if (block == baseBlock || culdesac) {
return false;
}
int links = block.getConnectedBlocks().size();
if (links > 2) {
return false;
}
// if (baseBlock.getRoomType()==) TODO
if (block.getType() == BLOCK_TYPE.CULDESAC) {
return false;
}
if (block.getConnectedBlocks().containsKey(baseBlock)) {
return false;
}
baseBlock.link(block, c);
block.link(baseBlock, c);
return true;
}
use of main.game.bf.Coordinates in project Eidolons by IDemiurge.
the class DC_Map method initMapCrystals.
private void initMapCrystals(String enemycrystals, String factioncrystals, String neutralcrystals, String randomcrystals, int randomCrystals) {
BF_OBJ_OWNER TYPE;
for (Coordinates c : Coordinates.getCoordinates(factioncrystals)) {
TYPE = BF_OBJ_OWNER.MY;
LogMaster.log(LogMaster.MAP_GENERATION_DEBUG, TYPE + " crystal at " + c);
crystals.put(c, BF_OBJ_OWNER.MY);
}
for (Coordinates c : Coordinates.getCoordinates(enemycrystals)) {
TYPE = BF_OBJ_OWNER.ENEMY;
LogMaster.log(LogMaster.MAP_GENERATION_DEBUG, TYPE + " crystal at " + c);
crystals.put(c, BF_OBJ_OWNER.ENEMY);
}
for (Coordinates c : Coordinates.getCoordinates(neutralcrystals)) {
TYPE = BF_OBJ_OWNER.NEUTRAL;
LogMaster.log(LogMaster.MAP_GENERATION_DEBUG, TYPE + " crystal at " + c);
crystals.put(c, BF_OBJ_OWNER.NEUTRAL);
}
for (Coordinates c : Coordinates.getCoordinates(randomcrystals)) {
TYPE = BF_OBJ_OWNER.RANDOM;
LogMaster.log(LogMaster.MAP_GENERATION_DEBUG, TYPE + " crystal at " + c);
crystals.put(c, BF_OBJ_OWNER.RANDOM);
}
for (int i = randomCrystals; i > 0; i--) {
Coordinates c = new Coordinates(100 + i, 0);
crystals.put(c, BF_OBJ_OWNER.RANDOM);
}
}
Aggregations