import random class Actions: def __init__(self, game): self.game = game def _perform_action(self, action_name, description, cost, success_effect, failure_effect, success_chance, influence_required=0, success_policy=None): print(f"Scenario: {description}") if self.game.money < cost: print(f"Not enough money to {action_name.lower()}.") return if self.game.influence < influence_required: print(f"Not enough influence to {action_name.lower()}.") return self.game.money -= cost if random.randint(1, 100) <= success_chance: for key, value in success_effect.items(): setattr(self.game, key, getattr(self.game, key) + value) if success_policy: self.game.policies.append(success_policy) print(f"Success! {description} was successful.") else: for key, value in failure_effect.items(): setattr(self.game, key, getattr(self.game, key) + value) print(f"Failure! {description} was unsuccessful.") def campaign(self): self._perform_action( action_name="Campaign", description="Door-to-Door Campaigning", cost=10, success_effect={"public_support": 10}, failure_effect={"public_support": -5}, success_chance=60 ) def pass_legislation(self): self._perform_action( action_name="Pass Legislation", description="Healthcare Reform Bill", cost=20, influence_required=30, success_effect={"public_support": 20}, success_policy="Healthcare Reform Bill", failure_effect={}, success_chance=100 ) def hold_rally(self): self._perform_action( action_name="Hold Rally", description="Community Unity Rally", cost=15, success_effect={"public_support": 15}, failure_effect={"public_support": -5}, success_chance=70 ) def media_campaign(self): print("Scenario: Media Campaign") print("Choose the type of media campaign:") print("1. Online (Facebook)") print("2. Online (TikTok)") print("3. Online (Twitter)") print("4. Online (Instagram)") print("5. Offline (TV, Radio, Newspapers)") choice = input("Enter the number of your choice: ") demographics_effect = { "1": {"age": "young", "gender": "female", "education": "medium"}, "2": {"age": "young", "gender": "female", "education": "low"}, "3": {"age": "middle-aged", "gender": "male", "education": "high"}, "4": {"age": "young", "gender": "female", "education": "high"}, "5": {"age": "senior", "gender": "male", "education": "low"} } if choice in demographics_effect: cost = 25 success_chance = random.randint(1, 100) if self.game.money < cost: print("Not enough money to launch a media campaign.") return self.game.money -= cost if success_chance <= 80: self.game.public_support += 25 dem = demographics_effect[choice] self.game.supporters.increase_support(dem) print(f"The {choice} campaign resonates with the public, increasing support by 25% and boosting support among {dem}.") else: self.game.public_support -= 10 print(f"The {choice} campaign backfires, leading to a decrease in support by 10%.") else: print("Invalid choice. Please try again.") def fundraise(self): print("Scenario: High-Profile Fundraiser Dinner") print("You host an exclusive fundraiser dinner with influential donors and supporters.") success_chance = random.randint(1, 100) if success_chance <= 50: funds_raised = random.randint(20, 50) self.game.money += funds_raised print(f"The event is a success, raising ${funds_raised}.") else: print("Poor attendance results in no funds being raised.") def debate(self): print("Scenario: Televised Debate with Opponent") print("You participate in a live televised debate against a key opponent, addressing critical issues and defending your policies.") opponent = random.choice(self.game.opponents) success_chance = random.randint(1, 100) if success_chance <= 50: self.game.influence += 20 self.game.public_support += 10 print(f"You outshine your opponent, increasing influence by 20 and public support by 10%.") else: self.game.influence -= 10 self.game.public_support -= 5 print(f"The debate goes poorly, decreasing influence by 10 and public support by 5% as voters favor {opponent}'s arguments.") def set_tax_policy(self): print("Scenario: Set Tax Policy") new_tax_rate = int(input("Enter the new tax rate (0-100): ")) if 0 <= new_tax_rate <= 100: self.game.tax_rate = new_tax_rate print(f"Tax rate set to {self.game.tax_rate}%.") if new_tax_rate > 30: self.game.public_support -= 10 print("High tax rate decreases public support by 10%.") elif new_tax_rate < 10: self.game.public_support += 10 print("Low tax rate increases public support by 10%.") else: print("Invalid tax rate. Please enter a value between 0 and 100.") def invest_in_sector(self): print("Scenario: Invest in a Sector") sectors = ["Infrastructure", "Education", "Healthcare"] print(f"Sectors available for investment: {', '.join(sectors)}") sector_choice = input("Enter the sector you want to invest in: ") if sector_choice in sectors: investment_amount = int(input("Enter the amount you want to invest: ")) if self.game.money >= investment_amount: self.game.money -= investment_amount self.game.gdp += investment_amount * 1.5 # Example multiplier self.game.unemployment_rate -= 1 # Reduce unemployment print(f"Invested ${investment_amount} in {sector_choice}. GDP increased by ${investment_amount * 1.5} and unemployment rate decreased.") else: print("Not enough money to invest.") else: print("Invalid sector choice.") def allocate_military_budget(self): print("Scenario: Allocate Military Budget") additional_budget = int(input("Enter the additional military budget (0-100): ")) if 0 <= additional_budget <= self.game.money: self.game.money -= additional_budget self.game.military_budget += additional_budget self.game.military_strength += additional_budget // 2 # Example conversion rate print(f"Allocated an additional ${additional_budget} to the military budget. Military strength increased by {additional_budget // 2}.") else: print("Invalid budget allocation. Please enter a value within your available money.") def opponent_friction(self): actions = [ ("Negative Campaign", "Your opponent launches a negative campaign against you. Public support decreases by 10%.", -10, 0, 0), ("Political Sabotage", "Your opponent sabotages your fundraising event. You raise no money.", 0, 0, -1), ("Influence Loss", "Your opponent spreads rumors, reducing your influence. Influence decreases by 15%.", 0, -15, 0) ] action = random.choice(actions) print(f"Opponent Action: {action[0]}") print(f"{action[1]}") self.game.public_support += action[2] self.game.influence += action[3] if action[0] == "Political Sabotage": return False # Indicate that fundraising failed due to sabotage return True def foreign_interference(self): actions = [ ("Russia", "Russia interferes with your campaign, spreading disinformation and causing distrust among voters. Public support decreases by 15%.", -15, 0, 0), ("China", "China launches a cyber-attack on your campaign infrastructure, reducing your influence. Influence decreases by 20%.", 0, -20, 0), ("Foreign Sabotage", "Opposition countries collaborate to sabotage your fundraising event. You raise no money.", 0, 0, -1) ] action = random.choice(actions) print(f"Foreign Interference: {action[0]}") print(f"{action[1]}") self.game.public_support += action[2] self.game.influence += action[3] if action[0] == "Foreign Sabotage": return False # Indicate that fundraising failed due to sabotage return True