ModernUO/Projects/UOContent.Tests/Tests
Kamron Batman 8e5e4f72c8
fix(ninjitsu): gate Animal Form gump by skill and stop mana drain (#2452) (#2468)
## Issue

Fixes #2452. A player with 30 Ninjitsu reported that the Animal Form menu showed **every** form; selecting one above their skill (e.g. Dog, req 40) **consumed mana** and returned "you need at least 40 skill", and afterwards the **gump never reopened** — every recast silently re-attempted the unusable form and drained more mana.

## Root cause

Three linked bugs, all reproduced from the code:

1. **Gump not gated by skill.** `AnimalFormGump.BuildLayout` compared `Skill.Fixed` (which is `Value * 10`, so 30 skill → `300`) against the raw 0–100 `ReqSkill` (Dog = `40`). `300 >= 40` is always true, so all forms were shown. `Morph` itself correctly uses `.Value`.
2. **Mana charged on a no-skill cast.** `Morph` returns `MorphResult.NoSkill` for an under-skilled form, but both call sites (`OnCast`, `OnResponse`) only special-cased `MorphResult.Fail`; `NoSkill` fell through to the branch that deducts mana.
3. **Menu never reopened.** Per OSI ([uo.com](https://uo.com/wiki/ultima-online-wiki/skills/ninjitsu/), [uoguide](https://www.uoguide.com/Animal_Form)), casting while **standing still always opens the selection menu**, and casting while **moving** quick-transforms into the last selected form. ModernUO only opened the menu when `lastAnimalForm == -1`, so once any form was selected a stationary recast skipped the menu.

## Fix

- Add `AnimalForm.CanSelectEntry` (compares `Skill.Value` to `ReqSkill`, plus the talisman check) and use it for the gump's per-entry enable check.
- `OnCast`: standing still always opens the menu; moving quick-transforms into the last form. `NoSkill` no longer costs mana.
- `OnResponse`: handle `Success` / `Fail` / `NoSkill` explicitly so `NoSkill` costs no mana.

## Tests

Adds `AnimalFormTests`:
- `CanSelectEntry` rejects forms above skill, accepts forms at/below skill, and requires a talisman for talisman-gated forms.
- `Morph` returns `NoSkill` (without transforming) when under-skilled, and `Success` when sufficiently skilled.

Verified the gating test catches the regression (reintroducing `.Fixed` fails it). Full solution build is clean; the 5 new tests plus 284 other UOContent tests pass (the pathfinding/AI sequential tests were excluded only because they deadlock under concurrent local runs — they are unrelated to this change).
2026-06-06 15:56:31 -07:00
..
Accounting feat: Adds Latin1 text support (#2317) 2026-01-22 15:51:00 -08:00
Engines feat(pathfinding): .swb uniform-chunk elision (format v5) — Trammel 592→232 MB (#2465) 2026-06-06 15:20:27 -07:00
Gumps feat: Adds grid support for the DynamicGump system (#2306) 2026-01-03 10:12:22 -08:00
Items refactor: decompose mobile/corpse hair, delete VirtualHairInfo, fix removal serial (#2462) (#2463) 2026-06-06 14:33:28 -07:00
Misc chore: Fixes name verification test (#2201) 2025-05-26 22:36:23 -07:00
Mobiles/AI fix(ai): creatures pathfind around concave obstacles instead of oscillating (#2461) 2026-06-06 10:20:52 -07:00
Multis feat: Upgrades networking to use io_uring. (#2315) 2026-02-01 16:02:32 -08:00
Network/Packets feat: Upgrades networking to use io_uring. (#2315) 2026-02-01 16:02:32 -08:00
Skills feat: Implements passive Detect Hidden mechanics (#2342) 2026-02-28 11:24:49 -08:00
Spells/Ninjitsu fix(ninjitsu): gate Animal Form gump by skill and stop mana drain (#2452) (#2468) 2026-06-06 15:56:31 -07:00
Utilities chore: Use var everywhere (#2294) 2025-12-27 16:47:28 -08:00
WorldSaves feat: Implements new robust/pluggable backup/archive system. (#2388) 2026-03-22 19:51:20 -07:00