Adding Player and Game classes

This commit is contained in:
Andrew Haynes
2026-08-31 14:14:30 -04:00
parent f537b04829
commit 7edf93b707
+62
View File
@@ -0,0 +1,62 @@
import random
class Player:
def __init__(self, fish_per_hour, wood_per_hour):
self.fish = 0
self.wood = 0
self.hours = 16
self.fish_per_hour = fish_per_hour
self.wood_per_hour = wood_per_hour
# If player does not have it, all fish expires at end of day.
self.fish_preserver = False
self.boat = False
class Game:
def __init__(self):
self.players_found = 0
def improve_fishing(self, player: Player):
player.fish_per_hour += 1
def improve_foraging(self, player: Player):
player.wood_per_hour += 1
def create_fish_preserver(self, player: Player):
if (player.hours >= 8 and player.fish >= 25):
player.hours -= 8
player.fish -= 25
player.fish_preserver = True
def create_boat(self, player: Player):
if (player.hours == 16 and player.wood >= 100):
player.hours -= 16
player.wood -= 100
player.boat = True
def create_player_values(self, player: Player):
fish = random.randint(1, 2)
wood = 0
if (fish == 1):
wood = 2
if (fish == 2):
wood = 1
player.fish = fish
player.wood = wood
def main():
running = True
while (running):
print("What do you want to spend your hours on?\n1. Fishing.\n2. Foraging.\n3. Improve Fishing.\n4. Improve Foraging.\n5. Build a preserver.\n6. Build a boat")
user_input = input()
if (user_input == "1")
print(type(user_input))
if __name__ == "__main__":
main()