feat: changed stats storage location, refactored code

This commit is contained in:
2025-11-21 15:47:56 +01:00
parent 043812606d
commit 052819a7c7
4 changed files with 115 additions and 64 deletions

18
main.ts
View File

@@ -46,7 +46,9 @@ class MorseGame {
await this.resetStats();
break;
case "exit":
console.log(colors.cyan("\nThanks for playing! 73 (Best regards in morse)\n"));
console.log(
colors.cyan("\nThanks for playing! 73 (Best regards in morse)\n")
);
return;
}
}
@@ -226,7 +228,9 @@ class MorseGame {
console.log(colors.bold.cyan("\n📈 QUICK STATS\n"));
console.log(`Games Played: ${colors.bold(stats.totalGames.toString())}`);
console.log(`Total Rounds: ${colors.bold(stats.totalRounds.toString())}`);
console.log(`Accuracy: ${colors.bold(getAccuracy(stats).toFixed(1) + "%")}`);
console.log(
`Accuracy: ${colors.bold(getAccuracy(stats).toFixed(1) + "%")}`
);
console.log(`Best Streak: ${colors.bold(stats.bestStreak.toString())}`);
console.log();
}
@@ -244,9 +248,13 @@ await new Command()
await app.runInteractive();
})
.command("play", "Start a quick game with specified settings")
.option("-m, --mode <mode:string>", "Game mode (letters, numbers, words, phrases)", {
default: "letters",
})
.option(
"-m, --mode <mode:string>",
"Game mode (letters, numbers, words, phrases)",
{
default: "letters",
}
)
.option("-r, --rounds <rounds:number>", "Number of rounds", { default: 10 })
.option("-t, --time <seconds:number>", "Seconds per round", { default: 30 })
.action(async (options) => {