Skip to content

Commit

Permalink
fix damage multiply
Browse files Browse the repository at this point in the history
  • Loading branch information
flick-ai committed Jun 6, 2024
1 parent fa8cf9d commit a51cf9a
Show file tree
Hide file tree
Showing 5 changed files with 183 additions and 10 deletions.
5 changes: 3 additions & 2 deletions genius_invocation/card/character/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,14 @@ def consume_energy(self, game: 'GeniusGame'):
assert self.from_character.power >= self.energy_cost
self.from_character.power -= self.energy_cost

def resolve_damage(self, game: 'GeniusGame', add_main_damage:int = 0, add_piercing_damage:int = 0):
def resolve_damage(self, game: 'GeniusGame', add_main_damage:int = 0, add_piercing_damage:int = 0, damage_multiply:int=1):
game.add_damage(Damage.create_damage(game, self.damage_type, self.main_damage_element,
self.main_damage + add_main_damage,
self.piercing_damage + add_piercing_damage,
self.from_character, get_opponent_active_character(game),
self.is_plunging_attack, self.is_charged_attack))
self.is_plunging_attack, self.is_charged_attack, damage_multiply))
game.resolve_damage()

def gain_energy(self, game: 'GeniusGame'):
self.from_character.power += self.energy_gain
self.from_character.power = min(self.from_character.power, self.from_character.max_power)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,8 @@ def on_call(self, game: 'GeniusGame'):
super().on_call(game)
self.consume_energy(game)
cards = self.from_character.from_player.hand_zone.discard_card_by_name(BonecrunchersEnergyBlock.name, max_num=MAX_HANDCARD)
sum_damage = self.main_damage * (len(cards) // 2)
add_damage = sum_damage - self.main_damage
self.resolve_damage(game, add_main_damage=add_damage)
multiply_num = 2 * (len(cards) // 2)
self.resolve_damage(game, damage_multiply=multiply_num)
game.manager.invoke(EventType.AFTER_USE_SKILL, game)

class ImmortalRemnantsAnemo(CharacterSkill):
Expand Down
4 changes: 2 additions & 2 deletions genius_invocation/card/character/characters/Mona.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def __init__(self, game: 'GeniusGame', from_player: 'GeniusPlayer', from_charact
def on_dealing_damage(self, game: 'GeniusGame'):
if isinstance(game.current_damage.damage_from, Character):
if game.current_damage.damage_from.from_player == self.from_player:
game.current_damage.main_damage *= 2
game.current_damage.damage_multiply += 1
self.on_destroy(game)

def update_listener_list(self):
Expand Down Expand Up @@ -264,7 +264,7 @@ def on_change(self, game:'GeniusGame'):
def on_dmg_after_reation(self, game:'GeniusGame'):
if self.talent:
if game.current_damage.damage_from.from_player == self.from_player:
if game.current_damage.reaction in [ElementalReactionType.Frozen,
if game.current_damage.reaction in [ElementalReactionType.Frozen,
ElementalReactionType.Vaporize,
ElementalReactionType.Bloom,
ElementalReactionType.Electro_Charged] \
Expand Down
168 changes: 168 additions & 0 deletions genius_invocation/card/character/characters/Wriothesley.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
from genius_invocation.card.character.import_head import *

class ForcefulFistsofFrost(NormalAttack):
name = 'Forceful Fists of Frost'
name_ch = "迅烈倾霜拳"
id: int = 11111
type: SkillType = SkillType.NORMAL_ATTACK

# damage
damage_type: SkillType = SkillType.NORMAL_ATTACK
main_damage_element: ElementType = ElementType.CRYO
main_damage: int = 1
piercing_damage: int = 0

# cost
cost = [{'cost_num': 1,'cost_type': CostType.CRYO},{'cost_num': 2,'cost_type': CostType.BLACK}]
energy_cost: int = 0
energy_gain: int = 1

def __init__(self, from_character: 'Character'):
super().__init__(from_character)

def on_call(self, game: 'GeniusGame'):
super().on_call(game)
# 处理伤害
self.resolve_damage(game)
# 获得能量
self.gain_energy(game)
# after skill
game.manager.invoke(EventType.AFTER_USE_SKILL, game)

class IcefangRush(ElementalSkill):
id = 11102
name = 'Icefang Rush'
name_ch = "冰牙突驰"
type: SkillType = SkillType.ELEMENTAL_SKILL

# damage
damage_type: SkillType = SkillType.ELEMENTAL_SKILL
main_damage_element: ElementType = ElementType.CRYO
main_damage: int = 2
piercing_damage: int = 0

# cost
cost = [{'cost_num': 3,'cost_type': CostType.CRYO},]
energy_cost: int = 0
energy_gain: int = 1

def __init__(self, from_character: 'Character'):
super().__init__(from_character)

def on_call(self, game: 'GeniusGame'):
super().on_call(game)
# 处理伤害
self.resolve_damage(game)
self.add_status(game, Snappy_Silhouette)

# 获得能量
self.gain_energy(game)
# after skill
game.manager.invoke(EventType.AFTER_USE_SKILL, game)


class Still_Photo_Comprehensive_Confirmation(ElementalBurst):
id = 11103
name = 'Still Photo: Comprehensive Confirmation'
name_ch = "定格·全方位确证"
type: SkillType = SkillType.ELEMENTAL_BURST

# damage
damage_type: SkillType = SkillType.ELEMENTAL_BURST
main_damage_element: ElementType = ElementType.CRYO
main_damage: int = 1
piercing_damage: int = 0

# cost
cost = [
{
'cost_num': 3,
'cost_type': CostType.CRYO
}
]

energy_cost: int = 2
energy_gain: int = 0

def __init__(self, from_character: 'Character'):
super().__init__(from_character)


def on_call(self, game: 'GeniusGame'):
super().on_call(game)
# 处理伤害
self.consume_energy(game)
self.resolve_damage(game)
for character in self.from_character.from_player.character_list:
if character.is_alive:
character.heal(1, game)
self.generate_summon(game, Newsflash_Field)
game.manager.invoke(EventType.AFTER_USE_SKILL, game)


class Wriothesley(Character):
id = 1111
name = 'Wriothesley'
name_ch = "莱欧斯利"
element = ElementType.CRYO
weapon_type = WeaponType.CATALYST
country = CountryType.FONTAINE

init_health_point = 10
max_health_point = 10
skill_list = [
Cool_Color_Capture,
Framing_Freezing_Point_Composition,
Still_Photo_Comprehensive_Confirmation
]
max_power = 3

def __init__(self, game: 'GeniusGame', zone: 'CharacterZone', from_player: 'GeniusPlayer', index:int, from_character = None, talent = False):
super().__init__(game, zone, from_player, index, from_character)
self.talent = talent
self.power = 0
self.talent_skill = self.skills[1]

class ChillingPenalty(Status):
name = 'Chilling Penalty'
name_ch = "寒烈的惩裁"
def __init__(self, game: 'GeniusGame', from_player: 'GeniusPlayer', from_character: 'Character', talent = False):
super().__init__(game, from_player, from_character)
self.current_usage = 2
self.is_

def on_calculate_dice(self, game: 'GeniusGame'):
if game.active_player_index == self.from_player.index:
if game.current_dice.from_character == self.from_character:
if game.current_dice.use_type == SkillType.NORMAL_ATTACK:
if self.from_character.health_point >= 6:
if self.current_usage > 0:
if game.current_dice.cost[1]['cost_num'] > 0:
game.current_dice.cost[1]['cost_num'] = max(0, game.current_dice.cost[1]['cost_num'] - 1)
return True

def on_damage_add(self, game: 'GeniusGame'):
if game.current_damage.damage_from == self.from_character:
if game.current_damage.main_damage_element is not ElementType.PIERCING:
if game.current_damage.damage_type == SkillType.NORMAL_ATTACK:
game.current_damage.main_damage += 1
self.current_usage -= 1
if self.from_character.health_point >= 6:
damage = Damage()


def on_skill(self, game: 'GeniusGame'):
if self.on_calculate_dice(game):
self.current_usage -= 1
self.is_use = True

def after_skill(self, game: 'GeniusGame'):




def update_listener_list(self):
self.listeners = [
(EventType.AFTER_USE_SKILL, ZoneType.CHARACTER_ZONE, self.after_skill),
(EventType.END_PHASE, ZoneType.CHARACTER_ZONE, self.on_end_phase)
]
11 changes: 8 additions & 3 deletions genius_invocation/event/damage/damage.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ class Damage:
def __init__(self, damage_type: 'SkillType', main_damage_element: 'ElementType',
main_damage: int, piercing_damage: int,
damage_from: 'Entity', damage_to: 'Character',
is_plunging_attack: bool=False, is_charged_attack: bool=False) -> None:
is_plunging_attack: bool=False, is_charged_attack: bool=False,
damage_multiply: int=1) -> None:
self.damage_type: SkillType = damage_type
self.main_damage_element: ElementType = main_damage_element
self.main_damage: int = main_damage
self.piercing_damage: int = piercing_damage

self.damage_multiply = damage_multiply

self.damage_from: Entity = damage_from
self.damage_to: Character = damage_to

Expand All @@ -32,8 +35,9 @@ def create_damage(cls, game: 'GeniusGame',
damage_type: 'SkillType', main_damage_element: 'ElementType',
main_damage: int, piercing_damage: int,
damage_from: 'Entity', damage_to: 'Entity',
is_plunging_attack: bool=False, is_charged_attack: bool=False):
dmg = cls(damage_type, main_damage_element, main_damage, piercing_damage, damage_from, damage_to, is_plunging_attack, is_charged_attack)
is_plunging_attack: bool=False, is_charged_attack: bool=False,
damage_multiply: int=1):
dmg = cls(damage_type, main_damage_element, main_damage, piercing_damage, damage_from, damage_to, is_plunging_attack, is_charged_attack, damage_multiply)
return dmg

# @staticmethod
Expand Down Expand Up @@ -76,6 +80,7 @@ def damage_add(self, game: 'GeniusGame'):
logger.debug(f"After Damage Add: {game.current_damage.main_damage}")
def damage_dealing(self, game: 'GeniusGame'):
game.manager.invoke(EventType.DEALING_DAMAGE, game)
self.main_damage = self.main_damage * self.damage_multiply
def damage_divide(self, game: 'GeniusGame'):
game.manager.invoke(EventType.DIVIDE_DAMAGE, game)
def damage_execute(self, game: 'GeniusGame'):
Expand Down

0 comments on commit a51cf9a

Please sign in to comment.