Lands the codex-worktree D.2b stream plus the extraction the 2026-07-02 UI architecture review mandated before commit: - ItemInteractionController: single owner of double-click use/equip/ container-open, targeted-use mode (health kits), drag-out drop; toolbar shortcut drags don't drop the real item. ItemEquipRules for multi-slot (coat) coverage via equip masks. - Cursor phase: CursorFeedbackController (semantic priority chain: drag > resize > window-move > target-mode > text) + RetailCursorCatalog (enums 0x27/0x28/0x29, hotspot 14,14; ClientUISystem::UpdateCursorState 0x00564630) resolved through the portal EnumIDMap chain by RetailCursorResolver; RetailCursorManager applies dat cursor art to the OS cursor. Register row AP-72 covers the OS standard-cursor fallback. - Character window goes live: CharacterSheetProvider owns sheet assembly, XP-curve/raise-cost math and the raise flow — extracted out of GameWindow per Code Structure Rule 1 instead of committing the ~430-line feature body there. Optimistic XP/credit debits go through eventful store APIs (new ClientObjectTable.UpdateInt64Property + LocalPlayerState.DebitIntProperty/DebitInt64Property) instead of raw property-dictionary writes; register row AP-73 covers the still-missing raise ledger (#163). - RetailWindowFrame: the shared nine-slice window mount recipe; the character window uses it, remaining windows migrate via #164. - Status-bar buttons toggle inventory/character windows; retail row-major backpack ordering; WorldSession.SendUseWithTarget + raise/train sends. GameWindow shrinks 14,214 -> 13,877 lines despite the new features; the sheet/raise logic is unit-tested in CharacterSheetProviderTests instead of trapped in the god object. Build green; full suite 3,286 tests pass. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
158 lines
4.4 KiB
C#
158 lines
4.4 KiB
C#
using System.Net;
|
|
using AcDream.Core.Combat;
|
|
using AcDream.Core.Net;
|
|
using AcDream.Core.Net.Messages;
|
|
|
|
namespace AcDream.Core.Net.Tests;
|
|
|
|
public sealed class WorldSessionCombatTests
|
|
{
|
|
private static WorldSession NewSession()
|
|
{
|
|
var ep = new IPEndPoint(IPAddress.Loopback, 65000);
|
|
return new WorldSession(ep);
|
|
}
|
|
|
|
[Fact]
|
|
public void SendChangeCombatMode_UsesSequenceAndRetailModeValue()
|
|
{
|
|
using var session = NewSession();
|
|
byte[]? captured = null;
|
|
session.GameActionCapture = body => captured = body;
|
|
|
|
session.SendChangeCombatMode(CombatMode.Magic);
|
|
|
|
Assert.NotNull(captured);
|
|
Assert.Equal(CharacterActions.BuildChangeCombatMode(
|
|
1,
|
|
CharacterActions.CombatMode.Magic), captured);
|
|
}
|
|
|
|
[Fact]
|
|
public void SendRaiseAttribute_UsesRetailBuilder()
|
|
{
|
|
using var session = NewSession();
|
|
byte[]? captured = null;
|
|
session.GameActionCapture = body => captured = body;
|
|
|
|
session.SendRaiseAttribute(5u, 110u);
|
|
|
|
Assert.NotNull(captured);
|
|
Assert.Equal(CharacterActions.BuildRaiseAttribute(1, 5u, 110u), captured);
|
|
}
|
|
|
|
[Fact]
|
|
public void SendRaiseVital_UsesRetailBuilder()
|
|
{
|
|
using var session = NewSession();
|
|
byte[]? captured = null;
|
|
session.GameActionCapture = body => captured = body;
|
|
|
|
session.SendRaiseVital(1u, 90u);
|
|
|
|
Assert.NotNull(captured);
|
|
Assert.Equal(CharacterActions.BuildRaiseVital(1, 1u, 90u), captured);
|
|
}
|
|
|
|
[Fact]
|
|
public void SendRaiseSkill_UsesRetailBuilder()
|
|
{
|
|
using var session = NewSession();
|
|
byte[]? captured = null;
|
|
session.GameActionCapture = body => captured = body;
|
|
|
|
session.SendRaiseSkill(34u, 111_000_000u);
|
|
|
|
Assert.NotNull(captured);
|
|
Assert.Equal(CharacterActions.BuildRaiseSkill(1, 34u, 111_000_000u), captured);
|
|
}
|
|
|
|
[Fact]
|
|
public void SendTrainSkill_UsesRetailBuilder()
|
|
{
|
|
using var session = NewSession();
|
|
byte[]? captured = null;
|
|
session.GameActionCapture = body => captured = body;
|
|
|
|
session.SendTrainSkill(21u, 6u);
|
|
|
|
Assert.NotNull(captured);
|
|
Assert.Equal(CharacterActions.BuildTrainSkill(1, 21u, 6u), captured);
|
|
}
|
|
|
|
[Fact]
|
|
public void SendMeleeAttack_UsesRetailMeleeBuilder()
|
|
{
|
|
using var session = NewSession();
|
|
byte[]? captured = null;
|
|
session.GameActionCapture = body => captured = body;
|
|
|
|
session.SendMeleeAttack(0x50000002u, AttackHeight.High, 0.75f);
|
|
|
|
Assert.NotNull(captured);
|
|
Assert.Equal(AttackTargetRequest.BuildMelee(
|
|
1,
|
|
0x50000002u,
|
|
(uint)AttackHeight.High,
|
|
0.75f), captured);
|
|
}
|
|
|
|
[Fact]
|
|
public void SendMissileAttack_UsesRetailMissileBuilder()
|
|
{
|
|
using var session = NewSession();
|
|
byte[]? captured = null;
|
|
session.GameActionCapture = body => captured = body;
|
|
|
|
session.SendMissileAttack(0x50000003u, AttackHeight.Low, 0.5f);
|
|
|
|
Assert.NotNull(captured);
|
|
Assert.Equal(AttackTargetRequest.BuildMissile(
|
|
1,
|
|
0x50000003u,
|
|
(uint)AttackHeight.Low,
|
|
0.5f), captured);
|
|
}
|
|
|
|
[Fact]
|
|
public void SendCancelAttack_UsesRetailCancelBuilder()
|
|
{
|
|
using var session = NewSession();
|
|
byte[]? captured = null;
|
|
session.GameActionCapture = body => captured = body;
|
|
|
|
session.SendCancelAttack();
|
|
|
|
Assert.NotNull(captured);
|
|
Assert.Equal(AttackTargetRequest.BuildCancel(1), captured);
|
|
}
|
|
|
|
[Fact]
|
|
public void SendQueryHealth_UsesRetailQueryHealthBuilder()
|
|
{
|
|
// Retail anchor: CM_Combat::Event_QueryHealth / gmToolbarUI::HandleSelectionChanged:198635
|
|
using var session = NewSession();
|
|
byte[]? captured = null;
|
|
session.GameActionCapture = body => captured = body;
|
|
|
|
session.SendQueryHealth(0x50000007u);
|
|
|
|
Assert.NotNull(captured);
|
|
Assert.Equal(SocialActions.BuildQueryHealth(1, 0x50000007u), captured);
|
|
}
|
|
|
|
[Fact]
|
|
public void SendUseWithTarget_UsesRetailBuilder()
|
|
{
|
|
using var session = NewSession();
|
|
byte[]? captured = null;
|
|
session.GameActionCapture = body => captured = body;
|
|
|
|
session.SendUseWithTarget(0x50000A01u, 0x50000001u);
|
|
|
|
Assert.NotNull(captured);
|
|
Assert.Equal(
|
|
InteractRequests.BuildUseWithTarget(1, 0x50000A01u, 0x50000001u),
|
|
captured);
|
|
}
|
|
}
|