Search in sources :

Example 1 with Refactor

use of main.system.util.Refactor 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 2 with Refactor

use of main.system.util.Refactor in project Eidolons by IDemiurge.

the class Spawner method spawn.

@Refactor
public void spawn() {
    // initFacing(units, player, mode);
    for (Object player1 : getBattleMaster().getPlayerManager().getPlayers()) {
        DC_Player player = (DC_Player) player1;
        if (player.isNeutral()) {
            continue;
        }
        UnitData data = player.getUnitData();
        if (data == null)
            data = generateData("", player, null);
        spawn(data, player, getSpawnMode(player, true));
    }
    spawnDone();
// initEmblem
}
Also used : DC_Player(eidolons.game.battlecraft.logic.battle.universal.DC_Player) Refactor(main.system.util.Refactor)

Example 3 with Refactor

use of main.system.util.Refactor in project Eidolons by IDemiurge.

the class ScriptParser method parseScript.

public static <T> ScriptTrigger parseScript(String script, DC_Game game, ScriptExecutor<T> executor, Class<T> funcClass) {
    // TODO
    script = ScriptMaster.getScriptByName(script);
    // non-trigger scripts?
    String originalText = script;
    String processedPart = StringMaster.getFirstItem(script, ScriptSyntax.PART_SEPARATOR);
    STANDARD_EVENT_TYPE event_type = parseEvent(processedPart);
    script = StringMaster.cropFirstSegment(script, ScriptSyntax.PART_SEPARATOR);
    Condition condition = null;
    condition = getDefaultCondition(event_type, VariableManager.getVars(processedPart));
    if (condition != null) {
        condition.setXml(XML_Converter.wrap("ScriptedCondition", XML_Converter.wrap("STANDARD_EVENT_TYPE", event_type.toString()) + XML_Converter.wrap("STRING", VariableManager.getVars(processedPart))));
    } else {
        String conditionPart = StringMaster.getFirstItem(script, ScriptSyntax.PART_SEPARATOR);
        condition = parseConditions(conditionPart);
        condition.setXml(conditionPart);
    }
    boolean isRemove = true;
    // if (contains("cyclic"))remove = false;
    Ability abilities = null;
    // TODO Global
    Ref ref = new Ref(game);
    script = StringMaster.getLastPart(script, ScriptSyntax.PART_SEPARATOR);
    String funcPart = VariableManager.removeVarPart(script);
    @Refactor T // TODO this won't work in generic way!!!!
    func = new EnumMaster<T>().retrieveEnumConst(funcClass, funcPart);
    if (func != null) {
        // TODO for multiple scripts, need another SEPARATOR!
        String separator = executor.getSeparator(func);
        List<String> strings = StringMaster.openContainer(VariableManager.getVars(script), separator);
        String[] args = strings.toArray(new String[strings.size()]);
        abilities = new AbilityImpl() {

            @Override
            public boolean activatedOn(Ref ref) {
                executor.execute(func, ref, args);
                // reset after? not like normal action certainly...
                return true;
            }
        };
    } else {
        abilities = AbilityConstructor.getAbilities(script, ref);
        if (abilities.getEffects().getEffects().isEmpty()) {
            main.system.auxiliary.log.LogMaster.log(1, "SCRIPT NOT FOUND: " + funcPart);
            return null;
        }
    }
    abilities.setRef(ref);
    ScriptTrigger trigger = new ScriptTrigger(originalText, event_type, condition, abilities);
    trigger.setRemoveAfterTriggers(isRemove);
    return trigger;
}
Also used : Condition(main.elements.conditions.Condition) Ability(main.ability.Ability) AbilityImpl(main.ability.AbilityImpl) STANDARD_EVENT_TYPE(main.game.logic.event.Event.STANDARD_EVENT_TYPE) Refactor(main.system.util.Refactor) Ref(main.entity.Ref)

Aggregations

Refactor (main.system.util.Refactor)3 DC_Player (eidolons.game.battlecraft.logic.battle.universal.DC_Player)1 MapBlock (eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock)1 Ability (main.ability.Ability)1 AbilityImpl (main.ability.AbilityImpl)1 Condition (main.elements.conditions.Condition)1 Ref (main.entity.Ref)1 Coordinates (main.game.bf.Coordinates)1 STANDARD_EVENT_TYPE (main.game.logic.event.Event.STANDARD_EVENT_TYPE)1 EnumMaster (main.system.auxiliary.EnumMaster)1 Node (org.w3c.dom.Node)1