use of com.ixale.starparse.ws.RaidCombatMessage in project StarParse by Ixale.
the class RaidServiceImpl method loadCombatStats.
@Override
public void loadCombatStats(final String combatLogName) {
lastCombatLogName = combatLogName;
final CombatLogStats combatLogStats = Marshaller.loadFromFile(getLocalFileName(combatLogName));
if (combatLogStats == null) {
return;
}
localCache.put(combatLogName, new HashMap<>());
for (final RaidCombatStats stats : combatLogStats.getRaids()) {
final HashMap<String, RaidCombatMessage> messages = new HashMap<>();
for (final RaidCombatMessage message : stats.getCombatStats()) {
messages.put(message.getCharacterName(), message);
}
localCache.get(combatLogName).put(stats.getCombatId(), messages);
}
}
use of com.ixale.starparse.ws.RaidCombatMessage in project StarParse by Ixale.
the class RaidServiceImpl method storeCombatStats.
@Override
public void storeCombatStats(final String combatLogName) {
if (!localCache.containsKey(combatLogName) || !dirtyLogs.contains(combatLogName)) {
return;
}
final CombatLogStats combatLogStats = new CombatLogStats();
combatLogStats.setCombatLogName(combatLogName);
for (Integer combatId : localCache.get(combatLogName).keySet()) {
int players = 0;
for (final RaidCombatMessage m : localCache.get(combatLogName).get(combatId).values()) {
if (Format.isFakePlayerName(m.getCharacterName())) {
continue;
}
players++;
if (players > 1) {
// two real players, proceed with saving
break;
}
}
if (players < 2) {
// fake players only
continue;
}
final RaidCombatStats stats = new RaidCombatStats();
stats.setCombatId(combatId);
stats.getCombatStats().addAll(localCache.get(combatLogName).get(combatId).values());
combatLogStats.getRaids().add(stats);
}
if (combatLogStats.getRaids().isEmpty()) {
// local parsing only
return;
}
if (Marshaller.storeToFile(combatLogStats, getLocalFileName(combatLogName))) {
dirtyLogs.remove(combatLogName);
lastStoreTime = System.currentTimeMillis();
}
}
use of com.ixale.starparse.ws.RaidCombatMessage in project StarParse by Ixale.
the class RaidPresenter method getShieldingSelf.
// TODO: move this somewhere more proper
public int[] getShieldingSelf(int tick) throws Exception {
if (lastCombat == null || combatLogName == null || characterName == null) {
return null;
}
if (!raidTable.getItems().isEmpty() && context.getCombatSelection() == null) {
// load from normally from the table
return new int[] { getShieldingTotal(characterName), getShieldingPerSecond(characterName) };
}
// try to load from the cache (if raiding was active)
final Collection<RaidCombatMessage> messages = getCombatUpdates(combatLogName, lastCombat);
int total = 0;
if (messages != null && context.getCombatSelection() == null) {
for (final RaidCombatMessage message : messages) {
if (message.getAbsorptionStats() != null) {
for (final AbsorptionStats s : message.getAbsorptionStats()) {
if (characterName.equals(s.getSource())) {
total += s.getTotal();
}
}
}
}
} else {
// last resort - load parsed data (self-only)
final List<AbsorptionStats> as = eventService.getAbsorptionStats(lastCombat, context.getCombatSelection(), characterName);
for (final AbsorptionStats abs : as) {
if (characterName.equals(abs.getSource())) {
total += abs.getTotal();
}
}
}
return new int[] { total, tick <= 0 ? 0 : (int) Math.round(total * 1000.0 / tick) };
}
use of com.ixale.starparse.ws.RaidCombatMessage in project StarParse by Ixale.
the class RaidPresenter method updateRaidCombatStats.
public void updateRaidCombatStats(final RaidCombatMessage[] messages) {
if (messages == null || messages.length == 0) {
return;
}
if (lastCombat == null || characterName == null) {
logger.debug("Ignoring raid updates before first combat");
return;
}
boolean isRefreshNeeded = false;
Integer combatId = null;
for (final RaidCombatMessage message : messages) {
if (message.getCombatTimeTo() == null) {
// running combat ...
if (message.getTimestamp() + MAX_UPDATE_AGE < lastCombat.getTimeFrom()) {
// ... somewhere in a distant past
if (logger.isDebugEnabled()) {
logger.debug("Ignoring too old combat update [" + lastCombat + "]: " + message);
}
continue;
// NOTREACHED
}
if (lastCombat.getTimeTo() != null && (message.getCombatTimeFrom() > lastCombat.getTimeTo())) {
// ... after our last one has ended - ignore (will be fetched once we start as well)
if (logger.isDebugEnabled()) {
logger.debug("Ignoring too new combat update [" + lastCombat + "]: " + message);
}
continue;
// NOTREACHED
}
// ... after the last one started
combatId = lastCombat.getCombatId();
} else if (lastCombat.getTimeTo() != null && (message.getCombatTimeFrom() > lastCombat.getTimeTo())) {
// closed combat after our last one finished
if (logger.isDebugEnabled()) {
logger.debug("Ignoring too new combat closure [" + lastCombat + "]: " + message);
}
continue;
// NOTREACHED
} else if (message.getCombatTimeTo() > lastCombat.getTimeFrom()) {
// closed combat after the last one started
combatId = lastCombat.getCombatId();
} else {
// try to find other combat which started before the message's combat beginning
for (Long from : combatBeginnings.keySet()) {
if (message.getCombatTimeTo() < from) {
break;
}
// keep going as long as possible // FIXME: reverse?
combatId = combatBeginnings.get(from);
}
if (combatId == null) {
// no suitable combat found (possible in previous log after DC?)
if (logger.isDebugEnabled()) {
logger.debug("Ignoring too old combat update (not after " + combatBeginnings.keySet().toArray()[0] + "): " + message);
}
continue;
// NOTREACHED
}
}
raidService.storeCombatUpdate(combatLogName, combatId, message);
if (currentCombat != null && combatId.equals(currentCombat.getCombatId())) {
// displaying this combat, update table
isRefreshNeeded = true;
createOrReplaceTableRow(message);
for (final RaidDataListener listener : listeners) {
listener.onRaidDataUpdate(currentCombat, message);
}
}
}
if (isRefreshNeeded) {
finalizeTable();
for (final RaidDataListener listener : listeners) {
listener.onRaidDataFinalize();
}
}
}
use of com.ixale.starparse.ws.RaidCombatMessage in project StarParse by Ixale.
the class BaseRaidPopoutPresenter method refreshCombatStats.
@Override
protected void refreshCombatStats(final Combat combat, final CombatStats stats) throws Exception {
if (raidPresenter.getCombatLogName() == null) {
// nothing started yet, nothing to display
return;
}
if (streamedCombat != null && combat.getCombatId() == streamedCombat.getCombatId()) {
// already displaying this combat with the latest data available
// bump to pick up boss
streamedCombat = combat;
return;
}
// other combat selected, reset the display
streamedCombat = combat;
// try to fetch latest data
final Collection<RaidCombatMessage> messages = raidPresenter.getCombatUpdates(raidPresenter.getCombatLogName(), combat);
if (messages != null) {
for (final RaidCombatMessage message : messages) {
onRaidDataUpdate(streamedCombat, message);
}
onRaidDataFinalize();
}
}
Aggregations