Food and bugfix
This commit is contained in:
@@ -1,8 +1,7 @@
|
|||||||
class Cat:
|
class Cat:
|
||||||
def __init__(self, name, traits, food=0, money=25, inventory={}):
|
def __init__(self, name, traits, money=25, inventory={}):
|
||||||
self.name = name
|
self.name = name
|
||||||
self.traits = traits
|
self.traits = traits
|
||||||
self.food = food
|
|
||||||
self.money = money
|
self.money = money
|
||||||
self.inventory = inventory
|
self.inventory = inventory
|
||||||
|
|
||||||
|
|||||||
9
game.py
9
game.py
@@ -6,6 +6,7 @@ import data.save
|
|||||||
import data.text
|
import data.text
|
||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
|
import traceback
|
||||||
|
|
||||||
|
|
||||||
class Game:
|
class Game:
|
||||||
@@ -40,8 +41,8 @@ class Game:
|
|||||||
options[0:0] = [ # AI came up with this, what the heck is [0:0]
|
options[0:0] = [ # AI came up with this, what the heck is [0:0]
|
||||||
"Save",
|
"Save",
|
||||||
"Save and quit",
|
"Save and quit",
|
||||||
"Settings",
|
|
||||||
"Quit",
|
"Quit",
|
||||||
|
"Settings",
|
||||||
]
|
]
|
||||||
else:
|
else:
|
||||||
print(
|
print(
|
||||||
@@ -76,7 +77,7 @@ class Game:
|
|||||||
print("Save complete.")
|
print("Save complete.")
|
||||||
self.game_loop()
|
self.game_loop()
|
||||||
|
|
||||||
# TODO: Add shop, make food buyable and add money system
|
# TODO: Add money system
|
||||||
def game_loop(self):
|
def game_loop(self):
|
||||||
ui.current_cat = self.cat
|
ui.current_cat = self.cat
|
||||||
while True:
|
while True:
|
||||||
@@ -155,9 +156,9 @@ if __name__ == "__main__":
|
|||||||
try:
|
try:
|
||||||
game = Game()
|
game = Game()
|
||||||
game.run()
|
game.run()
|
||||||
except Exception as e: # horrible coding right here
|
except: # horrible coding right here
|
||||||
print("Developer stuff incoming, if you can, tell me what this says:")
|
print("Developer stuff incoming, if you can, tell me what this says:")
|
||||||
print(e)
|
traceback.print_exc()
|
||||||
print(
|
print(
|
||||||
"Welp, seems that the game crashed, idk why. A common cause of this is pressing CTRL+C, which will cancel some UI stuff and just break the game. If you're on the desktop version, reopen it, if you're on the web version, reload, and don't use CTRL+C.\nOtherwise, great job! You found an issue in the game! If you can, please tell me."
|
"Welp, seems that the game crashed, idk why. A common cause of this is pressing CTRL+C, which will cancel some UI stuff and just break the game. If you're on the desktop version, reopen it, if you're on the web version, reload, and don't use CTRL+C.\nOtherwise, great job! You found an issue in the game! If you can, please tell me."
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,8 +1,15 @@
|
|||||||
import data.cat
|
import data.cat
|
||||||
|
import systems.world
|
||||||
|
import systems.ui as ui
|
||||||
|
|
||||||
|
|
||||||
def handle_item(cat: data.cat.Cat, item):
|
def item_menu(cat: data.cat.Cat, item):
|
||||||
match item:
|
match item:
|
||||||
|
case "Food":
|
||||||
|
match ui.select("Please choose an option", [f"Feed your cat", "Back"]):
|
||||||
|
case "Feed your cat":
|
||||||
|
systems.world.feed(cat)
|
||||||
|
case "Back":
|
||||||
|
pass
|
||||||
case _:
|
case _:
|
||||||
pass
|
pass
|
||||||
# TODO: MAKE THIS!
|
|
||||||
|
|||||||
@@ -99,7 +99,6 @@ def shop(cat: Cat):
|
|||||||
else:
|
else:
|
||||||
print("Cancelled.")
|
print("Cancelled.")
|
||||||
|
|
||||||
# TODO: idea, each item, when selected in house storage menu, call a item menu thing thats specific for each item
|
|
||||||
# TODO: make toy mouse that increases happyness (so also add emotions and sicknesses maybe) but has a 25% chance of getting lost under the couch and makes the cat tired possibly
|
# TODO: make toy mouse that increases happyness (so also add emotions and sicknesses maybe) but has a 25% chance of getting lost under the couch and makes the cat tired possibly
|
||||||
case "Leave the shop":
|
case "Leave the shop":
|
||||||
print("Goodbye!")
|
print("Goodbye!")
|
||||||
@@ -146,27 +145,26 @@ def pet(cat: Cat):
|
|||||||
print(f"You pet {cat.name} a lot. {cat.name} is very happy.")
|
print(f"You pet {cat.name} a lot. {cat.name} is very happy.")
|
||||||
|
|
||||||
|
|
||||||
def feed(cat):
|
def feed(cat: Cat):
|
||||||
# TODO: Make this use inventory["Food"] instead!
|
if cat.inventory.get("Food", 0) <= 0:
|
||||||
if cat.food <= 0:
|
|
||||||
print(f"You don't have any food. {cat.name} is sad.")
|
print(f"You don't have any food. {cat.name} is sad.")
|
||||||
return
|
return
|
||||||
cat.food -= 1
|
cat.inventory["Food"] -= 1
|
||||||
print(f"You feed {cat.name}, {cat.name} is happy")
|
print(f"You feed {cat.name}, {cat.name} is happy")
|
||||||
|
|
||||||
|
|
||||||
def storage(cat: Cat):
|
def storage(cat: Cat):
|
||||||
while True:
|
|
||||||
item = ui.select(
|
item = ui.select(
|
||||||
"Please choose an item",
|
"Please choose an item",
|
||||||
[
|
[
|
||||||
ui.Choice(title=f"{name}: {amount}", value=name)
|
ui.Choice(title=f"{name}: {amount}", value=name)
|
||||||
for name, amount in cat.inventory.items()
|
for name, amount in cat.inventory.items()
|
||||||
|
if amount > 0
|
||||||
]
|
]
|
||||||
+ ["Back"],
|
+ ["Back"],
|
||||||
)
|
)
|
||||||
if item == "Back":
|
if item == "Back":
|
||||||
break
|
return
|
||||||
systems.items.item_menu(cat, item)
|
systems.items.item_menu(cat, item)
|
||||||
|
|
||||||
|
|
||||||
@@ -187,7 +185,6 @@ def house(cat: Cat):
|
|||||||
print(
|
print(
|
||||||
f"{cat.name} - a {cat.traits["size"]} {cat.traits["color"]} with {cat.traits["eyes"]} eyes"
|
f"{cat.name} - a {cat.traits["size"]} {cat.traits["color"]} with {cat.traits["eyes"]} eyes"
|
||||||
)
|
)
|
||||||
print(f"Food: {cat.food}")
|
|
||||||
case "Pet your cat":
|
case "Pet your cat":
|
||||||
pet(cat)
|
pet(cat)
|
||||||
case "Feed your cat":
|
case "Feed your cat":
|
||||||
|
|||||||
Reference in New Issue
Block a user