Skip to content

Instantly share code, notes, and snippets.

@jeremyckahn
Created January 19, 2025 22:48
Show Gist options
  • Save jeremyckahn/71752f3b658e67a7aaa245402bfe2f9d to your computer and use it in GitHub Desktop.
Save jeremyckahn/71752f3b658e67a7aaa245402bfe2f9d to your computer and use it in GitHub Desktop.

Here's a summary of the game rules based on the state machine:

  1. 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.
  2. 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.
  3. 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).
  4. 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.
  5. 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.
  6. 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.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment