Skip to content

refactor(dr): workorders.lic comprehensive refactor#1

Closed
MahtraDR wants to merge 1 commit intomainfrom
refactor/workorders
Closed

refactor(dr): workorders.lic comprehensive refactor#1
MahtraDR wants to merge 1 commit intomainfrom
refactor/workorders

Conversation

@MahtraDR
Copy link
Owner

@MahtraDR MahtraDR commented Feb 8, 2026

Summary

Comprehensive refactor of workorders.lic following established refactoring patterns. Fixes NPC walking away bug and adds robust error handling.

Bug Fixes

  • NPC walking away during turn-in not handled — added "What is it you're trying to give" pattern to retry loop. When NPC wanders off mid-interaction, script now finds them again instead of timing out.
  • find_npc doesn't verify NPC presence — now returns boolean and confirms NPC is in room after walking

Code Improvements

  • Add frozen_string_literal: true
  • Extract 15 frozen pattern constants (GIVE_LOGBOOK_, REPAIR_, BUNDLE_, WORK_ORDER_, READ_LOGBOOK_, COUNT_, TAP_HERB_*, MATERIAL_NOUNS)
  • Replace 12+ Regexp.last_match with named captures
  • Replace all echo/DRC.message with Lich::Messaging.msg and WorkOrders: prefix
  • Add verbose messaging on all exit paths
  • Nil-safe iteration with &.each in buy_parts/order_parts
  • Remove unused reget call in enchanting_items

Test plan

  • 41 RSpec examples passing
  • Rubocop clean
  • In-game testing of work order turn-in with NPC present
  • In-game testing when NPC walks away during turn-in (verify retry works)

🤖 Generated with Claude Code

Bug fixes:
- Fix NPC walking away during turn-in not handled (add "What is it you're
  trying to give" pattern to retry loop)
- find_npc now returns boolean and verifies NPC presence after walking

Code improvements:
- Add frozen_string_literal: true
- Extract 15 frozen pattern constants (GIVE_LOGBOOK_*, REPAIR_*, BUNDLE_*,
  WORK_ORDER_*, READ_LOGBOOK_*, COUNT_*, TAP_HERB_*, MATERIAL_NOUNS)
- Replace all Regexp.last_match with named captures (WORK_ORDER_ITEM_PATTERN,
  LOGBOOK_REMAINING_PATTERN, POLISH_COUNT_PATTERN, TAP_HERB_PATTERN,
  HERB_COUNT_PATTERN, REMEDY_COUNT_PATTERN)
- Replace all echo/DRC.message with Lich::Messaging.msg and WorkOrders: prefix
- Add verbose messaging on all exit paths
- Nil-safe iteration with &. operator in buy_parts/order_parts
- Remove unused reget call in enchanting_items

Testing:
- Add 41 comprehensive specs covering constants, find_npc, complete_work_order,
  bundle_item, find_recipe, repair_items, buy_parts, order_parts, and pattern
  matching

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@MahtraDR MahtraDR closed this Feb 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant