Search in sources :

Example 6 with DC_TYPE

use of main.content.DC_TYPE in project Eidolons by IDemiurge.

the class ContainerMaster method preselectBaseType.

private ObjType preselectBaseType(CONTAINER_CONTENTS contents, ITEM_RARITY rarity) {
    DC_TYPE TYPE = getRandomTYPE(contents);
    boolean iterate = isIterateAlways() || TYPE == DC_TYPE.ITEMS || TYPE == DC_TYPE.JEWELRY;
    if (isFastSelect()) {
        String group = getItemGroup(contents, false, TYPE);
        String subgroup = getItemGroup(contents, true, TYPE);
        ObjType type = null;
        List<ObjType> types = DataManager.getTypes(TYPE, iterate);
        main.system.auxiliary.log.LogMaster.log(1, " group= " + group + " subgroup= " + subgroup + "; types = " + types);
        Iterator<ObjType> iterator = types.iterator();
        int n = 0;
        // Math.min(50, types.size() / 3));
        Loop loop = new Loop(5);
        while (true) {
            if (iterate) {
                if (!iterator.hasNext())
                    return null;
                type = iterator.next();
            } else {
                n++;
                type = new RandomWizard<ObjType>().getRandomListItem(types);
                if (n > types.size() / 5) {
                    if (!loop.continues())
                        return null;
                    group = getItemGroup(contents, false, TYPE);
                    subgroup = getItemGroup(contents, true, TYPE);
                    n = 0;
                }
            }
            if (type == null)
                break;
            if (type.isGenerated())
                continue;
            if (isRemoveBase(contents, type) && TYPE != DC_TYPE.JEWELRY)
                if (!type.checkProperty(PROPS.ITEM_RARITY, rarity.name()))
                    continue;
            if (group != null)
                if (!type.checkGroupingProperty(group))
                    continue;
            if (subgroup != null)
                if (!type.checkSubGroup(subgroup))
                    continue;
            break;
        }
        return type;
    }
    List<ObjType> list = new ArrayList<>();
    String groups = getItemGroups(contents, TYPE);
    if (groups == null)
        groups = " ;";
    for (String sub : groups.split(";")) {
        if (sub.trim().isEmpty())
            sub = null;
        List<ObjType> group = new ArrayList<>(isGroupsOrSubgroups(contents, TYPE) ? DataManager.getTypesGroup(TYPE, sub) : DataManager.getTypesSubGroup(TYPE, sub));
        // TODO set rarity to common by default
        FilterMaster.filterByPropJ8(group, PROPS.ITEM_RARITY.getName(), rarity.name());
        filter(contents, group, rarity, TYPE);
        if (group.isEmpty())
            continue;
        // group = generateTypes(c, rarity, group);
        // group.removeIf(type -> !type.isGenerated()); //remove base types
        list.addAll(group);
    }
    main.system.auxiliary.log.LogMaster.log(1, "type list= " + list);
    if (list.isEmpty()) {
        return null;
    }
    return new RandomWizard<ObjType>().getRandomListItem(list);
}
Also used : Loop(main.system.auxiliary.Loop) DC_TYPE(main.content.DC_TYPE) ObjType(main.entity.type.ObjType) RandomWizard(main.system.auxiliary.RandomWizard)

Example 7 with DC_TYPE

use of main.content.DC_TYPE in project Eidolons by IDemiurge.

the class ListEditor method launch.

@Override
public String launch(String value, String name) {
    if (listData == null && !listDataSet) {
        if (res_name != null) {
            listData = ResourceManager.getFilesInFolder(res_name);
            // StringMaster.formatResList(listData);
            Collections.sort(listData);
        } else if (ENUM) {
            // TODO get enum class by name (constants)
            if (enumClass != null) {
                listData = EnumMaster.getEnumConstantNames(enumClass);
            } else {
                Class<?> ENUM_CLASS = EnumMaster.getEnumClass(name);
                if (// TODO find
                ENUM_CLASS == null) {
                    ENUM_CLASS = EnumMaster.getEnumClass(name, MACRO_CONTENT_CONSTS.class);
                }
                listData = EnumMaster.getEnumConstantNames(ENUM_CLASS);
                StringMaster.formatList(listData);
            }
        } else {
            if (TYPE == null) {
                TYPE = DC_TYPE.ABILS;
                subgroup = name;
                if (!XML_Reader.getSubGroups(TYPE.toString()).contains(subgroup)) {
                    Err.info("No subgroup found! - " + subgroup);
                }
                if (getBASE_TYPE() instanceof DC_TYPE) {
                    switch((DC_TYPE) getBASE_TYPE()) {
                        case BF_OBJ:
                            TYPE = DC_TYPE.ACTIONS;
                            subgroup = null;
                            break;
                        case CHARS:
                            TYPE = DC_TYPE.ACTIONS;
                            subgroup = null;
                            break;
                        case UNITS:
                            TYPE = DC_TYPE.ACTIONS;
                            subgroup = null;
                            break;
                    }
                }
            }
            listData = DataManager.getTypeNamesGroup(TYPE, subgroup);
            if (filterGroup != null) {
                listData = DataManager.getTypeNamesGroup(TYPE, filterGroup);
            } else if (filterSubgroup != null) {
                listData = DataManager.getTypesSubGroupNames(TYPE, filterSubgroup);
            }
            if (getConditions() != null) {
                Ref ref = new Ref(Game.game, getEntity().getId());
                listData = DataManager.toStringList(new Filter<ObjType>(ref, getConditions()).filter(DataManager.toTypeList(listData, TYPE)));
            }
        }
    }
    ListChooser listChooser;
    if (mode == SELECTION_MODE.SINGLE) {
        listChooser = new ListChooser(listData, ENUM, TYPE);
    } else {
        secondListData = new ArrayList<>();
        if (value != null) {
            if (!value.equals(ContentManager.getDefaultEmptyValue())) {
                secondListData = ListMaster.toList(value.toString(), ENUM);
            }
        }
        listChooser = new ListChooser(listData, secondListData, ENUM, TYPE);
    }
    if (ENUM || TYPE == DC_TYPE.UNITS || TYPE == DC_TYPE.CHARS || TYPE == DC_TYPE.DEITIES) {
        columns = 1;
    }
    listChooser.setColumns(columns);
    listChooser.setVarTypes(getVarTypes());
    listChooser.setVarClass(getVarTypesClass());
    String newValue = listChooser.getString();
    return newValue;
}
Also used : Ref(main.entity.Ref) DC_TYPE(main.content.DC_TYPE) Filter(main.elements.Filter) ListChooser(main.swing.generic.components.editors.lists.ListChooser)

Example 8 with DC_TYPE

use of main.content.DC_TYPE in project Eidolons by IDemiurge.

the class Loader method createObjects.

