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;
}
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;
}
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);
}
}
}
}
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;
}
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);
}
Aggregations