use of com.ixale.starparse.domain.CombatChallenge in project StarParse by Ixale.
the class CombatDaoImpl method getCombatChallengeStats.
@Override
public List<ChallengeStats> getCombatChallengeStats(final Combat combat, final CombatSelection combatSel, final String playerName) throws Exception {
if ((combat.getBoss() == null) || ((availableChallenges = combat.getBoss().getRaid().getChallenges(combat.getBoss())) == null)) {
return null;
}
phasesToChallenges.clear();
for (final CombatChallenge ch : availableChallenges) {
phasesToChallenges.put(ch.getPhaseName(), ch);
}
final Map<String, Object> args = new HashMap<>();
args.put("combatId", combat.getCombatId());
args.put("tickFrom", combatSel != null && combatSel.getTickFrom() != null ? combatSel.getTickFrom() : 0);
args.put("tickTo", combatSel != null && combatSel.getTickTo() != null ? combatSel.getTickTo() : Integer.MAX_VALUE);
args.put("phaseNames", new ArrayList<>(phasesToChallenges.keySet()));
return getJdbcTemplate().query(SQL_GET_COMBAT_CHALLENGES, args, new RowMapper<ChallengeStats>() {
Long tickFrom, tickTo;
boolean noCache = false;
@Override
public ChallengeStats mapRow(ResultSet rs, int rowNum) {
try {
noCache = false;
if (combatSel != null) {
if (combatSel.getTickFrom() != null && (combatSel.getTickFrom() > rs.getLong("tick_from"))) {
tickFrom = combatSel.getTickFrom();
noCache = true;
} else {
tickFrom = rs.getLong("tick_from");
}
if (combatSel.getTickTo() != null && (getValueOrNull(rs, rs.getLong("tick_to")) == null || context.getTickTo() < rs.getLong("tick_to"))) {
tickTo = combatSel.getTickTo();
noCache = true;
} else {
tickTo = getValueOrNull(rs, rs.getLong("tick_to"));
noCache = noCache || tickTo == null;
}
} else {
tickFrom = rs.getLong("tick_from");
tickTo = getValueOrNull(rs, rs.getLong("tick_to"));
}
if (!noCache && cachedChallenges.containsKey(combat.getCombatId())) {
if (cachedChallenges.get(combat.getCombatId()).containsKey(playerName)) {
if (cachedChallenges.get(combat.getCombatId()).get(playerName).containsKey(rs.getLong("tick_from"))) {
return cachedChallenges.get(combat.getCombatId()).get(playerName).get(rs.getLong("tick_from"));
// NOTREACHED
}
}
}
final CombatSelection challengeCombatSel = new CombatSelection(rs.getInt("event_id_from"), getValueOrNull(rs, rs.getInt("event_id_to")), tickFrom, tickTo, phasesToChallenges.get(rs.getString("name")).getArgs(), phasesToChallenges.get(rs.getString("name")).getSql());
final CombatStats stats = getCombatStats(combat, challengeCombatSel, playerName, true);
final ChallengeStats challengeStats = new ChallengeStats(phasesToChallenges.get(rs.getString("name")).getChallengeName(), tickFrom, tickFrom + stats.getTick(), stats.getDamage(), stats.getHeal(), stats.getEffectiveHeal());
if (!noCache && (getValueOrNull(rs, rs.getLong("tick_to")) != null)) {
if (!cachedChallenges.containsKey(combat.getCombatId())) {
cachedChallenges.put(combat.getCombatId(), new HashMap<>());
}
if (!cachedChallenges.get(combat.getCombatId()).containsKey(playerName)) {
cachedChallenges.get(combat.getCombatId()).put(playerName, new HashMap<>());
}
cachedChallenges.get(combat.getCombatId()).get(playerName).put(rs.getLong("tick_from"), challengeStats);
}
return challengeStats;
} catch (Exception e) {
logger.error("Unable to get combat challenge: " + e.getMessage(), e);
return null;
}
}
});
}
use of com.ixale.starparse.domain.CombatChallenge in project StarParse by Ixale.
the class PersonalStatsPopoutPresenter method refreshCombatStats.
@Override
protected void refreshCombatStats(final Combat combat, final CombatStats stats) throws Exception {
if (MODE_DAMAGE.equals(getMode().mode)) {
refreshDamageStats(combat, stats);
} else if (MODE_HEALING.equals(getMode().mode)) {
refreshHealingStats(combat, stats);
} else {
refreshAllStats(combat, stats);
}
// any challenge available?
if ((combat.getBoss() == null) || ((availableChallenges = combat.getBoss().getRaid().getChallenges(combat.getBoss())) == null)) {
return;
}
currentChallenge = null;
availableChallengeStats = eventService.getCombatChallengeStats(combat, context.getCombatSelection(), context.getSelectedPlayer());
if (availableChallengeStats != null && !availableChallengeStats.isEmpty()) {
// try to map
for (final ChallengeStats chStats : availableChallengeStats) {
for (final CombatChallenge ch : availableChallenges) {
if (chStats.getChallengeName().equals(ch.getChallengeName())) {
currentChallenge = ch;
currentChallengeStats = chStats;
}
}
}
}
if (currentChallenge == null) {
if (lastChallenge != null) {
removeChallenge(lastChallenge);
lastChallenge = null;
}
return;
}
if (CombatChallenge.Type.FRIENDLY.equals(currentChallenge.getType()) && (currentChallengeStats.getDamage() == null || currentChallengeStats.getDamage() <= 0)) {
// do not display negative challenges unless broken
currentChallenge = null;
currentChallengeStats = null;
return;
}
if (lastChallenge != null) {
if (!lastChallenge.getPhaseName().equals(currentChallenge.getPhaseName())) {
removeChallenge(lastChallenge);
addChallenge(currentChallenge);
} else {
// nothing to do
}
} else {
addChallenge(currentChallenge);
}
updateChallenge(currentChallenge, currentChallengeStats);
lastChallenge = currentChallenge;
}
use of com.ixale.starparse.domain.CombatChallenge in project StarParse by Ixale.
the class PersonalStatsPopoutPresenter method resetCombatStats.
@Override
public void resetCombatStats() {
apm.setText("");
time.setText("");
dps.setText("");
damage.setText("");
hps.setText("");
heal.setText("");
ehps.setText("");
ehpsPercent.setText("");
tps.setText("");
threat.setText("");
aps.setText("");
absorbed.setText("");
dtps.setText("");
damageTaken.setText("");
healTaken.setText("");
hpsTaken.setText("");
ehpsTaken.setText("");
ehpsTakenPercent.setText("");
// damage
apm2.setText("");
time2.setText("");
dps2.setText("");
damage2.setText("");
critTotal2.setText("");
crit2.setText("");
// healing
apm3.setText("");
time3.setText("");
hps3.setText("");
heal3.setText("");
ehps3.setText("");
ehpsPercent3.setText("");
shield3.setText("");
sps3.setText("");
// challenges
for (final CombatChallenge ch : challenges.keySet()) {
statsGrid.getChildren().remove(challenges.get(ch));
}
challenges.clear();
currentChallenge = lastChallenge = null;
availableChallenges = null;
availableChallengeStats = null;
currentChallengeStats = null;
}
use of com.ixale.starparse.domain.CombatChallenge in project StarParse by Ixale.
the class PersonalStatsPopoutPresenter method repaint.
@Override
public void repaint(Object source) {
super.repaint(source);
setLabelColor(textColor);
for (final CombatChallenge challenge : challenges.keySet()) {
final AnchorPane pane = challenges.get(challenge);
final Rectangle bar = ((Rectangle) pane.getChildren().get(0));
if (this.bars) {
// showing bars
bar.setOpacity(opacity);
bar.setFill(getBarColor(challenge));
bar.setVisible(true);
} else {
bar.setVisible(false);
}
((Label) pane.getChildren().get(1)).setTextFill(this.textColor);
((Label) pane.getChildren().get(2)).setTextFill(this.textColor);
((Label) pane.getChildren().get(3)).setTextFill(this.textColor);
}
}
Aggregations