Archived
add effects to card
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
from typing import List
|
||||
from model import Serializable, CardRole, CardType, CardFaction
|
||||
from model.card_validator import Effect
|
||||
|
||||
|
||||
class Card(Serializable):
|
||||
@@ -11,6 +13,7 @@ class Card(Serializable):
|
||||
role: CardRole
|
||||
card_type: CardType
|
||||
faction: CardFaction
|
||||
effects: List[Effect]
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
@@ -19,6 +22,7 @@ class Card(Serializable):
|
||||
cost: int | None,
|
||||
card_type: CardType,
|
||||
faction: CardFaction,
|
||||
effects: List[Effect],
|
||||
):
|
||||
super().__init__()
|
||||
self.sprite = sprite
|
||||
@@ -26,6 +30,7 @@ class Card(Serializable):
|
||||
self.cost = cost
|
||||
self.card_type = card_type
|
||||
self.faction = faction
|
||||
self.effects = effects
|
||||
|
||||
|
||||
class CardChampion(Card):
|
||||
|
||||
@@ -62,7 +62,7 @@ class EffectType(str, Enum):
|
||||
|
||||
|
||||
class Effect(BaseModel):
|
||||
effect: str
|
||||
effect: CardEffects
|
||||
amount: int
|
||||
effect_type: Optional[EffectType] = None
|
||||
sub_effects: Optional[List["Effect"]] = None
|
||||
|
||||
+6
-11
@@ -63,10 +63,11 @@ class Game(Serializable):
|
||||
cost=c.cost,
|
||||
card_type=c.card_type,
|
||||
faction=c.faction,
|
||||
effects=c.effects,
|
||||
)
|
||||
)
|
||||
)
|
||||
random.shuffle(self.market)
|
||||
random.shuffle(self.market_stack)
|
||||
fire_gems = [c for c in self.loaded_cards if c.role == CardRole.FIRE_GEM]
|
||||
for c in fire_gems:
|
||||
for _ in range(c.init_amount):
|
||||
@@ -78,20 +79,12 @@ class Game(Serializable):
|
||||
cost=c.cost,
|
||||
card_type=c.card_type,
|
||||
faction=c.faction,
|
||||
effects=c.effects,
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
async def create_card(
|
||||
self,
|
||||
card: Card = Card(
|
||||
card_type=CardType.ACTION,
|
||||
faction=CardFaction.BLUE,
|
||||
cost=1,
|
||||
name="test",
|
||||
sprite="testsprite",
|
||||
),
|
||||
) -> Card:
|
||||
async def create_card(self, card: Card) -> Card:
|
||||
self.cards.append(card)
|
||||
await self.notify_controller("create", card.serialize_guest())
|
||||
|
||||
@@ -116,6 +109,7 @@ class Game(Serializable):
|
||||
cost=c.cost,
|
||||
card_type=c.card_type,
|
||||
faction=c.faction,
|
||||
effects=c.effects,
|
||||
)
|
||||
)
|
||||
)
|
||||
@@ -131,6 +125,7 @@ class Game(Serializable):
|
||||
|
||||
player.stack_pile = await self.create_base_deck("base")
|
||||
await self.notify_controller("create", player.serialize_guest())
|
||||
await self.notify_controller("update", self.serialize_guest())
|
||||
return player
|
||||
|
||||
async def create_team(self) -> Team:
|
||||
|
||||
Reference in New Issue
Block a user