Skip to content

Commit

Permalink
Merge pull request #29 from xpdota/timeline-enhancements-2
Browse files Browse the repository at this point in the history
Timeline enhancements 2
  • Loading branch information
xpdota authored Mar 3, 2022
2 parents 9820b98 + 9927a04 commit e901756
Show file tree
Hide file tree
Showing 42 changed files with 680 additions and 284 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public static void fromEvents(List<? extends Event> events, boolean decompress)
pico.addComponent(FakeACTTimeSource.class);
AutoEventDistributor dist = pico.getComponent(AutoEventDistributor.class);
PersistenceProvider pers = pico.getComponent(PersistenceProvider.class);
pers.save("gui.display-predicted-hp", "true");
EventMaster master = pico.getComponent(EventMaster.class);
ReplayController replayController = new ReplayController(master, events, decompress);
pico.addComponent(replayController);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ public static void fromEvents(List<? extends Event> events, boolean decompress)
MutablePicoContainer pico = XivMain.importInit();
AutoEventDistributor dist = pico.getComponent(AutoEventDistributor.class);
EventMaster master = pico.getComponent(EventMaster.class);
PersistenceProvider pers = pico.getComponent(PersistenceProvider.class);
pers.save("gui.display-predicted-hp", "true");
ReplayController replayController = new ReplayController(master, events, decompress);
pico.addComponent(replayController);
pico.getComponent(RawEventStorage.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class CdTrackerTest {
new XivAbility(cd.getPrimaryAbilityId(), "Reprisal"),
player,
theBoss,
Collections.singletonList(new StatusAppliedEffect(1193, true)),
Collections.singletonList(new StatusAppliedEffect(0, 0, 1193, 0, true)),
123,
0,
1
Expand All @@ -43,7 +43,7 @@ public class CdTrackerTest {
new XivAbility(cd.getPrimaryAbilityId(), "Reprisal"),
player,
theBoss,
Collections.singletonList(new StatusAppliedEffect(1193, true)),
Collections.singletonList(new StatusAppliedEffect(0, 0, 1193, 0, true)),
123,
1,
1
Expand All @@ -52,7 +52,7 @@ public class CdTrackerTest {
new XivAbility(cd.getPrimaryAbilityId(), "Reprisal"),
otherCharInParty,
theBoss,
Collections.singletonList(new StatusAppliedEffect(1193, true)),
Collections.singletonList(new StatusAppliedEffect(0, 0, 1193, 0, true)),
123,
0,
1
Expand All @@ -61,7 +61,7 @@ public class CdTrackerTest {
new XivAbility(cd.getPrimaryAbilityId(), "Reprisal"),
otherCharNotInParty,
theBoss,
Collections.singletonList(new StatusAppliedEffect(1193, true)),
Collections.singletonList(new StatusAppliedEffect(0, 0, 1193, 0, true)),
123,
0,
1
Expand Down
4 changes: 3 additions & 1 deletion xivdata/src/main/java/gg/xp/xivdata/data/ActionInfo.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package gg.xp.xivdata.data;

import org.jetbrains.annotations.Nullable;

// TODO: cooldown and stuff? What else would we want here?
public record ActionInfo(
long actionid,
String name,
long iconId
) {
public ActionIcon getIcon() {
public @Nullable ActionIcon getIcon() {
return ActionLibrary.iconForInfo(this);
}
}
30 changes: 30 additions & 0 deletions xivdata/src/main/java/gg/xp/xivdata/data/StatusEffectLibrary.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,36 @@ public static void readAltCsv(File file) {
return csvValues.get(id);
}

public static int getMaxStacks(long buffId) {
// There are two main considerations here.
// Sometimes, the 'stacks' value is used to represent something other than stacks (like on NIN)
// Therefore, we have to assume that it is a garbage value and assume 0 stacks (i.e. not a stacking buff)
// if rawStacks > maxStacks.
// However, there are also unknown status effects, therefore we just assume 16 is the max for those, since that
// seems to be the max for any legitimate buff.
StatusEffectInfo statusEffectInfo = forId(buffId);
long maxStacks;
if (statusEffectInfo == null) {
maxStacks = 16;
}
else {
maxStacks = statusEffectInfo.maxStacks();
}
//noinspection NumericCastThatLosesPrecision - never that high
return (int) maxStacks;
}

public static int calcActualStacks(long buffId, long rawStacks) {
int maxStacks = getMaxStacks(buffId);
if (rawStacks >= 0 && rawStacks <= maxStacks) {
return (int) rawStacks;
}
else {
return 0;
}

}

// Special value to indicate no icon
private static final StatusEffectIcon NULL_MARKER;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class BuffApplied extends BaseEvent implements HasSourceEntity, HasTarget

// Only for pre-apps
public BuffApplied(AbilityUsedEvent event, StatusAppliedEffect effect) {
this(effect.getStatus(), 9999, event.getSource(), event.getTarget(), 1, true);
this(effect.getStatus(), 9999, event.getSource(), event.getTarget(), effect.getRawStacks(), true);
}

public BuffApplied(XivStatusEffect buff, double durationRaw, XivCombatant source, XivCombatant target, long stacks) {
Expand Down Expand Up @@ -54,27 +54,8 @@ public BuffApplied(XivStatusEffect buff, double durationRaw, XivCombatant source
this.source = source;
this.target = target;
this.rawStacks = rawStacks;
// There are two main considerations here.
// Sometimes, the 'stacks' value is used to represent something other than stacks (like on NIN)
// Therefore, we have to assume that it is a garbage value and assume 0 stacks (i.e. not a stacking buff)
// if rawStacks > maxStacks.
// However, there are also unknown status effects, therefore we just assume 16 is the max for those, since that
// seems to be the max for any legitimate buff.
StatusEffectInfo statusEffectInfo = StatusEffectLibrary.forId(buff.getId());
long maxStacks;
if (statusEffectInfo == null) {
maxStacks = 16;
}
else {
maxStacks = statusEffectInfo.maxStacks();
}
if (rawStacks >= 0 && rawStacks <= maxStacks) {
stacks = rawStacks;
}
else {
stacks = 0;
}
this.isPreApp = isPreApp;
this.stacks = StatusEffectLibrary.calcActualStacks(buff.getId(), rawStacks);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ public long getRawEffectId() {
@Override
public List<AbilityEffect> getEffects() {
if (type == TickType.HOT) {
return Collections.singletonList(new HealEffect(HitSeverity.NORMAL, damage));
return Collections.singletonList(new HealEffect(0, 0, HitSeverity.NORMAL, damage));
}
else {
return Collections.singletonList(new DamageTakenEffect(HitSeverity.NORMAL, damage));
return Collections.singletonList(new DamageTakenEffect(0, 0, HitSeverity.NORMAL, damage));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,34 @@
package gg.xp.xivsupport.events.actlines.events.abilityeffect;

public class AbilityEffect {
public abstract class AbilityEffect {

private final long flags;
private final long value;
private final AbilityEffectType effectType;

protected AbilityEffect(AbilityEffectType effectType) {
protected AbilityEffect(long flags, long value, AbilityEffectType effectType) {
this.flags = flags;
this.value = value;
this.effectType = effectType;
}

public AbilityEffectType getEffectType() {
return effectType;
}

public String getDescription() {
public final long getFlags() {
return flags;
}

public final long getValue() {
return value;
}

protected String getBaseDescription() {
return toString();
};

public final String getDescription() {
return String.format("%s (raw: %08x %08x)", getBaseDescription(), flags, value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
public class BlockedDamageEffect extends AbilityEffect implements DamageEffect {
private final long amount;

public BlockedDamageEffect(long amount) {
super(AbilityEffectType.BLOCKED);
public BlockedDamageEffect(long flags, long value, long amount) {
super(flags, value, AbilityEffectType.BLOCKED);
this.amount = amount;
}

Expand All @@ -19,7 +19,7 @@ public String toString() {
}

@Override
public String getDescription() {
public String getBaseDescription() {
return String.format("Blocked Damage: %s", amount);
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package gg.xp.xivsupport.events.actlines.events.abilityeffect;

public class CurrentHpSetEffect extends AbilityEffect {
private final long value;
private final long hpAmount;

public CurrentHpSetEffect(long value) {
super(AbilityEffectType.HP_SET_TO);
this.value = value;
public CurrentHpSetEffect(long flags, long value, long hpAmount) {
super(flags, value, AbilityEffectType.HP_SET_TO);
this.hpAmount = value;
}

public long getValue() {
return value;
public long getHpAmount() {
return hpAmount;
}

public String toString() {
return String.format("HP=%s", value);
return String.format("HP=%s", hpAmount);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ public class DamageTakenEffect extends AbilityEffect implements DamageEffect {
private final HitSeverity severity;
private final long amount;

public DamageTakenEffect(HitSeverity severity, long amount) {
super(AbilityEffectType.DAMAGE);
public DamageTakenEffect(long flags, long value, HitSeverity severity, long amount) {
super(flags, value, AbilityEffectType.DAMAGE);
this.severity = severity;
this.amount = amount;
}
Expand All @@ -25,7 +25,7 @@ public String toString() {
}

@Override
public String getDescription() {
public String getBaseDescription() {
if (severity == HitSeverity.NORMAL) {
return String.format("Damage Taken: %s", amount);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

public class FullyResistedEffect extends AbilityEffect {

public FullyResistedEffect() {
super(AbilityEffectType.MISS);
public FullyResistedEffect(long flags, long value) {
super(flags, value, AbilityEffectType.MISS);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ public class HealEffect extends AbilityEffect {
private final HitSeverity severity;
private final long amount;

public HealEffect(HitSeverity severity, long amount) {
super(AbilityEffectType.HEAL);
public HealEffect(long flags, long value, HitSeverity severity, long amount) {
super(flags, value, AbilityEffectType.HEAL);
this.severity = severity;
this.amount = amount;
}
Expand All @@ -25,7 +25,7 @@ public String toString() {


@Override
public String getDescription() {
public String getBaseDescription() {
if (severity == HitSeverity.NORMAL) {
return String.format("Heal: %s", amount);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
public class InvulnBlockedDamageEffect extends AbilityEffect implements DamageEffect {
private final long amount;

public InvulnBlockedDamageEffect(long amount) {
super(AbilityEffectType.INVULN);
public InvulnBlockedDamageEffect(long flags, long value, long amount) {
super(flags, value, AbilityEffectType.INVULN);
this.amount = amount;
}

Expand All @@ -19,7 +19,7 @@ public String toString() {
}

@Override
public String getDescription() {
public String getBaseDescription() {
return String.format("Invulnerable: %s", amount);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

public class MissEffect extends AbilityEffect {

public MissEffect() {
super(AbilityEffectType.MISS);
public MissEffect(long flags, long value) {
super(flags, value, AbilityEffectType.MISS);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
public class MpGain extends AbilityEffect {
private final long amount;

public MpGain(long amount) {
super(AbilityEffectType.HEAL);
public MpGain(long flags, long value, long amount) {
super(flags, value, AbilityEffectType.HEAL);
this.amount = amount;
}

Expand All @@ -18,7 +18,7 @@ public String toString() {
}

@Override
public String getDescription() {
public String getBaseDescription() {
return String.format("Gained MP: %s", amount);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
public class MpLoss extends AbilityEffect {
private final long amount;

public MpLoss(long amount) {
super(AbilityEffectType.HEAL);
public MpLoss(long flags, long value, long amount) {
super(flags, value, AbilityEffectType.HEAL);
this.amount = amount;
}

Expand All @@ -18,7 +18,7 @@ public String toString() {
}

@Override
public String getDescription() {
public String getBaseDescription() {
return String.format("Lost MP: %s", amount);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

public class NoEffect extends AbilityEffect {

public NoEffect() {
super(AbilityEffectType.NO_EFFECT);
public NoEffect(long flags, long value) {
super(flags, value, AbilityEffectType.NO_EFFECT);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

public class OtherEffect extends AbilityEffect {

private final long flags;
private final long value;

public OtherEffect(long flags, long value) {
super(AbilityEffectType.OTHER);
this.flags = flags;
this.value = value;
super(flags, value, AbilityEffectType.OTHER);
}

@Override
public String toString() {
return String.format("Other(%x,%x)", flags, value);
return String.format("Other(%x,%x)", getFlags(), getValue());
}

@Override
protected String getBaseDescription() {
return "Other";
}
}
Loading

0 comments on commit e901756

Please sign in to comment.