Search in sources :

Example 11 with EnumMaster

use of main.system.auxiliary.EnumMaster in project Eidolons by IDemiurge.

the class AV_Tree method build.

private DefaultMutableTreeNode build(List<String> typesDoc, String group) {
    DefaultMutableTreeNode result = new DefaultMutableTreeNode(group);
    List<String> subGroups = new ArrayList<>();
    // if (workspace!=null) workspace.getGrouping() ;
    if (!StringMaster.isEmpty(group)) {
        try {
            Set<String> groups = XML_Reader.getTreeSubGroupMap().get(group);
            if (groups == null) {
                groups = XML_Reader.getTreeSubGroupMap(!XML_Reader.isMacro()).get(group);
            }
            subGroups = new ArrayList<>(groups);
            Class<?> ENUM = EnumMaster.getEnumClass(type.getSubGroupingKey().getName());
            if (ENUM != null) {
                Collections.sort(subGroups, new EnumMaster<>().getEnumSorter(ENUM));
            }
        } catch (Exception e) {
            main.system.ExceptionMaster.printStackTrace(e);
        }
    } else if (workspace != null) {
        subGroups = workspace.getSubgroups();
        if (subGroups == null) // TODO custom *grouping* -> enum class + property!
        {
            if (workspace.isSearch()) {
                subGroups = ListMaster.toStringList(DC_TYPE.values());
            } else {
                subGroups = ListMaster.toStringList(MetaEnums.WORKSPACE_GROUP.values());
                subGroups.add("");
            }
        }
    // subGroups = workspace.getSubgroups();
    // subGroups = workspace.getSubgroups();
    }
    // TODO filter generic groups
    if (subGroups.size() <= 1) {
        return buildSimple(typesDoc, group);
    }
    for (String subGroup : subGroups) {
        DefaultMutableTreeNode subNode = new DefaultMutableTreeNode(subGroup);
        List<String> upgrades = new ArrayList<>();
        List<String> list;
        if (workspace == null) {
            // Set<String> c = XML_Reader.getTreeSubGroupedTypeMap(XML_Reader.isMacro()).get(
            // subGroup);
            // if (!ListMaster.isNotEmpty(c)) {
            // c = XML_Reader.getTreeSubGroupedTypeMap(!XML_Reader.isMacro()).get(subGroup);
            // }
            // list = new ArrayList<>(c);
            // list.removeIf(t-> t==null );
            list = StringMaster.toNameList(main.system.entity.FilterMaster.getFilteredTypeList(type, type.getSubGroupingKey(), subGroup));
            try {
                Collections.sort(list, getComparator());
            } catch (Exception e) {
                main.system.ExceptionMaster.printStackTrace(e);
            }
        } else {
            if (workspace.isSearch()) {
                list = DataManager.toStringList(new Filter<ObjType>().filter(workspace.getTypeList(), G_PROPS.TYPE, subGroup));
                try {
                    Collections.sort(list, new EnumMaster<>().getEnumSorter(DC_TYPE.class));
                } catch (Exception e) {
                    try {
                        Collections.sort(list, new EnumMaster<>().getEnumSorter(EnumMaster.getEnumClass(type.getGroupingKey().getName())));
                    } catch (Exception e1) {
                        e1.printStackTrace();
                    }
                    main.system.ExceptionMaster.printStackTrace(e);
                }
            } else {
                PROPERTY filterValue = G_PROPS.WORKSPACE_GROUP;
                if (workspace.getSubgroupingProp() != null) {
                    filterValue = workspace.getSubgroupingProp();
                }
                list = DataManager.toStringList(new Filter<ObjType>().filter(workspace.getTypeList(), filterValue, subGroup));
                try {
                    Collections.sort(list, new EnumMaster<>().getEnumSorter(WORKSPACE_GROUP.class));
                } catch (Exception e) {
                    main.system.ExceptionMaster.printStackTrace(e);
                }
            }
        }
        for (String typeName : list) {
            if (!typesDoc.contains(typeName)) {
                continue;
            }
            addNode(subNode, typeName, upgrades);
        }
        if (!subNode.isLeaf()) {
            result.add(subNode);
        }
        // TODO is it ok?
        DefaultMutableTreeNode subNode2 = subNode;
        if (isFullNodeStructureOn()) {
            // ???
            for (String typeName : upgrades) {
                subNode.add(new DefaultMutableTreeNode(typeName));
            }
        } else {
            // add upgrade nodes - works only for 3 levels
            while (true) {
                List<String> upgrades2 = new ArrayList<>(upgrades);
                for (String typeName : upgrades2) {
                    // Node!
                    if (addUpgradeNode(subNode2, typeName)) {
                        upgrades.remove(typeName);
                    }
                }
                if (upgrades.isEmpty()) {
                    parent = null;
                    i = 0;
                    break;
                }
                /*
                     * basically, it seems that root type count limits depth
					 * the preCheck
					 *
					 *
					 */
                if (parent == null) {
                    if (subNode2 == null) {
                        parent = subNode2;
                    } else {
                        parent = subNode;
                    }
                }
                subNode2 = getNextNode();
                if (subNode2 == null) {
                    parent = null;
                    i = 0;
                    LogMaster.log(1, upgrades + " remain, parent=" + parent + i);
                    for (String typeName : upgrades) {
                        subNode.add(new DefaultMutableTreeNode(typeName));
                    }
                    break;
                }
            // tr
            }
        }
    }
    // return (DefaultMutableTreeNode) result.getFirstChild();
    return result;
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) DC_TYPE(main.content.DC_TYPE) PROPERTY(main.content.values.properties.PROPERTY) WORKSPACE_GROUP(main.content.enums.system.MetaEnums.WORKSPACE_GROUP) EnumMaster(main.system.auxiliary.EnumMaster) ObjType(main.entity.type.ObjType)

Example 12 with EnumMaster

use of main.system.auxiliary.EnumMaster in project Eidolons by IDemiurge.

the class PresetLauncher method initLaunch.

public static LAUNCH initLaunch(String option) {
    launch = new EnumMaster<LAUNCH>().retrieveEnumConst(LAUNCH.class, option);
    if (launch == null) {
        return null;
    }
    if (launch.logChannelsOn != null) {
        Arrays.stream(launch.logChannelsOn).forEach(c -> {
            c.setOn(true);
        });
    }
    if (launch.logChannelsOff != null) {
        Arrays.stream(launch.logChannelsOff).forEach(c -> {
            c.setOn(false);
        });
    }
    if (launch.preset != null) {
        Preset p = PresetMaster.loadPreset(launch.preset);
        PresetMaster.setPreset(p);
    }
    if (launch.dungeonPath != null) {
    // DungeonMaster.setDEFAULT_DUNGEON_PATH(launch.dungeonPath);
    }
    if (launch.dungeonType != null) {
    // DungeonMaster.setDEFAULT_DUNGEON(launch.dungeonType);
    }
    return launch;
}
Also used : EnumMaster(main.system.auxiliary.EnumMaster) Preset(eidolons.test.Preset)

Example 13 with EnumMaster

use of main.system.auxiliary.EnumMaster in project Eidolons by IDemiurge.

the class AutoTestRunner method run.

public void run() {
    Unit unit = master.getSource();
    RuleMaster.setScope(RULE_SCOPE.TEST);
    if (test.getArg(TEST_ARGS.RULE_SCOPE) != null) {
        RuleMaster.setScope(new EnumMaster<RULE_SCOPE>().retrieveEnumConst(RULE_SCOPE.class, test.getArg(TEST_ARGS.RULE_SCOPE)));
    }
    switch(test.getType()) {
        case ACTION_SKILL:
            runActionSkillTest();
            break;
        default:
            addTestTypes(unit);
            break;
    }
    runTestFunctions();
// switch (test.getAssertions()) {
// }
}
Also used : EnumMaster(main.system.auxiliary.EnumMaster) RULE_SCOPE(eidolons.game.battlecraft.rules.RuleMaster.RULE_SCOPE) Unit(eidolons.entity.obj.unit.Unit)

Example 14 with EnumMaster

use of main.system.auxiliary.EnumMaster in project Eidolons by IDemiurge.

the class ArcaneTower method genericInit.

public static void genericInit(boolean av) {
    EnumMaster.getAdditionalEnumClasses().add(StatEnums.class);
    ContentManager.setTypeMaster(new TypeMaster() {

        public OBJ_TYPE getOBJ_TYPE(String typeName) {
            // AT_OBJ_TYPE.valueOf(typeName);
            return new EnumMaster<AT_OBJ_TYPE>().retrieveEnumConst(AT_OBJ_TYPE.class, typeName);
        }
    });
    XML_Reader.setCustomTypesPath(getTypesPath());
    contentManager = new AT_ContentManager(dcSync);
    if (av) {
        launchAV();
    }
    // launchBackground();
    initSimulation();
    if (!av) {
        contentManager.contentInit();
        CoreEngine.systemInit();
        XML_Reader.loadXml(getTypesPath());
    }
    sim.initObjTypes();
    ContentManager.setInstance(contentManager);
}
Also used : TypeMaster(main.content.TypeMaster) OBJ_TYPE(main.content.OBJ_TYPE) EnumMaster(main.system.auxiliary.EnumMaster) AT_ContentManager(main.logic.value.AT_ContentManager)

