Here's a summary of the game rules based on the state machine:
-
Initial State:
- The game begins in an "UNINITIALIZED" state, waiting for each player to complete their setup.
- A prompt is issued to the session owner to start setting up.
-
Player Setup Phase:
- Players are prompted to set up their initial state (
PROMPT_PLAYER_FOR_SETUP
). - Once all players have completed their setup (though this condition isn't explicitly checked in the code), the game moves to the "WAITING_FOR_PLAYER_TURN_ACTION" state, ready for player turns.
- Players are prompted to set up their initial state (
-
Player Turn Phase:
- In the "WAITING_FOR_PLAYER_TURN_ACTION" state:
- A player's turn is initiated by the
START_TURN
event. - At this point, players can start playing cards from their hand (
PLAY_CARD
).
- A player's turn is initiated by the
- In the "WAITING_FOR_PLAYER_TURN_ACTION" state:
-
Card Playing Mechanics:
- When a card is played in the "PLAYING_CARD" state, it triggers specific actions based on the type of card:
- If a crop card is played, the game transitions to the "PLANTING_CROP" state.
- If a water card is played, the game moves to the "WATERING_CROP" state.
- When a card is played in the "PLAYING_CARD" state, it triggers specific actions based on the type of card:
-
Planting Crops:
- In the "PLANTING_CROP" state:
- The crop card is validated and added to the player's field (
CROP_PLANTED
). - The crop card is then moved from the player's hand to the discard pile.
- Once a crop is successfully planted, control returns to the "WAITING_FOR_PLAYER_TURN_ACTION" state.
- The crop card is validated and added to the player's field (
- In the "PLANTING_CROP" state:
-
Watering Crops:
- In the "WATERING_CROP" state:
- A prompt (
PROMPT_PLAYER_FOR_CROP_TO_WATER
) asks the player to select which crop in their field they want to water using the played water card. - Once a crop is selected and watered, the game updates the
waterCards
count for that crop and moves the water card from the hand to the discard pile. - The game then returns to the "WAITING_FOR_PLAYER_TURN_ACTION" state.
- A prompt (
- In the "WATERING_CROP" state:
Overall, the game involves players setting up their initial conditions, taking turns to play cards that either plant crops or water existing ones, and managing their field accordingly. Each turn allows for strategic decisions based on the available cards and current game state.