Search in sources :

Example 6 with DC_UnitAction

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;
}
Also used : ArrayList(java.util.ArrayList) AttackTooltip(eidolons.libgdx.gui.panels.dc.unitinfo.tooltips.AttackTooltip) VerticalValueContainer(eidolons.libgdx.gui.generic.VerticalValueContainer) ValueContainer(eidolons.libgdx.gui.generic.ValueContainer) DC_UnitAction(eidolons.entity.active.DC_UnitAction)

Example 7 with DC_UnitAction

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;
}
Also used : UNIT_INFO_PARAMS(eidolons.content.UNIT_INFO_PARAMS) Arrays(java.util.Arrays) PARAMS(eidolons.content.PARAMS) TextWrapper(main.system.text.TextWrapper) MultiValueContainer(eidolons.libgdx.gui.panels.dc.unitinfo.MultiValueContainer) StringUtils(org.apache.commons.lang3.StringUtils) Function(java.util.function.Function) ActionCostSourceImpl(eidolons.libgdx.gui.panels.dc.actionpanel.datasource.ActionCostSourceImpl) ArrayList(java.util.ArrayList) Pair(org.apache.commons.lang3.tuple.Pair) FutureBuilder(eidolons.game.battlecraft.ai.tools.future.FutureBuilder) Tooltip(eidolons.libgdx.gui.tooltips.Tooltip) G_PROPS(main.content.values.properties.G_PROPS) DC_Obj(eidolons.entity.obj.DC_Obj) DC_UnitAction(eidolons.entity.active.DC_UnitAction) ValueContainer(eidolons.libgdx.gui.generic.ValueContainer) Obj(main.entity.obj.Obj) Collectors(java.util.stream.Collectors) ImageManager(main.system.images.ImageManager) Objects(java.util.Objects) List(java.util.List) TextureCache(eidolons.libgdx.texture.TextureCache) ValueTooltip(eidolons.libgdx.gui.tooltips.ValueTooltip) DAMAGE_TYPE(main.content.enums.GenericEnums.DAMAGE_TYPE) VALUE(main.content.VALUE) ArrayList(java.util.ArrayList) VALUE(main.content.VALUE) MultiValueContainer(eidolons.libgdx.gui.panels.dc.unitinfo.MultiValueContainer) Objects(java.util.Objects) ArrayList(java.util.ArrayList) List(java.util.List) UNIT_INFO_PARAMS(eidolons.content.UNIT_INFO_PARAMS) PARAMS(eidolons.content.PARAMS) MultiValueContainer(eidolons.libgdx.gui.panels.dc.unitinfo.MultiValueContainer) ValueContainer(eidolons.libgdx.gui.generic.ValueContainer)

Example 8 with DC_UnitAction

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;
}
Also used : Context(main.game.logic.action.context.Context) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) DC_UnitAction(eidolons.entity.active.DC_UnitAction) DC_AttackMaster(eidolons.game.battlecraft.rules.combat.attack.DC_AttackMaster) PARAMS(eidolons.content.PARAMS) AiHandler(eidolons.game.battlecraft.ai.elements.generic.AiHandler) HashMap(java.util.HashMap) AiMaster(eidolons.game.battlecraft.ai.elements.generic.AiMaster) FuncMaster(main.system.math.FuncMaster) AttackCalculator(eidolons.game.battlecraft.rules.combat.attack.AttackCalculator) UnitAI(eidolons.game.battlecraft.ai.UnitAI) Map(java.util.Map) DC_ActionManager(eidolons.entity.active.DC_ActionManager) Unit(eidolons.entity.obj.unit.Unit) DC_SpellObj(eidolons.entity.active.DC_SpellObj) PositionMaster(main.system.math.PositionMaster) DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) Unit(eidolons.entity.obj.unit.Unit) DC_UnitAction(eidolons.entity.active.DC_UnitAction)

Example 9 with DC_UnitAction

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;
}
Also used : DC_ActiveObj(eidolons.entity.active.DC_ActiveObj) DC_UnitAction(eidolons.entity.active.DC_UnitAction)

Example 10 with DC_UnitAction

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);
}
Also used : Context(main.game.logic.action.context.Context) ActionInput(eidolons.game.core.ActionInput) DC_UnitAction(eidolons.entity.active.DC_UnitAction) Test(org.junit.Test)

Aggregations

DC_UnitAction (eidolons.entity.active.DC_UnitAction)22 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)10 ArrayList (java.util.ArrayList)10 Unit (eidolons.entity.obj.unit.Unit)4 Obj (main.entity.obj.Obj)3 PARAMS (eidolons.content.PARAMS)2 DC_SpellObj (eidolons.entity.active.DC_SpellObj)2 DC_Obj (eidolons.entity.obj.DC_Obj)2 Action (eidolons.game.battlecraft.ai.elements.actions.Action)2 ValueContainer (eidolons.libgdx.gui.generic.ValueContainer)2 Ref (main.entity.Ref)2 ObjType (main.entity.type.ObjType)2 Coordinates (main.game.bf.Coordinates)2 Context (main.game.logic.action.context.Context)2 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)1 FacingCondition (eidolons.ability.conditions.FacingCondition)1 ModifyValueEffect (eidolons.ability.effects.common.ModifyValueEffect)1 ActivateEffect (eidolons.ability.effects.oneshot.activation.ActivateEffect)1 UNIT_INFO_PARAMS (eidolons.content.UNIT_INFO_PARAMS)1 DC_ActionManager (eidolons.entity.active.DC_ActionManager)1