Skip to content

Commit

Permalink
Added sequenceID
Browse files Browse the repository at this point in the history
  • Loading branch information
xpdota committed Dec 12, 2021
1 parent df56e66 commit 6ac4139
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ public class AbilityUsedEvent extends BaseEvent implements HasSourceEntity, HasT
private final XivCombatant caster;
private final XivCombatant target;
private final List<AbilityEffect> effects;
private final long sequenceId;

public AbilityUsedEvent(XivAbility ability, XivCombatant caster, XivCombatant target, List<AbilityEffect> effects) {
public AbilityUsedEvent(XivAbility ability, XivCombatant caster, XivCombatant target, List<AbilityEffect> effects, long sequenceId) {
this.ability = ability;
this.caster = caster;
this.target = target;
this.effects = effects;
this.sequenceId = sequenceId;
}

public XivAbility getAbility() {
Expand All @@ -42,8 +44,13 @@ public List<AbilityEffect> getEffects() {
return Collections.unmodifiableList(effects);
}

// TODO: not accurate, need to account for parries and stuff
public long getDamage() {
return effects.stream().filter(effect -> effect instanceof DamageEffect).map(DamageEffect.class::cast)
.mapToLong(DamageEffect::getAmount).sum();
}

public long getSequenceId() {
return sequenceId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private String getRawField(int fieldIndex) {
return rawLineSplit[fieldIndex];
}

private long getRawHex(int fieldIndex) {
public long getRawHex(int fieldIndex) {
String rawField = getRawField(fieldIndex);
if (rawField.isEmpty()) {
return -1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ protected Event convert(FieldMapper<Fields> fields, int lineNumber, ZonedDateTim
fields.getAbility(Fields.abilityId, Fields.abilityName),
fields.getEntity(Fields.casterId, Fields.casterName),
fields.getEntity(Fields.targetId, Fields.targetName),
fields.getAbilityEffects(Fields.targetName.ordinal() + 3, 8)
fields.getAbilityEffects(Fields.targetName.ordinal() + 3, 8),
fields.getRawHex(44)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ protected Event convert(FieldMapper<Fields> fields, int lineNumber, ZonedDateTim
fields.getAbility(Fields.abilityId, Fields.abilityName),
fields.getEntity(Fields.casterId, Fields.casterName),
fields.getEntity(Fields.targetId, Fields.targetName),
fields.getAbilityEffects(Fields.targetName.ordinal() + 3, 8)
fields.getAbilityEffects(Fields.targetName.ordinal() + 3, 8),
fields.getRawHex(44)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public void positiveTest() {
Assert.assertEquals(event.getAbility().getId(), 0x200524E);
Assert.assertEquals(event.getSource().getId(), 0x107361AF);
Assert.assertEquals(event.getTarget().getId(), 0x107361AD);

Assert.assertEquals(event.getSequenceId(), 0x000BACE5);
Assert.assertEquals(event.getAbility().getName(), "Item_524E");
Assert.assertEquals(event.getSource().getName(), "Foo Bar");
Assert.assertEquals(event.getTarget().getName(), "The Target");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public void positiveTest() {
Assert.assertEquals(event.getAbility().getId(), 0x200524E);
Assert.assertEquals(event.getSource().getId(), 0x107361AF);
Assert.assertEquals(event.getTarget().getId(), 0x107361AD);
Assert.assertEquals(event.getSequenceId(), 0x000BACE5);

Assert.assertEquals(event.getAbility().getName(), "Item_524E");
Assert.assertEquals(event.getSource().getName(), "Foo Bar");
Expand Down

0 comments on commit 6ac4139

Please sign in to comment.