Search in sources :

Example 1 with CombatInfo

use of com.ixale.starparse.domain.CombatInfo in project StarParse by Ixale.

the class MainPresenter method updateCombatOverview.

private void updateCombatOverview(final Combat combat, final CombatStats stats, final int combatCount) {
    final CombatInfo combatInfo = context.getCombatInfo().get(combat.getCombatId());
    combatName.setText((combatInfo != null && combatInfo.getLocationInfo() != null && combatInfo.getLocationInfo().getInstanceName() != null ? combatInfo.getLocationInfo().getInstanceName() + ": " : "") + Format.formatCombatName(combat));
    // discipline
    combatTime.setText((stats.getDiscipline() != null ? stats.getDiscipline() + " " : "") + Format.formatCombatTime(combat));
    // Image icon = null;
    // if (combat != null && combat.getDiscipline() != null) {
    // icon = BaseStatsPresenter.getDisciplineIcon(combat.getDiscipline());
    // }
    // if (icon != null) {
    // if (disciplineIcon == null) {
    // disciplineIcon = new ImageView();
    // disciplineIcon.setFitHeight(20);
    // disciplineIcon.setFitWidth(20);
    // }
    // disciplineIcon.setImage(icon);
    // combatTime.setGraphic(disciplineIcon);
    // } else {
    // combatTime.setGraphic(null);
    // }
    apm.setText(Format.formatFloat(stats.getApm()));
    time.setText((combatCount > 1 ? "(" + combatCount + ") " : "") + Format.formatTime(stats.getTick()));
    dps.setText(Format.formatAdaptive(stats.getDps()));
    damage.setText(Format.formatMillions(stats.getDamage()));
    hps.setText(Format.formatAdaptive(stats.getHps()));
    heal.setText(Format.formatMillions(stats.getHeal()));
    ehps.setText(Format.formatAdaptive(stats.getEhps()));
    ehpsPercent.setText(Format.formatNumber(stats.getEhpsPercent()) + " %");
    tps.setText(Format.formatAdaptive(stats.getTps()));
    threat.setText(Format.formatMillions(stats.getThreat()));
    aps.setText(Format.formatAdaptive(stats.getAps()));
    absorbed.setText(Format.formatMillions(stats.getAbsorbed()));
    dtps.setText(Format.formatAdaptive(stats.getDtps()));
    damageTaken.setText(Format.formatMillions(stats.getDamageTaken()));
    healTaken.setText(Format.formatMillions(stats.getHealTaken()));
    hpsTaken.setText(Format.formatAdaptive(stats.getHpsTaken()));
    ehpsTaken.setText(Format.formatAdaptive(stats.getEhpsTaken()));
    ehpsTakenPercent.setText(Format.formatNumber(stats.getEhpsTakenPercent()) + " %");
}
Also used : CombatInfo(com.ixale.starparse.domain.CombatInfo)

Example 2 with CombatInfo

use of com.ixale.starparse.domain.CombatInfo in project StarParse by Ixale.

the class Parser method processEventCombat.

public void processEventCombat(final Event e) {
    // resolve combat
    if (combatConnectLimit != null && combatConnectLimit < e.getTimestamp()) {
        // window expired, close the running combat for good
        closeCurrentCombat();
    }
    final ActorState ac = actorStates.get(e.getSource());
    if (isEffectEnterCombat(e) && !isSourceOtherPlayer(e)) /* safety vor v7+ */
    {
        if (combatConnectLimit != null) {
            // within limit, reopen last combat
            combat.setEventIdTo(null);
            combat.setTimeTo(null);
            combatConnectLimit = null;
        } else if (combat != null) {
            // sometimes new combat is created even without exiting the previous one
            if (logger.isDebugEnabled()) {
                logger.debug("New combat was entered without exiting the previous one, silently connecting");
            }
        } else {
            // setup new combat
            combat = new Combat(++combatId, combatLogId, e.getTimestamp(), e.getEventId());
            context.getCombatInfo().put(combat.getCombatId(), new CombatInfo(new LocationInfo(instanceMode, instanceSize, instanceName, instanceGuid)));
            for (final Actor a : actorStates.keySet()) {
                // might have re-specced
                actorStates.get(a).role = null;
                actorStates.get(a).discipline = null;
            }
            if (isUsingMimCrystal) {
                context.addCombatEvent(combat.getCombatId(), e.getSource(), Event.Type.NIM_CRYSTAL, e.getTimestamp());
            }
            // assemble combat players; make sure SELF is there
            for (Map.Entry<Actor, ActorState> entry : actorStates.entrySet()) {
                entry.getValue().combatTotalThreat = 0;
                if (Actor.Type.SELF.equals(entry.getKey().getType())) {
                    context.addCombatPlayer(combat, entry.getKey(), entry.getKey().getDiscipline());
                    break;
                }
            }
        }
    } else if (combat != null && combatConnectLimit == null && (isEffectExitCombat(e) || (isTargetThisPlayer(e) && isEffectDeath(e)) || isEffectLoginImmunity(e))) {
        // exit event detected (and no window is set yet), setup candidates
        combat.setEventIdTo(e.getEventId());
        combat.setTimeTo(e.getTimestamp());
        if (isEffectExitCombat(e)) {
            context.addCombatEvent(combat.getCombatId(), e.getSource(), Event.Type.COMBAT_EXIT, e.getTimestamp());
        }
        // ... and setup limit for either revive or quick reconnect (and for lagged damage and healing)
        combatConnectLimit = e.getTimestamp() + (isEffectDeath(e) ? // died - setup REVIVE limit
        COMBAT_REVIVE_WINDOW : ((lastCombatDropEvent != null && (lastCombatDropEvent.getTimestamp() > (e.getTimestamp() - COMBAT_RETURN_WINDOW)) ? // recent (yet already consumed) combat drop event - "drop->enter->exit[now]->?enter" sequence can happen - setup RETURN window
        COMBAT_RETURN_WINDOW : // just regular window for delayed damage/healing events
        COMBAT_DELAY_WINDOW)));
    } else if (combat != null && combatConnectLimit != null) {
        if (isTargetThisPlayer(e) && isEffectRevive(e)) {
            // revived within REVIVE limit, setup RETURN limit and keep waiting
            combatConnectLimit = e.getTimestamp() + COMBAT_RETURN_WINDOW;
        } else if (isTargetThisPlayer(e) && isEffectCombatDrop(e)) {
            // combat drop detected within DELAY window, setup RETURN limit and keep waiting
            combatConnectLimit = e.getTimestamp() + COMBAT_RETURN_WINDOW;
            // all combat drops are suspicious as you can drop, enter, kill/discard add, exit combat and then enter again (e.g. Raptus challenge)
            lastCombatDropEvent = e;
        } else if (isSourceThisPlayer(e) && e.getValue() != null && (e.getThreat() != null || isEffectDamage(e))) {
            // gracefully include any delayed damage/healing abilities
            // (after dying, DOTs can be still ticking, although causing no threat)
            combat.setEventIdTo(e.getEventId());
        // combat.setTimeTo(e.getTimestamp()); // do not extend, keep the original time
        }
    }
    if (combat != null && isEffectDeath(e)) {
        context.addCombatEvent(combat.getCombatId(), e.getTarget(), Event.Type.DEATH, e.getTimestamp());
    }
    // resolve effective threat
    if (combat != null && ac != null && e.getThreat() != null) {
        if (ac.combatTotalThreat + e.getThreat() < 0) {
            e.setEffectiveThreat(ac.combatTotalThreat * -1);
            ac.combatTotalThreat = 0;
        } else {
            e.setEffectiveThreat(e.getThreat());
            ac.combatTotalThreat += e.getThreat();
        }
    }
    // resolve combat phase (ignore target set/cleared to avoid confusion)
    if (combat != null && combat.getBoss() != null && !(e.getEffect() != null && (e.getEffect().getGuid().equals(EntityGuid.TargetSet.getGuid()) || e.getEffect().getGuid().equals(EntityGuid.TargetCleared.getGuid())))) {
        final String newBossPhaseName;
        if ((newBossPhaseName = combat.getBoss().getRaid().getNewPhaseName(e, combat, currentBossPhase != null ? currentBossPhase.getName() : null)) != null) {
            // new phase detected
            if (currentBossPhase != null) {
                // close old - bounds are explicitly as <from, to)
                closePhase(currentBossPhase, e.getEventId() - 1, e.getTimestamp() - combat.getTimeFrom() - 1);
            }
            // setup new (if this is the very first one, assume it started at the beginning of this combat)
            currentBossPhase = new Phase(++phaseId, newBossPhaseName, Phase.Type.BOSS, combat.getCombatId(), (currentBossPhase == null ? combat.getEventIdFrom() : e.getEventId()), (currentBossPhase == null ? 0 : e.getTimestamp() - combat.getTimeFrom()));
        }
        if (combatBossUpgrade != null && e.getAbility() != null && e.getAbility().getGuid() != null) {
            resolveCombatUpgrade(combatBossUpgrade.upgradeByAbility(e.getAbility().getGuid(), e.getEffect().getGuid(), e.getValue()), false);
        }
    }
    // resolve damage phase
    if (combat != null && isSourceThisPlayer(e) && isEffectDamage(e) && e.getValue() > 0) {
        if (firstDamageEvent == null) {
            // open new damage phase
            firstDamageEvent = e;
        } else if (lastDamageEvent != null && (lastDamageEvent.getTimestamp() + PHASE_DAMAGE_WINDOW < e.getTimestamp())) {
            // close damage phase and open new one
            createDamagePhase(firstDamageEvent, lastDamageEvent);
            lastDamageEvent = null;
            firstDamageEvent = e;
        } else {
            // prolong current damage phase
            lastDamageEvent = e;
        }
    }
    // resolve discipline
    if (combat != null && ac != null && ac.discipline == null) {
        if (!ac.isDualWield && isEffectDualWield(e)) {
            ac.isDualWield = true;
        }
        if (isEffectAbilityActivate(e)) {
            ac.discipline = getDiscipline(e.getAbility().getGuid(), ac.isDualWield);
            if (ac.discipline != null) {
                ac.role = ac.discipline.getRole();
                if (logger.isDebugEnabled()) {
                    logger.debug(e.getSource() + ": Discipline detected as [" + ac.discipline + "] at " + e.getTs());
                }
                if (isEffectiveLogged || Actor.Type.SELF.equals(e.getSource().getType())) {
                    context.addCombatPlayer(combat, e.getSource(), ac.discipline);
                }
                if (isSourceThisPlayer(e)) {
                    // self
                    if (!CharacterRole.HEALER.equals(ac.discipline.getRole())) {
                        // make sure its reset
                        clearHotsTracking();
                    }
                }
            }
        }
    }
}
Also used : CombatInfo(com.ixale.starparse.domain.CombatInfo) Phase(com.ixale.starparse.domain.Phase) Helpers.isEffectEnterCombat(com.ixale.starparse.parser.Helpers.isEffectEnterCombat) Helpers.isEffectExitCombat(com.ixale.starparse.parser.Helpers.isEffectExitCombat) Combat(com.ixale.starparse.domain.Combat) Actor(com.ixale.starparse.domain.Actor) LocationInfo(com.ixale.starparse.domain.LocationInfo)

Example 3 with CombatInfo

use of com.ixale.starparse.domain.CombatInfo in project StarParse by Ixale.

the class Context method setCombatActorState.

public void setCombatActorState(final Combat combat, final Actor actor, final Raid.Npc npc, final String currentHp, final String maxHp, final long tick) {
    if (maxHp == null || currentHp == null || maxHp.equals(currentHp)) {
        return;
    }
    final CombatInfo combatInfo = this.combatInfo.get(combat.getCombatId());
    if (combatInfo != null) {
        CombatActorState cas = combatInfo.getCombatActorStates().get(actor);
        if (cas == null) {
            cas = new CombatActorState(actor, npc, tick);
            combatInfo.getCombatActorStates().put(actor, cas);
        } else {
            cas.setTick(tick);
        }
        cas.setCurrentHp(Long.valueOf(currentHp));
        cas.setMaxHp(Long.valueOf(maxHp));
    }
}
Also used : CombatInfo(com.ixale.starparse.domain.CombatInfo) CombatActorState(com.ixale.starparse.domain.CombatActorState)

Example 4 with CombatInfo

use of com.ixale.starparse.domain.CombatInfo in project StarParse by Ixale.

the class FileLoader method fillParselyCombatsInfo.

private static void fillParselyCombatsInfo(final List<Combat> combats, final List<ParselyCombatInfo> combatsInfo, final Context context) {
    combatsInfo.clear();
    if (combats == null) {
        return;
    }
    try {
        for (final Combat c : combats) {
            if (c == null) {
                continue;
            }
            final ParselyCombatInfo info = new ParselyCombatInfo();
            info.from = c.getTimeFrom();
            info.to = c.getTimeTo();
            info.raidBoss = c.getBoss();
            if (info.raidBoss != null && Raid.Mode.NiM.equals(info.raidBoss.getMode())) {
                for (final CombatEventStats e : context.getCombatEvents(c.getCombatId(), context.getSelectedPlayer())) {
                    if (Event.Type.NIM_CRYSTAL.equals(e.getType())) {
                        info.isNiMCrystal = true;
                        break;
                    }
                }
            }
            final CombatInfo combatInfo = context.getCombatInfo().get(c.getCombatId());
            if (combatInfo != null && combatInfo.getLocationInfo() != null) {
                info.instanceName = combatInfo.getLocationInfo().getInstanceName();
                info.instanceGuid = combatInfo.getLocationInfo().getInstanceGuid();
            }
            combatsInfo.add(info);
        }
    } catch (Exception e) {
        logger.error("Unable to assemble combats info for Parsely: " + e.getMessage(), e);
    }
}
Also used : ParselyCombatInfo(com.ixale.starparse.service.ParselyService.ParselyCombatInfo) CombatInfo(com.ixale.starparse.domain.CombatInfo) ParselyCombatInfo(com.ixale.starparse.service.ParselyService.ParselyCombatInfo) CombatEventStats(com.ixale.starparse.domain.stats.CombatEventStats) Combat(com.ixale.starparse.domain.Combat)

Aggregations

CombatInfo (com.ixale.starparse.domain.CombatInfo)4 Combat (com.ixale.starparse.domain.Combat)2 Actor (com.ixale.starparse.domain.Actor)1 CombatActorState (com.ixale.starparse.domain.CombatActorState)1 LocationInfo (com.ixale.starparse.domain.LocationInfo)1 Phase (com.ixale.starparse.domain.Phase)1 CombatEventStats (com.ixale.starparse.domain.stats.CombatEventStats)1 Helpers.isEffectEnterCombat (com.ixale.starparse.parser.Helpers.isEffectEnterCombat)1 Helpers.isEffectExitCombat (com.ixale.starparse.parser.Helpers.isEffectExitCombat)1 ParselyCombatInfo (com.ixale.starparse.service.ParselyService.ParselyCombatInfo)1