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.1.tar.gz (3.0 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.1-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for handy_cricket-1.0.1.tar.gz
Algorithm Hash digest
SHA256 96a4f85dae6b5c1b10632ba53f7a2749e2d4bd8b9f834686c61ae9b3683cb49d
MD5 68f6f1352355df3c9a1d0ab1de6acfac
BLAKE2b-256 eb7ed013332186527fdecc53697a85dc05fdc3c8e7768d56218178a82c3318cd

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for handy_cricket-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b9579f0060b8bb2a9231781538fd4b3a6271987a260eaf19f4c8701b54a3f1bd
MD5 1278bef4352d01c528c6b1aa646fb5f0
BLAKE2b-256 f123ff6a87b4a85ee2484dfdf5c9ab421e188194582b251eeab7b95d117f11a4

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