Example 15 with EnumMaster

use of main.system.auxiliary.EnumMaster in project Eidolons by IDemiurge.

the class HT_MapBuilder method getLinkVariant.

protected LINK_VARIANT getLinkVariant(ObjType type, int i, int sublingCount) {
    LINK_VARIANT variant = getDefaultLinkVariant();
    Integer circle = type.getIntParam(PARAMS.CIRCLE);
    String linkName = type.getProperty(PROPS.LINK_VARIANT);
    if (linkName.isEmpty()) {
        if (!isAddLinkPerChild()) {
            List<ObjType> typesOnRow = getTypesWithinRange(type, sublingCount, sublingCount, 64, 64);
            ObjType parent = DataManager.getParent(type);
            if (typesOnRow.size() >= 1) {
                int index = 0;
                while (index < typesOnRow.size()) {
                    if (alteredTypeLinkMap.containsKey(DataManager.getParent(typesOnRow.get(index)))) {
                        // TODO short? if any
                        return LINK_VARIANT.VERTICAL;
                    }
                    // in
                    // line are long!
                    index++;
                }
                LogMaster.log(1, type.getName() + "*!* Link made LONG! - " + typesOnRow);
                alteredTypeLinkMap.put(parent, type);
                return LINK_VARIANT.VERTICAL_LONG;
            }
        } else {
            if (sublingCount > 1) {
                if (sublingCount % 2 == 1) {
                    if ((i == sublingCount / 2)) {
                        // getSpecialLink?
                        variant = getDefaultLinkVariant();
                    } else if (i < sublingCount / 2) {
                        linkName += "ANGLE_TO_LEFT";
                    } else {
                        linkName += "ANGLE_TO_RIGHT";
                    }
                } else if (i % 2 == 0) {
                    linkName += "ANGLE_TO_LEFT";
                } else {
                    linkName += "ANGLE_TO_RIGHT";
                }
            }
            if (!linkName.isEmpty()) {
                if (circle > 0 && circle < 4) {
                    linkName += circle;
                }
            }
        }
    }
    if (!linkName.isEmpty()) {
        variant = new EnumMaster<LINK_VARIANT>().retrieveEnumConst(LINK_VARIANT.class, linkName);
    }
    if (variant == null) {
        variant = getDefaultLinkVariant();
    }
    return variant;
}
Also used : ObjType(main.entity.type.ObjType) EnumMaster(main.system.auxiliary.EnumMaster) LINK_VARIANT(eidolons.client.cc.gui.neo.tree.logic.TreeMap.LINK_VARIANT)

Aggregations

EnumMaster (main.system.auxiliary.EnumMaster)28 ObjType (main.entity.type.ObjType)10 Unit (eidolons.entity.obj.unit.Unit)4 LINK_VARIANT (eidolons.client.cc.gui.neo.tree.logic.TreeMap.LINK_VARIANT)3 ArrayList (java.util.ArrayList)3 PROPERTY (main.content.values.properties.PROPERTY)3 ListChooser (main.swing.generic.components.editors.lists.ListChooser)3 AddBuffEffect (eidolons.ability.effects.attachment.AddBuffEffect)2 RULE_SCOPE (eidolons.game.battlecraft.rules.RuleMaster.RULE_SCOPE)2 GAMEPLAY_OPTION (eidolons.system.options.GameplayOptions.GAMEPLAY_OPTION)2 MATERIAL (main.content.enums.entity.ItemEnums.MATERIAL)2 QUALITY_LEVEL (main.content.enums.entity.ItemEnums.QUALITY_LEVEL)2 Coordinates (main.game.bf.Coordinates)2 Color (com.badlogic.gdx.graphics.Color)1 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)1 Align (com.badlogic.gdx.utils.Align)1 DC_Effect (eidolons.ability.effects.DC_Effect)1 ModifyPropertyEffect (eidolons.ability.effects.common.ModifyPropertyEffect)1 AbilityEffect (eidolons.ability.effects.containers.AbilityEffect)1 RayEffect (eidolons.ability.effects.containers.customtarget.RayEffect)1