Skip to content

Commit

Permalink
finish 4.7 support card
Browse files Browse the repository at this point in the history
  • Loading branch information
flick-ai committed Jun 4, 2024
1 parent 50b0625 commit 199cc0f
Show file tree
Hide file tree
Showing 11 changed files with 370 additions and 19 deletions.
1 change: 1 addition & 0 deletions genius_invocation/card/action/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class ActionCard:
cost_num: int
cost_type: CostType
card_type: ActionCardType
can_tune: bool = True

def on_played(self, game: 'GeniusGame') -> None:
'''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Joyous_Celebration(ActionCard):
id: int = 330003
name = "Joyous Celebration"
name_ch = "愉舞欢游"
cost_num = 1
cost_num = 0
cost_type = CostType.WHITE
card_type = ActionCardType.EVENT_ARCANE_LEGEND
def __init__(self) -> None:
Expand Down
60 changes: 60 additions & 0 deletions genius_invocation/card/action/support/companion/SirArthur.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
from genius_invocation.utils import *
from genius_invocation.card.action.support.base import SupportCard
from genius_invocation.card.action.base import ActionCard
from typing import TYPE_CHECKING
from genius_invocation.entity.support import Support
from genius_invocation.entity.status import Combat_Status
from copy import deepcopy

if TYPE_CHECKING:
from genius_invocation.game.game import GeniusGame
from genius_invocation.game.player import GeniusPlayer

class SirArthurEntity(Support):
name: str = 'Sir Arthur'
name_ch = '亚瑟先生'
max_count = 2
def __init__(self, game: 'GeniusGame', from_player: 'GeniusPlayer', from_character=None):
super().__init__(game, from_player, from_character)
self.news_lead = 0

def on_tune_card(self, game: 'GeniusGame'):
if game.active_player_index == self.from_player.index:
self.news_lead = min(self.max_count, self.news_lead + 1)

def on_discard_card(self, game: 'GeniusGame'):
if game.active_player_index == self.from_player.index:
self.news_lead = min(self.max_count, self.news_lead + 1)

def on_end(self, game: 'GeniusGame'):
if game.active_player_index == self.from_player.index:
if self.news_lead == self.max_count:
self.news_lead = 0
card = get_opponent(game).card_zone.card[0]
self.from_player.hand_zone.add([deepcopy(card)])

def update_listener_list(self):
self.listeners = [
(EventType.ON_TUNE_CARD, ZoneType.SUPPORT_ZONE, self.on_tune_card),
(EventType.ON_DISCARD_CARD, ZoneType.SUPPORT_ZONE, self.on_discard_card),
(EventType.END_PHASE, ZoneType.SUPPORT_ZONE, self.on_end),
]

class SirArthur(SupportCard):
id: int = 322026
name: str = 'Sir Arthur'
name_ch = '亚瑟先生'
cost_num = 0
cost_type = None
card_type = ActionCardType.SUPPORT_COMPANION

def __init__(self) -> None:
super().__init__()
self.entity = None

def on_played(self, game: 'GeniusGame') -> None:
self.entity = SirArthurEntity(game, from_player=game.active_player)
super().on_played(game)



89 changes: 89 additions & 0 deletions genius_invocation/card/action/support/item/Kusava.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
from genius_invocation.utils import *
from genius_invocation.card.action.support.base import SupportCard
from typing import TYPE_CHECKING
from genius_invocation.entity.support import Support

if TYPE_CHECKING:
from genius_invocation.game.game import GeniusGame
from genius_invocation.game.player import GeniusPlayer


class KusavaEntity(Support):
name: str = 'Kusava'
name_ch = '苦舍桓'
max_count = 2
def __init__(self, game: 'GeniusGame', from_player: 'GeniusPlayer', from_character=None):
super().__init__(game, from_player, from_character)
self.memories_and_dreams = 0

def get_max_count_card(self, game: 'GeniusGame'):
max_count = 0
max_idx = []
for idx, action_card in enumerate(self.from_player.hand_zone.card):
if action_card.card_type == ActionCardType.EQUIPMENT_TALENT:
count = sum([i['cost_num'] for i in action_card.cost])
else:
count = action_card.cost_num

if count > max_count:
max_idx = []
max_count = count
max_idx.append(idx)
if count == max_count:
max_idx.append(idx)
return idx

def on_begin(self, game:'GeniusGame'):
if game.active_player_index == self.from_player.index:
max_count_idx = self.get_max_count_card(game)
if len(max_count_idx) == 0:
return
if len(max_count_idx) > 2:
max_count_idx = max_count_idx[0:2]

for idx in max_count_idx:
self.from_player.hand_zone.discard_card(idx)
self.memories_and_dreams = min(self.max_count, self.memories_and_dreams + 1)

def on_calculate_dice(self, game: 'GeniusGame') -> bool:
if game.active_player_index == self.from_player.index:
if game.current_dice.use_type in SkillType:
if self.from_player.round_play_cards == 0:
if self.memories_and_dreams > 0:
if game.current_dice.cost[0]['cost_num'] > 0:
game.current_dice.cost[0]['cost_num'] -= 1
return True
if len(game.current_dice.cost) > 1:
if game.current_dice.cost[1]['cost_num'] > 0:
game.current_dice.cost[1]['cost_num'] -= 1
return True
return False

def on_skill(self, game: 'GeniusGame') -> None:
if self.on_calculate_dice(game):
self.memories_and_dreams -= 1

def update_listener_list(self):
self.listeners = [
(EventType.ON_USE_SKILL, ZoneType.SUPPORT_ZONE, self.on_skill),
(EventType.CALCULATE_DICE, ZoneType.SUPPORT_ZONE, self.on_calculate_dice),
(EventType.BEGIN_ACTION_PHASE, ZoneType.SUPPORT_ZONE, self.on_begin),
]
def show(self):
return str(self.usage)

class Kusava(SupportCard):
id: int = 323008
name: str = 'Kusava'
name_ch = '苦舍桓'
cost_num = 0
cost_type = None
card_type = ActionCardType.SUPPORT_ITEM

def __init__(self) -> None:
super().__init__()
self.entity = None

def on_played(self, game: 'GeniusGame') -> None:
self.entity = KusavaEntity(game, from_player=game.active_player)
super().on_played(game)
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
from genius_invocation.utils import *
from genius_invocation.card.action.support.base import SupportCard
from typing import TYPE_CHECKING
from genius_invocation.entity.support import Support

if TYPE_CHECKING:
from genius_invocation.game.game import GeniusGame
from genius_invocation.game.player import GeniusPlayer


class CentralLaboratoryRuinsEntity(Support):
name = 'Central Laboratory Ruins'
name_ch = '中央实验室遗址'
max_usage = 9
def __init__(self, game: 'GeniusGame', from_player: 'GeniusPlayer', from_character=None):
super().__init__(game, from_player, from_character)
self.experimentalprogress = 0

def excute(self, game):
if self.experimentalprogress > 0:
if self.experimentalprogress % 3 == 0:
self.from_player.dice_zone.add([DiceType.OMNI.value])
if self.experimentalprogress == self.max_usage:
self.on_destroy(game)

def on_tune_card(self, game: 'GeniusGame'):
if game.active_player_index == self.from_player.index:
self.experimentalprogress += 1
self.excute(game)

def on_discard_card(self, game: 'GeniusGame'):
if game.active_player_index == self.from_player.index:
self.experimentalprogress += 1
self.excute(game)

def update_listener_list(self):
self.listeners = [
(EventType.ON_TUNE_CARD, ZoneType.SUPPORT_ZONE, self.on_tune_card),
(EventType.ON_DISCARD_CARD, ZoneType.SUPPORT_ZONE, self.on_discard_card),
]
def show(self):
return str(self.usage)

class CentralLaboratoryRuins(SupportCard):
id: int = 321017
name = 'Central Laboratory Ruins'
name_ch = '中央实验室遗址'
cost_num = 1
cost_type = CostType.WHITE
card_type = ActionCardType.SUPPORT_LOCATION

def __init__(self) -> None:
super().__init__()
self.entity = None

def on_played(self, game: 'GeniusGame') -> None:
self.entity = CentralLaboratoryRuinsEntity(game, from_player=game.active_player)
super().on_played(game)
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def update_listener_list(self):
]
class Fortress_of_Meropide_Entity(Support):
id: int = 322018
name = 'Fortress_of_Meropide'
name = 'Fortress of Meropide'
name_ch = '梅洛彼得堡'
max_usage = -1
max_count = 4
Expand Down Expand Up @@ -73,7 +73,7 @@ def show(self):

class Fortress_of_Meropide(SupportCard):
id: int = 321018
name: str = 'Fortress_of_Meropide'
name: str = 'Fortress of Meropide'
name_ch = '梅洛彼得堡'
cost_num = 1
cost_type = CostType.WHITE
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
from genius_invocation.utils import *
from genius_invocation.card.action.support.base import SupportCard
from typing import TYPE_CHECKING
from genius_invocation.entity.support import Support
from genius_invocation.entity.status import Combat_Status
from genius_invocation.event.damage import Damage


if TYPE_CHECKING:
from genius_invocation.game.game import GeniusGame
from genius_invocation.game.player import GeniusPlayer


class HasForbiddenKnowledge(Combat_Status):
name: str = 'Forbidden Knowledge'
name_ch = '禁忌知识'
def __init__(self, game: 'GeniusGame', from_player: 'GeniusPlayer', from_character=None):
super().__init__(game, from_player, from_character)

def on_end(self, game:'GeniusGame'):
self.on_destroy(game)

def update_listener_list(self):
self.listeners = [
(EventType.FINAL_END, ZoneType.ACTIVE_ZONE, self.on_end),
]

class ForbiddenKnowledge(ActionCard):
name = "Forbidden Knowledge"
name_ch = "禁忌知识"
cost_num = 0
cost_type = None
card_type = ActionCardType.EVENT
can_tune = False
def __init__(self) -> None:
super().__init__()

def on_played(self, game: 'GeniusGame') -> None:
dmg = Damage.create_damage(
game,
damage_type=SkillType.OTHER,
main_damage_element=ElementType.PIERCING,
main_damage=1,
piercing_damage=0,
damage_from=None,
damage_to=get_my_active_character(game),
)
game.add_damage(dmg)
game.resolve_damage()
game.active_player.get_card(num=1)

def on_tuning(self, game: 'GeniusGame') -> None:
pass

def find_target(self, game: 'GeniusGame'):
if game.active_player.last_die_round == game.round :
if game.active_player.team_combat_status.has_status(HasForbiddenKnowledge) is None:
return [1]
return []


class TheMausoleumofKingDeshretStatus(Combat_Status):
name: str = 'The Mausoleum of King Deshret'
name_ch = '赤王陵'
def __init__(self, game: 'GeniusGame', from_player: 'GeniusPlayer', from_character=None):
super().__init__(game, from_player, from_character)

def on_get_card(self, game: 'GeniusGame'):
if game.current_get_card.from_player == self.from_player:
self.from_player.card_zone.place_randomly([ForbiddenKnowledge()])

def on_end(self, game:'GeniusGame'):
self.on_destroy(game)

def update_listener_list(self):
self.listeners = [
(EventType.ON_PLAY_CARD, ZoneType.ACTIVE_ZONE, self.on_play),
(EventType.FINAL_END, ZoneType.ACTIVE_ZONE, self.on_end),
]


class TheMausoleumofKingDeshretEntity(Support):
name: str = 'The Mausoleum of King Deshret'
name_ch = '赤王陵'
max_count = 4
def __init__(self, game: 'GeniusGame', from_player: 'GeniusPlayer', from_character=None):
super().__init__(game, from_player, from_character)
self.count = 0
self.oppenent = get_opponent(game)

def on_get_card(self, game: 'GeniusGame'):
if game.current_get_card.from_player == self.oppenent:
self.count += 1
if self.count == self.max_count:
self.on_destroy(game)
for _ in range(2):
self.oppenent.card_zone.insert_randomly(ForbiddenKnowledge(), 0)
self.oppenent.team_combat_status.add_entity(TheMausoleumofKingDeshretStatus(game, self.oppenent))

def update_listener_list(self):
self.listeners = [
(EventType.ON_GET_CARD, ZoneType.SUPPORT_ZONE, self.on_get_card),
]

def show(self):
return str(self.count)

class TheMausoleumofKingDeshret(SupportCard):
id: int = 321018
name: str = 'The Mausoleum of King Deshret'
name_ch = '赤王陵'
cost_num = 1
cost_type = CostType.WHITE
card_type = ActionCardType.SUPPORT_LOCATION

def __init__(self) -> None:
super().__init__()
self.entity = None

def on_played(self, game: 'GeniusGame') -> None:
self.entity = TheMausoleumofKingDeshretEntity(game, from_player=game.active_player)
super().on_played(game)
4 changes: 2 additions & 2 deletions genius_invocation/game/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from genius_invocation.event.events import EventManager
from genius_invocation.card.character.base import Damage
from genius_invocation.card.action.base import ActionCard
from genius_invocation.game.zone import Dice
from genius_invocation.game.zone import Dice, GetCard
from genius_invocation.event.heal import Heal
from loguru import logger
from rich.console import Console
Expand Down Expand Up @@ -59,14 +59,14 @@ def __init__(self, player0_deck, player1_deck, seed=None, is_omni=False) -> None
self.current_skill: CharacterSkill = None
self.current_card: ActionCard = None
self.current_remove_from: Character = None
self.current_get_card: GetCard = None
self.damage_list: List[Damage] = []
self.is_change_player: bool = False
self.current_attach_reaction: ElementalReactionType = None # Save the reaction type when attachment (no dmg). Will be reset after the invoking of the event. keep None.
#TODO: CHECK THE INITIALIZE OF IS_CHANGE_PLAYER
self.is_end: bool = False
self.is_overload:GeniusPlayer = None
self.can_play_card = True
self.get_card_num = 0

self.init_game()

Expand Down
Loading

0 comments on commit 199cc0f

Please sign in to comment.