use of eidolons.entity.active.DC_UnitAction in project Eidolons by IDemiurge.
the class UnitDataSource method getWeaponDetail.
private List<ValueContainer> getWeaponDetail(DC_WeaponObj weapon) {
List<ValueContainer> result = new ArrayList<>();
if (weapon != null) {
for (DC_UnitAction el : weapon.getOrCreateAttackActions()) {
final ValueContainer valueContainer = new ValueContainer(getOrCreateR(el.getImagePath()));
AttackTooltip toolTip = AttackTooltipFactory.createAttackTooltip(el);
valueContainer.addListener(toolTip.getController());
result.add(valueContainer);
}
}
return result;
}
use of eidolons.entity.active.DC_UnitAction in project Eidolons by IDemiurge.
the class AttackTooltipFactory method createAttackTooltip.
public static AttackTooltip createAttackTooltip(DC_UnitAction el, boolean precalc, boolean costs, boolean additionalInfo, boolean combatMode, DC_Obj target) {
Pair<PARAMS, PARAMS> pair = ACTION_TOOLTIPS_PARAMS_MAP.get(ACTION_TOOLTIP_HEADER_KEY);
String name = ActionTooltipMaster.getStringForTableValue(ACTION_TOOLTIP_HEADER_KEY, el);
final String leftImage = ActionTooltipMaster.getIconPathForTableRow(pair.getLeft());
final String rightImage = ActionTooltipMaster.getIconPathForTableRow(pair.getRight());
MultiValueContainer head = new MultiValueContainer(name, leftImage, rightImage);
VALUE[] baseKeys = ACTION_TOOLTIP_BASE_KEYS;
final List<MultiValueContainer> base = extractActionValues(el, baseKeys);
baseKeys = ACTION_TOOLTIP_RANGE_KEYS;
final List<MultiValueContainer> range = extractActionValues(el, baseKeys);
List /*<List<MultiValueContainer>>*/
textsList = new ArrayList<>();
for (PARAMS[] params : ACTION_TOOLTIP_PARAMS_TEXT) {
textsList.add(Arrays.stream(params).map(p -> {
String textForTableValue = ActionTooltipMaster.getTextForTableValue(p, el);
textForTableValue = TextWrapper.wrapWithNewLine(textForTableValue, 50);
if (StringUtils.isEmpty(textForTableValue)) {
return null;
} else {
return new MultiValueContainer(textForTableValue, "");
}
}).filter(Objects::nonNull).collect(Collectors.toList()));
}
AttackTooltip toolTip = new AttackTooltip(el);
ValueContainer precalcRow = createPrecalcRow(precalc, el, target);
toolTip.setUserObject(new ActionTooltipSource() {
@Override
public MultiValueContainer getHead() {
return head;
}
@Override
public List<MultiValueContainer> getBase() {
return base;
}
@Override
public List<MultiValueContainer> getRange() {
return range;
}
@Override
public List<List<ValueContainer>> getText() {
return textsList;
}
@Override
public CostTableSource getCostsSource() {
return () -> ActionCostSourceImpl.getActionCostList(el);
}
@Override
public ValueContainer getPrecalcRow() {
return precalcRow;
}
});
return toolTip;
}
use of eidolons.entity.active.DC_UnitAction in project Eidolons by IDemiurge.
the class ThreatAnalyzer method getMeleeThreat.
public int getMeleeThreat(Unit enemy, boolean now) {
if (now) {
if (!enemy.canActNow() || !enemy.canAttack()) {
return 0;
}
}
int distance = 1 + PositionMaster.getDistance(getUnit(), enemy);
if (distance > 5)
return 0;
int threat = 0;
int factor = 1;
DC_UnitAction attack = enemy.getAction(DC_ActionManager.ATTACK);
if (attack == null) {
return 0;
}
DC_ActiveObj subAttack = (DC_ActiveObj) FuncMaster.getGreatestEntity(attack.getSubActions(), atk -> {
if (enemy.getIntParam(PARAMS.C_N_OF_ACTIONS) > atk.getIntParam(PARAMS.AP_COST))
return atk.getIntParam(PARAMS.AP_COST);
return 0;
});
DC_PriorityManager.toggleImplementation(new PriorityManagerImpl(getMaster()) {
@Override
public Unit getUnit() {
return enemy;
}
});
try {
threat = DC_PriorityManager.getAttackPriority(subAttack, getUnit()) * factor;
} catch (Exception e) {
main.system.ExceptionMaster.printStackTrace(e);
} finally {
DC_PriorityManager.toggleImplementation(null);
}
// special attacks? dual wielding?
threat /= distance;
main.system.auxiliary.log.LogMaster.log(1, getUnit() + " feels " + threat + " threat from " + enemy);
return threat;
}
use of eidolons.entity.active.DC_UnitAction in project Eidolons by IDemiurge.
the class DC_MovementManager method getMoves.
public static List<DC_ActiveObj> getMoves(Unit unit) {
List<DC_ActiveObj> moveActions = new ArrayList<>();
DequeImpl<DC_UnitAction> actions = unit.getActionMap().get(ActionEnums.ACTION_TYPE.SPECIAL_MOVE);
if (actions != null) {
moveActions = new ArrayList<>(Arrays.asList(actions.toArray(new DC_ActiveObj[actions.size()])));
}
if (moveActions.isEmpty()) {
moveActions.addAll(unit.getActionMap().get(ActionEnums.ACTION_TYPE.ADDITIONAL_MOVE));
} else {
for (DC_UnitAction a : unit.getActionMap().get(ActionEnums.ACTION_TYPE.ADDITIONAL_MOVE)) {
String name = a.getName();
switch(// have a switch to turn off all default moves!
name) {
case "Clumsy Leap":
if (!DataManager.toStringList(moveActions).contains("Leap")) {
moveActions.add(a);
}
continue;
case "Move Right":
case "Move Left":
if (!DataManager.toStringList(moveActions).contains("Sidestep Right")) {
moveActions.add(a);
}
continue;
}
moveActions.add(a);
}
}
moveActions.addAll(AiUnitActionMaster.getSpells(AiEnums.AI_LOGIC.MOVE, unit));
moveActions = DC_ActionManager.filterActionsByCanBePaid(moveActions);
return moveActions;
}
use of eidolons.entity.active.DC_UnitAction in project Eidolons by IDemiurge.
the class AttackTest method attackTest.
@Test
public void attackTest() {
assertTrue(source != null);
assertTrue(target != null);
int origToughness = target.getIntParam(PARAMS.C_TOUGHNESS);
int origEndurance = target.getIntParam(PARAMS.C_ENDURANCE);
assertTrue(source.getNaturalWeapon() != null);
DC_UnitAction attackAction = source.getAction("punch");
assertTrue(attackAction != null);
Eidolons.getGame().getGameLoop().actionInput(new ActionInput(attackAction, new Context(source, target)));
// old! attackAction.activateOn(target);
Boolean result = (Boolean) WaitMaster.waitForInput(WAIT_OPERATIONS.ACTION_COMPLETE);
assertTrue(result);
Integer newToughness = target.getIntParam(PARAMS.C_TOUGHNESS);
Integer newEndurance = target.getIntParam(PARAMS.C_ENDURANCE);
assertTrue(newToughness < origToughness);
assertTrue(newEndurance < origEndurance);
}
Aggregations