Skip to content

Code defects surfaced by the docstring pass (PRs #87 to #99) #100

Description

@mmacy

The docstring pass in PRs #87 through #99 documented what the code does rather than changing it. Along the way the coders and reviewers found code that disagrees with its own intent. This issue collects those findings so none is lost. The docstrings in each PR already describe the current behaviour; the fix for each item is a code change plus the docstring update that follows from it.

Each entry names the PR that reported it and the file. A comment is added for each PR as it merges, repeating the defects that PR names.

PR Where Defect
#87 crawl/exploration.py, check_fatigue The guard is any(...) over living members, so a character who joins the party partway through an unrested stretch is never marked fatigued until the next Rest resets the counter. Documented as the current behaviour; probably unintended.
#88 crawl/battle.py, _party_movement BattleDeclaration.move accepts withdraw, but the resolver branches only on close, fighting_withdrawal, and retreat. A withdraw declaration passes validation and moves nobody.
#89 core/spells.py, cast_from_scroll Validation runs with the raw reader and resolution with the scroll's caster level. A 6th-level magic-user reading a magic missile scroll must supply three targets and hits all three, and the two spells with a per-level range are range-checked at the reader's level. Fix shape: build the _ScrollReader before validate_cast.
#91 core/treasure.py, generate_treasure, generate_treasure_entries, generate_unguarded_treasure The tier argument is validated only when a roll reaches a magic item, so tier="bogus" silently yields a coins-only hoard. generate_magic_item shows the pre-check shape.
#93 core/character.py, Character.literacy Nothing in osrlib reads the field. The docstring now says so; either a rule should consume it or the field is dead.
#97 crawl/dungeon.py, DungeonState.discovered_features Declared and never written or read. Secret doors record discovery on DoorState.discovered; features go to found_traps and found_tricks. Removing it is a schema decision.
#99 crawl/battle.py, crawl/encounter.py, EncounterGroup.surrendered The surrender path is declared end to end (message template, battle.side.surrendered code, a dozen reads of the flag, the surrendered defeat outcome in end_encounter), but no code path ever sets the flag.

PRs #90, #92, #94, #95, #96, and #98 reported no code defect.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions