Search in sources :

Example 26 with Ref

use of main.entity.Ref in project Eidolons by IDemiurge.

the class DialogueHandler method lineSpoken.

public void lineSpoken(DialogScenario actorObject) {
    Ref ref = new Ref(game);
    ref.setAmount(map.get(actorObject).getId());
    game.fireEvent(new Event(STANDARD_EVENT_TYPE.DIALOGUE_LINE_SPOKEN, ref));
}
Also used : Ref(main.entity.Ref) Event(main.game.logic.event.Event)

Example 27 with Ref

use of main.entity.Ref in project Eidolons by IDemiurge.

the class DialogueHandler method dialogueDone.

public void dialogueDone() {
    Ref ref = new Ref(game);
    ref.setValue(KEYS.STRING, dialogue.getName());
    game.fireEvent(new Event(STANDARD_EVENT_TYPE.DIALOGUE_FINISHED, ref));
}
Also used : Ref(main.entity.Ref) Event(main.game.logic.event.Event)

Example 28 with Ref

use of main.entity.Ref in project Eidolons by IDemiurge.

the class DC_RuleImpl method check.

@Override
public boolean check(Event event) {
    if (isOn())
        return false;
    if (event_types != null) {
        if (!Arrays.asList(event_types).contains(event.getType())) {
            return false;
        }
    } else {
        if (!getEventType().equals(event.getType())) {
            return false;
        }
    }
    if (conditions == null) {
        return true;
    }
    Ref ref = Ref.getCopy(event.getRef());
    ref.setEvent(event);
    LogMaster.log(LOG_CHANNEL.RULES_DEBUG, toString() + " checked on " + ref.getSourceObj());
    return conditions.preCheck(ref);
}
Also used : Ref(main.entity.Ref)

Example 29 with Ref

use of main.entity.Ref in project Eidolons by IDemiurge.

the class DC_MathManager method calculateClaimedObjects.

@Override
public int calculateClaimedObjects(Obj obj, String BF_OBJECT_TYPE) {
    Conditions conditions = ConditionMaster.getClaimedBfObjConditions(BF_OBJECT_TYPE);
    Ref ref = new Ref(game, obj.getId());
    int i = new Filter<>(ref, conditions).getObjects().size();
    PARAMETER param = ContentManager.getPARAM("CLAIMED_" + BF_OBJECT_TYPE + "S");
    obj.setParam(param, i);
    return i;
}
Also used : Ref(main.entity.Ref) Filter(main.elements.Filter) Conditions(main.elements.conditions.Conditions) PARAMETER(main.content.values.parameters.PARAMETER)

Example 30 with Ref

use of main.entity.Ref in project Eidolons by IDemiurge.

the class HC_Tree method updateText.

