mirror of
https://github.com/DavidGailleton/42-Piscine_Python.git
synced 2026-03-14 05:06:55 +01:00
28 lines
838 B
Python
28 lines
838 B
Python
from ex0 import Card
|
|
from typing import Union
|
|
|
|
|
|
class SpellCard(Card):
|
|
def __init__(
|
|
self, name: str, cost: int, rarity: str, effect_type: str, mana: int
|
|
) -> None:
|
|
super().__init__(name, cost, rarity)
|
|
self.effect_type = effect_type
|
|
self.mana = mana
|
|
|
|
def play(self, game_state: dict) -> dict:
|
|
try:
|
|
res: dict[str, Union[int, str]] = {}
|
|
if game_state["mana"] < 3:
|
|
raise Exception("Not enough mana")
|
|
res["card_played"] = self.name
|
|
res["mana_used"] = 3
|
|
res["effect"] = self.effect_type
|
|
return res
|
|
except Exception as err:
|
|
print(err)
|
|
return {}
|
|
|
|
def resolve_effect(self, targets: list) -> dict:
|
|
return {"card": self.name, "targets": targets, "resolved": True}
|