use of main.entity.Ref in project Eidolons by IDemiurge.
the class ArenaBattleConstructor method constructWaveSequence.
public Map<Wave, Integer> constructWaveSequence(ENCOUNTER_TYPE[] encounter_sequence) {
Integer round = getRoundNumber();
if (SkirmishMaster.isSkirmish()) {
return SkirmishMaster.constructWaveSequences(round);
}
Map<Wave, Integer> map = new XLinkedMap<>();
if (alt != null) {
alt = !alt;
} else {
alt = checkAltEncounter();
}
List<ObjType> waves = getWaveTypes(getDungeon().getType(), alt);
List<ObjType> waveBuffer = new ArrayList<>(waves);
for (ENCOUNTER_TYPE type : encounter_sequence) {
if (waveBuffer.isEmpty()) {
waveBuffer = DataManager.getTypesGroup(DC_TYPE.ENCOUNTERS, StringMaster.getWellFormattedString(type.toString()));
}
waves = new ArrayList<>(waveBuffer);
Conditions conditions = new Conditions(getEncounterTypeCondition(type));
List<ObjType> filteredWaves = new Filter<ObjType>(game, conditions).filter(waves);
if (!filteredWaves.isEmpty()) {
waves = filteredWaves;
} else {
continue;
}
ObjType waveType = getWaveType(waves, type);
waveType = new ObjType(waveType);
FACING_DIRECTION side = null;
// getMaster().getDungeonMaster().getPositioner().nextSide();
waveType.setProperty(PROPS.SPAWNING_SIDE, side.getName());
Coordinates c = pickSpawnCoordinateForWave(type, round, waveType);
Wave wave = new Wave(c, waveType, game, new Ref(game), game.getPlayer(false));
wave.initUnitMap();
map.put(wave, round);
if (Eidolons.DEV_MODE) {
game.getLogManager().logInfo(wave.toString() + " on round #" + round);
}
LogMaster.log(1, wave.toString() + " on round #" + round);
// TODO subtract from
round += getRoundsToFight(waveType, type);
// total pool
}
setIndex(getIndex() + 1);
return map;
}
use of main.entity.Ref in project Eidolons by IDemiurge.
the class FutureBuilder method getDamage.
public static int getDamage(DC_ActiveObj active, Obj targetObj, Effect e, Boolean min_max_normal) {
Integer damage;
Ref ref = active.getOwnerObj().getRef().getCopy();
ref.setTarget(targetObj.getId());
ref.setID(KEYS.ACTIVE, active.getId());
e.setRef(ref);
if (e instanceof DealDamageEffect) {
ref.setAmount(e.getFormula().getInt(ref));
if (((DealDamageEffect) e).getDamageType() != null) {
ref.setValue(KEYS.DAMAGE_TYPE, ((DealDamageEffect) e).getDamageType().toString());
}
damage = DamageCalculator.precalculateDamage(ref);
} else {
Attack attack = ((AttackEffect) e).initAttack();
// attack.setAttacked((DC_HeroObj) targetObj);
Map<String, Integer> _cache = getCache(min_max_normal);
damage = _cache.get(getCacheKey(active, targetObj));
if (damage == null) {
damage = DamageCalculator.precalculateDamage(attack, min_max_normal);
_cache.put(getCacheKey(active, targetObj), damage);
}
}
// active.toBase();
LogMaster.log(1, active.getName() + " on " + targetObj.getName() + " - damage precalculated: " + damage);
return damage;
}
use of main.entity.Ref in project Eidolons by IDemiurge.
the class ListEditor method launch.
@Override
public String launch(String value, String name) {
if (listData == null && !listDataSet) {
if (res_name != null) {
listData = ResourceManager.getFilesInFolder(res_name);
// StringMaster.formatResList(listData);
Collections.sort(listData);
} else if (ENUM) {
// TODO get enum class by name (constants)
if (enumClass != null) {
listData = EnumMaster.getEnumConstantNames(enumClass);
} else {
Class<?> ENUM_CLASS = EnumMaster.getEnumClass(name);
if (// TODO find
ENUM_CLASS == null) {
ENUM_CLASS = EnumMaster.getEnumClass(name, MACRO_CONTENT_CONSTS.class);
}
listData = EnumMaster.getEnumConstantNames(ENUM_CLASS);
StringMaster.formatList(listData);
}
} else {
if (TYPE == null) {
TYPE = DC_TYPE.ABILS;
subgroup = name;
if (!XML_Reader.getSubGroups(TYPE.toString()).contains(subgroup)) {
Err.info("No subgroup found! - " + subgroup);
}
if (getBASE_TYPE() instanceof DC_TYPE) {
switch((DC_TYPE) getBASE_TYPE()) {
case BF_OBJ:
TYPE = DC_TYPE.ACTIONS;
subgroup = null;
break;
case CHARS:
TYPE = DC_TYPE.ACTIONS;
subgroup = null;
break;
case UNITS:
TYPE = DC_TYPE.ACTIONS;
subgroup = null;
break;
}
}
}
listData = DataManager.getTypeNamesGroup(TYPE, subgroup);
if (filterGroup != null) {
listData = DataManager.getTypeNamesGroup(TYPE, filterGroup);
} else if (filterSubgroup != null) {
listData = DataManager.getTypesSubGroupNames(TYPE, filterSubgroup);
}
if (getConditions() != null) {
Ref ref = new Ref(Game.game, getEntity().getId());
listData = DataManager.toStringList(new Filter<ObjType>(ref, getConditions()).filter(DataManager.toTypeList(listData, TYPE)));
}
}
}
ListChooser listChooser;
if (mode == SELECTION_MODE.SINGLE) {
listChooser = new ListChooser(listData, ENUM, TYPE);
} else {
secondListData = new ArrayList<>();
if (value != null) {
if (!value.equals(ContentManager.getDefaultEmptyValue())) {
secondListData = ListMaster.toList(value.toString(), ENUM);
}
}
listChooser = new ListChooser(listData, secondListData, ENUM, TYPE);
}
if (ENUM || TYPE == DC_TYPE.UNITS || TYPE == DC_TYPE.CHARS || TYPE == DC_TYPE.DEITIES) {
columns = 1;
}
listChooser.setColumns(columns);
listChooser.setVarTypes(getVarTypes());
listChooser.setVarClass(getVarTypesClass());
String newValue = listChooser.getString();
return newValue;
}
use of main.entity.Ref in project Eidolons by IDemiurge.
the class EntityChoiceView method initData.
protected void initData() {
if (list != null) {
// empty?
if (list.get(0) instanceof ObjType) {
data = new ArrayList<>(new DequeImpl<ObjType>().getAddAllCast(list));
} else {
// TODO
}
} else {
if (getGroup() != null) {
data = DataManager.getFilteredTypes(getGroup(), getTYPE(), getFilterValue());
} else {
data = DataManager.getTypes(getTYPE());
}
Ref ref = new Ref(DC_Game.game);
if (hero != null) {
ref = Ref.getCopy(hero.getRef());
}
if (getFilterOption() != null) {
WORKSPACE_GROUP ws = new EnumMaster<WORKSPACE_GROUP>().retrieveEnumConst(WORKSPACE_GROUP.class, getFilterOption());
data = new Filter<ObjType>(ref, ConditionMaster.getWorkspaceCondition(true, ws)).filter(data);
}
if (getFilterConditions() != null) {
data = new Filter<ObjType>(ref, getFilterConditions()).filter(data);
}
}
sortData();
}
use of main.entity.Ref in project Eidolons by IDemiurge.
the class BindingDamageEffect method applyThis.
@Override
public boolean applyThis() {
// Can be initialized() just once
GroupImpl group = ref.getGroup();
Effects effects = new Effects();
STANDARD_EVENT_TYPE event_type;
if (shareOrRedirect) {
// TODO splitMode!
event_type = STANDARD_EVENT_TYPE.UNIT_IS_DEALT_TOUGHNESS_DAMAGE;
if (spellDmgOnly != null) {
if (spellDmgOnly) {
event_type = STANDARD_EVENT_TYPE.UNIT_HAS_BEEN_DEALT_SPELL_DAMAGE;
}
}
if (physicalDmgOnly != null) {
if (physicalDmgOnly) {
event_type = STANDARD_EVENT_TYPE.UNIT_HAS_BEEN_DEALT_PHYSICAL_DAMAGE;
}
}
} else {
effects.add(new AlteringEffect(false, formula.getNegative().toString()));
event_type = Event.STANDARD_EVENT_TYPE.UNIT_IS_BEING_DEALT_DAMAGE;
if (spellDmgOnly != null) {
if (spellDmgOnly) {
event_type = STANDARD_EVENT_TYPE.UNIT_IS_BEING_DEALT_SPELL_DAMAGE;
}
}
if (physicalDmgOnly != null) {
if (physicalDmgOnly) {
event_type = STANDARD_EVENT_TYPE.UNIT_IS_BEING_DEALT_PHYSICAL_DAMAGE;
}
}
}
Targeting targeting_other_units = new AutoTargeting(new Conditions(new GroupCondition(Ref.KEYS.MATCH.name(), group), // negative
new RefCondition(KEYS.EVENT_TARGET, KEYS.MATCH, true)));
effects.add(new CustomTargetEffect(targeting_other_units, new DealDamageEffect(getDamageFormula(), GenericEnums.DAMAGE_TYPE.PURE)));
/*
* ensure there is no deadlock
*/
conditions = new Conditions();
conditions.add(new NonTriggeredEventCondition());
KEYS OBJ_REF = Ref.KEYS.EVENT_TARGET;
conditions.add(new GroupCondition(OBJ_REF, group));
// has the group...
Ref REF = Ref.getCopy(ref);
// REF.setTarget(null); // ???
new AddTriggerEffect(event_type, conditions, OBJ_REF, effects).apply(REF);
return true;
}
Aggregations