feat: implement support cards

- insurance
- absorb
- tanker
- lifesteal
- sword mastery
- invisibility
- potion
- all out attack
This commit is contained in:
istamarahsan 2025-01-26 05:00:37 +07:00
parent 152ade51da
commit fc70d205b3
15 changed files with 110 additions and 88 deletions

View file

@ -1,12 +1,13 @@
[gd_resource type="Resource" script_class="SupportCard" load_steps=3 format=3 uid="uid://be01tdq1fxlct"] [gd_resource type="Resource" script_class="SimpleSupportCard" load_steps=3 format=3 uid="uid://cc0ebl4g4ffyk"]
[ext_resource type="Script" path="res://tcg/card/support_card_effect_instance.gd" id="1_mhxdy"] [ext_resource type="Script" path="res://tcg/card/support_card_effect_instance.gd" id="1_mhxdy"]
[ext_resource type="Script" path="res://tcg/card/support_card.gd" id="2_x8k3o"] [ext_resource type="Script" path="res://tcg/card/implemented_support_card.gd" id="2_f6hay"]
[resource] [resource]
script = ExtResource("2_x8k3o") script = ExtResource("2_f6hay")
scope = "turn"
magnitude = 0
type = "red" type = "red"
priority = 0 effects = Array[ExtResource("1_mhxdy")]([])
effects = Array[ExtResource("1_mhxdy")]([null])
name = "Absorb" name = "Absorb"
description = "Enemy damage converted to heal your Active Monster Field HP during this turn." description = "Enemy damage converted to heal your Active Monster Field HP during this turn."

View file

@ -1,12 +1,13 @@
[gd_resource type="Resource" script_class="SupportCard" load_steps=3 format=3 uid="uid://dgxcvdo6x6kst"] [gd_resource type="Resource" script_class="SimpleSupportCard" load_steps=3 format=3 uid="uid://dgxcvdo6x6kst"]
[ext_resource type="Script" path="res://tcg/card/support_card_effect_instance.gd" id="1_fd50n"] [ext_resource type="Script" path="res://tcg/card/support_card_effect_instance.gd" id="1_fd50n"]
[ext_resource type="Script" path="res://tcg/card/support_card.gd" id="2_1tjl7"] [ext_resource type="Script" path="res://tcg/card/implemented_support_card.gd" id="2_61mgn"]
[resource] [resource]
script = ExtResource("2_1tjl7") script = ExtResource("2_61mgn")
scope = "instant"
magnitude = 0
type = "green" type = "green"
priority = 0
effects = Array[ExtResource("1_fd50n")]([null]) effects = Array[ExtResource("1_fd50n")]([null])
name = "All-Out Attack" name = "All-Out Attack"
description = "Combine all Rock Paper Scissor during this turn, and got additional damage from the lowest Rock Paper Scissor you got." description = "Combine all Rock Paper Scissor during this turn, and got additional damage from the lowest Rock Paper Scissor you got."

View file

@ -1,12 +1,13 @@
[gd_resource type="Resource" script_class="SupportCard" load_steps=3 format=3 uid="uid://c0grh1y65e0f3"] [gd_resource type="Resource" script_class="SimpleSupportCard" load_steps=3 format=3 uid="uid://c0grh1y65e0f3"]
[ext_resource type="Script" path="res://tcg/card/support_card_effect_instance.gd" id="1_pkc1x"] [ext_resource type="Script" path="res://tcg/card/support_card_effect_instance.gd" id="1_pkc1x"]
[ext_resource type="Script" path="res://tcg/card/support_card.gd" id="2_qqko6"] [ext_resource type="Script" path="res://tcg/card/implemented_support_card.gd" id="2_iq88n"]
[resource] [resource]
script = ExtResource("2_qqko6") script = ExtResource("2_iq88n")
scope = "turn"
magnitude = 0
type = "green" type = "green"
priority = 0
effects = Array[ExtResource("1_pkc1x")]([null]) effects = Array[ExtResource("1_pkc1x")]([null])
name = "Energy Booster" name = "Energy Booster"
description = "Add 1 additional Energy." description = "Add 1 additional Energy."

