use of main.entity.obj.Attachment in project Eidolons by IDemiurge.
the class StateCloner method cloneAttachments.
private void cloneAttachments(DC_GameState state, DC_GameState clone) {
state.getAttachments().forEach(attachment -> {
Attachment a = cloneAttachment(attachment);
clone.getAttachments().add(a);
Obj basis = a.getBasis();
if (basis != null) {
MapMaster.addToListMap(clone.getAttachmentsMap(), basis, a);
}
});
}
use of main.entity.obj.Attachment in project Eidolons by IDemiurge.
the class BuffMaster method addAttachment.
public void addAttachment(Attachment attachment, Obj basis) {
List<Attachment> list = getState().getAttachmentsMap().get(basis);
if (list == null) {
list = new ArrayList<>();
getState().getAttachmentsMap().put(basis, list);
}
if (attachment instanceof BuffObj) {
basis.addBuff((BuffObj) attachment);
}
getState().addAttachment(attachment);
list.add(attachment);
if (// e.g. auras
attachment.isTransient()) {
return;
}
for (Effect e : attachment.getEffects()) {
// e.apply(basis.getRef()); // how to add retain conditions?
// else
// if (!(e instanceof AttachmentEffect))
getState().addEffect(e);
}
}
use of main.entity.obj.Attachment 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.obj.Attachment in project Eidolons by IDemiurge.
the class DC_BuffPanel method getData.
@Override
public Collection<DC_BuffObj> getData() {
if (obj == null) {
return getEmptyData();
}
DequeImpl<BuffObj> attachments = obj.getBuffs();
if (attachments == null) {
return getEmptyData();
}
if (attachments.isEmpty()) {
return getEmptyData();
}
data = new ArrayList<>();
for (Attachment attachment : attachments) {
if (attachment instanceof DC_BuffObj) {
data.add((DC_BuffObj) attachment);
}
}
return data;
}
use of main.entity.obj.Attachment in project Eidolons by IDemiurge.
the class DispelEffect method applyThis.
@Override
public boolean applyThis() {
for (Attachment attachment : game.getState().getAttachmentsMap().get(ref.getTargetObj())) {
if (!(attachment instanceof BuffObj)) {
continue;
}
BuffObj buff = (BuffObj) attachment;
if (!buff.isDispelable()) {
continue;
}
if (!friendlyFire) {
if (buff.getOwner().isMe()) {
continue;
}
}
if (positiveOnly) {
// if (buff.getBuffType() ==)
}
boolean result = true;
// Ref REF = Ref.getCopy(ref);
// REF.setTarget(buff.getId());
// REF.setID(KEYS.SUMMONER, buff.getOwnerObj()); // is it owner or
// // basis? ;)
//
// Roll roll = new Roll(ROLL_TYPES.DISPEL, chance.getInt(ref));
// result = RollMaster.roll(roll);
// TODO ROLL!
Integer amount = durationMod.getInt(ref);
buff.modifyDuration(amount);
}
return true;
}
Aggregations