a tiny virtual pet CLI written in Rust because apparently taking care of imaginary text is now a terminal responsibility!!!
i made this mainly to practice working with:
- error handling (especially with
Result<T, E>)
pet is a command-line virtual pet simulator written in Rust . . . (AS ALWAYS??)
create your own pets, check up on them, feed them, play with them, and let them rest--all from your terminal!! (how convenient for.. ppl who never leave their chair coding?? all day????)
this project combines a little virtual-pet gameplay with practical systems such as command parsing, data persistence, inventory management, and error handling!! (as well as Rust's hell-level gimmicks..)
i made this mainly to practice working with, uhm:
trait-basedpolymorphismcommand-lineargumentparsing- data
serializationand persistence - inventory and
collectionmanagement errorhandling- modular application architecture
Rust'sownershipandborrowingsystem (LIKE ALWAYS. this is a canon event for all Rust coders)
- multiple pet types:
animals (dog+cat),blobs, androbots - animal varieties, including dogs and cats
ASCIIart models that reflect your pets'states- pet profiles with stats such as HP, hunger, happiness, and their
gimmickstat (such asenergyfor animal types) feedpets using items from your inventoryplaywith your pets and let themsleeprenamepets ordisownthem (idk why i made this.. oh how i pity them....)- manage an inventory and create your own
fooditems - persistent pet and inventory data between runs
- a
command-lineinterface for basically managing everything.!!
RustCargo
clone the repository:
git clone https://github.com/jayywashere/pet
cd petbuild the release executable:
cargo build --release
# idk about that "--release" tag's significance, so you decideideally, check all the available commands first with:
pet helpcreate a dog named Mochi: (quick fun fact: i named all my dogs after food)
pet new --name Mochi --kind animal --animalKind dogyou can also create other kinds of pets, such as blobs and robots!!
view every pet:
pet viewview a specific pet:
pet view --name Mochi
# replace "Mochi" with the actual name of the desired peteach profile displays the pet's information, current state, stats, and ASCII art model!>!>
feed a pet using an inventory item:
pet feed --name Mochi --item apple
# do make sure you have an "apple" in your inventory
# and to do that, you can enter "pet inventory" to view it!play with your pets:
pet play # this applies to all your pets
pet play --name Mochi # this applies to a specific pet that's named "Mochi"or let them sleep:
pet sleep # this applies to all your pets, too
pet sleep --name Mochi # this applies to a specific pet that's named "Mochi", toorename a pet:
pet rename --name Mochi --newName Mochi2
# by the way, a reserved word is "all", and i also don't know why i made it reserved
# so.... yeah!! make sure it's not "all" and not a name that a different pet already ownsdisown a specific pet: (awwh.)
pet disown # this disowns EVERY SINGLE PET YOU HAVE!!!! practice extreme CAUTION. (unless you're a maniac /j)
pet disown --name Mochi # this disowns.. only "Mochi"... how sad....... such a cruel world this is, no?.. .....view your inventory:
pet inventorycreate and get that item:
pet shop --name apple
# you get a free item named "apple", so it's like.. you make your own thing
# it defaults to a "quantity" of 1, btwcreate an item and receive multiple duplicates of it (depending on quantity given):
pet shop --name apple --quantity 5
# you create an item named "apple" 5 times that you obtainfurthermore, your pets and inventory are saved locally, allowing them to persist between program runs. (I'M TELLING YOU. I SUFFERED IN CODING THE PERSISTENCE MECHANIC THE MOST.)
the application initializes its save data automatically when needed!! you don't need to run a separate setup command (i don't even got one.. so how??)
i lowk wanted to build smth more interesting than another basic CLI program while practicing Rust and working with a more structed app!! (don't make me remember how many times i've said this, but it remains the truth)
anyway!! a virtual pet simulator gave me an excuse to work with traits, different pet implementations, collections, inventories, command parsing, serialization, and persistent data . . .
AND, OF COURSE, ASCII PETS
See LICENSE.