View file

@ -1,12 +1,13 @@
[gd_resource type="Resource" script_class="SupportCard" load_steps=3 format=3 uid="uid://dfocg5yfh22e8"] [gd_resource type="Resource" script_class="SimpleSupportCard" load_steps=3 format=3 uid="uid://dfocg5yfh22e8"]
[ext_resource type="Script" path="res://tcg/card/support_card_effect_instance.gd" id="1_gtyqr"] [ext_resource type="Script" path="res://tcg/card/support_card_effect_instance.gd" id="1_gtyqr"]
[ext_resource type="Script" path="res://tcg/card/support_card.gd" id="2_286ne"] [ext_resource type="Script" path="res://tcg/card/implemented_support_card.gd" id="2_3ixor"]
[resource] [resource]
script = ExtResource("2_286ne") script = ExtResource("2_3ixor")
scope = "turn"
magnitude = 10
type = "red" type = "red"
priority = 0
effects = Array[ExtResource("1_gtyqr")]([null]) effects = Array[ExtResource("1_gtyqr")]([null])
name = "Insurance" name = "Insurance"
description = "If your monster supposed to be dead in this turn, keep it alive at 10 HP." description = "If your monster supposed to be dead in this turn, keep it alive at 10 HP."

View file

@ -1,12 +1,13 @@
[gd_resource type="Resource" script_class="SupportCard" load_steps=3 format=3 uid="uid://by4yg81uqti3u"] [gd_resource type="Resource" script_class="SimpleSupportCard" load_steps=3 format=3 uid="uid://by4yg81uqti3u"]
[ext_resource type="Script" path="res://tcg/card/support_card_effect_instance.gd" id="1_5tnpm"] [ext_resource type="Script" path="res://tcg/card/support_card_effect_instance.gd" id="1_5tnpm"]
[ext_resource type="Script" path="res://tcg/card/support_card.gd" id="2_hsvj6"] [ext_resource type="Script" path="res://tcg/card/implemented_support_card.gd" id="2_6c2xo"]
[resource] [resource]
script = ExtResource("2_hsvj6") script = ExtResource("2_6c2xo")
scope = "turn"
magnitude = 0
type = "green" type = "green"
priority = 0
effects = Array[ExtResource("1_5tnpm")]([null]) effects = Array[ExtResource("1_5tnpm")]([null])
name = "Invisibility" name = "Invisibility"
description = "Ignore any damage to your monster in this turn." description = "Ignore any damage to your monster in this turn."

View file

@ -1,12 +1,13 @@
[gd_resource type="Resource" script_class="SupportCard" load_steps=3 format=3 uid="uid://bcrlaam8uq6xt"] [gd_resource type="Resource" script_class="SimpleSupportCard" load_steps=3 format=3 uid="uid://bcrlaam8uq6xt"]
[ext_resource type="Script" path="res://tcg/card/support_card_effect_instance.gd" id="1_b33y4"] [ext_resource type="Script" path="res://tcg/card/support_card_effect_instance.gd" id="1_b33y4"]
[ext_resource type="Script" path="res://tcg/card/support_card.gd" id="2_qww3m"] [ext_resource type="Script" path="res://tcg/card/implemented_support_card.gd" id="2_khaf1"]
[resource] [resource]
script = ExtResource("2_qww3m") script = ExtResource("2_khaf1")
scope = "turn"
magnitude = 0
type = "green" type = "green"
priority = 0
effects = Array[ExtResource("1_b33y4")]([null]) effects = Array[ExtResource("1_b33y4")]([null])
name = "Lifesteal" name = "Lifesteal"
description = "During this turn your attack also heals your HP." description = "During this turn your attack also heals your HP."

