Keine Beschreibung

game.py 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. import random
  2. from actions import Actions
  3. from events import Events
  4. from supporters import Supporters
  5. class PoliticalSimulationGame:
  6. def __init__(self):
  7. self.money = 100
  8. self.influence = 50
  9. self.public_support = 50
  10. self.day = 1
  11. self.policies = []
  12. self.opponents = ["Opponent 1", "Opponent 2", "Opponent 3"]
  13. self.gdp = 1000 # Gross Domestic Product
  14. self.unemployment_rate = 5 # Unemployment rate in percentage
  15. self.tax_rate = 20 # Tax rate in percentage
  16. self.military_budget = 50 # Initial military budget
  17. self.military_strength = 100 # Initial military strength
  18. self.actions_per_day = 3 # Number of actions allowed per day
  19. self.post_election = False
  20. self.supporters = Supporters()
  21. def display_status(self):
  22. print(f"\n*****************************")
  23. print(f"Day {self.day}")
  24. print(f"Money: ${self.money}")
  25. print(f"Influence: {self.influence}")
  26. print(f"Public Support: {self.public_support}%")
  27. print(f"Policies: {', '.join(self.policies) if self.policies else 'None'}")
  28. print(f"GDP: ${self.gdp}")
  29. print(f"Unemployment Rate: {self.unemployment_rate}%")
  30. print(f"Tax Rate: {self.tax_rate}%")
  31. print(f"Military Budget: ${self.military_budget}")
  32. print(f"Military Strength: {self.military_strength}")
  33. self.supporters.display()
  34. print(f"\n*****************************")
  35. def take_action(self, action_number):
  36. actions = Actions(self)
  37. if action_number == "1":
  38. actions.campaign()
  39. elif action_number == "2":
  40. actions.pass_legislation()
  41. elif action_number == "3":
  42. actions.hold_rally()
  43. elif action_number == "4":
  44. actions.media_campaign()
  45. elif action_number == "5":
  46. if not actions.opponent_friction() or not actions.foreign_interference():
  47. return False # Skip fundraising if sabotaged
  48. actions.fundraise()
  49. elif action_number == "6":
  50. actions.debate()
  51. elif action_number == "7":
  52. actions.set_tax_policy()
  53. elif action_number == "8":
  54. actions.invest_in_sector()
  55. elif action_number == "9":
  56. actions.allocate_military_budget()
  57. self.display_status() # Show status after each action
  58. return True
  59. def end_day(self):
  60. self.day += 1
  61. self.money += self.tax_rate * 10 # Example revenue generation
  62. print(f"Day ended. You earned ${self.tax_rate * 10} from taxes.")
  63. self.display_status() # Show status at end of day
  64. def check_win_condition(self):
  65. if self.public_support >= 100:
  66. print("Congratulations! You've won the election!")
  67. self.post_election = True
  68. return True
  69. elif self.public_support <= 0:
  70. print("You've lost the election. Better luck next time.")
  71. return True
  72. return False
  73. def post_election_actions(self):
  74. print("Congratulations on winning the election! Now you need to maintain your approval ratings and pass significant legislation.")
  75. self.actions_per_day = 2 # Fewer actions per day post-election to increase difficulty
  76. while True:
  77. self.display_status()
  78. actions_left = self.actions_per_day
  79. while actions_left > 0:
  80. print("Choose an action:")
  81. print("1. Pass Legislation")
  82. print("2. Hold Rally")
  83. print("3. Media Campaign")
  84. print("4. Allocate Military Budget")
  85. choice = input("Enter the number of your choice: ")
  86. if not self.take_action(choice):
  87. continue
  88. actions_left -= 1
  89. if random.randint(1, 100) <= 30:
  90. self.random_event()
  91. if self.check_win_condition():
  92. return
  93. self.end_day()
  94. def play(self):
  95. print("Welcome to the Enhanced Political Simulation Game with Economic, Military, Opponent Friction, and Demographic Elements!")
  96. while True:
  97. if self.post_election:
  98. self.post_election_actions()
  99. break
  100. self.display_status()
  101. actions_left = self.actions_per_day
  102. while actions_left > 0:
  103. print("Choose an action:")
  104. print("1. Campaign")
  105. print("2. Pass Legislation")
  106. print("3. Hold Rally")
  107. print("4. Media Campaign")
  108. print("5. Fundraise")
  109. print("6. Debate")
  110. print("7. Set Tax Policy")
  111. print("8. Invest in a Sector")
  112. print("9. Allocate Military Budget")
  113. choice = input("Enter the number of your choice: ")
  114. if not self.take_action(choice):
  115. continue
  116. actions_left -= 1
  117. if random.randint(1, 100) <= 30:
  118. self.random_event()
  119. if self.check_win_condition():
  120. break
  121. self.end_day()
  122. def random_event(self):
  123. events = Events(self)
  124. events.random_event()
  125. self.display_status() # Show status after random event