use of main.entity.Ref in project Eidolons by IDemiurge.
the class EncounterMaster method getWaveSequence.
private static Map<Wave, Integer> getWaveSequence(Encounter e) {
Map<Wave, Integer> waves = new XLinkedMap<>();
int i = 0;
for (String typeName : StringMaster.open(e.getTypeNames())) {
ObjType waveType = DataManager.getType(typeName, DC_TYPE.ENCOUNTERS);
Wave wave = new Wave(waveType, DC_Game.game, new Ref(), DC_Game.game.getPlayer(false));
// TODO is the field ready for coordinates?
wave.initUnitMap();
int j = i;
// + DC_Game.game.getBattleMaster().getBattleConstructor().getRoundsToFight(
// waveType);
Integer round = RandomWizard.getRandomIntBetween(i, j);
i += round;
waves.put(wave, round);
}
return waves;
}
use of main.entity.Ref in project Eidolons by IDemiurge.
the class PatrolMaster method getWaitAction.
private static Action getWaitAction(Patrol patrol, UnitAI ai) {
Unit unit = ai.getUnit();
Unit blocker = getBlockingUnit(patrol, ai);
if (blocker == null) {
return null;
}
Ref ref = new Ref(unit);
ref.setTarget(blocker.getId());
new Action(ai.getUnit().getAction("Wait"), ref);
return null;
}
use of main.entity.Ref in project Eidolons by IDemiurge.
the class SimulationManager method createUnit.
public static void createUnit(ObjType type) {
if (unitMap.containsKey(type)) {
return;
}
Unit unit = new Unit(type, 0, 0, DC_Player.NEUTRAL, getGame(), new Ref(getGame()));
getGame().getState().addObject(unit);
try {
resetUnit(unit);
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
}
unitMap.put(type, unit);
}
use of main.entity.Ref in project Eidolons by IDemiurge.
the class InterruptEffect method applyThis.
@Override
public boolean applyThis() {
// }
if (ref.getEvent() == null) {
return false;
}
Ref REF = ref.getEvent().getRef();
Interruptable i = REF.getEffect();
// if (OBJ_REF != null) {
i = (Interruptable) REF.getObj(KEYS.ACTIVE);
// }
if (i == null) {
return false;
}
i.setInterrupted(true);
return true;
}
use of main.entity.Ref in project Eidolons by IDemiurge.
the class EffectImpl method apply.
@Override
public boolean apply(Ref ref) {
setRef(ref);
// for logging
boolean active = getLayer() != BUFF_RULE && ref.getObj(KEYS.ACTIVE) != null && (!(ref.getObj(KEYS.ABILITY) instanceof PassiveAbilityObj));
if ((ref.getGroup() == null && targetGroup == null) || isIgnoreGroupTargeting()) {
// single-target effect
return apply();
} else {
// multi-target effect, applies to each target
GroupImpl group = ref.getGroup();
if (group == null) {
group = targetGroup;
} else if (targetGroup == null) {
// group.setIgnoreGroupTargeting(true);// TODO later instead?
targetGroup = group;
}
if (group.isIgnoreGroupTargeting()) {
return apply();
}
List<Integer> groupIds = group.getObjectIds();
boolean result = true;
for (Integer id : groupIds) {
if (isInterrupted()) {
break;
}
Ref REF = this.ref.getCopy();
// REF.setGroup(new GroupImpl(targetGroup));
REF.getGroup().setIgnoreGroupTargeting(true);
REF.setTarget(id);
if (construct != null) {
result &= getCopy().apply(REF);
} else {
// this.ref.setTarget(id);
setIgnoreGroupTargeting(true);
result &= apply(REF);
setIgnoreGroupTargeting(false);
}
}
// game.getManager().refreshAll();
return result;
}
}
Aggregations