Create new interaction interface #438
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!438
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "inquirer"
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 #436
Closes #384
Closes #15
interactmoduleWhich card do you want to play?Was not able to find the class of this card.\nWhat is the class of this card?Summary by CodeRabbit
Bug Fixes
New Features
Refactoring
Tests
✏️ Tip: You can customize this high-level summary in your review settings.
Walkthrough
Replaced many string-based console prompts with Inquirer.js-driven menus across core and tooling, updated several public APIs and types (AI, Card, Player, GameConfig), adjusted test input tokens to new prompt tokens, and refactored tools (card/deck/packager) and hub to interactive flows; also guarded script main lifecycles.
Changes
cards/Classes/Neutral/Uncollectible/Spells/0-Cost/reign-of-chaos-2ef76c34.ts,cards/Examples/3/1-manathirst.ts,cards/Lackeys/goblin-4cde4d98.ts,cards/Lackeys/kobold-bf5c86d3.ts,cards/Lackeys/witchy-39591f26.ts,cards/StartingHeroes/Mage/heropower-4b71b3e6.ts,cards/StartingHeroes/Priest/heropower-7b3ef914.ts"1","face","y") to new token identifiers (e.g.,"e0","f0","pe","pf") to match new prompt semantics; no gameplay logic changes.config.ts,src/types/other.tsdebug.hideRedundantInformation; addedadvanced.gameloopUseOldUserInterfaceto GameConfig.src/ai.ts,src/card.ts,src/player.tsAI.question→AI.chooseFromList(returns stringsrc/game.tslogTranslate,inputTranslate,inputTranslateWithOptions,pauseTranslate.src/functions/interact.ts,src/functions/card.tscustomSelect,customSelectEnum,configureArray,configureArrayEnum,configureObject), extended target APIs withshouldBeDisabledcallbacks, migrated mulligan/dredge/discover/choose flows to prompt-driven UX, and addedreadables()for card displays.src/commands.tshelpColumns/helpDebugColumns; replaced numeric/string prompts withcustomSelectflows (e.g., Titan ability selection); adjusted separators and pause behavior.src/functions/deckcode.ts,src/functions/info.ts,src/functions/util.tsparseInt(..., 10)across parsing sites; standardized multi-match selection flows to usecustomSelect.src/event.tshub.ts,scripts/test/cards.ts,scripts/test/crash.ts,scripts/vanilla/generate.tscardCreator()); guarded top-level game initialization and exportedmain()functions; removed unconditional process.exit() calls and conditionalized script runs onimport.meta.main.tools/cardcreator/class.ts,tools/cardcreator/custom.ts,tools/cardcreator/vanilla.ts,tools/cardcreator/lib.tsblueprint.idon create and immediately push blueprint + regenerate IDs.tools/deckcreator.ts,tools/packager.tsaskClass()may returnundefined; addedrules()command; packager migrated togame.prompt.customSelect, increased pageSize, and replaced metadata helpers with prompt configuration APIs.src/functions/card.ts,src/functions/deckcode.ts,src/functions/interact.ts,src/functions/util.tsreadables()mapping for card displays; standardized numeric parsing; replaced many console prompts with prompt APIs; minor formatting/TODO updates.test/src/functions/card.test.ts,test/src/functions/interact.test.ts,test/src/game.test.ts,test/src/player.test.tstest.todoentries to reflect new prompt APIs and removed translation-related todos; added todos forreadables, prompt utilities,canActuallyAttack, andinputQueueNext.README.mdEstimated code review effort
🎯 5 (Critical) | ⏱️ ~120 minutes
Areas that will need careful review:
Possibly related PRs
Suggested labels
type: improvementPoem
Pre-merge checks and finishing touches
❌ Failed checks (1 warning, 1 inconclusive)
@coderabbitai generate docstringsto improve docstring coverage.✅ Passed checks (3 passed)
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.@ -1,290 +1,331 @@import { Card } from "@Game/card.ts";Only change the what was changed by the user. Do
card[key] = valuewhere we doblueprint[key] = value. Add special case for keywords.tagsinstead of all this.Actionable comments posted: 9
🧹 Nitpick comments (13)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between
8508a839acandfd2e5266cd.📒 Files selected for processing (35)
README.md(1 hunks)cards/Classes/Neutral/Uncollectible/Spells/0-Cost/reign-of-chaos-2ef76c34.ts(1 hunks)cards/Examples/3/1-manathirst.ts(1 hunks)cards/Lackeys/goblin-4cde4d98.ts(1 hunks)cards/Lackeys/kobold-bf5c86d3.ts(1 hunks)cards/Lackeys/witchy-39591f26.ts(1 hunks)cards/StartingHeroes/Mage/heropower-4b71b3e6.ts(1 hunks)cards/StartingHeroes/Priest/heropower-7b3ef914.ts(1 hunks)config.ts(3 hunks)hub.ts(2 hunks)scripts/test/cards.ts(3 hunks)scripts/test/crash.ts(2 hunks)scripts/vanilla/generate.ts(3 hunks)src/ai.ts(4 hunks)src/card.ts(6 hunks)src/commands.ts(8 hunks)src/event.ts(1 hunks)src/functions/card.ts(4 hunks)src/functions/deckcode.ts(6 hunks)src/functions/info.ts(1 hunks)src/functions/interact.ts(29 hunks)src/functions/util.ts(1 hunks)src/game.ts(0 hunks)src/player.ts(4 hunks)src/types/other.ts(1 hunks)test/src/functions/card.test.ts(1 hunks)test/src/functions/interact.test.ts(1 hunks)test/src/game.test.ts(0 hunks)test/src/player.test.ts(2 hunks)tools/cardcreator/class.ts(2 hunks)tools/cardcreator/custom.ts(2 hunks)tools/cardcreator/lib.ts(3 hunks)tools/cardcreator/vanilla.ts(3 hunks)tools/deckcreator.ts(7 hunks)tools/packager.ts(7 hunks)💤 Files with no reviewable changes (2)
🧰 Additional context used
🧬 Code graph analysis (14)
hub.ts (6)
tools/cardcreator/class.ts (3)
tools/deckcreator.ts (1)
tools/cardcreator/vanilla.ts (3)
tools/cardcreator/lib.ts (3)
src/functions/util.ts (2)
scripts/vanilla/generate.ts (3)
src/functions/card.ts (1)
src/commands.ts (2)
scripts/test/crash.ts (4)
src/player.ts (3)
scripts/test/cards.ts (6)
tools/cardcreator/custom.ts (3)
src/functions/interact.ts (4)
🔇 Additional comments (60)
@ -69,0 +301,4 @@new Separator(),"Done",);⚠️ Potential issue | 🟡 Minor
Missing
awaiton asynconLoopcallback.Unlike
configureArray(line 203) andconfigureObject(line 388) which correctly useawait onLoop?.(), this call is missing theawait, which could cause timing issues with watermark rendering.📝 Committable suggestion
🤖 Prompt for AI Agents
✅ Addressed in commit
837c778⚠️ Potential issue | 🟡 Minor
Unclosed color tag in warning message.
The closing tag uses
<yellow>instead of</yellow>, which may cause unintended color rendering.📝 Committable suggestion
🤖 Prompt for AI Agents
✅ Addressed in commit
837c778@ -35,0 +52,4 @@const card = await Card.create(game.cardIds.sheep_668b9054_7ca9_49af_9dd9_4f0126c6894c,game.player,);⚠️ Potential issue | 🟠 Major
Logic errors in the
set()helper function.Two issues:
Line 51:
(card.keywords as any)[key]whenkey === "keywords"setscard.keywords["keywords"]to undefined, which doesn't seem intentional.Line 55:
Array.isArray(typeof (card as any)[key])is alwaysfalsebecausetypeofreturns a string (e.g.,"object"), not an array. The condition should check the value directly.🤖 Prompt for AI Agents
@ -160,0 +321,4 @@}delete blueprint[key];}⚠️ Potential issue | 🟡 Minor
Unclosed color tag in warning message.
Same issue as in
class.ts- the closing tag uses<yellow>instead of</yellow>.📝 Committable suggestion
🤖 Prompt for AI Agents
✅ Addressed in commit
837c778⚠️ Potential issue | 🟡 Minor
Missing
awaiton asyncdoBlueprintcall.doBlueprintis an async function. Withoutawait, the blueprint reset may not complete before the loop continues, potentially displaying stale card state.📝 Committable suggestion
🤖 Prompt for AI Agents
✅ Addressed in commit
837c778⚠️ Potential issue | 🟡 Minor
Chalk tags won't render in inquirer prompt message.
The
input()function from@inquirer/promptsdoesn't automatically parse chalk tags like<red>...</red>. The message will display the raw tags.Wrap the message with
parseTags():📝 Committable suggestion
🤖 Prompt for AI Agents
✅ Addressed in commit
837c778@ -208,0 +244,4 @@return cards;},pageSize: 15,});⚠️ Potential issue | 🟡 Minor
cardCostmay beNaNwhen user types "unknown".The validation at line 207 allows
value.toLowerCase() === "unknown"to pass, but thenparseIntat line 203 returnsNaN. ThisNaNis assigned tocardCostand used in the filter at lines 222-223, wherec.cost === cardCostwill always befalsewhencardCostisNaN.If "unknown" is meant to skip cost filtering, set
cardCosttoundefinedinstead:📝 Committable suggestion
🤖 Prompt for AI Agents
@ -680,4 +90,3 @@/*** Generates a deckcode from the current deck.*⚠️ Potential issue | 🟠 Major
🧩 Analysis chain
🏁 Script executed:
Repository: LunarTides/Hearthstone.js
Length of output: 89
🏁 Script executed:
Repository: LunarTides/Hearthstone.js
Length of output: 116
🏁 Script executed:
Repository: LunarTides/Hearthstone.js
Length of output: 207
🏁 Script executed:
Repository: LunarTides/Hearthstone.js
Length of output: 91
🏁 Script executed:
Repository: LunarTides/Hearthstone.js
Length of output: 262
🏁 Script executed:
Repository: LunarTides/Hearthstone.js
Length of output: 2755
🏁 Script executed:
Repository: LunarTides/Hearthstone.js
Length of output: 783
🏁 Script executed:
Repository: LunarTides/Hearthstone.js
Length of output: 233
Avoid persisting
"Back"as a hero class when cancellingaskClassThe
askClassfunction assigns directly toplayer.heroClassfromcustomSelectEnumbefore checking for the "Back" option:When a user selects "Back",
player.heroClassis left as the invalid string"Back"instead of reverting to its previous value. This breaks the invariant thatplayer.heroClassis always a validClassenum value and can leak into downstream logic.Use an intermediate variable to validate before assignment:
🤖 Prompt for AI Agents
✅ Addressed in commit
837c778@ -305,7 +260,7 @@ async function exportPack() {if (⚠️ Potential issue | 🟡 Minor
Missing
awaitongame.pause().game.pause()is an async function, butawaitis missing. This could cause thecontinueto execute before the user sees the message.📝 Committable suggestion
🤖 Prompt for AI Agents
✅ Addressed in commit
837c778Actionable comments posted: 3
♻️ Duplicate comments (4)
🧹 Nitpick comments (11)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between
fd2e5266cdand837c7780ef.📒 Files selected for processing (7)
src/card.ts(6 hunks)src/functions/interact.ts(29 hunks)tools/cardcreator/class.ts(2 hunks)tools/cardcreator/custom.ts(2 hunks)tools/cardcreator/vanilla.ts(3 hunks)tools/deckcreator.ts(7 hunks)tools/packager.ts(8 hunks)🧰 Additional context used
🧬 Code graph analysis (5)
tools/cardcreator/vanilla.ts (2)
tools/deckcreator.ts (4)
tools/cardcreator/class.ts (1)
tools/cardcreator/custom.ts (4)
src/functions/interact.ts (2)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🔇 Additional comments (15)
@ -5,0 +131,4 @@default: false,});if (done) {⚠️ Potential issue | 🔴 Critical
🧩 Analysis chain
🌐 Web query:
@inquirer/prompts number function required option TypeScript types💡 Result:
Short answer — the number prompt options are typed roughly like this:
type NumberValidate = (value: number | undefined) => boolean | string | Promise<boolean | string>;
interface NumberOptions {
message: string;
default?: number;
min?: number;
max?: number;
step?: number | 'any';
required?: boolean; // defaults to false
validate?: NumberValidate;
theme?: unknown;
}
Usage example:
import { number } from '@inquirer/prompts';
const answer = await number({
message: 'Enter a value',
required: true, // prevents empty (undefined) answers
validate: (v) => (v === undefined ? 'Required' : v >= 0 || 'Must be >= 0'),
});
Sources: @inquirer/number/@inquirer/prompts docs (options table, including required and validate signatures). [1][2]
🌐 Web query:
@inquirer/prompts number function return type Promise signature💡 Result:
Signature (TypeScript, concise):
Notes: the prompt returns a cancelable Promise (callable .cancel() to reject/cleanup). Source: @inquirer/prompts / @inquirer/number docs. [1][2]
Sources
[1] @inquirer/number (npm) — options/validate docs.
[2] @inquirer/prompts (package README / docs) — “All prompt functions are returning a cancelable promise.”
number()still returnsnumber | undefinedeven withrequired: true.The
@inquirer/promptsnumber()function returnsPromise<number | undefined>regardless of therequiredoption. Therequired: truesetting only prevents users from submitting empty values in the UI but does not narrow the TypeScript return type. The assignment toheropowerBlueprint.costcould therefore receiveundefined, creating a type safety issue.🤖 Prompt for AI Agents
⚠️ Potential issue | 🔴 Critical
Critical bug:
Boolean("false")always returnstrue.The variable
newRarityis a string ("true" or "false"), andBoolean("false")evaluates totruebecause any non-empty string is truthy. This means selecting "False" will incorrectly set the value totrue.📝 Committable suggestion
🤖 Prompt for AI Agents
✅ Addressed in commit 5b5bc74
⚠️ Potential issue | 🟡 Minor
Validation function and JSON.parse have issues.
Line 298:
typeof value === "number"is always false sinceinput()returns a string. The validation never triggers.Line 309:
JSON.parse(newValue)can throw on malformed input with no error handling.📝 Committable suggestion
🤖 Prompt for AI Agents
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between
837c7780efand 5b5bc74dfea3c19ec9f6d3018a5c2ed9e282e103.📒 Files selected for processing (1)
tools/cardcreator/custom.ts(2 hunks)🧰 Additional context used
🧬 Code graph analysis (1)
tools/cardcreator/custom.ts (3)
🔇 Additional comments (6)
⚠️ Potential issue | 🟡 Minor
Unhandled
JSON.parseexception and redundant assignment.Line 313:
JSON.parse(newValue)can throw if the user enters malformed JSON. Since validation only checks for valid numbers whenblueprint[key]is a number, other types could receive invalid JSON input.Line 316:
dirty = trueis redundant sinceset()already setsdirty = trueon line 49.📝 Committable suggestion
🤖 Prompt for AI Agents