Simulation class Simulation: def init(self): self.simulation = { "wages": { "name":…
- User
Simulation
class Simulation: def init(self): self.simulation = { "wages": { "name": "Average Wage", "desc": "Average earnings per hour.", "value": 3.24, "minval": 0, "maxval": None, "type": "economic", } }
self.policy_effects = { "minimum_wage": "wages", } def apply_policy(self, policy): policy_key = list(policy.keys())[0] if policy_key in self.policy_effects: sim_key = self.policy_effects[policy_key] sim_data = self.simulation[sim_key] new_value = max(sim_data["minval"], policy[policy_key]["value"]) if sim_data["maxval"] is not None: new_value = min(sim_data["maxval"], new_value) sim_data["value"] = new_valuePolicies
class Policies: def init(self): self.policies = { "minimum_wage": { "name": "Minimum Wage", "desc": "Legal minimum wage employers must pay out.", "active": False, "value": 7, "minval": 0, "maxval": None, "type": "economic", }, }
def apply_policies(self, sim): """Applies all active policies to the simulation.""" for policy_key, policy_data in self.policies.items(): if policy_data["active"]: sim.apply_policy({policy_key: policy_data})Turn Calculation
class Turns: pass
Gamestate
class GameState: def init(self): self.sim = Simulation() self.pol = Policies() self.turns = Turns()
self.commands={ # Creates the commands dictionary. "SOCIAL": social, "ECONOMIC": economic, "POLITICAL": political, "FOREIGN": foreign, "QUIT": return_menu, "DEV": developer, } self.is_running = True # Is game running? True! self.in_menu = True # Is game in menu? True!def main(): # Main menu. Barebones. Will eventually require a rehaul with new game, load game, options, etc. game_state = GameState() while game_state.in_menu: print("""
| | | | | WELCOME | | | |________________| """) print("Please select an option:") print("[1]: Start Game") print("[2]: Exit Game") try: command = int(input("Write the option you want: \n")) match command: case 1: print("Welcome!") start_game(game_state) game_state.is_running=True case 2: print("Goodbye!") game_state.in_menu = False case _: print("That number does not work. Please try again.") except ValueError: print("Error!")
def start_game(game_state): # Prints the start game text. Any important pre-gameloop stages will be set here if any come up.. print("""WELCOME TO THE GAME. THIS SECTION WILL EVENTUALLY HAVE COUNTRY SELECTION.""") game_loop(game_state)
def game_loop(game_state): # Core came loop. Prints location name, all possible commands. Simple. Clean. Beautiful. while game_state.is_running: print(f"\nWelcome back, leader.") print("[SOCIAL] SPHERE") print("[ECONOMIC] SPHERE") print("[POLITICAL] SPHERE") print("[FOREIGN] SPHERE") print("[QUIT]: Return to Main Menu") try: command = input("Select option: \n").upper() if command in game_state.commands: if game_state.commands[command]: game_state.commands else: print("Unknown command. Try again.") except ValueError: print("Error!")
- Assistant