From 6026a32429a1cbd7a93fe2f86652129d9c90fcd8 Mon Sep 17 00:00:00 2001 From: istamarahsan Date: Sun, 26 Jan 2025 02:48:27 +0700 Subject: [PATCH] feat: Sword Masteryyyy --- tcg/match/match_manager.gd | 16 ++++++++++++++-- tcg/match/match_player.gd | 1 + 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/tcg/match/match_manager.gd b/tcg/match/match_manager.gd index 12a1b7d..1bff5e2 100644 --- a/tcg/match/match_manager.gd +++ b/tcg/match/match_manager.gd @@ -118,9 +118,9 @@ func resolve(action_by_player_id: Dictionary) -> PhaseTransition: var player_1_win = rps_wins[player_1_action.move] == player_2_action.move var player_2_win = rps_wins[player_2_action.move] == player_1_action.move if tie or player_1_win: - player_2.monster.health_delta -= player_1.monster.card.damage[player_1_action.move] + player_2.monster.health_delta -= player_1.monster.card.damage[player_1_action.move] + _resolve_damage_delta(player_1) if tie or player_2_win: - player_1.monster.health_delta -= player_2.monster.card.damage[player_2_action.move] + player_1.monster.health_delta -= player_2.monster.card.damage[player_2_action.move] + _resolve_damage_delta(player_2) phase = Match.Phase.SUPPORT_2 Match.Phase.SUPPORT_2: var support_cards = [] @@ -148,6 +148,7 @@ func resolve(action_by_player_id: Dictionary) -> PhaseTransition: var monster_final_health = player.monster.health + player.monster.health_delta if monster_final_health <= 0: player.monster = null + player.active_support_cards = [] events.append(EventMonsterDied.new(player.id)) else: player.monster.health += player.monster.health_delta @@ -183,4 +184,15 @@ func _resolve_support_card_effects(player: MatchPlayer, card: SupportCard) -> Ar "heal": player.monster.health_delta += magnitude events.append(EventSupportEffectApplied.new(player.id, effect_instance)) + "sword_mastery": + player.active_support_cards.append(card) + events.append(EventSupportEffectApplied.new(player.id, effect_instance)) return events + +func _resolve_damage_delta(player: MatchPlayer): + var final_delta: int = 0 + for card in player.active_support_cards: + match card.id: + "sword_mastery": + final_delta += card.magnitude + return final_delta diff --git a/tcg/match/match_player.gd b/tcg/match/match_player.gd index 48c7a9e..5eaf6ce 100644 --- a/tcg/match/match_player.gd +++ b/tcg/match/match_player.gd @@ -6,6 +6,7 @@ var hand: Array[Card] = [] var deck: Array[Card] var energy: int = 5 var monster: MatchMonster = null +var active_support_cards: Array[SupportCard] = [] func _init(id: int, deck: Array[Card]) -> void: self.id = id