Skip to main content

An example of a package developed with pyenv, built with build using setuptools, uploaded to PyPI using twine, and distributed via pip.

Project description

Python Package Exercise - Virtual Pet 🐾

log github events

Link to PyPI

Description

Virtual Pet is a Python package for creating and interacting with a virtual pet, providing a playful and nostalgic experience for developers. The pet has attributes like happiness, cleanness, and sleep status, which can be managed through various actions. Users can feed, play with, and take care of their pet by giving it hugs, kisses, or showers, and can even put it to sleep. The virtual pet responds with different emojis based on its current state, adding a whimsical element to the interactions. The goal of this package is to add a bit of joy to everyday coding routines by incorporating a fun, interactive companion.

How to Install and Use the VirtualPet Package

  1. Set Up a Virtual Environment and Install the Package

    • Create a pipenv-managed virtual environment and install your package: Run the following command to install the virtualpet package from TestPyPI:
     pipenv install virtualpet-game
    
    • Activate the Virtual Environment:
      pipenv shell
      
  2. Create a Python Program to Use the Package:

    • Create a Python file to test the package. To see a full code example using all functions of the virtualpet package, check out the Code example for all functions file. Code example for all functions
  3. Run the Package Directly from the Command Line;

    • Set up and activate the pipenv virtual environment as before:
      pipenv install virtualpet-game
      pipenv shell
      
    • Run the Package Directly:
      python3 -m virtualpet
      
    • Exit the Virtual Environment:
      exit
      

Available Functions

feed_pet(): Feed your pet to increase its happiness and reduce its cleanness.

pet.feed_pet()

play_with_pet(action: Literal['hug', 'pet', 'kiss']): Play with your pet to make it happier. You can use the actions:hug, pet, or kiss

pet.play_with_pet('hug')
pet.play_with_pet('pet')
pet.play_with_pet('kiss')

take_shower(): Give your pet a shower to reset its cleanness level.

pet.take_shower()

pet_sleep(): Put your pet to sleep for a random amount of time (between 20 to 25 seconds in the current version).

pet.pet_sleep()

restart(): Restart your pet to default levels for both happiness and cleanness.

pet.restart()

exit(): Exit and say goodbye to your pet. This will end the program.

pet.exit()

_display_status(): Display your pet's current happiness, cleanness, and state with a cute emoji representation.

Note: _display_status() is used internally, but you can call it directly to check the current status.

pet._display_status()

You can see how to use all of the functions in an example Python program: Example Python Program

Example of Use

  • Here is a snippet from the use_virtual_pet.py file:
    from virtualpet.pet import VirtualPet
    
    def main():
        pet_name = input("What would you like to name your pet? ")
        pet = VirtualPet(pet_name)
    
        while pet.active:
            action = input("(Options: feed/play/take shower/check status/sleep/restart/exit): ").strip().lower()
            if action == "feed":
                pet.feed_pet()
            elif action == "play":
                sub_action = input("Choose how to play with your pet (hug/pet/kiss): ").strip().lower()
                pet.play_with_pet(sub_action)
            elif action == "take shower":
                pet.take_shower()
            elif action == "check status":
                pet._display_status()
            elif action == "sleep":
                pet.pet_sleep()
            elif action == "restart":
                pet.restart()
            elif action == "exit":
                pet.exit()
            else:
                print("Invalid action. Please choose a valid action.")
    
    if __name__ == "__main__":
        main()
    

Steps necessary to run the software(for Development)

  1. Install Python:

    • Make sure Python 3.8 or higher is installed on your system. You can download it from python.org.
  2. Clone the repository:

    • Run the following commands to create and activate the virtual environment:
      git clone https://github.com/software-students-fall2024/3-python-package-straight-a.git
      cd your-repository-folder
      
  3. Set up a Virtual Environment:

    • Run the following commands to create and activate the virtual environment:
      python3 -m venv venv
      
    • Activate the virtual environment:
      • On Windows:
        .\venv\Scripts\activate
        
      • On macOS/Linux:
        source venv/bin/activate
        
  4. Install Dependencies::

    • With the virtual environment activated, install the necessary dependencies, including pytest for testing and twine for PyPI uploads (if needed):
    pip install -r requirements.txt
    
  5. Build and Test the Package::

    • Build the Package: Use build to package the project:
      python3 -m build
      
    • Install the Package Locally: Install the package locally to test its functionality: bash pip install .
    • Run Tests: Use pytest to run the test suite and verify that everything is working correctly: bash pytest

Team Members

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

virtualpet_game-0.1.2.tar.gz (45.6 kB view details)

Uploaded Source

Built Distribution

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

virtualpet_game-0.1.2-py3-none-any.whl (30.3 kB view details)

Uploaded Python 3

File details

Details for the file virtualpet_game-0.1.2.tar.gz.

File metadata

  • Download URL: virtualpet_game-0.1.2.tar.gz
  • Upload date:
  • Size: 45.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.13.0

File hashes

Hashes for virtualpet_game-0.1.2.tar.gz
Algorithm Hash digest
SHA256 6a10904e81ddecacba2248cdfb2f4f7dc3828aba413c3ac6656c75927534cead
MD5 43fee99f8bd379a97a9fb2125a53717c
BLAKE2b-256 039ce1159d96f3b695bb2cd29f713d16472305cebc63ca99a97a9bc397fc16f1

See more details on using hashes here.

File details

Details for the file virtualpet_game-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for virtualpet_game-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 102515b6b579c84b0d655e471d7d9e39f800d762e9b0788b5cf77b8aeaa94f64
MD5 cf64592191b1754b9afd0f668e3ae1a5
BLAKE2b-256 949345a0bfa32b6906420eb8934a667f120f495c17174374658fb927f001230c

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