feat: equipped weapon drives melee damage & swing time (#26) #27

Merged
marco merged 1 commit from feat/equip-combat into main 2026-07-17 14:43:45 +02:00
Owner

Closes part of #26.

Summary

The equipped weapon now actually changes combat, server-side. Equipping a sword makes you hit for 10 (vs the unarmed 5) on a faster swing (8 ticks vs 12) — a rat dies in ~2 hits instead of ~4. Unequip and you're back to fists.

  • Per-kind weapon stats in ItemCatalog (WeaponStats): sword = 10 dmg / 8-tick swing. No per-instance stats yet (a "sword" is always the same) — magic/variable weapons are future.
  • CombatSystem.ApplyWeapon(player, stats?) sets damage + swing cooldown (null = unarmed baseline from CombatOptions).
  • World recomputes from the Weapon slot on equip, unequip, and restore-on-reconnect — all under its single lock. ItemRegistry gained EquippedWeaponKind. Invariants preserved: ItemRegistry = placement, CombatSystem = rules, World = orchestration.
  • Fully authoritative: the client never sends damage; only the equip intent (already validated) flows in.

Scope note (honest)

This delivers the gameplay half of #26. The visual half — the sword animating on your body — is deliberately deferred to #18 (layered equipment): a 1H sword shares the same body attack action (UO action 9) as unarmed, so the difference is the weapon sprite overlaid on the body, not a different animation. Weapon-specific body actions (2H, bow) come when we add those weapon types. The equip effect is already visible today via the damage numbers (-10 vs -5).

How it was tested

New unit tests (WorldTests): equipping overrides damage; equipping overrides swing cadence (lands exactly on the weapon's swing time); unequip reverts to the unarmed baseline; a weapon restored already equipped at reconnect re-arms the wielder. Existing combat/equip/persistence tests unchanged and green.

Checklist

  • just lint clean (CSharpier + analyzers)
  • just test green (180 tests)
  • Whole solution builds, zero warnings
  • Multi-platform preserved (pure .NET)
  • Tests added
Closes part of #26. ## Summary The equipped weapon now actually changes combat, server-side. Equipping a sword makes you hit for **10** (vs the unarmed **5**) on a **faster** swing (8 ticks vs 12) — a rat dies in ~2 hits instead of ~4. Unequip and you're back to fists. - Per-kind weapon stats in `ItemCatalog` (`WeaponStats`): `sword = 10 dmg / 8-tick swing`. No per-instance stats yet (a "sword" is always the same) — magic/variable weapons are future. - `CombatSystem.ApplyWeapon(player, stats?)` sets damage + swing cooldown (null = unarmed baseline from `CombatOptions`). - `World` recomputes from the Weapon slot on **equip**, **unequip**, and **restore-on-reconnect** — all under its single lock. `ItemRegistry` gained `EquippedWeaponKind`. Invariants preserved: ItemRegistry = placement, CombatSystem = rules, World = orchestration. - Fully authoritative: the client never sends damage; only the equip intent (already validated) flows in. ## Scope note (honest) This delivers the **gameplay** half of #26. The **visual** half — the sword *animating on your body* — is deliberately deferred to **#18 (layered equipment)**: a 1H sword shares the same body attack action (UO action 9) as unarmed, so the difference is the weapon *sprite overlaid* on the body, not a different animation. Weapon-specific body actions (2H, bow) come when we add those weapon types. The equip effect is already **visible today** via the damage numbers (`-10` vs `-5`). ## How it was tested New unit tests (`WorldTests`): equipping overrides damage; equipping overrides swing cadence (lands exactly on the weapon's swing time); unequip reverts to the unarmed baseline; a weapon restored **already equipped** at reconnect re-arms the wielder. Existing combat/equip/persistence tests unchanged and green. ## Checklist - [x] `just lint` clean (CSharpier + analyzers) - [x] `just test` green (180 tests) - [x] Whole solution builds, zero warnings - [x] Multi-platform preserved (pure .NET) - [x] Tests added
feat(combat): equipped weapon drives melee damage and swing time
All checks were successful
ci / Lint & Test (pull_request) Successful in 1m30s
b31369b593
The equipped weapon now overrides the wielder's unarmed melee damage and
swing cadence server-side. Weapon stats live in a per-kind ItemCatalog
(sword = 10 dmg / 8-tick swing vs the unarmed 5 dmg / 12-tick baseline).
World recomputes a player's combat stats from their Weapon slot on equip,
unequip, and on restore at reconnect — CombatSystem owns the stat application
(ApplyWeapon), ItemRegistry owns placement, World orchestrates under its lock.
All authoritative: the client never sends damage. The effect is visible today
through the damage numbers; showing the weapon on the body is layered
equipment (#18).
marco merged commit bf12bda463 into main 2026-07-17 14:43:45 +02:00
marco deleted branch feat/equip-combat 2026-07-17 14:43:45 +02:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
marco/IsoMmo!27
No description provided.