private void updateText() {
    textMap.clear();
    textBgPoint1 = null;
    textBgPoint2 = null;
    if (isViewMode()) {
        return;
    }
    if (Launcher.DEV_MODE) {
        if (CoreEngine.isArcaneVault()) {
            return;
        }
    }
    // TODO draw black background for this!
    if (isDisplayRequirements()) {
        boolean rank = false;
        if (reqTextType == null) {
            reqTextType = getSelectedType();
        } else {
            rank = true;
        }
        if (types.contains(reqTextType)) {
            Integer x = null;
            Integer y = map.getPointForType(reqTextType).y + 58;
            boolean above = false;
            boolean centered = false;
            Integer originX = null;
            if (y >= HT_MapBuilder.defTreeHeight - 130) {
                y = map.getPointForType(reqTextType).y - 20;
                above = true;
            }
            int mode = 0;
            // display SD ?
            if (rank) {
                mode = RequirementsManager.RANK_MODE;
            }
            Requirements reqs = reqTextType.getGame().getRequirementsManager().getRequirements((rank ? hero.getFeat(isSkill(), reqTextType) : reqTextType), mode);
            Point point;
            Color color = ColorManager.CRIMSON;
            Font font = getDefaultFont();
            List<String> list;
            if (reasons != null) {
                list = reasons;
            } else {
                Ref ref = new Ref(hero);
                ref.setMatch((reqTextType).getId());
                reqs.preCheck(ref);
                list = reqs.getReasons();
                reasons = new ArrayList<>();
            }
            for (String text : list) {
                if (text.equals(InfoMaster.NOT_ENOUGH_MASTERY)) {
                    text = InfoMaster.NOT_ENOUGH_MASTERY_SLOTS + ((SkillPointCondition) reqs.getReqMap().get(text)).getPointsRequired();
                }
                text = TextParser.parse(text, new Ref(getHero()));
                text = text.replace(StringMaster.MASTERY + " ", "");
                text = text.replace(" needed", "");
                text = text.replace(" required", "");
                if (!text.contains(" or ")) {
                    if (text.contains(": ")) {
                        String varPart = text.split(": ")[1];
                        if (varPart.startsWith("(") || StringMaster.isInteger("" + varPart.charAt(0))) {
                            String parsedVarPart = "";
                            try {
                                parsedVarPart = "" + new Formula(varPart).getInt(new Ref(getHero()));
                            } catch (Exception e) {
                                main.system.ExceptionMaster.printStackTrace(e);
                            }
                            if (!parsedVarPart.isEmpty()) // TextParser.parse(varPart, new
                            // Ref(getHero()));
                            {
                                text = text.replace(varPart, parsedVarPart);
                            }
                        }
                    }
                }
                reasons.add(text);
            }
            Collections.sort(reasons, new Comparator<String>() {

                public int compare(String o1, String o2) {
                    if (o1.length() < o2.length()) {
                        return 1;
                    }
                    if (o1.length() > o2.length()) {
                        return -1;
                    }
                    return 0;
                }
            });
            int stringWidth;
            for (String text : reasons) {
                SmartText smartText = new SmartText(text, color);
                smartText.setFont(font);
                stringWidth = FontMaster.getStringWidth(font, text);
                if (x == null) {
                    x = map.getPointForType(reqTextType).x;
                    if (x + stringWidth >= getPanel().getWidth() - 10) {
                        x = getPanel().getWidth() - stringWidth - 10;
                        originX = x;
                        centered = true;
                    }
                } else if (centered) {
                    x = originX;
                // x = stringWidth - originX / 2 + getPanel().getWidth()
                // - stringWidth / 2;
                }
                if (x == map.getPointForType(reqTextType).x) {
                    x = map.getPointForType(reqTextType).x - stringWidth / 4;
                }
                if (x < 0) {
                    x = 0;
                }
                if (above) {
                    y -= 20;
                } else {
                    y += 20;
                }
                if (x == null) {
                    x = map.getPointForType(reqTextType).x;
                }
                point = new Point(x, y);
                textMap.put(point, smartText);
                // TODO if above... vice versa
                if (textBgPoint1 == null) {
                    textBgPoint1 = new Point(x + stringWidth, y - FontMaster.getFontHeight(font));
                }
            }
            textBgPoint2 = new Point(x, y);
            if (above) {
                Point buffer = textBgPoint1;
                textBgPoint1 = new Point(textBgPoint2.x, textBgPoint2.y - FontMaster.getFontHeight(font));
                textBgPoint2 = new Point(buffer.x, buffer.y + FontMaster.getFontHeight(font));
            }
        // mouse map on reqs -> goto req-skill or so
        }
    }
    reasons = null;
    reqTextType = null;
}
Also used : SmartText(main.system.text.SmartText) Requirements(main.elements.conditions.Requirements) Formula(main.system.math.Formula) Ref(main.entity.Ref) SkillPointCondition(eidolons.ability.conditions.req.SkillPointCondition)

Aggregations

Ref (main.entity.Ref)155 Unit (eidolons.entity.obj.unit.Unit)28 ObjType (main.entity.type.ObjType)23 Event (main.game.logic.event.Event)16 ArrayList (java.util.ArrayList)15 Obj (main.entity.obj.Obj)15 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)13 Coordinates (main.game.bf.Coordinates)13 Conditions (main.elements.conditions.Conditions)12 Formula (main.system.math.Formula)11 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)10 ModifyValueEffect (eidolons.ability.effects.common.ModifyValueEffect)9 PARAMETER (main.content.values.parameters.PARAMETER)9 DC_SpellObj (eidolons.entity.active.DC_SpellObj)8 Effects (main.ability.effects.Effects)8 AddBuffEffect (eidolons.ability.effects.attachment.AddBuffEffect)7 Wave (eidolons.game.battlecraft.logic.battle.arena.Wave)7 Effect (main.ability.effects.Effect)7 DC_HeroItemObj (eidolons.entity.item.DC_HeroItemObj)5 DC_QuickItemObj (eidolons.entity.item.DC_QuickItemObj)5