Improve runes #418
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!418
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "runes"
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?
Use a new
Runeenum rather than a string using characters.Closes #417
Summary by CodeRabbit
New Features
Bug Fixes
Tests
Walkthrough
Migrates rune representation from a string (e.g., "FFB") to a typed
Rune[]enum (e.g.,[Rune.Frost, Rune.Frost, Rune.Blood]). AddsRuneenum and updates types, core classes, deckcode import/export, tools, examples, and tests to use the newRune[]shape.Changes
src/types/card.tsenum Rune { Blood, Frost, Unholy }; changeBlueprintWithOptional.runestype fromstringtoRune[].src/card.ts,src/player.tsCard.runesandPlayer.runesfromstringtoRune[]; updatePlayer.testRunes(runes: Rune[])and its comparison logic to operate on arrays ofRune.src/functions/deckcode.tsrunes: Rune[]; map rune characters ↔Runeenum on import and export and adjust serialization/validation logic.cards/Examples/2/4-runes.ts,cards/Examples/2/lastb-main.tsRune; change blueprintself.runesassignments from string literals toRune[]arrays.tools/cardcreator/custom.ts,tools/cardcreator/lib.ts,tools/deckcreator.tsRune[]; validate/map input characters toRuneenum; add conditionalRuneimports in generated content.test/src/player.test.tsRune[]toPlayer.testRunes()and assert behavior with enum-based inputs.package.json,cards/...Sequence Diagram(s)
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~25 minutes
src/functions/deckcode.ts— mapping between rune chars andRuneenum and serialization/round-trip correctness.src/player.ts—testRuneslogic and counts using arrays instead of string counts.tools/cardcreator/lib.ts&tools/deckcreator.ts— generated templates and CLI input validation for Rune[].Possibly related PRs
Rune[]migration across types, models, deckcode, tools, and tests; likely the closest code-level match.Poem
Pre-merge checks and finishing touches
❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
📜 Recent review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between b831562550698d267197eb9e3ed76a2acf18947e and
d66560d9ab.📒 Files selected for processing (3)
src/functions/deckcode.ts(6 hunks)tools/cardcreator/custom.ts(2 hunks)tools/deckcreator.ts(3 hunks)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: 0
🧹 Nitpick comments (5)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between
99b306e0b3anda105ec6aa2.📒 Files selected for processing (10)
cards/Examples/2/4-runes.ts(2 hunks)cards/Examples/2/lastb-main.ts(2 hunks)src/card.ts(2 hunks)src/functions/deckcode.ts(6 hunks)src/player.ts(3 hunks)src/types/card.ts(2 hunks)test/src/player.test.ts(2 hunks)tools/cardcreator/custom.ts(2 hunks)tools/cardcreator/lib.ts(2 hunks)tools/deckcreator.ts(3 hunks)🧰 Additional context used
🧬 Code graph analysis (3)
tools/deckcreator.ts (1)
tools/cardcreator/custom.ts (2)
tools/cardcreator/lib.ts (1)
🔇 Additional comments (8)
Actionable comments posted: 1
🧹 Nitpick comments (3)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between
a105ec6aa2and b831562550698d267197eb9e3ed76a2acf18947e.📒 Files selected for processing (3)
src/functions/deckcode.ts(6 hunks)tools/cardcreator/custom.ts(2 hunks)tools/deckcreator.ts(3 hunks)🚧 Files skipped from review as they are similar to previous changes (1)
🧰 Additional context used
🧬 Code graph analysis (2)
tools/cardcreator/custom.ts (2)
src/functions/deckcode.ts (3)
🔇 Additional comments (2)
@ -117,12 +118,27 @@ async function common(): Promise<BlueprintWithOptional> {.map((k) => game.lodash.startCase(k) as Keyword);⚠️ Potential issue | 🟠 Major
🧩 Analysis chain
Fix case-insensitive matching and potential ambiguity in rune selection.
The current implementation has two critical issues:
Case sensitivity:
rune.startsWith(char)is case-sensitive. If users enter lowercase letters (e.g., "f" for Frost) but the enum values are capitalized, the match will fail and throw "Invalid rune found."Ambiguous matching: Using
.find()with.startsWith()returns only the first matching rune. If multiple runes start with the same letter (e.g., "Frost" and "Fire" both start with "F"), users cannot select the second one.Apply this diff to fix both issues by matching case-insensitively and using a map for unambiguous lookup:
This change:
Mapfor O(1) lookup and unambiguous matchingRun the following script to verify the Rune enum definition and check for initial collisions:
🏁 Script executed:
Length of output: 654
Fix case-sensitivity in rune selection logic.
The case-sensitivity issue is valid—users entering lowercase letters will be rejected even though the prompt only shows uppercase initials. However, verification shows the Rune enum has unique first characters (B, F, U), so there is no collision/ambiguity concern.
A simpler fix addresses only the actual issue:
This normalizes input to uppercase, making matching case-insensitive without overcomplicating the logic.
📝 Committable suggestion
🤖 Prompt for AI Agents