Search in sources :

Example 76 with Ref

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

the class RaiseEffect method applyThis.

@Override
public boolean applyThis() {
    corpse = ref.getGame().getGraveyardManager().destroyTopCorpse(ref.getTargetObj().getCoordinates());
    humanoid = corpse.checkProperty(G_PROPS.CLASSIFICATIONS, "" + UnitEnums.CLASSIFICATIONS.HUMANOID);
    initUnitType();
    super.applyThis();
    // upkeep/sickness
    // perhaps it should be done via resurrect then...!
    Ref REF = Ref.getSelfTargetingRefCopy(unit);
    REF.setID(CORPSE_REF, corpse.getId());
    getRevenantBuff().apply(REF);
    if (isEquipItems(raiseType)) {
        equipOriginalItems();
    }
    // skeleton mage should have same spells!
    return true;
}
Also used : Ref(main.entity.Ref)

Example 77 with Ref

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

the class SpellMaster method initSpellpool.

private List<DC_SpellObj> initSpellpool(MicroObj obj, PROPERTY PROP) {
    List<DC_SpellObj> spells = new ArrayList<>();
    String spellList = obj.getProperty(PROP);
    List<String> spellpool;
    spellpool = StringMaster.openContainer(spellList);
    for (String typeName : spellpool) {
        Ref ref = Ref.getCopy(obj.getRef());
        ObjType type = DataManager.getType(typeName, DC_TYPE.SPELLS);
        if (type == null) {
            continue;
        }
        Map<ObjType, MicroObj> cache = spellCache.get(obj);
        if (cache == null) {
            cache = new HashMap<>();
            spellCache.put(obj, cache);
        }
        MicroObj spell = cache.get(type);
        if (spell == null) {
            spell = getGame().createSpell(type, obj, ref);
            cache.put(type, spell);
        }
        SPELL_POOL spellPool = new EnumMaster<SPELL_POOL>().retrieveEnumConst(SPELL_POOL.class, PROP.getName());
        if (spellPool != null) {
            spell.setProperty(G_PROPS.SPELL_POOL, spellPool.toString());
        } else {
            LogMaster.log(1, PROP.getName() + " spell pool not found for " + typeName);
        }
        spells.add((DC_SpellObj) spell);
    }
    return spells;
}
Also used : MicroObj(main.entity.obj.MicroObj) Ref(main.entity.Ref) ObjType(main.entity.type.ObjType) ArrayList(java.util.ArrayList) DC_SpellObj(eidolons.entity.active.DC_SpellObj) SPELL_POOL(main.content.enums.entity.SpellEnums.SPELL_POOL)

Example 78 with Ref

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

the class DC_StateManager method checkRules.

@Override
public void checkRules(Event e) {
    DequeImpl<DC_RuleImpl> triggerRules = getGame().getRules().getTriggerRules();
    if (triggerRules.size() == 0) {
        return;
    }
    for (Rule rule : triggerRules) {
        if (rule.isOn()) {
            if (rule.check(e)) {
                Ref ref = Ref.getCopy(e.getRef());
                ref.setEvent(e);
                rule.apply(ref);
            }
        }
    }
}
Also used : Ref(main.entity.Ref) DC_RuleImpl(eidolons.game.battlecraft.rules.DC_RuleImpl) RoundRule(eidolons.game.battlecraft.rules.round.RoundRule) Rule(main.game.logic.event.Rule) DC_CounterRule(eidolons.game.battlecraft.rules.counter.DC_CounterRule) DamageCounterRule(eidolons.game.battlecraft.rules.counter.DamageCounterRule)

Example 79 with Ref

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

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

the class DealDamageEffectTest method dealDamageEffectTest.

@Test
public void dealDamageEffectTest() {
    assertTrue(source != null);
    assertTrue(target != null);
    int origToughness = target.getIntParam(PARAMS.C_TOUGHNESS);
    int origEndurance = target.getIntParam(PARAMS.C_ENDURANCE);
    Effect eff = new DealDamageEffect(new Formula("50"), GenericEnums.DAMAGE_TYPE.BLUDGEONING.getName(), DAMAGE_MODIFIER.UNBLOCKABLE);
    Ref ref = new Ref(source);
    ref.setTarget(target.getId());
    ref.setID(KEYS.ACTIVE, source.getAction("Attack").getId());
    eff.apply(ref);
    Integer newToughness = target.getIntParam(PARAMS.C_TOUGHNESS);
    Integer newEndurance = target.getIntParam(PARAMS.C_ENDURANCE);
    assertTrue(newToughness < origToughness);
    assertTrue(newEndurance < origEndurance);
}
Also used : Formula(main.system.math.Formula) Ref(main.entity.Ref) DealDamageEffect(eidolons.ability.effects.oneshot.DealDamageEffect) Effect(main.ability.effects.Effect) DealDamageEffect(eidolons.ability.effects.oneshot.DealDamageEffect) FastDcTest(tests.FastDcTest) Test(org.junit.Test)

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