use of main.game.logic.event.Event in project Eidolons by IDemiurge.
the class Costs method pay.
@Override
public boolean pay(Ref ref) {
setRef(ref);
boolean result = true;
for (Cost cost : costs) {
if (cost != null) {
result &= cost.pay(this.ref);
}
}
game.fireEvent(new Event(STANDARD_EVENT_TYPE.COSTS_HAVE_BEEN_PAID, ref));
return result;
}
use of main.game.logic.event.Event in project Eidolons by IDemiurge.
the class DataModel method fireParamEvent.
public boolean fireParamEvent(PARAMETER param, String amount, CONSTRUCTED_EVENT_TYPE event_type) {
if (!isValueEventsOn(param.getName())) {
return true;
}
if (param.isMastery()) {
// TODO [PERFORMANCE] DEMANDS...
return true;
}
if (ref == null || !getGame().isStarted() || getGame().isSimulation() || this instanceof ObjType) {
return true;
}
Ref REF = Ref.getCopy(ref);
REF.setAmount(amount);
REF.setTarget(id);
return getGame().fireEvent(new Event(event_type, "" + param, REF));
}
use of main.game.logic.event.Event in project Eidolons by IDemiurge.
the class ChangeFacingEffect method applyThis.
@Override
public boolean applyThis() {
if (!(ref.getTargetObj() instanceof Unit)) {
return false;
}
Unit obj = (Unit) ref.getTargetObj();
FACING_DIRECTION oldDirection = obj.getFacing();
FACING_DIRECTION newDirection = null;
if (isClockwise() == null) {
for (FACING_DIRECTION f : FACING_DIRECTION.values()) {
Obj active = ref.getObj(KEYS.ACTIVE);
if (active == null) {
return false;
}
if (FacingMaster.getSingleFacing(f, obj, (BfObj) active.getRef().getTargetObj()) == UnitEnums.FACING_SINGLE.IN_FRONT) {
newDirection = f;
break;
}
}
} else {
newDirection = FacingMaster.rotate(oldDirection, isClockwise());
}
obj.setFacing(newDirection);
game.fireEvent(new Event(getEventTypeDone(), ref));
return true;
}
use of main.game.logic.event.Event in project Eidolons by IDemiurge.
the class WaitEffect method applyThis.
@Override
public boolean applyThis() {
if (ref.getTargetObj() == ref.getSourceObj()) {
ref.getGame().fireEvent(new Event(STANDARD_EVENT_TYPE.UNIT_WAITS, game));
return true;
}
Ref REF = Ref.getCopy(ref);
REF.setValue(KEYS.TARGET2, ref.getTarget() + "");
REF.setTarget(ref.getSource());
boolean result = new AddBuffEffect(getRetainConditions(), getBuffName(), getEffects(REF)).apply(REF);
if (!result) {
return false;
}
try {
WaitRule.addWaitingUnit((Unit) ref.getSourceObj(), (Unit) ref.getTargetObj());
} catch (Exception e) {
return false;
}
return result;
}
use of main.game.logic.event.Event 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;
}
Aggregations