Skip to main content

A fun, interactive hand cricket game where you can play against the computer.

Project description

Hand Cricket

A fun, interactive hand cricket game where you can play against the computer. Choose to bat or bowl and see if you can win!

Features

  • Interactive Gameplay: Play against the computer in a classic hand cricket match.
  • Toss Mechanism: Choose "Even" or "Odd" for the toss to decide your role.
  • Batting and Bowling: Experience both roles and aim to outscore the opponent.

What's New (Latest Version)

  • Improved Input Handling: All user input is now validated in loops (no recursion), preventing crashes from repeated invalid input.
  • Graceful Exits: The game now handles Ctrl+C/Ctrl+D (KeyboardInterrupt/EOFError) gracefully, exiting with a friendly message.
  • Playful User Experience: All print statements have been rewritten to be more playful, clear, and consistent, making the game more engaging.
  • Direct Script Execution: Added an entry point (if __name__ == "__main__": main()) so you can run the script directly.
  • Robust and User-Friendly: The game is now safer, more robust, and easier to use for everyone.

How is this different from older versions?

  • No more recursion errors or stack overflows from repeated invalid input.
  • Clearer, friendlier prompts and results throughout the game.
  • Handles unexpected exits gracefully.
  • Code is easier to maintain and extend.

Installation

pip install handy_cricket

Usage

  • import handy_cricket
  • handy_cricket.main()

This will automatically trigger the game, and you can start playing.

Functions

Here is a quick overview of the main functions in the package:

main()

Starts the hand cricket game. This function handles the main menu where you can start the game, view instructions, or exit.

start_game()

Initiates the toss and begins the gameplay based on the user’s selection (Even or Odd).

toss(opt)

Handles the toss logic where the user chooses either Even or Odd.

user_batting()

Executes the gameplay when the user chooses to bat first.

comp_batting()

Executes the gameplay when the computer bats first.

show_instructions()

Displays the instructions on how to play the game.

Contributing

Feel free to fork this repository and submit a pull request. Suggestions, issues, and improvements are always welcome!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

handy_cricket-1.0.2.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

handy_cricket-1.0.2-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file handy_cricket-1.0.2.tar.gz.

File metadata

  • Download URL: handy_cricket-1.0.2.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for handy_cricket-1.0.2.tar.gz
Algorithm Hash digest
SHA256 6814dd40a628b993470449fc8589fd5d88940bfce9278d63f076655aa02c3bd9
MD5 470c31896aeedb0af87e539d809785ee
BLAKE2b-256 88ac46641318f8c42e9aeec140f47aba2cf96a527b33fcd4731d4e5e9469ad64

See more details on using hashes here.

File details

Details for the file handy_cricket-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: handy_cricket-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for handy_cricket-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 745c7b086ea3e2bb89a3ebd6523ecfa154639dd31ef53a113abcda1f8909aad7
MD5 0dd109cdfdf3204b1529835a47b6e004
BLAKE2b-256 62da3374fb20dd8088c9916dc708c0d1609ddb1e67d66ea4e3a5cd51404e15e8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page