From e4e69b21f5c87d8e334fac2cfec0a8fe8f41d5fa Mon Sep 17 00:00:00 2001 From: Flick <79459207+flick-ai@users.noreply.github.com> Date: Tue, 27 Aug 2024 01:53:40 +0800 Subject: [PATCH] fix 5.0 bug --- .../character/characters/KaedeharaKazuha.py | 34 ++++++++++++------- genius_invocation/game/player.py | 16 ++++++--- genius_invocation/game/zone.py | 2 +- genius_invocation/main.py | 2 +- genius_invocation/user_layout.py | 9 ++--- 5 files changed, 39 insertions(+), 24 deletions(-) diff --git a/genius_invocation/card/character/characters/KaedeharaKazuha.py b/genius_invocation/card/character/characters/KaedeharaKazuha.py index 7c96c004..b04a9662 100644 --- a/genius_invocation/card/character/characters/KaedeharaKazuha.py +++ b/genius_invocation/card/character/characters/KaedeharaKazuha.py @@ -29,13 +29,15 @@ def __init__(self, from_character: 'Character'): def on_call(self, game: 'GeniusGame'): super().on_call(game) - - self.resolve_damage(game) - self.gain_energy(game) game.manager.invoke(EventType.AFTER_USE_SKILL, game) +class SpecialAttack(Garyuu_Bladework): + def on_call(self, game: 'GeniusGame'): + super().on_call(game) + self.from_character.from_player.prepared_skill = None + class Chihayaburu(ElementalSkill): name = 'Chihayaburu' @@ -64,6 +66,7 @@ def add_status(self, game: 'GeniusGame'): assert self.from_character.character_zone.has_entity(Midare_Ranzan) is None status = Midare_Ranzan(game, self.from_character.from_player, self.from_character, self.from_character.last_swirl) self.from_character.character_zone.add_entity(status) + self.from_character.from_player.prepared_skill = status def on_call(self, game: 'GeniusGame'): super().on_call(game) @@ -118,6 +121,7 @@ def __init__(self, game:'GeniusGame', from_player: 'GeniusPlayer', from_characte self.element = ElementType.ANEMO else: self.element = element + self.prepared_skill = SpecialAttack(from_character) self.usage = 1 self.current_usage = 1 @@ -128,21 +132,25 @@ def on_change_character(self, game:'GeniusGame'): def infusion(self, game:'GeniusGame'): if game.current_damage.damage_from == self.from_character: - if game.current_damage.is_plunging_attack: + if game.current_damage.damage_type == SkillType.NORMAL_ATTACK: game.current_damage.main_damage_element = self.element - def before_any_action(self, game:'GeniusGame'): - if self.from_character.is_active: - skill = self.from_character.skills[0] - skill.before_use_skill(game) - skill.on_call(game) - if not get_opponent(game).is_pass: - game.change_active_player() - self.on_destroy(game) + # def before_any_action(self, game:'GeniusGame'): + # if self.from_character.is_active: + # skill = self.from_character.skills[0] + # skill.before_use_skill(game) + # skill.on_call(game) + # if not get_opponent(game).is_pass: + # game.change_active_player() + # self.on_destroy(game) + + def on_call(self, game:'GeniusGame'): + self.prepared_skill.on_call(game) + self.on_destroy(game) def update_listener_list(self): self.listeners = [ - (EventType.BEFORE_ANY_ACTION, ZoneType.CHARACTER_ZONE, self.before_any_action), + # (EventType.BEFORE_ANY_ACTION, ZoneType.CHARACTER_ZONE, self.before_any_action), (EventType.INFUSION, ZoneType.CHARACTER_ZONE, self.infusion), (EventType.AFTER_CHANGE_CHARACTER, ZoneType.CHARACTER_ZONE, self.on_change_character) ] diff --git a/genius_invocation/game/player.py b/genius_invocation/game/player.py index 7d62babb..d245681b 100644 --- a/genius_invocation/game/player.py +++ b/genius_invocation/game/player.py @@ -149,11 +149,17 @@ def change_to_id(self, idx: int, type: SwitchType=SwitchType.SPECIAL_SWICH): ''' 基本行动: 切换到指定人 ''' - assert self.active_idx in range(self.character_num) - self.game.current_switch = Switch(from_player=self.character_list[self.active_idx], - to_player=self.character_list[idx], - swicth_type=type) - self.game.manager.invoke(EventType.ON_CHANGE_CHARACTER, self.game) + if self.active_idx in range(self.character_num): + self.game.current_switch = Switch(from_character=self.character_list[self.active_idx], + to_character=self.character_list[idx], + swicth_type=type) + self.game.manager.invoke(EventType.ON_CHANGE_CHARACTER, self.game) + else: + self.game.current_switch = Switch(from_character=None, + to_character=self.character_list[idx], + swicth_type=type) + self.game.manager.invoke(EventType.ON_CHANGE_CHARACTER, self.game) + if self.game.current_switch != None: if self.active_idx >= 0: diff --git a/genius_invocation/game/zone.py b/genius_invocation/game/zone.py index ae4eab51..da0f3ec8 100644 --- a/genius_invocation/game/zone.py +++ b/genius_invocation/game/zone.py @@ -19,7 +19,7 @@ class Switch: def __init__(self, from_character, to_character, swicth_type) -> None: - self.from_player = from_character.from_player + self.from_player = to_character.from_player self.from_character = from_character self.to_character = to_character self.type = swicth_type diff --git a/genius_invocation/main.py b/genius_invocation/main.py index e6136b3e..0c8fa179 100644 --- a/genius_invocation/main.py +++ b/genius_invocation/main.py @@ -186,7 +186,7 @@ def code_to_deck(code): 'PaidinFull','PaidinFull','Send_Off','Starsigns','Starsigns'] } deck2 = { - 'character': ['Barbara', 'Beidou', 'Xingqiu'], + 'character': ['Barbara', 'Beidou', 'KaedeharaKazuha'], 'action_card': ['Koholasaurus' for i in range(15)] + \ ['Yumkasaurus' for i in range(15)] } diff --git a/genius_invocation/user_layout.py b/genius_invocation/user_layout.py index 3f925a73..74a20b52 100644 --- a/genius_invocation/user_layout.py +++ b/genius_invocation/user_layout.py @@ -105,10 +105,6 @@ def get_character(player: 'GeniusPlayer', idx: int): str(character_list[idx].power), style=color, ) - sponsor_message.add_row( - character_list[idx].character_zone.special_skill.show() if character_list[idx].character_zone.special_skill != None else "No Special Skill", - style=color, - ) if character_list[idx].character_zone.weapon_card != None: sponsor_message.add_row( @@ -125,6 +121,11 @@ def get_character(player: 'GeniusPlayer', idx: int): f"Has Talent", style=color, ) + if character_list[idx].character_zone.special_skill != None: + sponsor_message.add_row( + character_list[idx].character_zone.special_skill.show(), + style=color, + ) for status in character_list[idx].character_zone.status_list: if isinstance(status, Shield): col = 'yellow'