From 64e79704bf832a9241839a13b5d36992311bbe97 Mon Sep 17 00:00:00 2001 From: kennetha123 Date: Sun, 26 Jan 2025 07:15:58 +0700 Subject: [PATCH] fix: minor spelling mistakes --- data/cards/support/absorb.tres | 3 +-- data/cards/support/all_out_attack.tres | 3 +-- data/cards/support/energy_booster.tres | 3 +-- data/cards/support/insurance.tres | 3 +-- data/cards/support/lifesteal.tres | 3 +-- data/cards/support/sword_mastery.tres | 3 +-- demo_game.tscn | 13 +++++++++--- player_side.gd | 8 ++++---- tcg/match/match_manager.gd | 28 +++++++++++--------------- 9 files changed, 32 insertions(+), 35 deletions(-) diff --git a/data/cards/support/absorb.tres b/data/cards/support/absorb.tres index 8d7403c..ef6568c 100644 --- a/data/cards/support/absorb.tres +++ b/data/cards/support/absorb.tres @@ -1,4 +1,4 @@ -[gd_resource type="Resource" script_class="SimpleSupportCard" load_steps=3 format=3 uid="uid://cc0ebl4g4ffyk"] +[gd_resource type="Resource" script_class="ImplementedSupportCard" load_steps=3 format=3 uid="uid://be01tdq1fxlct"] [ext_resource type="Script" path="res://tcg/card/support_card_effect_instance.gd" id="1_mhxdy"] [ext_resource type="Script" path="res://tcg/card/implemented_support_card.gd" id="2_f6hay"] @@ -6,7 +6,6 @@ [resource] script = ExtResource("2_f6hay") scope = "turn" -magnitude = 0 type = "red" effects = Array[ExtResource("1_mhxdy")]([]) name = "Absorb" diff --git a/data/cards/support/all_out_attack.tres b/data/cards/support/all_out_attack.tres index ec8850c..35814a9 100644 --- a/data/cards/support/all_out_attack.tres +++ b/data/cards/support/all_out_attack.tres @@ -1,4 +1,4 @@ -[gd_resource type="Resource" script_class="SimpleSupportCard" load_steps=3 format=3 uid="uid://dgxcvdo6x6kst"] +[gd_resource type="Resource" script_class="ImplementedSupportCard" 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/implemented_support_card.gd" id="2_61mgn"] @@ -6,7 +6,6 @@ [resource] script = ExtResource("2_61mgn") scope = "instant" -magnitude = 0 type = "green" effects = Array[ExtResource("1_fd50n")]([null]) name = "All-Out Attack" diff --git a/data/cards/support/energy_booster.tres b/data/cards/support/energy_booster.tres index ea24a0b..bf64881 100644 --- a/data/cards/support/energy_booster.tres +++ b/data/cards/support/energy_booster.tres @@ -1,4 +1,4 @@ -[gd_resource type="Resource" script_class="SimpleSupportCard" load_steps=3 format=3 uid="uid://c0grh1y65e0f3"] +[gd_resource type="Resource" script_class="ImplementedSupportCard" 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/implemented_support_card.gd" id="2_iq88n"] @@ -6,7 +6,6 @@ [resource] script = ExtResource("2_iq88n") scope = "turn" -magnitude = 0 type = "green" effects = Array[ExtResource("1_pkc1x")]([null]) name = "Energy Booster" diff --git a/data/cards/support/insurance.tres b/data/cards/support/insurance.tres index 5183f9f..e63e98f 100644 --- a/data/cards/support/insurance.tres +++ b/data/cards/support/insurance.tres @@ -1,4 +1,4 @@ -[gd_resource type="Resource" script_class="SimpleSupportCard" load_steps=3 format=3 uid="uid://dfocg5yfh22e8"] +[gd_resource type="Resource" script_class="ImplementedSupportCard" 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/implemented_support_card.gd" id="2_3ixor"] @@ -6,7 +6,6 @@ [resource] script = ExtResource("2_3ixor") scope = "turn" -magnitude = 10 type = "red" effects = Array[ExtResource("1_gtyqr")]([null]) name = "Insurance" diff --git a/data/cards/support/lifesteal.tres b/data/cards/support/lifesteal.tres index 726912d..79a4497 100644 --- a/data/cards/support/lifesteal.tres +++ b/data/cards/support/lifesteal.tres @@ -1,4 +1,4 @@ -[gd_resource type="Resource" script_class="SimpleSupportCard" load_steps=3 format=3 uid="uid://bcrlaam8uq6xt"] +[gd_resource type="Resource" script_class="ImplementedSupportCard" 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/implemented_support_card.gd" id="2_khaf1"] @@ -6,7 +6,6 @@ [resource] script = ExtResource("2_khaf1") scope = "turn" -magnitude = 0 type = "green" effects = Array[ExtResource("1_b33y4")]([null]) name = "Lifesteal" diff --git a/data/cards/support/sword_mastery.tres b/data/cards/support/sword_mastery.tres index 1d48401..fdb68c0 100644 --- a/data/cards/support/sword_mastery.tres +++ b/data/cards/support/sword_mastery.tres @@ -1,4 +1,4 @@ -[gd_resource type="Resource" script_class="SimpleSupportCard" load_steps=5 format=3 uid="uid://2xeb6keaoabo"] +[gd_resource type="Resource" script_class="ImplementedSupportCard" 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="Resource" uid="uid://bs4i85slalkgd" path="res://data/support_effects/sword_mastery.tres" id="2_omhdb"] @@ -12,7 +12,6 @@ effect = ExtResource("2_omhdb") [resource] script = ExtResource("3_37rh4") scope = "monster" -magnitude = 20 type = "green" effects = Array[ExtResource("1_y6yvj")]([SubResource("Resource_wwv02")]) name = "Sword Mastery" diff --git a/demo_game.tscn b/demo_game.tscn index 83eaf33..bfff989 100644 --- a/demo_game.tscn +++ b/demo_game.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=12 format=3 uid="uid://bgc0u117jqyr1"] +[gd_scene load_steps=19 format=3 uid="uid://bgc0u117jqyr1"] [ext_resource type="Script" path="res://demo_game.gd" id="1_jn16u"] [ext_resource type="Script" path="res://player_side.gd" id="2_w4tnt"] @@ -7,10 +7,17 @@ [ext_resource type="Resource" uid="uid://cs7q8i7bvohmj" path="res://data/cards/monster/capytain.tres" id="3_we1tk"] [ext_resource type="Resource" uid="uid://4eod3m0vc5a8" path="res://data/cards/support/potion.tres" id="4_kkhfk"] [ext_resource type="Resource" uid="uid://di76avwc0gn8e" path="res://data/cards/monster/axoluna.tres" id="5_3cm5x"] +[ext_resource type="Resource" uid="uid://bcrlaam8uq6xt" path="res://data/cards/support/lifesteal.tres" id="6_potm8"] [ext_resource type="PackedScene" uid="uid://bhrelvt51cbp2" path="res://ui/card_template/monster_card.tscn" id="7_4ah45"] +[ext_resource type="Resource" uid="uid://dgxcvdo6x6kst" path="res://data/cards/support/all_out_attack.tres" id="7_nvv8k"] [ext_resource type="PackedScene" uid="uid://b60vuykleugjn" path="res://ui/card_template/skip_card.tscn" id="7_skjyk"] [ext_resource type="PackedScene" uid="uid://dg5amjm1gqi06" path="res://ui/card_template/support_card_green.tscn" id="8_dytl5"] +[ext_resource type="Resource" uid="uid://be01tdq1fxlct" path="res://data/cards/support/absorb.tres" id="8_ewr4v"] [ext_resource type="PackedScene" uid="uid://cds50kwwhlgam" path="res://ui/card_template/support_card_red.tscn" id="9_cabcc"] +[ext_resource type="Resource" uid="uid://dfocg5yfh22e8" path="res://data/cards/support/insurance.tres" id="9_ga5hf"] +[ext_resource type="Resource" uid="uid://c0grh1y65e0f3" path="res://data/cards/support/energy_booster.tres" id="10_3rg8q"] +[ext_resource type="Resource" uid="uid://2xeb6keaoabo" path="res://data/cards/support/sword_mastery.tres" id="11_seakd"] +[ext_resource type="Resource" uid="uid://bmst884k0myvd" path="res://data/cards/monster/cattogato.tres" id="12_xqqfn"] [node name="DemoGame" type="Control"] layout_mode = 3 @@ -20,8 +27,8 @@ anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 script = ExtResource("1_jn16u") -player_1_deck = Array[ExtResource("2_xuft0")]([ExtResource("3_we1tk"), ExtResource("4_kkhfk"), ExtResource("4_kkhfk"), ExtResource("4_kkhfk"), ExtResource("5_3cm5x")]) -player_2_deck = Array[ExtResource("2_xuft0")]([ExtResource("5_3cm5x"), ExtResource("4_kkhfk"), ExtResource("4_kkhfk"), ExtResource("4_kkhfk"), ExtResource("3_we1tk")]) +player_1_deck = Array[ExtResource("2_xuft0")]([ExtResource("3_we1tk"), ExtResource("4_kkhfk"), ExtResource("5_3cm5x"), ExtResource("6_potm8"), ExtResource("7_nvv8k"), ExtResource("8_ewr4v"), ExtResource("9_ga5hf"), ExtResource("10_3rg8q"), ExtResource("11_seakd")]) +player_2_deck = Array[ExtResource("2_xuft0")]([ExtResource("12_xqqfn"), ExtResource("4_kkhfk"), ExtResource("6_potm8"), ExtResource("7_nvv8k"), ExtResource("8_ewr4v"), ExtResource("9_ga5hf"), ExtResource("10_3rg8q"), ExtResource("11_seakd"), ExtResource("5_3cm5x")]) [node name="Own" type="Control" parent="." node_paths=PackedStringArray("deck", "energy_label")] layout_mode = 1 diff --git a/player_side.gd b/player_side.gd index 5bfcd9e..21b4a04 100644 --- a/player_side.gd +++ b/player_side.gd @@ -46,14 +46,14 @@ func _on_update(transition): return energy_label.text = "Energy: " + str(player.energy) - if match_manager.support_cards_1.has(player): + if match_manager.players[player.id].active_support_cards.size() > 0: support1_green.visible = true - support1_green.card = match_manager.support_cards_1[player] + support1_green.card = match_manager.players[player.id].active_support_cards[0] else: support1_green.visible = false - if match_manager.support_cards_2.has(player): - var card: SupportCard = match_manager.support_cards_2[player] + if match_manager.players[player.id].active_support_cards.size() > 1: + var card: SupportCard = match_manager.players[player.id].active_support_cards[1] if card.type == "green": support2_green.visible = true support2_green.card = card diff --git a/tcg/match/match_manager.gd b/tcg/match/match_manager.gd index fa6e724..6ec765d 100644 --- a/tcg/match/match_manager.gd +++ b/tcg/match/match_manager.gd @@ -35,14 +35,12 @@ func init(decks: Dictionary, actual_p1_id: int, actual_p2_id: int): cleanup() for player_id in [PLAYER_1_ID, PLAYER_2_ID]: var deck_shuffled = decks[player_id].duplicate() as Array[Card] + deck_shuffled.shuffle() var first_monster = deck_shuffled.filter(func(card): return card is MonsterCard)[0] var first_monster_idx = deck_shuffled.find(first_monster) deck_shuffled.pop_at(first_monster_idx) - var zero_idx_card = deck_shuffled.pop_at(0) - deck_shuffled.insert(0, first_monster) - deck_shuffled.insert(first_monster_idx, zero_idx_card) + deck_shuffled.push_back(first_monster) - deck_shuffled.shuffle() players[player_id] = MatchPlayer.new(player_id, deck_shuffled) @@ -97,12 +95,11 @@ func resolve(action_by_player_id: Dictionary) -> PhaseTransition: "card": 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) for played_card in support_cards: var player: MatchPlayer = played_card.player var card: SupportCard = played_card.card - if played_card is ImplementedSupportCard and played_card.scope != 'instant': - player.active_support_cards.append(played_card) + if card is ImplementedSupportCard and card.scope != 'instant': + player.active_support_cards.append(card) var executed_instant_effects_events = _execute_support_card_instant_effects(player, card) events.append_array(executed_instant_effects_events) phase = Match.Phase.RPS @@ -116,7 +113,7 @@ func resolve(action_by_player_id: Dictionary) -> PhaseTransition: if tie or player_2_win: 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] + var computed_damage = pair.from.monster.card.damage[action_by_player_id[pair.from.id].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) @@ -142,12 +139,11 @@ func resolve(action_by_player_id: Dictionary) -> PhaseTransition: "card": 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) for played_card in support_cards: var player: MatchPlayer = played_card.player var card: SupportCard = played_card.card - if played_card is ImplementedSupportCard and played_card.scope != 'instant': - player.active_support_cards.append(played_card) + if card is ImplementedSupportCard and card.scope != 'instant': + player.active_support_cards.append(card) events.append_array(_execute_support_card_instant_effects(player, card)) for player: MatchPlayer in players.values(): @@ -161,10 +157,10 @@ func resolve(action_by_player_id: Dictionary) -> PhaseTransition: if monster_final_health <= 0: player.monster = null 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) + player.active_support_cards = player.active_support_cards.filter(func (card): return not card_expires_with_monster.call(card)) events.append(EventMonsterDied.new(player.id)) else: - player.monster.health += player.monster.health_delta + player.monster.health = monster_final_health player.monster.health_delta = 0 var drawn_card = player.deck.pop_back() if drawn_card: @@ -172,7 +168,7 @@ func resolve(action_by_player_id: Dictionary) -> PhaseTransition: 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) + player.active_support_cards = player.active_support_cards.filter(func (card): return not card_expires_this_turn.call(card)) var players_without_monster = players.values().filter(func(player): return player.monster == null) if players_without_monster.size() == 0: @@ -197,9 +193,9 @@ func _execute_support_card_instant_effects(player: MatchPlayer, card: SupportCar if card is ImplementedSupportCard: match card.id: "potion": - player.monster.health_delta += card.magnitude + player.monster.health_delta += 20 "energy_booster": - player.energy += card.magnitude + player.energy += 1 # events.append(Event) return events