import random class Card: def init(self, name, cost=0, issustainable=False): self.name =…
- User
import random
class Card: def init(self, name, cost=0, is_sustainable=False): self.name = name self.cost = cost self.rotated = False self.is_sustainable = is_sustainable self.damage = 0 self.severe_damage = 0
def rotate(self): if not self.rotated: self.rotated = True return True return False def ready(self): self.rotated = False def heal(self, amount=None): if amount is None: self.damage = 0 else: self.damage = max(0, self.damage - amount) def heal_severe(self): if self.severe_damage > 0: self.severe_damage -= 1 else: self.rotated = False def inflict_damage(self, amount): self.damage += amount def inflict_severe_damage(self, amount): self.severe_damage += amount def is_neutralized(self): return self.damage >= self.get_max_ability() def get_max_ability(self): # Placeholder for actual ability logic return 3class ConflictCard: def init(self, name, target=None): self.name = name self.target = target self.face_down = True
def reveal(self): self.face_down = Falseclass AgendaCard(Card): def init(self, name, cost=0, is_major=False, hidden=False): super().init(name, cost) self.is_major = is_major self.hidden = hidden
def can_be_sponsored(self): # Placeholder for actual logic return True def reveal(self): self.hidden = False print(f"Agenda '{self.name}' is now revealed.")class MercenaryCard(Card): def init(self, name, cost=0): super().init(name, cost) self.bids = {}
def bid(self, player, amount): if player in self.bids: self.bids[player] += amount else: self.bids[player] = amount def highest_bidder(self): if self.bids: return max(self.bids, key=self.bids.get) return Noneclass Player: def init(self, name, influence_rating, cards=[], ambassador=None): self.name = name self.influence_rating = influence_rating self.current_influence = influence_rating self.cards = cards self.ambassador = ambassador self.initiative = 0 self.conflict_card = None self.passed = False self.agenda = None self.mercenaries = [] self.conflicts_initiated = []
def ready_cards(self): for card in self.cards: if card.is_sustainable and card.rotated: continue card.ready() def restore_influence(self): self.current_influence = self.influence_rating def determine_initiative(self, players): players.sort(key=lambda p: p.influence_rating) for i, player in enumerate(players): player.initiative = i print(f"{player.name} initiative: {player.initiative}") def declare_conflict(self, conflict_card): if self.conflict_card is None: self.conflict_card = conflict_card self.conflicts_initiated.append(conflict_card) print(f"{self.name} declares a conflict: {conflict_card.name}") def perform_action(self, action_type, *args): if action_type == "rotate": self.use_card_effect(*args) elif action_type == "play_event": self.play_event(*args) elif action_type == "build_influence": self.build_influence(*args) elif action_type == "sponsor": self.sponsor(*args) elif action_type == "promote": self.promote(*args) elif action_type == "replace": self.replace_character(*args) elif action_type == "support": self.support_conflict(*args) elif action_type == "oppose": self.oppose_conflict(*args) elif action_type == "attack": self.attack(*args) elif action_type == "heal": self.heal_character(*args) elif action_type == "repair": self.repair_location_or_fleet(*args) elif action_type == "lead_fleet": self.lead_fleet(*args) elif action_type == "discard_agenda": self.discard_agenda() elif action_type == "play_agenda": self.play_agenda(*args) elif action_type == "reveal_agenda": self.reveal_agenda() elif action_type == "replace_agenda": self.replace_agenda(*args) elif action_type == "bid_mercenary": self.bid_mercenary(*args) elif action_type == "pass": self.pass_action() else: print(f"Unknown action type: {action_type}") def use_card_effect(self, card): if card in self.cards and card.rotate(): print(f"{self.name} uses effect of {card.name}") def play_event(self, event_card): print(f"{self.name} plays event card: {event_card.name}") def build_influence(self): if self.influence_rating <= 9: self.influence_rating += 1 self.current_influence += 1 print(f"{self.name} builds influence. New influence rating: {self.influence_rating}") def sponsor(self, new_card): if self.current_influence >= new_card.cost: self.current_influence -= new_card.cost self.cards.append(new_card) print(f"{self.name} sponsors new card: {new_card.name}") else: print(f"{self.name} cannot afford to sponsor {new_card.name}") def promote(self, supporting_card): if supporting_card in self.cards: print(f"{self.name} promotes {supporting_card.name} to Inner Circle") def replace_character(self, old_card, new_card): if old_card in self.cards: self.cards.remove(old_card) self.cards.append(new_card) new_card.ready() print(f"{self.name} replaces {old_card.name} with {new_card.name}") def support_conflict(self, conflict, supporting_card): if supporting_card in self.cards and supporting_card.rotate(): print(f"{self.name} supports conflict {conflict.name} with {supporting_card.name}") def oppose_conflict(self, conflict, opposing_card): if opposing_card in self.cards and opposing_card.rotate(): print(f"{self.name} opposes conflict {conflict.name} with {opposing_card.name}") def attack(self, target_card, attacker): if attacker in self.cards and attacker.rotate(): target_card.inflict_damage(attacker.get_max_ability()) print(f"{self.name} attacks {target_card.name} with {attacker.name}") def heal_character(self, card): if card in self.cards and card.rotate(): if card.is_neutralized(): card.heal_severe() else: card.heal() print(f"{self.name} heals {card.name}") def repair_location_or_fleet(self, card): if card in self.cards and card.rotate(): repair_cost = card.damage if self.current_influence >= repair_cost: self.current_influence -= repair_cost card.heal(card.damage) print(f"{self.name} repairs {card.name}") else: print(f"{self.name} cannot afford to repair {card.name}") def lead_fleet(self, fleet, leader): if leader in self.cards and fleet in self.cards and leader.rotate(): print(f"{self.name} leads {fleet.name} with {leader.name}") def discard_agenda(self): if self.agenda and not self.agenda.is_major: print(f"{self.name} discards agenda: {self.agenda.name}") self.agenda = None else: print(f"{self.name} cannot discard a major agenda or has no agenda.") def play_agenda(self, new_agenda, character): if character in self.cards and character.rotate(): self.agenda = new_agenda if new_agenda.hidden: print(f"{self.name} plays a hidden agenda.") else: print(f"{self.name} plays agenda: {new_agenda.name}") def reveal_agenda(self): if self.agenda and self.agenda.hidden: self.agenda.reveal() if not self.agenda.can_be_sponsored(): print(f"{self.name}'s agenda {self.agenda.name} cannot be sponsored and is discarded.") self.agenda = None else: print(f"{self.name} has no hidden agenda to reveal.") def replace_agenda(self, new_agenda): if self.agenda and self.agenda.is_major and new_agenda.is_major: print(f"{self.name} replaces agenda {self.agenda.name} with {new_agenda.name}") self.agenda = new_agenda else: print(f"{self.name} can only replace a major agenda with another major agenda.") def bid_mercenary(self, mercenary, amount): if self.current_influence >= amount: self.current_influence -= amount mercenary.bid(self, amount) print(f"{self.name} bids {amount} influence on mercenary {mercenary.name}") else: print(f"{self.name} does not have enough influence to bid on mercenary {mercenary.name}") def pass_action(self): self.passed = True print(f"{self.name} passes their action.") - Assistant
- User
- Assistant
- User
Traceback (most recent call last): File "C:\Users\1thes\PycharmProjects\pythonProject\b5.py", line 526, in main() File "C:\Users\1thes\PycharmProjects\pythonProject\b5.py", line 521, in main while game.play_turn(): File "C:\Users\1thes\PycharmProjects\pythonProject\b5.py", line 502, in play_turn self.draw_round() File "C:\Users\1thes\PycharmProjects\pythonProject\b5.py", line 450, in draw_round if not player.draw_deck: AttributeError: 'Player' object has no attribute 'draw_deck'
- Assistant