Make the history command more readable #448
No reviewers
Labels
No labels
breaking change
duplicate
good first issue
help wanted
invalid
question
scope: card
scope: docs
scope: game
scope: registry
scope: script
scope: tool
scope: universe
tracker
type: bug
type: card request
type: documentation
type: enhancement
type: improvement
type: parity
wontfix
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
LunarTides/Hearthstone.js!448
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "history"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #445
Summary by CodeRabbit
New Features
Refactor
Bug Fixes
Chores
✏️ Tip: You can customize this high-level summary in your review settings.
📝 Walkthrough
Walkthrough
Adds a configurable per-event
readableHistorymapping to produce human-readable history entries, removesEvent.GameLoop(switching tick emission toEvent.Dummy), updates history initialization and rendering logic, adjusts tests and interaction prompts, and addsPlayer.readable()plus a minor comment inCard.readable().Changes
cards/Debug/inf-mana-47a7e94b.ts,cards/Examples/4/5-tick-hook.tsEvent.GameLoopwithEvent.Dummyandundefinedpayloads (tick trigger/source changed).config.tsconfig.advanced.readableHistorywith per-event async handlers; expanded public imports to includeAlignmentandTargetType.src/types/event.ts,src/types/other.tsEvent.GameLoopenum member and itsEventValuemapping; addedEventValueimport and typedGameConfig.advanced.readableHistory.src/event.ts,src/commands.tshandle(value, hide)flow; integratedreadableHistorycallbacks when rendering history; adjusted hide/reveal checks and history formatting.src/functions/interact.tsEvent.GameLooptoEvent.Dummy; unified input wrapper signature; changed prompt call/spacing in UI path.src/player.ts,src/card.tsPlayer.readable()method; inserted a TODO comment inCard.readable().Sequence Diagram(s)
Estimated code review effort
🎯 4 (Complex) | ⏱️ ~45 minutes
Possibly related PRs
config.advanced.readableHistoryhandlers and history rendering changes; strong overlap with this PR's history formatting work.src/functions/interact.tsand test tick changes.Suggested labels
breaking changePoem
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
#445: adds readableHistory config mapping for human-readable event messages and integrates it into the history command.✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share
Comment
@coderabbitai helpto get the list of available commands and usage tips.Actionable comments posted: 2
🤖 Fix all issues with AI agents
🧹 Nitpick comments (2)
@ -365,6 +371,127 @@ export const config: GameConfig = {Event.AddCardToHand,⚠️ Potential issue | 🟡 Minor
🧩 Analysis chain
🏁 Script executed:
Repository: LunarTides/Hearthstone.js
Length of output: 1147
🏁 Script executed:
Repository: LunarTides/Hearthstone.js
Length of output: 505
🏁 Script executed:
Repository: LunarTides/Hearthstone.js
Length of output: 235
Fix misleading health restoration message text.
The message says
"restored <b>${value}</b> health", which impliesvalueis the amount restored (delta). However, examining the broadcasts insrc/card.ts(lines 914, 919), theHealthRestoredevent passes the resulting health total (this.maxHealthorthis.health), not the delta. The type comment insrc/types/event.ts(lines 143-146) correctly reflects this as "The amount of health after restore."Change the message to
"restored to <b>${value}</b> health"or calculate and pass the delta as the event value instead.🤖 Prompt for AI Agents
✅ Addressed in commit
f9712c9⚠️ Potential issue | 🟡 Minor
Unclosed bold tag.
The closing tag is missing a forward slash:
<b>${amount}<b>should be<b>${amount}</b>.🔧 Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents
✅ Addressed in commit
f9712c9Actionable comments posted: 1
🤖 Fix all issues with AI agents
🧹 Nitpick comments (1)
⚠️ Potential issue | 🔴 Critical
🧩 Analysis chain
🏁 Script executed:
Repository: LunarTides/Hearthstone.js
Length of output: 161
🏁 Script executed:
Repository: LunarTides/Hearthstone.js
Length of output: 371
🏁 Script executed:
Repository: LunarTides/Hearthstone.js
Length of output: 467
🏁 Script executed:
Repository: LunarTides/Hearthstone.js
Length of output: 562
Replace enum lookups with explicit
!== undefinedchecks inTargetSelectionStarts.The current truthiness checks will fail when
flags.targetTypeorflags.alignmentis0, which are valid enum values (TargetType.PlayerandAlignment.Friendlyrespectively). This causes the fallback"All"to display incorrectly.Fix: Use explicit undefined checks
📝 Committable suggestion
🤖 Prompt for AI Agents
✅ Addressed in commit 2fca7ec
Actionable comments posted: 1
🤖 Fix all issues with AI agents
🧹 Nitpick comments (1)
@ -395,2 +392,2 @@if (!hide || value.owner === player) {return await showCard(value);if (!hide || value.owner === game.player) {return await value.readable();⚠️ Potential issue | 🔴 Critical
Missing
awaitforPlayer.readable()call.Player.readable()is an async method (returnsPromise<string>per the relevant snippet), but the call on line 379 is not awaited. This will return a Promise object instead of the resolved string.🐛 Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents
✅ Addressed in commit
bcdcabf