Skip to content

Nigeria-Sui-Builders/Fighters

Repository files navigation

Petsy Sui Module

petsy is a Sui Move smart contract module implementing a Tamagotchi-style on-chain pet system. Users can adopt, care for, train, and trade virtual pets using SUI coins and in-game currency. The module supports pet evolution, accessories, and a full marketplace for pets and items.

Features

  • Pet Lifecycle

    • Adopt up to 3 pets per user
    • Feed, play with, exercise, rest, and work for coins
    • Let pets sleep and wake them up
    • Track stats: health, hunger, cleanliness, coins, experience, and maturity
    • Evolve pets based on maturity and experience
  • Accessories

    • Mint and equip accessories (glasses, hats, toys)
    • Accessory effects are reflected visually on the pet
    • Equip/unequip functionality
  • Marketplace

    • List and buy pets and accessories
    • Payments handled via SUI coins
    • Event emission for listings and sales
  • Game Economy

    • Coins can be purchased with SUI
    • Experience points (XP) for pet actions
    • Game balance constants define costs, gains, and stat changes
  • Events

    • PetAdopted, PetAction, PetEvolved, PetBred
    • PetListed, PetSold, AccessoryListed, AccessorySold
    • CoinsPurchased

Structures

  • ContractOwner – Tracks the module owner
  • PetRegistry – Maps users to the number of pets they own
  • Pet – Main pet object storing stats, game data, and personality
  • PetAccessory – Accessories for pets
  • PetStats & PetGameData – Stores pet health, hunger, cleanliness, coins, XP, and maturity
  • PetListing & AccessoryListing – Objects for marketplace listings

Entry Functions

  • adopt_pet – Adopt a new pet
  • feed_pet – Feed a pet to restore hunger
  • play_with_pet – Play with a pet to increase XP
  • exercise – Exercise a pet
  • rest – Rest to recover health
  • work_for_coins – Earn coins via pet work
  • let_pet_sleep & wake_up_pet – Manage pet sleep and recovery
  • try_evolve – Evolve pets based on maturity
  • mint_hat, mint_toy – Create accessories
  • list_pet, buy_listed_pet, cancel_pet_listing – Marketplace operations
  • list_accessory, buy_listed_accessory, cancel_accessory_listing
  • equip_accessory, unequip_accessory – Equip or unequip accessories
  • buy_coins_with_sui – Exchange SUI for in-game coins

Utility Functions

  • get_pet_name, get_pet_health, get_pet_hunger, get_pet_maturity
  • get_pet_coins, get_pet_xp, get_pet_personality
  • get_pet_stats, get_pet_game_data
  • is_sleeping – Checks if a pet is currently sleeping

Constants

  • Error codes for common validation failures (e.g., max pets reached, pet too tired)
  • URLs for pet images at different stages of evolution and accessories
  • Keys for dynamic fields (e.g., equipped item, evolution stage, sleep timestamp)
  • Default game balance parameters for feeding, playing, working, resting, etc.

Testing

The module provides a test-only initializer:

#[test_only]
public fun init_for_testing(ctx: &mut TxContext) {
    init(PETSY {}, ctx);
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors