Search in sources :

Example 11 with MapBlock

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;
}
Also used : EnumMaster(main.system.auxiliary.EnumMaster) Coordinates(main.game.bf.Coordinates) Node(org.w3c.dom.Node) MapBlock(eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock) Refactor(main.system.util.Refactor)

Example 12 with MapBlock

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;
}
Also used : RandomWizard(main.system.auxiliary.RandomWizard) Coordinates(main.game.bf.Coordinates) MapBlock(eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock)

Example 13 with MapBlock

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?
    }
}
Also used : Wave(eidolons.game.battlecraft.logic.battle.arena.Wave) Ref(main.entity.Ref) ObjType(main.entity.type.ObjType) Coordinates(main.game.bf.Coordinates) MapBlock(eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock)

Example 14 with MapBlock

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;
}
Also used : MapZone(eidolons.game.battlecraft.logic.dungeon.location.building.MapZone) Coordinates(main.game.bf.Coordinates) MapBlock(eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock)

Example 15 with MapBlock

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;
    }
}
Also used : MapBlock(eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock)

Aggregations

MapBlock (eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock)22 Coordinates (main.game.bf.Coordinates)13 MapZone (eidolons.game.battlecraft.logic.dungeon.location.building.MapZone)9 Obj (main.entity.obj.Obj)4 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)3 ObjType (main.entity.type.ObjType)3 ArrayList (java.util.ArrayList)2 XList (main.data.XList)2 Ref (main.entity.Ref)2 FACING_DIRECTION (main.game.bf.Coordinates.FACING_DIRECTION)2 Node (org.w3c.dom.Node)2 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)1 DC_Obj (eidolons.entity.obj.DC_Obj)1 Unit (eidolons.entity.obj.unit.Unit)1 GroupAI (eidolons.game.battlecraft.ai.GroupAI)1 Wave (eidolons.game.battlecraft.logic.battle.arena.Wave)1 ROOM_TYPE (eidolons.game.battlecraft.logic.dungeon.location.LocationBuilder.ROOM_TYPE)1 BuildHelper (eidolons.game.battlecraft.logic.dungeon.location.building.BuildHelper)1 DungeonPlan (eidolons.game.battlecraft.logic.dungeon.location.building.DungeonPlan)1 Entrance (eidolons.game.module.dungeoncrawl.dungeon.Entrance)1