Search in sources :

Example 1 with AttackType

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

the class DamageTakenPresenter method refreshCombatStats.

@Override
protected void refreshCombatStats(final Combat combat, final CombatStats stats) throws Exception {
    if (sourceTypeButton.isSelected()) {
        sourceInstanceButton.setDisable(false);
    } else {
        sourceInstanceButton.setSelected(false);
        sourceInstanceButton.setDisable(true);
    }
    sourceNameCol.setVisible((sourceTypeButton.isSelected() || sourceInstanceButton.isSelected()) || !abilityButton.isSelected());
    sourceTimeFromCol.setVisible(sourceInstanceButton.isSelected());
    nameCol.setVisible(abilityButton.isSelected());
    attackTypeCol.setVisible(abilityButton.isSelected() && combat != null && (combat.getBoss() != null || Boolean.TRUE.equals(combat.isPvp())));
    damageTypeCol.setVisible(abilityButton.isSelected());
    if (combat == null) {
        clearTable(damageTakenTable);
        return;
    }
    // mitigation overview
    final CombatMitigationStats mitiStats = eventService.getCombatMitigationStats(combat, context.getCombatSelection(), context.getSelectedPlayer());
    if (mitiStats == null) {
        // combat gone away
        resetCombatStats();
        return;
    }
    ie.setText(Format.formatMillions(mitiStats.getInternal() + mitiStats.getElemental()));
    iePercent.setText(Format.formatFloat(mitiStats.getInternalPercent() + mitiStats.getElementalPercent()) + " %");
    ke.setText(Format.formatMillions(mitiStats.getEnergy() + mitiStats.getKinetic()));
    kePercent.setText(Format.formatFloat(mitiStats.getEnergyPercent() + mitiStats.getKineticPercent()) + " %");
    // FIXME: database
    int ftTotal = 0, mrTotal = 0, total = 0;
    List<DamageTakenStats> dtStats = eventService.getDamageTakenStats(combat, sourceTypeButton.isSelected(), sourceInstanceButton.isSelected(), true, context.getCombatSelection(), context.getSelectedPlayer());
    for (final DamageTakenStats dts : dtStats) {
        total += dts.getTotal();
        if (dts.getGuid() > 0 && context.getAttacks().containsKey(dts.getGuid())) {
            switch(context.getAttacks().get(dts.getGuid())) {
                case FT:
                    ftTotal += dts.getTotal();
                    break;
                case MR:
                    ftTotal += dts.getTotalIe();
                    mrTotal += dts.getTotal() - dts.getTotalIe();
                    break;
            }
        } else {
            ftTotal += dts.getTotalIe();
        }
    }
    ft.setText(Format.formatMillions(ftTotal));
    ftPercent.setText(Format.formatFloat(total > 0 ? (ftTotal * 100.0 / total) : 0) + " %");
    mr.setText(Format.formatMillions(mrTotal));
    mrPercent.setText(Format.formatFloat(total > 0 ? (mrTotal * 100.0 / total) : 0) + " %");
    missPercent.setText(Format.formatFloat(mitiStats.getMissPercent()) + " %");
    shieldPercent.setText(Format.formatFloat(mitiStats.getShieldPercent()) + " %");
    absorbedSelfPercent.setText(Format.formatFloat(mitiStats.getAbsorbedSelfPercent()) + " %");
    absorbedSelf.setText(Format.formatMillions(mitiStats.getAbsorbedSelf()));
    absorbedOthersPercent.setText(Format.formatFloat(mitiStats.getAbsorbedOthersPercent()) + " %");
    absorbedOthers.setText(Format.formatMillions(mitiStats.getAbsorbedOthers()));
    // damage taken table
    final List<DamageTakenItem> items = new ArrayList<>();
    if (!abilityButton.isSelected()) {
        dtStats = eventService.getDamageTakenStats(combat, sourceTypeButton.isSelected(), sourceInstanceButton.isSelected(), abilityButton.isSelected(), context.getCombatSelection(), context.getSelectedPlayer());
    }
    for (final DamageTakenStats dts : dtStats) {
        final DamageTakenItem a = new DamageTakenItem();
        a.guid = dts.getGuid();
        a.source.set(dts.getSource());
        a.name.set(dts.getName() == null || dts.getName().isEmpty() ? "(" + dts.getGuid() + ")" : dts.getName());
        a.absorbed.set(dts.getTotalAbsorbed());
        a.ticks.set(dts.getTicks());
        a.total.set(dts.getTotal());
        a.max.set(dts.getMax());
        a.pctTotal.set(dts.getPercentTotal());
        a.avgNormal.set((int) dts.getAverageNormal());
        a.pctShield.set(dts.getPercentShield());
        a.pctMiss.set(dts.getPercentMiss());
        a.dtps.set(dts.getDtps());
        if (dts.getDamageType() != null && !dts.getDamageType().isEmpty()) {
            a.damageType.set(dts.getDamageType());
        }
        if (dts.getGuid() > 0 && context.getAttacks().containsKey(dts.getGuid())) {
            final AttackType at = context.getAttacks().get(dts.getGuid());
            if (AttackType.MR.equals(at) && dts.getTotalIe() > 0) {
                a.attackType.set("++");
            } else {
                a.attackType.set(at.toString());
            }
        } else if (dts.getTotalIe() > 0) {
            a.attackType.set(AttackType.FT.toString());
        }
        a.totalIe.set(dts.getTotalIe());
        if (dts.getTimeFrom() != null) {
            a.since.set(Format.formatTime(dts.getTimeFrom() - combat.getTimeFrom()));
        }
        a.tickFrom.set(dts.getTimeFrom() - combat.getTimeFrom());
        a.tickTo.set(dts.getTimeTo() - combat.getTimeFrom());
        items.add(a);
    }
    damageTakenTable.getItems().setAll(items);
    resortTable(damageTakenTable);
}
Also used : DamageTakenStats(com.ixale.starparse.domain.stats.DamageTakenStats) ArrayList(java.util.ArrayList) CombatMitigationStats(com.ixale.starparse.domain.stats.CombatMitigationStats) AttackType(com.ixale.starparse.domain.AttackType) DamageTakenItem(com.ixale.starparse.gui.table.item.DamageTakenItem)

Aggregations

AttackType (com.ixale.starparse.domain.AttackType)1 CombatMitigationStats (com.ixale.starparse.domain.stats.CombatMitigationStats)1 DamageTakenStats (com.ixale.starparse.domain.stats.DamageTakenStats)1 DamageTakenItem (com.ixale.starparse.gui.table.item.DamageTakenItem)1 ArrayList (java.util.ArrayList)1