private static List<Obj> createObjects(List<String> objectNodes) {
    DC_Game game = DC_Game.game;
    List<Obj> objects = new ArrayList<>();
    // TODO ID ORDER MUST BE PRESERVED! put in parameter?
    for (String typesNode : objectNodes) {
        Document node = XML_Converter.getDoc(typesNode);
        DC_TYPE TYPE = DC_TYPE.getType(node.getNodeName());
        for (Node subNode : XML_Converter.getNodeList(node)) {
            String sub = XML_Converter.getStringFromXML(subNode);
            game.setIdManager(new DC_IdManager(game));
            Map<PROPERTY, String> props = getPropsFromNode(sub);
            Map<PARAMETER, String> params = getParamsFromNode(sub);
            ObjType type = DataManager.getType(subNode.getNodeName(), TYPE);
            // preset ID?! init containers by id... including buffs; but first create them
            Ref ref = new Ref(game);
            Node refNode = XML_Converter.findNode(sub, Saver.OBJ_NODE);
            if (refNode != null)
                for (String substring : StringMaster.open(refNode.getTextContent())) {
                    ref.setValue(KEYS.valueOf(substring.split("=")[0].toUpperCase()), substring.split("=")[1]);
                }
            String ownerName = null;
            DC_Player owner = game.getBattleMaster().getPlayerManager().getPlayer(// property?
            ownerName);
            if (owner == null) {
                owner = DC_Player.NEUTRAL;
            }
            Coordinates c = new Coordinates(params.get(G_PARAMS.POS_X) + "-" + params.get(G_PARAMS.POS_Y));
            Obj object = createObj(type, c.x, c.y, owner, game, ref);
            object.getPropMap().putAll(props);
            object.getParamMap().putAll(params);
            object.setId(StringMaster.getInteger(props.get(G_PROPS.ID)));
            objects.add(object);
            init(object);
        }
    }
    return objects;
}
Also used : DC_TYPE(main.content.DC_TYPE) PROPERTY(main.content.values.properties.PROPERTY) Node(org.w3c.dom.Node) Coordinates(main.game.bf.Coordinates) ArrayList(java.util.ArrayList) DC_Game(eidolons.game.core.game.DC_Game) Document(org.w3c.dom.Document) DC_Player(eidolons.game.battlecraft.logic.battle.universal.DC_Player) Ref(main.entity.Ref) DC_IdManager(eidolons.entity.DC_IdManager) ObjType(main.entity.type.ObjType) DC_WeaponObj(eidolons.entity.item.DC_WeaponObj) DC_QuickItemObj(eidolons.entity.item.DC_QuickItemObj) DC_BuffObj(eidolons.entity.obj.attach.DC_BuffObj) DC_FeatObj(eidolons.entity.obj.attach.DC_FeatObj) DC_JewelryObj(eidolons.entity.item.DC_JewelryObj) DC_SpellObj(eidolons.entity.active.DC_SpellObj) Obj(main.entity.obj.Obj) DC_ArmorObj(eidolons.entity.item.DC_ArmorObj) PARAMETER(main.content.values.parameters.PARAMETER)

Example 9 with DC_TYPE

use of main.content.DC_TYPE in project Eidolons by IDemiurge.

the class XlsMaster method main.

public static void main(String[] args) {
    String types = "units;";
    for (DC_TYPE type : TYPES) {
        types += type.getName() + ";";
    }
    CoreEngine.setSelectivelyReadTypes(types);
    // args[0];
    String path = "Y:\\Google Drive\\Project Eidolons\\content\\";
    String filename = path + "content.xls";
    DC_Engine.mainMenuInit();
    int i = 0;
    HSSFWorkbook workbook = new HSSFWorkbook();
    new DC_Game();
    for (DC_TYPE TYPE : TYPES) {
        PARAMS[] params = PARAM_ARRAYS[i];
        String[] formulas = FORMULA_ARRAYS[i];
        createSheet(workbook, TYPE, GROUPS_ARRAYS[i], params, formulas);
        i++;
    }
    try {
        FileOutputStream fileOut = new FileOutputStream(filename);
        workbook.write(fileOut);
        fileOut.close();
    } catch (IOException e) {
        main.system.ExceptionMaster.printStackTrace(e);
    }
    System.out.println("Content excel file has been generated!");
}
Also used : DC_TYPE(main.content.DC_TYPE) FileOutputStream(java.io.FileOutputStream) DC_Game(eidolons.game.core.game.DC_Game) PARAMS(eidolons.content.PARAMS) IOException(java.io.IOException) HSSFWorkbook(org.apache.poi.hssf.usermodel.HSSFWorkbook)

Example 10 with DC_TYPE

use of main.content.DC_TYPE in project Eidolons by IDemiurge.

the class ArcaneVault method main.

