Skip to content

Commit

Permalink
Merge pull request #4 from marmelab/detect-winner
Browse files Browse the repository at this point in the history
Detect winner
  • Loading branch information
atilbian authored Jan 17, 2025
2 parents ccf247e + 06cd182 commit 7cf89a3
Show file tree
Hide file tree
Showing 9 changed files with 562 additions and 144 deletions.
15 changes: 14 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ Each player must have the same number of tokens +/-1 (depending on who have play
Save the game grid where you want, in the format shown above, in a text (json) file.
Ex: `myGameGrid.json`

# Play a token
# each player in turn plays a token

Once the game started, the board displayed, representing the provided json file.

Expand All @@ -118,3 +118,16 @@ Put your choice `Please enter the column number you want to play your token o [1
then press enter

![image](https://github.com/user-attachments/assets/52a567ac-5714-4054-8881-9a7b8d639ba8)

It's now the scond player turn.

# End game and win detection

You have 3 end game conditions :
- Player 1 win
- Player 2 win
- It's a game draw

The game automatically detects victory and highlights the 4 victorious tokens in a row.

![image](https://github.com/user-attachments/assets/861c03a5-841f-4621-b467-ae67c87718f7)
8 changes: 7 additions & 1 deletion src/config/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@ export const PLACEHOLDER = "$";
export const messages = {
INFORMATIONS:
"\n-- You are player " + PLACEHOLDER + ": " + PLACEHOLDER + " --",
PROMPT:
PROMPT_ASK_COLUMN:
"Please enter the column number you want to play your token $ [1-7]: ",
PROMPT_ASK_NEXT_ROUND: "Ready for another round? [Y|N]: ",
ERROR_INVALID_COLUMN_NUMBER: "Invalid column number.\n",
ERROR_COLUMN_FULL: "Cannot add token into column $ which is full.\n",
WINNER_MESSAGE:
"\n-- Player " + PLACEHOLDER + ": " + PLACEHOLDER + " Win! --",
DRAW_MESSAGE: "\n-- It's a draw ! --\n",
ERROR_INVALID_NEXT_ROUND_ANSWER:
"Invalid answer, please tip Y if you want another round, otherwise N.",
};
Loading

0 comments on commit 7cf89a3

Please sign in to comment.