diff --git a/genius_invocation/card/action/equipment/artifact/artifacts/AmethystCrown.py b/genius_invocation/card/action/equipment/artifact/artifacts/AmethystCrown.py index 05bc8d76..5eae06e9 100644 --- a/genius_invocation/card/action/equipment/artifact/artifacts/AmethystCrown.py +++ b/genius_invocation/card/action/equipment/artifact/artifacts/AmethystCrown.py @@ -32,7 +32,7 @@ def on_end(self, game: 'GeniusGame'): def update_listener_list(self): self.listeners = [ - (EventType.FINAL_EXECUTE, ZoneType.CHARACTER_ZONE, self.on_damage), + (EventType.EXECUTE_DAMAGE, ZoneType.CHARACTER_ZONE, self.on_damage), (EventType.FINAL_END, ZoneType.CHARACTER_ZONE, self.on_end) ] diff --git a/genius_invocation/card/action/equipment/artifact/artifacts/FlowerofParadiseLost.py b/genius_invocation/card/action/equipment/artifact/artifacts/FlowerofParadiseLost.py index fb4c231c..48843d17 100644 --- a/genius_invocation/card/action/equipment/artifact/artifacts/FlowerofParadiseLost.py +++ b/genius_invocation/card/action/equipment/artifact/artifacts/FlowerofParadiseLost.py @@ -35,7 +35,7 @@ def on_end(self, game: 'GeniusGame'): def update_listener_list(self): self.listeners = [ - (EventType.FINAL_EXECUTE, ZoneType.CHARACTER_ZONE, self.on_damage), + (EventType.EXECUTE_DAMAGE, ZoneType.CHARACTER_ZONE, self.on_damage), (EventType.FINAL_END, ZoneType.CHARACTER_ZONE, self.on_end) ] diff --git a/genius_invocation/card/action/equipment/artifact/artifacts/HeartofKhvarenasBrilliance.py b/genius_invocation/card/action/equipment/artifact/artifacts/HeartofKhvarenasBrilliance.py index 491572b2..c1e3497d 100644 --- a/genius_invocation/card/action/equipment/artifact/artifacts/HeartofKhvarenasBrilliance.py +++ b/genius_invocation/card/action/equipment/artifact/artifacts/HeartofKhvarenasBrilliance.py @@ -14,17 +14,23 @@ class HeartofKhvarenasBrillianceEntity(Artifact): def __init__(self, game: 'GeniusGame', from_player: 'GeniusPlayer', from_character = None, artifact_card = None): super().__init__(game, from_player, from_character, artifact_card) self.usage_round = -1 + self.is_excute = False def after_damage(self, game:'GeniusGame'): if self.usage_round != game.round: if game.current_damage.damage_to == self.from_character: - if self.from_character.is_active: - self.from_player.get_card(num=1) - self.usage_round = game.round + self.is_excute = True + + def on_excute(self, game: 'GeniusGame'): + if self.is_excute: + if self.from_character.is_active and self.from_character.is_alive: + self.from_player.get_card(num=1) + self.is_excute = False def update_listener_list(self): self.listeners = [ - (EventType.FINAL_EXECUTE, ZoneType.CHARACTER_ZONE, self.after_damage), + (EventType.EXECUTE_DAMAGE, ZoneType.CHARACTER_ZONE, self.after_damage), + (EventType.FINAL_EXECUTE, ZoneType.CHARACTER_ZONE, self.on_excute) ] diff --git a/genius_invocation/card/action/equipment/artifact/artifacts/MarechausseeHunter.py b/genius_invocation/card/action/equipment/artifact/artifacts/MarechausseeHunter.py index 87969b66..8fed96ff 100644 --- a/genius_invocation/card/action/equipment/artifact/artifacts/MarechausseeHunter.py +++ b/genius_invocation/card/action/equipment/artifact/artifacts/MarechausseeHunter.py @@ -14,6 +14,7 @@ class MarechausseeHunterEntity(Artifact): def __init__(self, game: 'GeniusGame', from_player: 'GeniusPlayer', from_character = None, artifact_card = None): super().__init__(game, from_player, from_character, artifact_card) self.round_usage = 0 + self.is_excute = False def excute(self, game): if self.round_usage == 0 or self.round_usage == 3: @@ -26,10 +27,15 @@ def excute(self, game): self.from_player.get_card(num=1) return + def on_excute(self, game:'GeniusGame'): + if self.is_excute: + if self.from_character.is_alive: + self.excute(game) + self.is_excute = False def after_damage(self, game:'GeniusGame'): if game.current_damage.damage_to == self.from_character: - self.excute(game) + self.is_excute = True def after_heal(self, game:'GeniusGame'): if game.current_heal.heal_to_character == self.from_character: @@ -40,9 +46,10 @@ def on_end(self, game: 'GeniusGame'): def update_listener_list(self): self.listeners = [ - (EventType.FINAL_EXECUTE, ZoneType.CHARACTER_ZONE, self.after_damage), + (EventType.EXECUTE_DAMAGE, ZoneType.CHARACTER_ZONE, self.after_damage), (EventType.AFTER_HEAL, ZoneType.CHARACTER_ZONE, self.after_heal), - (EventType.FINAL_END, ZoneType.CHARACTER_ZONE, self.on_end) + (EventType.FINAL_END, ZoneType.CHARACTER_ZONE, self.on_end), + (EventType.FINAL_EXECUTE, ZoneType.CHARACTER_ZONE, self.on_excute) ] diff --git a/genius_invocation/card/action/equipment/artifact/artifacts/VeteransVisage.py b/genius_invocation/card/action/equipment/artifact/artifacts/VeteransVisage.py index 8c3b95a8..e0e63284 100644 --- a/genius_invocation/card/action/equipment/artifact/artifacts/VeteransVisage.py +++ b/genius_invocation/card/action/equipment/artifact/artifacts/VeteransVisage.py @@ -14,6 +14,7 @@ class VeteransVisageEntity(Artifact): def __init__(self, game: 'GeniusGame', from_player: 'GeniusPlayer', from_character = None, artifact_card = None): super().__init__(game, from_player, from_character, artifact_card) self.round_usage = 0 + self.is_excute = False def excute(self, game): if self.round_usage == 0: @@ -25,10 +26,16 @@ def excute(self, game): self.round_usage += 1 self.from_player.get_card(num=1) return + + def on_excute(self, game): + if self.is_excute: + if self.from_character.is_alive: + self.is_excute = False + self.excute(game) def after_damage(self, game:'GeniusGame'): if game.current_damage.damage_to == self.from_character: - self.excute(game) + self.is_excute = True def after_heal(self, game:'GeniusGame'): if game.current_heal.heal_to_character == self.from_character: @@ -39,9 +46,10 @@ def on_end(self, game: 'GeniusGame'): def update_listener_list(self): self.listeners = [ - (EventType.FINAL_EXECUTE, ZoneType.CHARACTER_ZONE, self.after_damage), + (EventType.EXECUTE_DAMAGE, ZoneType.CHARACTER_ZONE, self.after_damage), (EventType.AFTER_HEAL, ZoneType.CHARACTER_ZONE, self.after_heal), - (EventType.FINAL_END, ZoneType.CHARACTER_ZONE, self.on_end) + (EventType.FINAL_END, ZoneType.CHARACTER_ZONE, self.on_end), + (EventType.FINAL_EXECUTE, ZoneType.CHARACTER_ZONE, self.on_excute), ] diff --git a/genius_invocation/card/action/equipment/artifact/artifacts/VourukashasGlow.py b/genius_invocation/card/action/equipment/artifact/artifacts/VourukashasGlow.py index f4b0b65f..45238a7f 100644 --- a/genius_invocation/card/action/equipment/artifact/artifacts/VourukashasGlow.py +++ b/genius_invocation/card/action/equipment/artifact/artifacts/VourukashasGlow.py @@ -14,14 +14,20 @@ class VourukashasGlowEntity(Artifact): def __init__(self, game: 'GeniusGame', from_player: 'GeniusPlayer', from_character = None, artifact_card = None): super().__init__(game, from_player, from_character, artifact_card) self.usage_round = -1 + self.is_excute = False def after_damage(self, game:'GeniusGame'): if self.usage_round != game.round: if game.current_damage.damage_to == self.from_character: - if self.from_character.is_active: - self.from_player.get_card(num=1) - self.usage_round = game.round - + self.is_excute = True + + def on_excute(self, game): + if self.is_excute: + if self.from_character.is_active and self.from_character.is_alive: + self.from_player.get_card(num=1) + self.usage_round = game.round + self.is_excute = False + def on_end(self, game: 'GeniusGame'): if game.active_player_index == self.from_player.index: if self.usage_round == game.round: @@ -29,8 +35,9 @@ def on_end(self, game: 'GeniusGame'): def update_listener_list(self): self.listeners = [ - (EventType.FINAL_EXECUTE, ZoneType.CHARACTER_ZONE, self.after_damage), - (EventType.END_PHASE, ZoneType.CHARACTER_ZONE, self.on_end) + (EventType.EXECUTE_DAMAGE, ZoneType.CHARACTER_ZONE, self.after_damage), + (EventType.END_PHASE, ZoneType.CHARACTER_ZONE, self.on_end), + (EventType.FINAL_EXECUTE, ZoneType.CHARACTER_ZONE, self.on_excute) ] diff --git a/genius_invocation/card/action/equipment/weapon/weapons/BeaconoftheReedSea.py b/genius_invocation/card/action/equipment/weapon/weapons/BeaconoftheReedSea.py index 71a60d98..38779126 100644 --- a/genius_invocation/card/action/equipment/weapon/weapons/BeaconoftheReedSea.py +++ b/genius_invocation/card/action/equipment/weapon/weapons/BeaconoftheReedSea.py @@ -55,7 +55,7 @@ def update_listener_list(self): self.listeners = [ (EventType.DAMAGE_ADD, ZoneType.CHARACTER_ZONE, self.on_damage_add), (EventType.AFTER_USE_SKILL, ZoneType.CHARACTER_ZONE, self.on_after_skill), - (EventType.FINAL_EXECUTE, ZoneType.CHARACTER_ZONE, self.after_damage), + (EventType.EXECUTE_DAMAGE, ZoneType.CHARACTER_ZONE, self.after_damage), ] diff --git a/genius_invocation/card/action/equipment/weapon/weapons/CashflowSupervision.py b/genius_invocation/card/action/equipment/weapon/weapons/CashflowSupervision.py index 33301566..998b1dc3 100644 --- a/genius_invocation/card/action/equipment/weapon/weapons/CashflowSupervision.py +++ b/genius_invocation/card/action/equipment/weapon/weapons/CashflowSupervision.py @@ -63,7 +63,7 @@ def update_listener_list(self): self.listeners = [ (EventType.DAMAGE_ADD, ZoneType.CHARACTER_ZONE, self.on_damage_add), (EventType.FINAL_END, ZoneType.CHARACTER_ZONE, self.on_end), - (EventType.FINAL_EXECUTE, ZoneType.CHARACTER_ZONE, self.after_damage), + (EventType.EXECUTE_DAMAGE, ZoneType.CHARACTER_ZONE, self.after_damage), (EventType.AFTER_HEAL, ZoneType.CHARACTER_ZONE, self.after_heal), (EventType.CALCULATE_DICE, ZoneType.CHARACTER_ZONE, self.on_calculate_dice), (EventType.ON_USE_SKILL, ZoneType.CHARACTER_ZONE, self.on_skill), diff --git a/genius_invocation/card/action/equipment/weapon/weapons/SplendorofTranquilWaters.py b/genius_invocation/card/action/equipment/weapon/weapons/SplendorofTranquilWaters.py index 87f8d7c0..6c697625 100644 --- a/genius_invocation/card/action/equipment/weapon/weapons/SplendorofTranquilWaters.py +++ b/genius_invocation/card/action/equipment/weapon/weapons/SplendorofTranquilWaters.py @@ -61,7 +61,7 @@ def update_listener_list(self): self.listeners = [ (EventType.DAMAGE_ADD, ZoneType.CHARACTER_ZONE, self.on_damage_add), (EventType.FINAL_END, ZoneType.CHARACTER_ZONE, self.on_end), - (EventType.FINAL_EXECUTE, ZoneType.CHARACTER_ZONE, self.after_damage), + (EventType.EXECUTE_DAMAGE, ZoneType.CHARACTER_ZONE, self.after_damage), (EventType.AFTER_HEAL, ZoneType.CHARACTER_ZONE, self.after_heal), (EventType.CALCULATE_DICE, ZoneType.CHARACTER_ZONE, self.on_calculate_dice), (EventType.ON_USE_SKILL, ZoneType.CHARACTER_ZONE, self.on_skill), diff --git a/genius_invocation/card/action/equipment/weapon/weapons/TomeoftheEternalFlow.py b/genius_invocation/card/action/equipment/weapon/weapons/TomeoftheEternalFlow.py index fc4547fc..0598e827 100644 --- a/genius_invocation/card/action/equipment/weapon/weapons/TomeoftheEternalFlow.py +++ b/genius_invocation/card/action/equipment/weapon/weapons/TomeoftheEternalFlow.py @@ -53,7 +53,7 @@ def update_listener_list(self): self.listeners = [ (EventType.DAMAGE_ADD, ZoneType.CHARACTER_ZONE, self.on_damage_add), (EventType.FINAL_END, ZoneType.CHARACTER_ZONE, self.on_end), - (EventType.FINAL_EXECUTE, ZoneType.CHARACTER_ZONE, self.after_damage), + (EventType.EXECUTE_DAMAGE, ZoneType.CHARACTER_ZONE, self.after_damage), (EventType.AFTER_HEAL, ZoneType.CHARACTER_ZONE, self.after_heal), ] diff --git a/genius_invocation/card/action/event/events/CountdowntotheShow3.py b/genius_invocation/card/action/event/events/CountdowntotheShow3.py index f52434fa..a02989f9 100644 --- a/genius_invocation/card/action/event/events/CountdowntotheShow3.py +++ b/genius_invocation/card/action/event/events/CountdowntotheShow3.py @@ -27,7 +27,7 @@ def find_target(self, game:'GeniusGame'): else: return [] - def on_discard(self, game: GeniusGame): + def on_discard(self, game: 'GeniusGame'): target_card_name = self.base_name + str(self.cost_num - 1) target_card = eval(target_card_name)() game.active_player.card_zone.insert_randomly(target_card, num=0) diff --git a/genius_invocation/card/action/event/events/Machine_Assembly_Line.py b/genius_invocation/card/action/event/events/Machine_Assembly_Line.py index 89020081..7db9af12 100644 --- a/genius_invocation/card/action/event/events/Machine_Assembly_Line.py +++ b/genius_invocation/card/action/event/events/Machine_Assembly_Line.py @@ -43,7 +43,7 @@ def on_use(self, game:'GeniusGame'): def update_listener_list(self): self.listeners = [ - (EventType.FINAL_EXECUTE, ZoneType.ACTIVE_ZONE, self.on_damage), + (EventType.EXECUTE_DAMAGE, ZoneType.ACTIVE_ZONE, self.on_damage), (EventType.AFTER_HEAL, ZoneType.ACTIVE_ZONE, self.on_heal), (EventType.CALCULATE_DICE, ZoneType.ACTIVE_ZONE, self.on_calculate), (EventType.ON_PLAY_CARD, ZoneType.ACTIVE_ZONE, self.on_use), diff --git a/genius_invocation/card/action/event/events/WaterandJustice.py b/genius_invocation/card/action/event/events/WaterandJustice.py index 947dc708..2750b01e 100644 --- a/genius_invocation/card/action/event/events/WaterandJustice.py +++ b/genius_invocation/card/action/event/events/WaterandJustice.py @@ -1,5 +1,6 @@ from genius_invocation.card.action.base import ActionCard from genius_invocation.utils import * +from genius_invocation.event.damage import Damage if TYPE_CHECKING: from genius_invocation.game.game import GeniusGame @@ -15,19 +16,48 @@ def __init__(self) -> None: super().__init__() def calculate_target_point(self,sum_point: int, max_points: List[int]): - # 重新平均分配生命值 - target_point = [] + # 计算重新平均分配生命值 + need_character = len(max_points) + target_point = [0 for i in range(need_character)] + target_idx = [i for i in range(need_character)] + + while sum_point > 0: + for idx in target_idx: + target_point[idx] += 1 + sum_point -= 1 + if sum_point == 0: + break + if max_points[idx] == target_point[idx]: + target_idx.remove(idx) + + return target_point def on_played(self, game: 'GeniusGame'): sum_point = 0 max_points = [] - target_idx = [] - for player in game.active_player.character_list: - if player.is_alive: - sum_point += player.health_point - max_points.append(player.max_health_point) - target_idx.append(player.idx) + character_list = [get_my_active_character(game)].extend(get_my_standby_character(game)) + for character in character_list: + sum_point += character.health_point + max_points.append(character.max_health_point) target_point = self.calculate_target_point(sum_point, max_points) + # 进行对应操作 + for idx, character in enumerate(character_list): + if target_point > character.health_point: + character.heal(heal=target_point[idx]-character.health_point, game=game) + elif target_point < character.health_point: + damage = Damage.create_damage( + game=game, + damage_type=SkillType.OTHER, + main_damage_element=ElementType.PIERCING, + main_damage=character.health_point-target_point[idx], + piercing_damage=0, + damage_from=None, + damage_to=character + ) + game.add_damage(damage) + game.resolve_damage() + + character.heal(heal=1, game=game) diff --git a/genius_invocation/card/action/event/foods/Rainbow_Macarons.py b/genius_invocation/card/action/event/foods/Rainbow_Macarons.py index d9b340e7..7122cbd4 100644 --- a/genius_invocation/card/action/event/foods/Rainbow_Macarons.py +++ b/genius_invocation/card/action/event/foods/Rainbow_Macarons.py @@ -16,16 +16,23 @@ def __init__(self, game: 'GeniusGame', from_player: 'GeniusPlayer', from_charact super().__init__(game, from_player, from_character) self.from_character.heal(heal=1,game=game) self.current_usage = 3 + self.is_heal = False - def on_damage(self, game: 'GeniusGame'): - if game.current_damage.damage_to == self.from_character: + def on_excute(self, game: 'GeniusGame'): + if self.is_heal: + self.is_heal = False self.from_character.heal(heal=1, game=game) self.current_usage -= 1 if self.current_usage <=0: self.on_destroy(game) + def on_damage(self, game: 'GeniusGame'): + if game.current_damage.damage_to == self.from_character: + self.is_heal = True + def update_listener_list(self): self.listeners = [ + (EventType.EXECUTE_DAMAGE, ZoneType.CHARACTER_ZONE, self.on_damage), (EventType.FINAL_EXECUTE, ZoneType.CHARACTER_ZONE, self.on_damage), ] diff --git a/genius_invocation/card/action/support/item/Kusava.py b/genius_invocation/card/action/support/item/Kusava.py index 552728a1..f62b34dd 100644 --- a/genius_invocation/card/action/support/item/Kusava.py +++ b/genius_invocation/card/action/support/item/Kusava.py @@ -17,30 +17,26 @@ def __init__(self, game: 'GeniusGame', from_player: 'GeniusPlayer', from_charact self.memories_and_dreams = 0 def get_max_count_card(self, game: 'GeniusGame'): - max_count = 0 - max_idx = [] + card_list = [] 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 + card_list.append((idx, count)) + max_count_card = sorted(card_list, key=lambda x:x[-1]) + if len(max_count_card) == 0: + return [] + elif len(max_count_card) == 1: + return [max_count_card[0]] + else: + max_count_idx = [i[0] for i in max_count_card[0:2]] + return max_count_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) diff --git a/genius_invocation/card/action/support/location/TheMausoleumofKingDeshret.py b/genius_invocation/card/action/support/location/TheMausoleumofKingDeshret.py index 976585b5..d51d72ca 100644 --- a/genius_invocation/card/action/support/location/TheMausoleumofKingDeshret.py +++ b/genius_invocation/card/action/support/location/TheMausoleumofKingDeshret.py @@ -4,6 +4,7 @@ from genius_invocation.entity.support import Support from genius_invocation.entity.status import Combat_Status from genius_invocation.event.damage import Damage +from genius_invocation.card.action.base import ActionCard if TYPE_CHECKING: diff --git a/genius_invocation/event/events.py b/genius_invocation/event/events.py index 9cbb96e5..d1a2c13e 100644 --- a/genius_invocation/event/events.py +++ b/genius_invocation/event/events.py @@ -51,7 +51,7 @@ def __init__(self, need_character=False) -> None: def append_action(self, action, character_index=None) -> ListenerNode: - if character_index: + if character_index is not None: node = ListenerNode(action, self.character_tails[character_index].before, self.character_tails[character_index]) self.character_tails[character_index].before.next = node self.character_tails[character_index].before = node @@ -63,7 +63,7 @@ def append_action(self, action, character_index=None) -> ListenerNode: return node def __call__(self, game: 'GeniusGame', character_index=None) -> None: - if not character_index: + if character_index is None: listener = self.head.next tail_before = self.tail.before while listener != self.tail: diff --git a/genius_invocation/game/player.py b/genius_invocation/game/player.py index d62d1e66..1a68759b 100644 --- a/genius_invocation/game/player.py +++ b/genius_invocation/game/player.py @@ -42,8 +42,8 @@ def __init__(self, game: 'GeniusGame', deck, idx) -> None: # 初始化牌库、起始5张手牌、骰子区 self.card_zone: CardZone = CardZone(game, self, deck['action_card']) # 牌库区 self.hand_zone: HandZone = HandZone(game, self) # 手牌区 - arcanes = self.card_zone.find_card(ActionCardType.EVENT_ARCANE_LEGEND, num=-1) - self.hand_zone.add(self.card_zone.get_card(num=5-len(arcanes))+arcanes) + arcanes = self.card_zone.find_card(ActionCardType.EVENT_ARCANE_LEGEND, num=-1, invoke=False) + self.hand_zone.add(self.card_zone.get_card(num=5-len(arcanes), invoke=False)+arcanes) self.dice_zone: DiceZone = DiceZone(game, self) # 环境中的基本状态 diff --git a/genius_invocation/game/zone.py b/genius_invocation/game/zone.py index 03363752..600a00e7 100644 --- a/genius_invocation/game/zone.py +++ b/genius_invocation/game/zone.py @@ -257,7 +257,7 @@ def invoke_get_card(self, num): self.game.manager.invoke(EventType.ON_GET_CARD, self.game) self.game.current_get_card = None - def find_card(self, card_type: 'ActionCardType', num=1): + def find_card(self, card_type: 'ActionCardType', num=1, invoke=True): ''' 检索并获取特定类型的牌 ''' @@ -273,7 +273,8 @@ def find_card(self, card_type: 'ActionCardType', num=1): for idx in idx_list: self.card.pop(idx) - self.invoke_get_card(num) + if invoke: + self.invoke_get_card(num) return get_list def random_find_card(self, card_type: 'ActionCardType', num=1): @@ -292,7 +293,7 @@ def random_find_card(self, card_type: 'ActionCardType', num=1): self.invoke_get_card(num) return get_list - def get_card(self, num): + def get_card(self, num, invoke=True): ''' 随机获取牌 ''' @@ -301,7 +302,8 @@ def get_card(self, num): get_list.append(self.card.pop()) self.card_num = len(self.card) - self.invoke_get_card(num) + if invoke: + self.invoke_get_card(num) return get_list def return_card(self, card_list: List): diff --git a/genius_invocation/main.py b/genius_invocation/main.py index 794f503e..20faab30 100644 --- a/genius_invocation/main.py +++ b/genius_invocation/main.py @@ -178,7 +178,7 @@ def code_to_deck(code): } deck2 = { 'character': ['Neuvillette', 'Lisa', 'Qiqi'], - 'action_card': ['HeirtotheAncientSeasAuthority' for i in range(30)] + 'action_card': ['VourukashasGlow' for i in range(30)] } # deck2 = { # 'character': ['Arataki_Itto', 'Dehya', 'Noelle'],