public static void main(String[] args) {
    CoreEngine.setArcaneVault(true);
    if (args.length > 0) {
        setMacroMode(true);
        if (args.length > 1) {
            worldEditAutoInit = true;
        }
        selectiveLaunch = false;
        types = microForMacro;
    }
    GuiManager.init();
    if (selectiveLaunch) {
        int init = DialogMaster.optionChoice("Launch Options", LAUNCH_OPTIONS);
        if (init == -1) {
            return;
        }
        HT_View.setWorkspaceLaunch(workspaceLaunch);
        WorkspaceManager.ADD_WORKSPACE_TAB_ON_INIT = workspaceLaunch;
        selectiveInit = !"Full".equals(LAUNCH_OPTIONS[init]);
        if (selectiveInit) {
            types = presetTypes;
            switch(LAUNCH_OPTIONS[init]) {
                case "Battlecraft":
                    List<DC_TYPE> enumList = new EnumMaster<DC_TYPE>().getEnumList(DC_TYPE.class);
                    for (DC_TYPE sub : DC_TYPE.values()) {
                        if (sub.isNonBattlecraft()) {
                            enumList.remove(sub);
                        }
                    }
                    types = StringMaster.constructStringContainer(enumList);
                    break;
                case "Last":
                    types = FileManager.readFile(getLastTypesFilePath());
                    break;
                case "Arcane Tower":
                    arcaneTower = true;
                    // XML_Reader.setCustomTypesPath(customTypesPath);
                    break;
                case "Workspace":
                    break;
                case "Selective Custom":
                    types = ListChooser.chooseEnum(DC_TYPE.class, SELECTION_MODE.MULTIPLE);
                    try {
                        FileManager.write(types, getLastTypesFilePath());
                    } catch (Exception e) {
                        main.system.ExceptionMaster.printStackTrace(e);
                    }
                    break;
                case "Selective":
                    init = DialogMaster.optionChoice("Selective Templates", WORKSPACE_TEMPLATE.values());
                    if (init == -1) {
                        return;
                    }
                    template = WORKSPACE_TEMPLATE.values()[init];
                    types = template.getTypes();
                    break;
            }
            CoreEngine.setSelectivelyReadTypes(types);
        } else {
            AV_Tree.setFullNodeStructureOn(true);
        }
    }
    ItemGenerator.setGenerationOn(!ENABLE_ITEM_GENERATION);
    LogMaster.PERFORMANCE_DEBUG_ON = showTime;
    LogMaster.log(3, "Welcome to Arcane Vault! \nBrace yourself to face the darkest mysteries of Edalar...");
    initialize();
    if (macroMode) {
        ContentGenerator.generatePlaces();
    }
    if (artGen) {
        // ResourceMaster.createArtFolders(types);
        ResourceMaster.createUpdatedArtDirectory();
    // ModelManager.saveAll();
    // return;
    }
    if (imgPathUpdate) {
        ResourceMaster.updateImagePaths();
    }
    mainBuilder = new MainBuilder();
    mainBuilder.setKeyListener(new AV_KeyListener(getGame()));
    if (!isCustomLaunch()) {
        if (XML_Reader.getTypeMaps().keySet().contains(MACRO_OBJ_TYPES.FACTIONS.getName())) {
            UnitGroupMaster.modifyFactions();
        }
    }
    // ModelManager.generateFactions();
    showAndCreateGUI();
    if (worldEditAutoInit) {
    // WorldEditor.editDefaultCampaign();
    }
    ModelManager.startSaving();
    if (selectiveInit) {
        afterInit(template);
    }
// CoreEngine.setWritingLogFilesOn(true);
}
Also used : AV_KeyListener(main.utilities.hotkeys.AV_KeyListener) DC_TYPE(main.content.DC_TYPE) MainBuilder(main.gui.builders.MainBuilder)

Aggregations

DC_TYPE (main.content.DC_TYPE)18 ObjType (main.entity.type.ObjType)9 ArrayList (java.util.ArrayList)5 Ref (main.entity.Ref)4 DC_SpellObj (eidolons.entity.active.DC_SpellObj)2 DC_Game (eidolons.game.core.game.DC_Game)2 PARAMETER (main.content.values.parameters.PARAMETER)2 PROPERTY (main.content.values.properties.PROPERTY)2 Entity (main.entity.Entity)2 Coordinates (main.game.bf.Coordinates)2 ListChooser (main.swing.generic.components.editors.lists.ListChooser)2 Document (org.w3c.dom.Document)2 Node (org.w3c.dom.Node)2 AddBuffEffect (eidolons.ability.effects.attachment.AddBuffEffect)1 ModifyPropertyEffect (eidolons.ability.effects.common.ModifyPropertyEffect)1 PARAMS (eidolons.content.PARAMS)1 DC_IdManager (eidolons.entity.DC_IdManager)1 DC_ArmorObj (eidolons.entity.item.DC_ArmorObj)1 DC_HeroItemObj (eidolons.entity.item.DC_HeroItemObj)1 DC_JewelryObj (eidolons.entity.item.DC_JewelryObj)1