use of main.entity.Ref in project Eidolons by IDemiurge.
the class SummonEffect method applyThis.
@Override
public boolean applyThis() {
// TODO XP -> LEVEL!
Ref REF = Ref.getCopy(ref);
REF.setValue(KEYS.STRING, typeName);
ObjType type = DataManager.getType(typeName, getTYPE());
game.fireEvent(new Event(getEventType(), REF));
Coordinates c = ref.getTargetObj().getCoordinates();
if (type == null) {
String str = new Property(typeName, true).getStr(ref);
type = DataManager.getType(str);
}
if (type.getOBJ_TYPE_ENUM() != DC_TYPE.CHARS) {
type = addXp(type);
}
if (owner == null) {
owner = ref.getSourceObj().getOwner();
}
setUnit((BattleFieldObject) game.createUnit(type, c.x, c.y, owner, ref.getCopy()));
if (unit instanceof Unit) {
if (!((Unit) unit).isHero()) {
UnitTrainingMaster.train((Unit) unit);
}
}
getUnit().getRef().setID(KEYS.SUMMONER, ref.getSource());
REF.setID(KEYS.SUMMONED, getUnit().getId());
ref.setID(KEYS.SUMMONED, getUnit().getId());
game.fireEvent(new Event(getEventTypeDone(), REF));
unit.getRef().setID(KEYS.ACTIVE, ref.getId(KEYS.ACTIVE));
UpkeepRule.addUpkeep(unit);
if (unit instanceof Unit) {
SummoningSicknessRule.apply((Unit) unit);
}
if (effects != null) {
REF.setTarget(getUnit().getId());
return effects.apply(REF);
}
DC_SoundMaster.playEffectSound(SOUNDS.READY, unit);
return true;
}
use of main.entity.Ref in project Eidolons by IDemiurge.
the class BuffMaster method copyBuff.
public void copyBuff(BuffObj buff, Obj obj, Condition retainCondition) {
Ref REF = buff.getRef().getCopy();
REF.setBasis(obj.getId());
REF.setTarget(obj.getId());
createBuff(buff.getType(), buff.getActive(), buff.getOwner(), REF, buff.getEffect(), buff.getDuration(), Conditions.join(buff.getRetainConditions(), retainCondition));
}
use of main.entity.Ref in project Eidolons by IDemiurge.
the class BuffMaster method createBuff.
public BuffObj createBuff(BuffType type, Obj active, Player player, Ref ref, Effect effect, double duration, Condition retainCondition) {
ref = Ref.getCopy(ref);
if (type.getName().equals(BuffObj.DUMMY_BUFF_TYPE)) {
try {
String name = ref.getObj(KEYS.ACTIVE.name()).getName() + "'s buff";
String img = ref.getObj(KEYS.ACTIVE.name()).getProperty(G_PROPS.IMAGE);
type = new BuffType(type);
type.setProperty(G_PROPS.NAME, name);
type.setProperty(G_PROPS.IMAGE, img);
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
}
Obj basis = game.getObjectById(ref.getBasis());
if (basis == null) {
return null;
}
DC_BuffObj buff = (DC_BuffObj) basis.getBuff(type.getName());
if (buff != null) {
if (!type.checkBool(GenericEnums.STD_BOOLS.STACKING) && !active.checkBool(GenericEnums.STD_BOOLS.STACKING)) {
basis.removeBuff(type.getName());
// TODO duration or do nothing
} else {
if (buff.isMaxStacks()) {
return buff;
}
buff.modifyParameter(PARAMS.BUFF_STACKS, 1);
}
} else {
// preCheck cache
}
buff = new DC_BuffObj(type, player, getGame(), ref, effect, duration, retainCondition);
buff.setActive(active);
// be careful!
buff.applyEffect();
buffCreated(buff, basis);
if (type.checkBool(GenericEnums.STD_BOOLS.APPLY_THRU) || active.checkBool(GenericEnums.STD_BOOLS.APPLY_THRU)) {
buff.setAppliedThrough(true);
if (basis instanceof Unit) {
Ref REF = ref.getCopy();
Obj cell = game.getCellByCoordinate(basis.getCoordinates());
if (!cell.hasBuff(buff.getName())) {
REF.setBasis(cell.getId());
REF.setTarget(cell.getId());
// copy buff
Effect copy = effect.getCopy();
if (copy == null) {
LogMaster.error("APPLY THRU ERROR: " + effect + " HAS NO CONSTRUCT");
} else {
createBuff(type, active, player, REF, copy, duration, retainCondition).setAppliedThrough(true);
}
}
}
}
return buff;
}
use of main.entity.Ref in project Eidolons by IDemiurge.
the class DeathMaster method unitDies.
public void unitDies(DC_ActiveObj activeObj, Obj _killed, Obj _killer, boolean leaveCorpse, boolean quietly) {
if (_killed.isDead())
return;
String message = null;
if (_killed == _killer) {
// + _killed.getInfoString();
message = _killed + " dies ";
} else
message = _killed + " killed by " + _killer + " with " + activeObj;
SpecialLogger.getInstance().appendSpecialLog(SPECIAL_LOG.MAIN, message);
_killed.setDead(true);
BattleFieldObject killed = (BattleFieldObject) _killed;
BattleFieldObject killer = (BattleFieldObject) _killer;
Ref ref = Ref.getCopy(killed.getRef());
ref.setSource(killer.getId());
ref.setTarget(killed.getId());
for (AbilityObj abil : killed.getPassives()) {
abil.kill();
}
if (killed.getBuffs() != null) {
for (Attachment attach : killed.getBuffs()) {
if (!attach.isRetainAfterDeath()) {
getState().getAttachmentsMap().get(killed).remove(attach);
attach.remove();
}
}
}
if (!leaveCorpse) {
// leave a *ghost*?
// destroy items?
} else {
if (killed instanceof Unit) {
try {
getGame().getDroppedItemManager().dropDead((Unit) killed);
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
}
try {
getGame().getGraveyardManager().unitDies(killed);
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
}
// getGame().getBattleField().remove(killed); // TODO GRAVEYARD
if (!quietly) {
Ref REF = Ref.getCopy(killer.getRef());
REF.setTarget(killed.getId());
REF.setSource(killer.getId());
if (activeObj != null)
REF.setObj(KEYS.ACTIVE, activeObj);
if (killed instanceof Unit) {
getGame().getRules().getMoraleKillingRule().unitDied((Unit) killed, killer.getRef().getAnimationActive());
}
LogEntryNode node = game.getLogManager().newLogEntryNode(ENTRY_TYPE.DEATH, killed);
if (killer.getRef().getAnimationActive() != null) {
ANIM animation = killer.getRef().getAnimationActive().getAnimation();
if (animation != null) {
animation.addPhase(new AnimPhase(PHASE_TYPE.DEATH, killer, killed));
node.setLinkedAnimation(animation);
}
}
DC_SoundMaster.playEffectSound(SOUNDS.DEATH, killed);
game.getLogManager().logDeath(killed, killer);
getGame().fireEvent(new Event(STANDARD_EVENT_TYPE.UNIT_HAS_BEEN_KILLED, REF));
game.getLogManager().doneLogEntryNode();
} else {
GuiEventManager.trigger(GuiEventType.DESTROY_UNIT_MODEL, killed);
}
// refreshAll();
}
use of main.entity.Ref in project Eidolons by IDemiurge.
the class PrincipleMaster method fixParamBonuses.
private static void fixParamBonuses(ObjType type) {
String prop = type.getProperty(PROPS.PARAMETER_BONUSES);
Map<PARAMS, String> map = new RandomWizard<PARAMS>().constructStringWeightMap(prop, PARAMS.class);
Ref ref = new Ref(type.getGame());
ref.setID(KEYS.INFO, type.getId());
for (PARAMS param : map.keySet()) {
if (!(param.getName().contains(StringMaster.ALIGNMENT) || param.getName().contains(StringMaster.IDENTITY))) {
continue;
}
String string = map.get(param);
// string = TextParser.parse(string, ref,
// TextParser.INFO_PARSING_CODE);
// Ref.setInfoObject(type); TODO support {n} or is it useless?
int amount = StringMaster.getInteger(TextParser.parse(string, ref, TextParser.INFO_PARSING_CODE));
// if (param.getName().contains(StringMaster.ALIGNMENT)) {
//
// type.modifyParameter(param, amount);
// } else if (param.getName().contains(StringMaster.IDENTITY)) {
type.setParameter(param, amount);
String value = param.getName() + StringMaster.wrapInParenthesis(string + "");
type.removeProperty(PROPS.PARAMETER_BONUSES, value);
LogMaster.log(1, value + " move to parameter on " + type);
}
// TODO from prop to params
}
Aggregations