View file

@ -1,12 +1,13 @@
[gd_resource type="Resource" script_class="SupportCard" load_steps=3 format=3 uid="uid://cl0jcer7o04uc"] [gd_resource type="Resource" script_class="SimpleSupportCard" load_steps=3 format=3 uid="uid://cl0jcer7o04uc"]
[ext_resource type="Script" path="res://tcg/card/support_card_effect_instance.gd" id="1_awvxv"] [ext_resource type="Script" path="res://tcg/card/support_card_effect_instance.gd" id="1_awvxv"]
[ext_resource type="Script" path="res://tcg/card/support_card.gd" id="2_v8fdj"] [ext_resource type="Script" path="res://tcg/card/implemented_support_card.gd" id="2_tr5ug"]
[resource] [resource]
script = ExtResource("2_v8fdj") script = ExtResource("2_tr5ug")
scope = "turn"
magnitude = 0
type = "red" type = "red"
priority = 1
effects = Array[ExtResource("1_awvxv")]([null]) effects = Array[ExtResource("1_awvxv")]([null])
name = "Negate" name = "Negate"
description = "Cancel 1 of the Support Card played by your opponent. This card will always be played last." description = "Cancel 1 of the Support Card played by your opponent. This card will always be played last."

View file

@ -1,9 +1,8 @@
[gd_resource type="Resource" script_class="SupportCard" load_steps=6 format=3 uid="uid://4eod3m0vc5a8"] [gd_resource type="Resource" script_class="SimpleSupportCard" load_steps=5 format=3 uid="uid://4eod3m0vc5a8"]
[ext_resource type="Script" path="res://tcg/card/support_card_effect_instance.gd" id="1_ujm0o"] [ext_resource type="Script" path="res://tcg/card/support_card_effect_instance.gd" id="1_ujm0o"]
[ext_resource type="Resource" uid="uid://cvu0rtt5nggf" path="res://data/support_effects/heal.tres" id="2_k1cnl"] [ext_resource type="Resource" uid="uid://cvu0rtt5nggf" path="res://data/support_effects/heal.tres" id="2_k1cnl"]
[ext_resource type="Script" path="res://tcg/card/support_card.gd" id="3_6r4k4"] [ext_resource type="Script" path="res://tcg/card/implemented_support_card.gd" id="3_at5nt"]
[ext_resource type="Texture2D" uid="uid://rh3aswb0p7ri" path="res://assets/energy.png" id="3_kyx3v"]
[sub_resource type="Resource" id="Resource_88lmk"] [sub_resource type="Resource" id="Resource_88lmk"]
script = ExtResource("1_ujm0o") script = ExtResource("1_ujm0o")
@ -11,10 +10,10 @@ magnitude = 30
effect = ExtResource("2_k1cnl") effect = ExtResource("2_k1cnl")
[resource] [resource]
script = ExtResource("3_6r4k4") script = ExtResource("3_at5nt")
scope = "turn"
magnitude = 30
type = "green" type = "green"
priority = 0
effects = Array[ExtResource("1_ujm0o")]([SubResource("Resource_88lmk")]) effects = Array[ExtResource("1_ujm0o")]([SubResource("Resource_88lmk")])
name = "Potion" name = "Potion"
description = "Heal 30 HP" description = "Heal 30 HP"
icon = ExtResource("3_kyx3v")

View file

@ -1,12 +1,13 @@
[gd_resource type="Resource" script_class="SupportCard" load_steps=3 format=3 uid="uid://c1gsrru1wa6ao"] [gd_resource type="Resource" script_class="SimpleSupportCard" load_steps=3 format=3 uid="uid://c1gsrru1wa6ao"]
[ext_resource type="Script" path="res://tcg/card/support_card_effect_instance.gd" id="1_mk2or"] [ext_resource type="Script" path="res://tcg/card/support_card_effect_instance.gd" id="1_mk2or"]
[ext_resource type="Script" path="res://tcg/card/support_card.gd" id="2_fliii"] [ext_resource type="Script" path="res://tcg/card/implemented_support_card.gd" id="2_igbok"]
[resource] [resource]
script = ExtResource("2_fliii") script = ExtResource("2_igbok")
scope = "turn"
magnitude = 0
type = "red" type = "red"
priority = 0
effects = Array[ExtResource("1_mk2or")]([null]) effects = Array[ExtResource("1_mk2or")]([null])
name = "Reflection" name = "Reflection"
description = "Enemy got the same amount of damage as our monster in this turn." description = "Enemy got the same amount of damage as our monster in this turn."

View file

@ -1,8 +1,8 @@
[gd_resource type="Resource" script_class="SupportCard" load_steps=5 format=3 uid="uid://2xeb6keaoabo"] [gd_resource type="Resource" script_class="SimpleSupportCard" load_steps=5 format=3 uid="uid://2xeb6keaoabo"]
[ext_resource type="Script" path="res://tcg/card/support_card_effect_instance.gd" id="1_y6yvj"] [ext_resource type="Script" path="res://tcg/card/support_card_effect_instance.gd" id="1_y6yvj"]
[ext_resource type="Resource" uid="uid://bs4i85slalkgd" path="res://data/support_effects/sword_mastery.tres" id="2_omhdb"] [ext_resource type="Resource" uid="uid://bs4i85slalkgd" path="res://data/support_effects/sword_mastery.tres" id="2_omhdb"]
[ext_resource type="Script" path="res://tcg/card/support_card.gd" id="2_vp8a3"] [ext_resource type="Script" path="res://tcg/card/implemented_support_card.gd" id="3_37rh4"]
[sub_resource type="Resource" id="Resource_wwv02"] [sub_resource type="Resource" id="Resource_wwv02"]
script = ExtResource("1_y6yvj") script = ExtResource("1_y6yvj")
@ -10,9 +10,10 @@ magnitude = 20
effect = ExtResource("2_omhdb") effect = ExtResource("2_omhdb")
[resource] [resource]
script = ExtResource("2_vp8a3") script = ExtResource("3_37rh4")
scope = "monster"
magnitude = 20
type = "green" type = "green"
priority = 0
effects = Array[ExtResource("1_y6yvj")]([SubResource("Resource_wwv02")]) effects = Array[ExtResource("1_y6yvj")]([SubResource("Resource_wwv02")])
name = "Sword Mastery" name = "Sword Mastery"
description = "Permanently add 20 damage for all Rock Paper Scissor to 1 Active Monster." description = "Permanently add 20 damage for all Rock Paper Scissor to 1 Active Monster."

View file

@ -1,12 +1,13 @@
[gd_resource type="Resource" script_class="SupportCard" load_steps=3 format=3 uid="uid://dsmrqyxt8mdp5"] [gd_resource type="Resource" script_class="SimpleSupportCard" load_steps=3 format=3 uid="uid://dsmrqyxt8mdp5"]
[ext_resource type="Script" path="res://tcg/card/support_card_effect_instance.gd" id="1_1fvcb"] [ext_resource type="Script" path="res://tcg/card/support_card_effect_instance.gd" id="1_1fvcb"]
[ext_resource type="Script" path="res://tcg/card/support_card.gd" id="2_m4ahe"] [ext_resource type="Script" path="res://tcg/card/implemented_support_card.gd" id="2_d0adk"]
[resource] [resource]
script = ExtResource("2_m4ahe") script = ExtResource("2_d0adk")
scope = "turn"
magnitude = 0
type = "red" type = "red"
priority = 0
effects = Array[ExtResource("1_1fvcb")]([null]) effects = Array[ExtResource("1_1fvcb")]([null])
name = "Tanker" name = "Tanker"
description = "Add your HP with your selected (Rock Paper Scissor) during this turn, and reduce to max HP if current HP higher than max HP." description = "Add your HP with your selected (Rock Paper Scissor) during this turn, and reduce to max HP if current HP higher than max HP."

View file

@ -2,7 +2,7 @@ extends Resource
class_name Card class_name Card
@export var name: String @export var name: String
@export var description: String @export_multiline var description: String
@export var icon: Texture2D @export var icon: Texture2D
var id: String: var id: String:

View file

@ -0,0 +1,4 @@
extends SupportCard
class_name ImplementedSupportCard
@export_enum("instant", "turn", "monster", "match") var scope = "instant"

View file

@ -2,5 +2,4 @@ extends Card
class_name SupportCard class_name SupportCard
@export_enum("red", "green") var type = "green" @export_enum("red", "green") var type = "green"
@export var priority: int = 0
@export var effects: Array[SupportCardEffectInstance] = [null] @export var effects: Array[SupportCardEffectInstance] = [null]

View file

@ -22,9 +22,6 @@ var player_2: MatchPlayer:
return players[actual_p2_id] as MatchPlayer return players[actual_p2_id] as MatchPlayer
var phase: Match.Phase = Match.Phase.PREGAME var phase: Match.Phase = Match.Phase.PREGAME
var support_cards_1: Dictionary = {}
var support_cards_2: Dictionary = {}
var actual_p1_id: int var actual_p1_id: int
var actual_p2_id: int var actual_p2_id: int
@ -38,7 +35,6 @@ func init(decks: Dictionary, actual_p1_id: int, actual_p2_id: int):
cleanup() cleanup()
for player_id in [PLAYER_1_ID, PLAYER_2_ID]: for player_id in [PLAYER_1_ID, PLAYER_2_ID]:
var deck_shuffled = decks[player_id].duplicate() as Array[Card] var deck_shuffled = decks[player_id].duplicate() as Array[Card]
var first_monster = deck_shuffled.filter(func(card): return card is MonsterCard)[0] var first_monster = deck_shuffled.filter(func(card): return card is MonsterCard)[0]
var first_monster_idx = deck_shuffled.find(first_monster) var first_monster_idx = deck_shuffled.find(first_monster)
deck_shuffled.pop_at(first_monster_idx) deck_shuffled.pop_at(first_monster_idx)
@ -49,6 +45,7 @@ func init(decks: Dictionary, actual_p1_id: int, actual_p2_id: int):
deck_shuffled.shuffle() deck_shuffled.shuffle()
players[player_id] = MatchPlayer.new(player_id, deck_shuffled) players[player_id] = MatchPlayer.new(player_id, deck_shuffled)
func cleanup(): func cleanup():
for player_id in [PLAYER_1_ID, PLAYER_2_ID]: for player_id in [PLAYER_1_ID, PLAYER_2_ID]:
var existing = players.get(player_id) var existing = players.get(player_id)
@ -75,8 +72,6 @@ func resolve(action_by_player_id: Dictionary) -> PhaseTransition:
) )
phase = Match.Phase.SUMMON phase = Match.Phase.SUMMON
Match.Phase.SUMMON: Match.Phase.SUMMON:
support_cards_1.clear()
support_cards_2.clear()
for player_id in action_by_player_id.keys(): for player_id in action_by_player_id.keys():
var action = action_by_player_id[player_id] var action = action_by_player_id[player_id]
@ -89,38 +84,48 @@ func resolve(action_by_player_id: Dictionary) -> PhaseTransition:
if players.values().all(func(player: MatchPlayer): return player.monster): if players.values().all(func(player: MatchPlayer): return player.monster):
phase = Match.Phase.SUPPORT_1 phase = Match.Phase.SUPPORT_1
Match.Phase.SUPPORT_1: Match.Phase.SUPPORT_1:
support_cards_1.clear()
support_cards_2.clear()
var support_cards = [] var support_cards = []
if player_1_action is ActionPlayCard: if player_1_action is ActionPlayCard:
support_cards.append({ support_cards.append({
"player": player_1, "player": player_1,
"card": player_1_action.card "card": player_1_action.card
}) })
support_cards_1[player_1] = player_1_action.card
player_1.hand.erase(player_1_action.card) player_1.hand.erase(player_1_action.card)
if player_2_action is ActionPlayCard: if player_2_action is ActionPlayCard:
support_cards.append({ support_cards.append({
"player": player_2, "player": player_2,
"card": player_2_action.card "card": player_2_action.card
}) })
support_cards_1[player_2] = player_2_action.card
player_2.hand.erase(player_2_action.card) player_2.hand.erase(player_2_action.card)
support_cards.sort_custom(func(a, b): return a.card.priority < b.card.priority) support_cards.sort_custom(func(a, b): return a.card.priority < b.card.priority)
for played_card in support_cards: for played_card in support_cards:
var player: MatchPlayer = played_card.player var player: MatchPlayer = played_card.player
var card: SupportCard = played_card.card var card: SupportCard = played_card.card
events.append_array(_resolve_support_card_effects(player, card)) var executed_instant_effects_events = _execute_support_card_immediate_effects(player, card)
player.active_support_cards.append(card)
events.append_array(executed_instant_effects_events)
phase = Match.Phase.RPS phase = Match.Phase.RPS
Match.Phase.RPS: Match.Phase.RPS:
var damage_pairs = []
var tie = player_1_action.move == player_2_action.move var tie = player_1_action.move == player_2_action.move
var player_1_win = rps_wins[player_1_action.move] == player_2_action.move 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 var player_2_win = rps_wins[player_2_action.move] == player_1_action.move
if tie or player_1_win: if tie or player_1_win:
player_2.monster.health_delta -= player_1.monster.card.damage[player_1_action.move] + _resolve_damage_delta(player_1) damage_pairs.append({"from": player_1, "to": player_2})
if tie or player_2_win: if tie or player_2_win:
player_1.monster.health_delta -= player_2.monster.card.damage[player_2_action.move] + _resolve_damage_delta(player_2) damage_pairs.append({"from": player_2, "to": player_1})
for pair in damage_pairs:
var computed_damage = pair.from.monster.card.damage[pair.from.move]
if _player_has_active_support_card(pair.from, "all_out_attack"):
var rps = [pair.from.monster.card.rock, pair.from.monster.card.paper, pair.from.monster.card.scissors]
computed_damage = rps.reduce(func (a, b): return a + b, 0)
pair.from.health_delta -= rps.min()
if _player_has_active_support_card(pair.from, "sword_mastery"):
computed_damage += 20
if _player_has_active_support_card(pair.from, "lifesteal"):
pair.from.health_delta += computed_damage
pair.to.monster.health_delta -= computed_damage
phase = Match.Phase.SUPPORT_2 phase = Match.Phase.SUPPORT_2
Match.Phase.SUPPORT_2: Match.Phase.SUPPORT_2:
var support_cards = [] var support_cards = []
@ -129,26 +134,32 @@ func resolve(action_by_player_id: Dictionary) -> PhaseTransition:
"player": player_1, "player": player_1,
"card": player_1_action.card "card": player_1_action.card
}) })
support_cards_2[player_1] = player_1_action.card
player_1.hand.erase(player_1_action.card) player_1.hand.erase(player_1_action.card)
if player_2_action is ActionPlayCard: if player_2_action is ActionPlayCard:
support_cards.append({ support_cards.append({
"player": player_2, "player": player_2,
"card": player_2_action.card "card": player_2_action.card
}) })
support_cards_2[player_2] = player_2_action.card
player_2.hand.erase(player_2_action.card) player_2.hand.erase(player_2_action.card)
support_cards.sort_custom(func(a, b): return a.card.priority < b.card.priority) support_cards.sort_custom(func(a, b): return a.card.priority < b.card.priority)
for played_card in support_cards: for played_card in support_cards:
var player: MatchPlayer = played_card.player var player: MatchPlayer = played_card.player
var card: SupportCard = played_card.card var card: SupportCard = played_card.card
events.append_array(_resolve_support_card_effects(player, card)) player.active_support_cards.append(played_card)
events.append_array(_execute_support_card_immediate_effects(player, card))
for player: MatchPlayer in players.values(): for player: MatchPlayer in players.values():
if _player_has_active_support_card(player, "absorb") and player.monster.health_delta < 0:
player.monster.health_delta = -player.monster.health_delta
var monster_final_health = player.monster.health + player.monster.health_delta var monster_final_health = player.monster.health + player.monster.health_delta
if _player_has_active_support_card(player, "invisibility"):
monster_final_health = player.monster.health
if _player_has_active_support_card(player, "insurance"):
monster_final_health = max(10, monster_final_health)
if monster_final_health <= 0: if monster_final_health <= 0:
player.monster = null player.monster = null
player.active_support_cards = [] var card_expires_with_monster = func(card): return card is ImplementedSupportCard and card.scope == 'monster'
player.active_support_cards = player.active_support_cards.filter(card_expires_with_monster)
events.append(EventMonsterDied.new(player.id)) events.append(EventMonsterDied.new(player.id))
else: else:
player.monster.health += player.monster.health_delta player.monster.health += player.monster.health_delta
@ -157,6 +168,10 @@ func resolve(action_by_player_id: Dictionary) -> PhaseTransition:
if drawn_card: if drawn_card:
player.hand.append(drawn_card) player.hand.append(drawn_card)
events.append(EventCardDrawn.new(player.id, drawn_card)) events.append(EventCardDrawn.new(player.id, drawn_card))
var card_expires_this_turn = func(card): return card is ImplementedSupportCard and card.scope == 'turn'
player.active_support_cards = player.active_support_cards.filter(card_expires_this_turn)
var players_without_monster = players.values().filter(func(player): return player.monster == null) var players_without_monster = players.values().filter(func(player): return player.monster == null)
if players_without_monster.size() == 0: if players_without_monster.size() == 0:
phase = Match.Phase.SUPPORT_1 phase = Match.Phase.SUPPORT_1
@ -175,24 +190,19 @@ func resolve(action_by_player_id: Dictionary) -> PhaseTransition:
func _monster_from_card(card: MonsterCard) -> MatchMonster: func _monster_from_card(card: MonsterCard) -> MatchMonster:
return MatchMonster.new(card, card.base_health, 0) return MatchMonster.new(card, card.base_health, 0)
func _resolve_support_card_effects(player: MatchPlayer, card: SupportCard) -> Array[Event]: func _execute_support_card_immediate_effects(player: MatchPlayer, card: SupportCard) -> Array[Event]:
var events: Array[Event] var events: Array[Event]
for effect_instance in card.effects: if card is ImplementedSupportCard:
var effect = effect_instance.effect match card.id:
var magnitude = effect_instance.magnitude "potion":
match effect.id: player.monster.health_delta += card.magnitude
"heal": "energy_booster":
player.monster.health_delta += magnitude player.energy += card.magnitude
events.append(EventSupportEffectApplied.new(player.id, effect_instance)) # events.append(Event)
"sword_mastery":
player.active_support_cards.append(card)
events.append(EventSupportEffectApplied.new(player.id, effect_instance))
return events return events
func _resolve_damage_delta(player: MatchPlayer): func _player_has_active_support_card(player: MatchPlayer, card_id: String) -> bool:
var final_delta: int = 0 return player.active_support_cards.any(func (card): return card.id == card_id)
for card in player.active_support_cards:
match card.id: func _player_opponent(player: MatchPlayer) -> MatchPlayer:
"sword_mastery": return player_2 if player.id == PLAYER_1_ID else player_1
final_delta += card.magnitude
return final_delta