use of com.ixale.starparse.domain.stats.DamageTakenStats 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);
}
use of com.ixale.starparse.domain.stats.DamageTakenStats in project StarParse by Ixale.
the class EventServiceTest method testStatsFull.
@Test
public void testStatsFull() throws Exception {
// load test source file
final File sourceLog = new File(getClass().getClassLoader().getResource("combat_2014-02-26_03_01_11_705182.txt").toURI());
parser.setCombatLogFile(sourceLog);
// check DAO
eventService.storeCombatLog(parser.getCombatLog());
// parse one by one, with intermediary flushes
FileReader fr = null;
BufferedReader br = null;
try {
fr = new FileReader(sourceLog);
br = new BufferedReader(fr);
String line;
int i = 0;
while ((line = br.readLine()) != null) {
parser.parseLogLine(line);
if (++i % 3000 == 0) {
eventService.flushEvents(parser.getEvents(), parser.getCombats(), parser.getCurrentCombat(), parser.getEffects(), parser.getCurrentEffects(), parser.getPhases(), parser.getCurrentPhase(), parser.getAbsorptions(), parser.getActorStates());
}
}
eventService.flushEvents(parser.getEvents(), parser.getCombats(), parser.getCurrentCombat(), parser.getEffects(), parser.getCurrentEffects(), parser.getPhases(), parser.getCurrentPhase(), parser.getAbsorptions(), parser.getActorStates());
} finally {
try {
br.close();
} catch (Exception ignored) {
}
try {
fr.close();
} catch (Exception ignored) {
}
}
// check result
Combat c = null;
DamageDealtStats dds = null;
List<DamageDealtStats> damageDealtStats = null;
DamageTakenStats dts = null;
List<DamageTakenStats> damageTakenStats = null;
CombatMitigationStats cms = null;
HealingTakenStats hts = null;
List<HealingTakenStats> healingTakenStats = null;
SimpleDateFormat sdf = new SimpleDateFormat("YYYY-MM-dd HH:mm:ss.SSS", Locale.ENGLISH);
List<Combat> combats = eventService.getCombats();
assertEquals(25, combats.size());
assertEquals("Ixaar", parser.getCombatLog().getCharacterName());
// verify combat 25
c = combats.get(24);
assertEquals("2014-02-26 04:28:04.902", sdf.format(c.getTimeFrom()));
assertEquals("Dread Master Brontes (HM 8m)", c.getBoss().toString());
assertEquals(420490, c.getTimeTo() - c.getTimeFrom());
// damage dealt
damageDealtStats = eventService.getDamageDealtStats(c, false, false, true, null, parser.getCombatLog().getCharacterName());
assertEquals(15, damageDealtStats.size());
dds = damageDealtStats.get(0);
assertEquals("Blade Storm", dds.getName());
assertEquals(27, dds.getTicks());
assertEquals(2857.0, dds.getAverageCrit());
assertEquals(1852.0, dds.getAverageNormal());
// damage taken
damageTakenStats = eventService.getDamageTakenStats(c, false, false, true, null, parser.getCombatLog().getCharacterName());
assertEquals(14, damageTakenStats.size());
dts = damageTakenStats.get(1);
assertEquals("Fire and Forget", dts.getName());
assertEquals(120, dts.getTicks());
assertEquals(12.5, dts.getPercentMiss());
assertEquals(37.5, dts.getPercentShield());
assertEquals(703.0, dts.getAverageNormal());
assertEquals(6818, dts.getTotalAbsorbed());
assertEquals(84343, dts.getTotal());
// mitigation
cms = eventService.getCombatMitigationStats(c, null, parser.getCombatLog().getCharacterName());
assertEquals(275, cms.getTicks());
assertEquals(491144, cms.getDamage());
assertEquals(13141, cms.getInternal());
assertEquals(2.7, cms.getInternalPercent());
assertEquals(77469, cms.getElemental());
assertEquals(15.8, cms.getElementalPercent());
assertEquals(68449, cms.getEnergy());
assertEquals(13.9, cms.getEnergyPercent());
assertEquals(332085, cms.getKinetic());
assertEquals(67.6, cms.getKineticPercent());
assertEquals(22.2, cms.getMissPercent());
assertEquals(27.3, cms.getShieldPercent());
assertEquals(86381, cms.getAbsorbedSelf() + cms.getAbsorbedOthers());
assertEquals(17.6, cms.getAbsorbedSelfPercent() + cms.getAbsorbedOthersPercent());
assertEquals(205, cms.getAps());
// absorptions & healing
healingTakenStats = eventService.getHealingTakenStats(c, true, true, null, parser.getCombatLog().getCharacterName());
assertEquals(15, healingTakenStats.size());
hts = healingTakenStats.get(0);
assertNotNull(hts);
}
use of com.ixale.starparse.domain.stats.DamageTakenStats in project StarParse by Ixale.
the class CombatDaoImpl method getDamageTakenStats.
@Override
public List<DamageTakenStats> getDamageTakenStats(final Combat combat, boolean bySourceType, boolean bySourceInstance, boolean byAbility, final CombatSelection combatSel, final String playerName) throws Exception {
final Boundaries bounds = getBoundaries(combat, combatSel);
final Map<String, Object> args = createArgs(bounds);
args.put("playerName", playerName == null ? getCharacterName(combat) : playerName);
StringBuilder pivotsCols = new StringBuilder(), pivotsWhere = new StringBuilder(), pivotsGroup = new StringBuilder();
if (bySourceInstance) {
pivotsCols.append(", e.source_name, e.source_instance");
pivotsGroup.append(", e.source_name, e.source_instance");
} else if (bySourceType) {
pivotsCols.append(", e.source_name, 0 source_instance");
pivotsGroup.append(", e.source_name");
} else {
pivotsCols.append(", 'Total' source_name, 0 source_instance");
}
if (byAbility) {
pivotsCols.append(", e.ability_name, e.ability_guid");
pivotsGroup.append(", e.ability_name, e.ability_guid");
} else {
pivotsCols.append(", 'Total' ability_name, 0 ability_guid");
}
return getJdbcTemplate().query(SQL_GET_DAMAGE_TAKEN_TOTALS.replace("%pivots_cols", pivotsCols.substring(2)).replace("%pivots_where", pivotsWhere.length() > 0 ? pivotsWhere : "").replace("%pivots_group", pivotsGroup.length() > 0 ? pivotsGroup.substring(2) : "1"), args, (rs, rowNum) -> new DamageTakenStats(rs.getString("source_name"), rs.getString("ability_name"), rs.getLong("ability_guid"), rs.getInt("ticks"), rs.getInt("ticks_shield"), rs.getInt("ticks_miss"), rs.getInt("total"), rs.getInt("total_ie"), rs.getInt("max"), rs.getInt("total_absorbed"), rs.getInt("dtps"), rs.getDouble("pct_total"), rs.getDouble("avg_normal"), rs.getDouble("pct_shield"), rs.getDouble("pct_miss"), rs.getString("damage_type"), getTimestamp(rs, (getTimestamp(rs, "source_time_from") != null ? "source_time_from" : "sub_time_from")).getTime(), getTimestamp(rs, (getTimestamp(rs, "source_time_to") != null ? "source_time_to" : "sub_time_to")).getTime()));
}
Aggregations