diff --git a/main.py b/main.py index 54d4d5d..2b61fe5 100644 --- a/main.py +++ b/main.py @@ -6,6 +6,7 @@ class Player: 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 @@ -14,10 +15,20 @@ class Player: 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 @@ -26,16 +37,12 @@ class Game: 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 + player.wood -= 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 + player.wood -= 100 + player.boat = True def create_player_values(self, player: Player): fish = random.randint(1, 2) @@ -45,17 +52,119 @@ class Game: if (fish == 2): wood = 1 - player.fish = fish - player.wood = wood + 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(): - 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)) + 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__": diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..a194f2a --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,4 @@ +[tool.autopep8] +max-line-length = 120 +ignore = "E501,W6" +aggressive = 2