Commit 0537de5
feat(treim.lic): v3.0.0 modernize for Ruby 4.0 / current Lich5 API (#2429)
## Summary
- Full rewrite of `treim.lic` from a flat 789-line procedural script
into a namespaced, YARD-documented `Treim` module (`Geography`,
`Bosses`, `Attack`, `ClearProgress`, `Party`, `Runner`), following the
same modernization pattern established in `dailyvote.lic`.
- Every constant is guarded with `unless const_defined?` so repeated
`;treim` invocations in the same Lich process never redefine/warn.
- Adopts current Lich5 API surface: the native `Group` API replaces
manual `GROUP` command text-parsing, `Lich::Util.issue_command` replaces
the hand-rolled `silence` proc + `DownstreamHook` pairs, and
`Frontend.supports_xml?` replaces the `$frontend` regex check.
- Boss-wave stage progression (Village → Road → … → Royal) is now
data-driven (`Geography::STAGES`) instead of five copy-pasted `elsif`
branches, and the ~10 near-identical stance-dance/attack blocks in the
old `attack_routine` collapse into shared helpers behind a `case`
dispatch in `Attack`.
- Fixes two real crash bugs found during the rewrite:
`variable[2].downcase` and the help/reuse-attack-type check both called
`.downcase` on `nil` in very common invocation paths (any run without a
second argument; any no-arg rerun after an attack type was already
configured) — both raised `NoMethodError`.
- Behavior is otherwise preserved 1:1 against the original, including a
couple of intentionally-kept legacy quirks (documented inline) where
"fixing" them wasn't this PR's call to make.
- Adds `spec/scripts/treim_spec.rb`, extracting the pure/near-pure
modules (`Geography`, `Bosses`, `SeenIds`, `Config`, `Attack` dispatch +
handler bodies, `ClearProgress`, `Party`, `FamiliarWindow`) from the
shipped source the same way `ledger_spec.rb`/`eloot_spec.rb` do, so the
specs fail if the production code drifts.
## Test plan
- [x] `ruby -c scripts/treim.lic` — syntax OK
- [x] `rubocop scripts/treim.lic spec/scripts/treim_spec.rb` — zero
offenses
- [x] `rspec spec/scripts/treim_spec.rb` — 56 examples, 0 failures
- [x] `rspec spec/scripts` (full suite) — 204 examples, 0 failures
- [ ] Live REIM run to confirm `Lich::Util.issue_command`-based REIM
INFO/title-show parsing and native `Group` API behavior against real
game output (not exercised by the spec suite; noted as an open item)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
- **New Features**
- Improved automated REIM navigation, wave handling, combat actions,
progress tracking, party coordination, trap responses, and
familiar-window messages.
- Added improved configuration options for attack styles, stance
control, lag and spam controls, ambient toggles, and rare-item
announcements.
- **Bug Fixes**
- Improved handling for missing arguments, leader detection, floods,
bosses, stage transitions, and shutdown cleanup.
- **Tests**
- Expanded automated coverage for navigation, combat, progress
reporting, party status, configuration, and message formatting.
- Added shared testing utilities for more consistent script validation.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>1 parent 08d4b38 commit 0537de5
6 files changed
Lines changed: 2291 additions & 965 deletions
File tree
- scripts
- spec
- scripts
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
0 commit comments