feat(player): port retail augmentation stat chain
This commit is contained in:
parent
0cb60d98a0
commit
461a1fb7b4
22 changed files with 953 additions and 138 deletions
|
|
@ -639,6 +639,56 @@ public sealed class GameEventWiringTests
|
|||
Assert.Equal(60d, record.Duration);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WireAll_MagicUpdateEnchantment_PropagatesFullStatModMidSession()
|
||||
{
|
||||
var dispatcher = new GameEventDispatcher();
|
||||
var book = new Spellbook(SpellTable.Create([TestSpell(42u)]));
|
||||
var player = new LocalPlayerState(book);
|
||||
player.OnSkillUpdate(
|
||||
skillId: 7u,
|
||||
ranks: 100u,
|
||||
status: 2u,
|
||||
xp: 0u,
|
||||
init: 0u,
|
||||
resistance: 0u,
|
||||
lastUsed: 0d,
|
||||
formulaBonus: 0u);
|
||||
int changed = 0;
|
||||
book.EnchantmentsChanged += () => changed++;
|
||||
GameEventWiring.WireAll(
|
||||
dispatcher,
|
||||
new ClientObjectTable(),
|
||||
new CombatState(),
|
||||
book,
|
||||
new ChatLog(),
|
||||
localPlayer: player,
|
||||
clientTime: () => 100d);
|
||||
|
||||
byte[] payload = BuildEnchantment(
|
||||
spellId: 42,
|
||||
layer: 3,
|
||||
duration: 60,
|
||||
caster: 0xBEEF,
|
||||
startTime: 10,
|
||||
lastDegraded: 2,
|
||||
statModType: 0x00008010u,
|
||||
statModKey: 7u,
|
||||
statModValue: 25f);
|
||||
dispatcher.Dispatch(GameEventEnvelope.TryParse(
|
||||
WrapEnvelope(
|
||||
GameEventType.MagicUpdateEnchantment,
|
||||
payload))!.Value);
|
||||
|
||||
ActiveEnchantmentRecord record =
|
||||
Assert.Single(book.ActiveEnchantmentSnapshot);
|
||||
Assert.Equal(0x00008010u, record.StatModType);
|
||||
Assert.Equal(7u, record.StatModKey);
|
||||
Assert.Equal(25f, record.StatModValue);
|
||||
Assert.Equal(125, player.GetEffectiveSkill(7u));
|
||||
Assert.Equal(1, changed);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WireAll_WeenieError_RoutesToChatLog()
|
||||
{
|
||||
|
|
@ -1294,14 +1344,16 @@ public sealed class GameEventWiringTests
|
|||
uint caster,
|
||||
double startTime,
|
||||
double lastDegraded,
|
||||
uint statModType)
|
||||
uint statModType,
|
||||
uint statModKey = 7u,
|
||||
float statModValue = 1.25f)
|
||||
{
|
||||
byte[] payload = new byte[60];
|
||||
int offset = 0;
|
||||
WriteU16(spellId); WriteU16(layer); WriteU16(3); WriteU16(0);
|
||||
WriteU32(8); WriteF64(startTime); WriteF64(duration); WriteU32(caster);
|
||||
WriteF32(0.1f); WriteF32(-1f); WriteF64(lastDegraded);
|
||||
WriteU32(statModType); WriteU32(7); WriteF32(1.25f);
|
||||
WriteU32(statModType); WriteU32(statModKey); WriteF32(statModValue);
|
||||
return payload;
|
||||
|
||||
void WriteU16(ushort value) { BinaryPrimitives.WriteUInt16LittleEndian(payload.AsSpan(offset), value); offset += 2; }
|
||||
|
|
@ -1310,4 +1362,9 @@ public sealed class GameEventWiringTests
|
|||
void WriteF64(double value) { BinaryPrimitives.WriteDoubleLittleEndian(payload.AsSpan(offset), value); offset += 8; }
|
||||
}
|
||||
|
||||
private static SpellMetadata TestSpell(uint spellId) => new(
|
||||
spellId, "Test", "War Magic", 0u, 0u, "", 0f, 0,
|
||||
false, false, "", 0, 0, 0u, 0, false, false, true,
|
||||
0f, 0u, 0u, 0u, 0);
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue