import random class Player: def __init__(self, fish_per_hour, wood_per_hour): self.fish = 0 self.wood = 0 self.hours = 16 self.obtained_boat = 0 # when they got boat 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 def strip_hours(self, hours): self.hours -= hours class Game: def __init__(self): self.players_found = 0 self.days = 0 def fishing(self, player: Player, hours): player.fish += player.fish_per_hour * hours def collect_wood(self, player: Player, hours): player.wood += player.wood_per_hour * hours 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): player.wood -= 25 player.fish_preserver = True def create_boat(self, player: Player): 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_per_hour = fish player.wood_per_hour = wood def state(self, player: Player): running = True invalid = False while (running): if (player.boat and player.obtained_boat < self.days and player.fish >= 24): print("Good fucking job lad. You win!") break if (player.hours <= 0): if (player.fish >= 8 and player.wood >= 4): self.days += 1 player.hours += 16 player.wood -= 4 if (not player.fish_preserver): player.fish = 0 else: player.fish -= 8 else: print("You fucking died!") break print("\033[H\033[J", end="") if (invalid): print("LAST RESPONSE WAS INVALID!\n") invalid = False print(f"Game Days: {self.days}\n") print(f"Player Production: {player.hours} hours left") print("╭───────────────┬───────────────╮\n" "│ Fish Per Hour │ Wood Per Hour │\n" f"│ {player.fish_per_hour} │ {player.wood_per_hour} │\n" "╰───────────────┴───────────────╯") print("╭────────────────┬─────────────────╮\n" "│ Owns Preserver │ Owns Boat │\n" f"│ {player.fish_preserver} │ {player.boat} │\n" "╰────────────────┴─────────────────╯") print("╭─────────────┬─────────────╮\n" "│ Stored Fish │ Stored Wood │\n" f"│ {player.fish} │ {player.wood} │\n" "╰─────────────┴─────────────╯") 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.\nQ to quit") user_input = input() if (user_input == "q"): print("Leaving self. Does not save. Tough shit.") break elif (user_input == "1"): print("How many hours do you want to fish?") user_input = input() if (player.hours >= int(user_input)): self.fishing(player, int(user_input)) player.strip_hours(int(user_input)) else: print( f"You dont have the hours to do that much work. Hours left: {int(user_input)}") elif (user_input == "2"): print("How many hours do you want to forage?") user_input = input() if (player.hours >= int(user_input)): self.collect_wood(player, int(user_input)) player.strip_hours(int(user_input)) else: print( f"You dont have the hours to do that much work. Hours left: {player.hours}") elif (user_input == "3"): print("Do you want to improve your fishing efficiency?") user_input = input() if (user_input == "Y" and player.hours >= 8): self.improve_fishing(player) player.strip_hours(8) else: print( f"You dont have the hours to do that much work. Hours left: {player.hours}") elif (user_input == "4"): print("Do you want to improve your foraging efficiency?") user_input = input() if (user_input == "Y" and player.hours >= 8): self.improve_foraging(player) player.strip_hours(8) else: print( f"You dont have the hours to do that much work. Hours left: {player.hours}") elif (user_input == "5"): print("Do you want to build a fish preserver?") user_input = input() if (user_input == "Y" and player.hours >= 8 and player.wood >= 25): self.create_fish_preserver(player) player.strip_hours(8) else: print( f"You dont have the hours to do that much work. Hours left: {player.hours}") elif (user_input == "6"): print("Do you want to build a boat?") user_input = input() if (user_input == "Y" and player.hours >= 16 and player.wood >= 100): self.create_boat(player) player.strip_hours(16) player.obtained_boat = self.days else: print( f"You dont have the hours to do that much work. Hours left: {player.hours}") else: invalid = True def main(): game = Game() player = Player(0, 0) game.create_player_values(player) game.state(player) print("1. How did scarcity come into play durig this simulation?\n") print("2. How did you determine if and under what terms to trade?\n") print("3. How did your starting production levels determine your success in the game?\n") if __name__ == "__main__": main()