feat: changed stats storage location, refactored code
This commit is contained in:
18
main.ts
18
main.ts
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user