Search in sources :

Example 1 with SUBDUNGEON_TYPE

use of main.content.enums.DungeonEnums.SUBDUNGEON_TYPE in project Eidolons by IDemiurge.

the class Location method constructSublevels.

private void constructSublevels() {
    dungeon = bossLevel;
    int z = dungeon.getZ();
    ENTRANCE_LAYOUT entranceLayout = getFirstEntranceLayout(root, DirectionMaster.getRandomDirection());
    if (isScenario()) {
        // Map<SUBDUNGEON_TYPE, String> map = new
        // RandomWizard<SUBDUNGEON_TYPE>()
        // .constructStringWeightMap(scenario.getProperty(MACRO_PROPS.RANDOM_SUBLEVELS),
        // SUBDUNGEON_TYPE.class);
        // e.g. "cave(2);dungeon(3);caste(1); ++ insert *BETWEEN* preset
        // string - lvlN(n) - which could be key?.. perhaps just a list of
        // strings!
        // new RandomWizard<>().constructStringWeightMapInversed(scenario
        // .getProperty(MACRO_PROPS.RANDOM_SUBLEVELS), SUBDUNGEON_TYPE)
        List<String> list = new ArrayList<>();
        for (String stretch : StringMaster.open(scenario.getProperty(MACRO_PROPS.RANDOM_SUBLEVELS))) {
            int i = 0;
            if (StringMaster.isInteger(stretch)) {
                // for (int i = 0; i < StringMaster.getInteger(stretch);
                // i++) {
                // dungeon = dungeon.getSubLevels().getOrCreate(0); // TODO unsafe
                // }
                i = StringMaster.getInteger(stretch);
                continue;
            }
            String typeName;
            if (stretch.contains(StringMaster.OR)) {
                List<String> names = StringMaster.openContainer(stretch, StringMaster.OR);
                stretch = names.get(RandomWizard.getRandomListIndex(names));
            }
            typeName = VariableManager.removeVarPart(stretch);
            int depth = (StringMaster.getInteger(VariableManager.getVarPart(stretch)));
            SUBDUNGEON_TYPE type = new EnumMaster<SUBDUNGEON_TYPE>().retrieveEnumConst(SUBDUNGEON_TYPE.class, typeName);
            String element = i + "=" + typeName + StringMaster.wrapInParenthesis("" + depth);
            list.add(element);
        // depth = Math.max(1, depth);
        }
        Dungeon dungeon = root;
        for (String stretch : StringMaster.open(scenario.getProperty(PROPS.SUBLEVELS))) {
            for (String s : list) {
                int i = StringMaster.getInteger(s.split("=")[0]);
                VariableManager.removeVarPart((s.split("=")[1]));
                VariableManager.getVarPart((s.split("=")[1]));
            }
        }
        String stretch = null;
        int depth = RandomWizard.getRandomInt(StringMaster.getInteger(VariableManager.getVarPart(stretch)));
        for (int level = 0; level < depth; level++) {
            z = (up) ? z++ : z--;
            String typeName = null;
            File randomFile = FileManager.getRandomFile(PathFinder.getDungeonLevelFolder() + typeName);
            // filter?
            String data = FileManager.readFile(randomFile);
            DungeonPlan plan = new LocationBuilder().loadDungeonMap(data);
            ObjType dungeonType = null;
            newSublevel(dungeon, dungeonType, z, level, entranceLayout);
        // adjust plan , set z
        }
    } else {
        int i = maxLevel;
        List<ObjType> typePool = DataManager.toTypeList(getPlaceOrScenario().getProperty(MACRO_PROPS.SUBLEVEL_POOL), DC_TYPE.DUNGEONS);
        Map<Integer, ObjType> map = distributeLevels(typePool, maxLevel);
        ObjType prevType = null;
        int level = 0;
        while (true) {
            i--;
            ObjType type = map.get(i);
            if (type != prevType) {
                level = 0;
            }
            z = (up) ? z++ : z--;
            level++;
            entranceLayout = getNextEntranceLayout(entranceLayout);
            dungeon = newSublevel(dungeon, type, z, level, entranceLayout);
            // checkAddSecretLevels(dungeon);
            if (i <= 0) {
                break;
            }
            prevType = type;
        }
    }
// dungeon.getSubLevels().add(bossLevel);
}
Also used : DungeonPlan(eidolons.game.battlecraft.logic.dungeon.location.building.DungeonPlan) ArrayList(java.util.ArrayList) ENTRANCE_LAYOUT(eidolons.game.module.dungeoncrawl.dungeon.DungeonLevelMaster.ENTRANCE_LAYOUT) LocationBuilder(eidolons.game.battlecraft.logic.dungeon.location.LocationBuilder) ObjType(main.entity.type.ObjType) Dungeon(eidolons.game.battlecraft.logic.dungeon.universal.Dungeon) SUBDUNGEON_TYPE(main.content.enums.DungeonEnums.SUBDUNGEON_TYPE) File(java.io.File)

Aggregations

LocationBuilder (eidolons.game.battlecraft.logic.dungeon.location.LocationBuilder)1 DungeonPlan (eidolons.game.battlecraft.logic.dungeon.location.building.DungeonPlan)1 Dungeon (eidolons.game.battlecraft.logic.dungeon.universal.Dungeon)1 ENTRANCE_LAYOUT (eidolons.game.module.dungeoncrawl.dungeon.DungeonLevelMaster.ENTRANCE_LAYOUT)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 SUBDUNGEON_TYPE (main.content.enums.DungeonEnums.SUBDUNGEON_TYPE)1 ObjType (main.entity.type.ObjType)1