Search in sources :

Example 71 with Ref

use of main.entity.Ref in project Eidolons by IDemiurge.

the class ArenaBattleConstructor method constructWaveSequence.

public Map<Wave, Integer> constructWaveSequence(ENCOUNTER_TYPE[] encounter_sequence) {
    Integer round = getRoundNumber();
    if (SkirmishMaster.isSkirmish()) {
        return SkirmishMaster.constructWaveSequences(round);
    }
    Map<Wave, Integer> map = new XLinkedMap<>();
    if (alt != null) {
        alt = !alt;
    } else {
        alt = checkAltEncounter();
    }
    List<ObjType> waves = getWaveTypes(getDungeon().getType(), alt);
    List<ObjType> waveBuffer = new ArrayList<>(waves);
    for (ENCOUNTER_TYPE type : encounter_sequence) {
        if (waveBuffer.isEmpty()) {
            waveBuffer = DataManager.getTypesGroup(DC_TYPE.ENCOUNTERS, StringMaster.getWellFormattedString(type.toString()));
        }
        waves = new ArrayList<>(waveBuffer);
        Conditions conditions = new Conditions(getEncounterTypeCondition(type));
        List<ObjType> filteredWaves = new Filter<ObjType>(game, conditions).filter(waves);
        if (!filteredWaves.isEmpty()) {
            waves = filteredWaves;
        } else {
            continue;
        }
        ObjType waveType = getWaveType(waves, type);
        waveType = new ObjType(waveType);
        FACING_DIRECTION side = null;
        // getMaster().getDungeonMaster().getPositioner().nextSide();
        waveType.setProperty(PROPS.SPAWNING_SIDE, side.getName());
        Coordinates c = pickSpawnCoordinateForWave(type, round, waveType);
        Wave wave = new Wave(c, waveType, game, new Ref(game), game.getPlayer(false));
        wave.initUnitMap();
        map.put(wave, round);
        if (Eidolons.DEV_MODE) {
            game.getLogManager().logInfo(wave.toString() + " on round #" + round);
        }
        LogMaster.log(1, wave.toString() + " on round #" + round);
        // TODO subtract from
        round += getRoundsToFight(waveType, type);
    // total pool
    }
    setIndex(getIndex() + 1);
    return map;
}
Also used : XLinkedMap(main.data.XLinkedMap) ENCOUNTER_TYPE(main.content.enums.EncounterEnums.ENCOUNTER_TYPE) Coordinates(main.game.bf.Coordinates) ArrayList(java.util.ArrayList) Conditions(main.elements.conditions.Conditions) FACING_DIRECTION(main.game.bf.Coordinates.FACING_DIRECTION) Ref(main.entity.Ref) ObjType(main.entity.type.ObjType)

Example 72 with Ref

use of main.entity.Ref in project Eidolons by IDemiurge.

the class FutureBuilder method getDamage.

public static int getDamage(DC_ActiveObj active, Obj targetObj, Effect e, Boolean min_max_normal) {
    Integer damage;
    Ref ref = active.getOwnerObj().getRef().getCopy();
    ref.setTarget(targetObj.getId());
    ref.setID(KEYS.ACTIVE, active.getId());
    e.setRef(ref);
    if (e instanceof DealDamageEffect) {
        ref.setAmount(e.getFormula().getInt(ref));
        if (((DealDamageEffect) e).getDamageType() != null) {
            ref.setValue(KEYS.DAMAGE_TYPE, ((DealDamageEffect) e).getDamageType().toString());
        }
        damage = DamageCalculator.precalculateDamage(ref);
    } else {
        Attack attack = ((AttackEffect) e).initAttack();
        // attack.setAttacked((DC_HeroObj) targetObj);
        Map<String, Integer> _cache = getCache(min_max_normal);
        damage = _cache.get(getCacheKey(active, targetObj));
        if (damage == null) {
            damage = DamageCalculator.precalculateDamage(attack, min_max_normal);
            _cache.put(getCacheKey(active, targetObj), damage);
        }
    }
    // active.toBase();
    LogMaster.log(1, active.getName() + " on " + targetObj.getName() + " - damage precalculated: " + damage);
    return damage;
}
Also used : Ref(main.entity.Ref) AttackEffect(eidolons.ability.effects.oneshot.attack.AttackEffect) DealDamageEffect(eidolons.ability.effects.oneshot.DealDamageEffect) Attack(eidolons.game.battlecraft.rules.combat.attack.Attack)

Example 73 with Ref

use of main.entity.Ref 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 74 with Ref

use of main.entity.Ref in project Eidolons by IDemiurge.

the class EntityChoiceView method initData.

protected void initData() {
    if (list != null) {
        // empty?
        if (list.get(0) instanceof ObjType) {
            data = new ArrayList<>(new DequeImpl<ObjType>().getAddAllCast(list));
        } else {
        // TODO
        }
    } else {
        if (getGroup() != null) {
            data = DataManager.getFilteredTypes(getGroup(), getTYPE(), getFilterValue());
        } else {
            data = DataManager.getTypes(getTYPE());
        }
        Ref ref = new Ref(DC_Game.game);
        if (hero != null) {
            ref = Ref.getCopy(hero.getRef());
        }
        if (getFilterOption() != null) {
            WORKSPACE_GROUP ws = new EnumMaster<WORKSPACE_GROUP>().retrieveEnumConst(WORKSPACE_GROUP.class, getFilterOption());
            data = new Filter<ObjType>(ref, ConditionMaster.getWorkspaceCondition(true, ws)).filter(data);
        }
        if (getFilterConditions() != null) {
            data = new Filter<ObjType>(ref, getFilterConditions()).filter(data);
        }
    }
    sortData();
}
Also used : Ref(main.entity.Ref) WORKSPACE_GROUP(main.content.enums.system.MetaEnums.WORKSPACE_GROUP) ObjType(main.entity.type.ObjType) Filter(main.elements.Filter)

Example 75 with Ref

use of main.entity.Ref in project Eidolons by IDemiurge.

the class BindingDamageEffect method applyThis.

@Override
public boolean applyThis() {
    // Can be initialized() just once
    GroupImpl group = ref.getGroup();
    Effects effects = new Effects();
    STANDARD_EVENT_TYPE event_type;
    if (shareOrRedirect) {
        // TODO splitMode!
        event_type = STANDARD_EVENT_TYPE.UNIT_IS_DEALT_TOUGHNESS_DAMAGE;
        if (spellDmgOnly != null) {
            if (spellDmgOnly) {
                event_type = STANDARD_EVENT_TYPE.UNIT_HAS_BEEN_DEALT_SPELL_DAMAGE;
            }
        }
        if (physicalDmgOnly != null) {
            if (physicalDmgOnly) {
                event_type = STANDARD_EVENT_TYPE.UNIT_HAS_BEEN_DEALT_PHYSICAL_DAMAGE;
            }
        }
    } else {
        effects.add(new AlteringEffect(false, formula.getNegative().toString()));
        event_type = Event.STANDARD_EVENT_TYPE.UNIT_IS_BEING_DEALT_DAMAGE;
        if (spellDmgOnly != null) {
            if (spellDmgOnly) {
                event_type = STANDARD_EVENT_TYPE.UNIT_IS_BEING_DEALT_SPELL_DAMAGE;
            }
        }
        if (physicalDmgOnly != null) {
            if (physicalDmgOnly) {
                event_type = STANDARD_EVENT_TYPE.UNIT_IS_BEING_DEALT_PHYSICAL_DAMAGE;
            }
        }
    }
    Targeting targeting_other_units = new AutoTargeting(new Conditions(new GroupCondition(Ref.KEYS.MATCH.name(), group), // negative
    new RefCondition(KEYS.EVENT_TARGET, KEYS.MATCH, true)));
    effects.add(new CustomTargetEffect(targeting_other_units, new DealDamageEffect(getDamageFormula(), GenericEnums.DAMAGE_TYPE.PURE)));
    /*
         * ensure there is no deadlock
		 */
    conditions = new Conditions();
    conditions.add(new NonTriggeredEventCondition());
    KEYS OBJ_REF = Ref.KEYS.EVENT_TARGET;
    conditions.add(new GroupCondition(OBJ_REF, group));
    // has the group...
    Ref REF = Ref.getCopy(ref);
    // REF.setTarget(null); // ???
    new AddTriggerEffect(event_type, conditions, OBJ_REF, effects).apply(REF);
    return true;
}
Also used : AutoTargeting(main.elements.targeting.AutoTargeting) Targeting(main.elements.targeting.Targeting) AutoTargeting(main.elements.targeting.AutoTargeting) NonTriggeredEventCondition(main.elements.conditions.standard.NonTriggeredEventCondition) STANDARD_EVENT_TYPE(main.game.logic.event.Event.STANDARD_EVENT_TYPE) RefCondition(main.elements.conditions.RefCondition) CustomTargetEffect(main.ability.effects.continuous.CustomTargetEffect) DealDamageEffect(eidolons.ability.effects.oneshot.DealDamageEffect) Effects(main.ability.effects.Effects) Conditions(main.elements.conditions.Conditions) AddTriggerEffect(eidolons.ability.effects.attachment.AddTriggerEffect) Ref(main.entity.Ref) GroupImpl(main.entity.group.GroupImpl) KEYS(main.entity.Ref.KEYS) AlteringEffect(eidolons.ability.effects.oneshot.misc.AlteringEffect) GroupCondition(main.elements.conditions.standard.GroupCondition)

Aggregations

Ref (main.entity.Ref)155 Unit (eidolons.entity.obj.unit.Unit)28 ObjType (main.entity.type.ObjType)23 Event (main.game.logic.event.Event)16 ArrayList (java.util.ArrayList)15 Obj (main.entity.obj.Obj)15 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)13 Coordinates (main.game.bf.Coordinates)13 Conditions (main.elements.conditions.Conditions)12 Formula (main.system.math.Formula)11 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)10 ModifyValueEffect (eidolons.ability.effects.common.ModifyValueEffect)9 PARAMETER (main.content.values.parameters.PARAMETER)9 DC_SpellObj (eidolons.entity.active.DC_SpellObj)8 Effects (main.ability.effects.Effects)8 AddBuffEffect (eidolons.ability.effects.attachment.AddBuffEffect)7 Wave (eidolons.game.battlecraft.logic.battle.arena.Wave)7 Effect (main.ability.effects.Effect)7 DC_HeroItemObj (eidolons.entity.item.DC_HeroItemObj)5 DC_QuickItemObj (eidolons.entity.item.DC_QuickItemObj)5