From e304dd671b05baabd80a3eec44b1f672374a0ad6 Mon Sep 17 00:00:00 2001 From: istamarahsan Date: Fri, 24 Jan 2025 22:08:25 +0700 Subject: [PATCH 1/4] feat: define cards as resources --- card/card.gd | 6 ++++++ card/monster_card.gd | 8 ++++++++ card/support_card.gd | 5 +++++ card/support_card_effect.gd | 7 +++++++ card/support_card_effect_instance.gd | 5 +++++ data/cards/potion.tres | 16 ++++++++++++++++ data/support_effects/heal.tres | 6 ++++++ data/support_effects/swap_monst.er.tres | 7 +++++++ 8 files changed, 60 insertions(+) create mode 100644 card/card.gd create mode 100644 card/monster_card.gd create mode 100644 card/support_card.gd create mode 100644 card/support_card_effect.gd create mode 100644 card/support_card_effect_instance.gd create mode 100644 data/cards/potion.tres create mode 100644 data/support_effects/heal.tres create mode 100644 data/support_effects/swap_monst.er.tres diff --git a/card/card.gd b/card/card.gd new file mode 100644 index 0000000..80e6c1b --- /dev/null +++ b/card/card.gd @@ -0,0 +1,6 @@ +extends Resource +class_name Card + +var id: String: + get: + return resource_path.rsplit(".", true, 1)[0] diff --git a/card/monster_card.gd b/card/monster_card.gd new file mode 100644 index 0000000..0d5304e --- /dev/null +++ b/card/monster_card.gd @@ -0,0 +1,8 @@ +extends Card +class_name MonsterCard + +@export var rock: int = 0 +@export var paper: int = 0 +@export var scissors: int = 0 +@export var energy_cost: int = 1 +@export var base_health: int = 100 diff --git a/card/support_card.gd b/card/support_card.gd new file mode 100644 index 0000000..23d736e --- /dev/null +++ b/card/support_card.gd @@ -0,0 +1,5 @@ +extends Card +class_name SupportCard + +@export_enum("red", "green") var type = "green" +@export var effect: Array[SupportCardEffectInstance] = [null] diff --git a/card/support_card_effect.gd b/card/support_card_effect.gd new file mode 100644 index 0000000..a03d17c --- /dev/null +++ b/card/support_card_effect.gd @@ -0,0 +1,7 @@ +@tool +extends Resource +class_name SupportCardEffect + +var id: String: + get: + return resource_path.rsplit(".", true, 1)[0] diff --git a/card/support_card_effect_instance.gd b/card/support_card_effect_instance.gd new file mode 100644 index 0000000..e2ced1c --- /dev/null +++ b/card/support_card_effect_instance.gd @@ -0,0 +1,5 @@ +extends Resource +class_name SupportCardEffectInstance + +@export var magnitude: int +@export var effect: SupportCardEffect diff --git a/data/cards/potion.tres b/data/cards/potion.tres new file mode 100644 index 0000000..dc1ae47 --- /dev/null +++ b/data/cards/potion.tres @@ -0,0 +1,16 @@ +[gd_resource type="Resource" script_class="SupportCard" load_steps=5 format=3 uid="uid://bhk1nc02g0gtb"] + +[ext_resource type="Script" path="res://card/support_card_effect_instance.gd" id="1_fq8c7"] +[ext_resource type="Resource" uid="uid://h1ki1kya43v7" path="res://data/support_effects/heal.tres" id="2_3x5mu"] +[ext_resource type="Script" path="res://card/support_card.gd" id="2_44syi"] + +[sub_resource type="Resource" id="Resource_l7fsx"] +script = ExtResource("1_fq8c7") +magnitude = 3 +effect = ExtResource("2_3x5mu") + +[resource] +script = ExtResource("2_44syi") +type = null +effect = Array[ExtResource("1_fq8c7")]([SubResource("Resource_l7fsx")]) +id = "" diff --git a/data/support_effects/heal.tres b/data/support_effects/heal.tres new file mode 100644 index 0000000..68f851e --- /dev/null +++ b/data/support_effects/heal.tres @@ -0,0 +1,6 @@ +[gd_resource type="Resource" script_class="SupportCardEffect" load_steps=2 format=3 uid="uid://h1ki1kya43v7"] + +[ext_resource type="Script" path="res://card/support_card_effect.gd" id="1_exmke"] + +[resource] +script = ExtResource("1_exmke") diff --git a/data/support_effects/swap_monst.er.tres b/data/support_effects/swap_monst.er.tres new file mode 100644 index 0000000..b641e34 --- /dev/null +++ b/data/support_effects/swap_monst.er.tres @@ -0,0 +1,7 @@ +[gd_resource type="Resource" script_class="SupportCardEffect" load_steps=2 format=3 uid="uid://xinrslggye4"] + +[ext_resource type="Script" path="res://card/support_card_effect.gd" id="1_7awm5"] + +[resource] +script = ExtResource("1_7awm5") +id = "swap_monster" From fbe2432819fce74e12e60a26040e3d053b99669c Mon Sep 17 00:00:00 2001 From: istamarahsan Date: Sat, 25 Jan 2025 11:57:55 +0700 Subject: [PATCH 2/4] feat: trying to make game --- data/cards/baraga.tres | 19 ++ data/cards/taiman.tres | 11 ++ demo_game.gd | 61 +++++++ demo_game.tscn | 169 ++++++++++++++++++ player_side.gd | 55 ++++++ tcg/card/card.gd | 6 + tcg/card/monster_card.gd | 8 + tcg/card/support_card.gd | 6 + tcg/card/support_card_effect.gd | 6 + tcg/card/support_card_effect_instance.gd | 5 + tcg/match/action/action.gd | 2 + tcg/match/action/action_play_card.gd | 7 + tcg/match/action/action_rps_move.gd | 7 + tcg/match/event/event.gd | 2 + tcg/match/event/event_damage_dealt.gd | 5 + tcg/match/event/event_draw_card.gd | 9 + tcg/match/event/event_monster_died.gd | 4 + tcg/match/event/event_monster_summoned.gd | 7 + .../event/event_support_effect_applied.gd | 9 + tcg/match/match.gd | 10 ++ tcg/match/match_manager.gd | 112 ++++++++++++ tcg/match/match_manager.tscn | 6 + tcg/match/match_monster.gd | 11 ++ tcg/match/match_player.gd | 12 ++ tcg/match/match_player.tscn | 6 + tcg/match/monster.tscn | 17 ++ tcg/match/phase_transition.gd | 11 ++ 27 files changed, 583 insertions(+) create mode 100644 data/cards/baraga.tres create mode 100644 data/cards/taiman.tres create mode 100644 demo_game.gd create mode 100644 demo_game.tscn create mode 100644 player_side.gd create mode 100644 tcg/card/card.gd create mode 100644 tcg/card/monster_card.gd create mode 100644 tcg/card/support_card.gd create mode 100644 tcg/card/support_card_effect.gd create mode 100644 tcg/card/support_card_effect_instance.gd create mode 100644 tcg/match/action/action.gd create mode 100644 tcg/match/action/action_play_card.gd create mode 100644 tcg/match/action/action_rps_move.gd create mode 100644 tcg/match/event/event.gd create mode 100644 tcg/match/event/event_damage_dealt.gd create mode 100644 tcg/match/event/event_draw_card.gd create mode 100644 tcg/match/event/event_monster_died.gd create mode 100644 tcg/match/event/event_monster_summoned.gd create mode 100644 tcg/match/event/event_support_effect_applied.gd create mode 100644 tcg/match/match.gd create mode 100644 tcg/match/match_manager.gd create mode 100644 tcg/match/match_manager.tscn create mode 100644 tcg/match/match_monster.gd create mode 100644 tcg/match/match_player.gd create mode 100644 tcg/match/match_player.tscn create mode 100644 tcg/match/monster.tscn create mode 100644 tcg/match/phase_transition.gd diff --git a/data/cards/baraga.tres b/data/cards/baraga.tres new file mode 100644 index 0000000..0b217a1 --- /dev/null +++ b/data/cards/baraga.tres @@ -0,0 +1,19 @@ +[gd_resource type="Resource" script_class="MonsterCard" load_steps=4 format=3 uid="uid://cs7q8i7bvohmj"] + +[ext_resource type="Script" path="res://tcg/card/monster_card.gd" id="1_v65bb"] + +[sub_resource type="Gradient" id="Gradient_mubps"] +offsets = PackedFloat32Array(0, 0.510204, 1) +colors = PackedColorArray(0, 0, 0, 1, 0.159184, 0.159184, 0.159184, 1, 1, 1, 1, 1) + +[sub_resource type="GradientTexture1D" id="GradientTexture1D_784dy"] +gradient = SubResource("Gradient_mubps") + +[resource] +script = ExtResource("1_v65bb") +rock = 100 +paper = 100 +scissors = 100 +energy_cost = 3 +base_health = 170 +art = SubResource("GradientTexture1D_784dy") diff --git a/data/cards/taiman.tres b/data/cards/taiman.tres new file mode 100644 index 0000000..aa4681d --- /dev/null +++ b/data/cards/taiman.tres @@ -0,0 +1,11 @@ +[gd_resource type="Resource" script_class="MonsterCard" load_steps=2 format=3 uid="uid://di76avwc0gn8e"] + +[ext_resource type="Script" path="res://tcg/card/monster_card.gd" id="1_j4601"] + +[resource] +script = ExtResource("1_j4601") +rock = 50 +paper = 50 +scissors = 50 +energy_cost = 1 +base_health = 120 diff --git a/demo_game.gd b/demo_game.gd new file mode 100644 index 0000000..d7c041b --- /dev/null +++ b/demo_game.gd @@ -0,0 +1,61 @@ +extends Control + +@export var player_1_deck: Array[Card] +@export var player_2_deck: Array[Card] +@onready var match_manager = $MatchManager +@onready var own_side = $Own +@onready var opponent_side = $Opponent +@onready var start_game_btn = $StartGameButton + +var player_action_queue: Dictionary +var player_1_action: Action: + get: + return player_action_queue.get(MatchManager.PLAYER_1_ID) + set(value): + player_action_queue[MatchManager.PLAYER_1_ID] = value +var player_2_action: Action: + get: + return player_action_queue.get(MatchManager.PLAYER_2_ID) + set(value): + player_action_queue[MatchManager.PLAYER_2_ID] = value + +func _ready() -> void: + match_manager.init({ + MatchManager.PLAYER_1_ID: player_1_deck, + MatchManager.PLAYER_2_ID: player_2_deck + }) + own_side.attach(match_manager) + opponent_side.attach(match_manager) + match_manager.state_transitioned.connect(_on_match_manager_state_transitioned) + +var transition_history: Array[PhaseTransition] = [] +func _on_match_manager_state_transitioned(transition: PhaseTransition): + start_game_btn.visible = match_manager.phase == Match.Phase.PREGAME + transition_history.append(transition) + +func _on_start_game_button_button_up() -> void: + match_manager.resolve({}) + +func _on_own_play_card(card: Card) -> void: + player_1_action = ActionPlayCard.new(card) + if player_2_action: + match_manager.resolve(player_action_queue) + player_action_queue.clear() + +func _on_opponent_play_card(card: Card) -> void: + player_2_action = ActionPlayCard.new(card) + if player_1_action: + match_manager.resolve(player_action_queue) + player_action_queue.clear() + +func _on_own_rps_move(move: String) -> void: + player_1_action = ActionRPSMove.new(move) + if player_2_action: + match_manager.resolve(player_action_queue) + player_action_queue.clear() + +func _on_opponent_rps_move(move: String) -> void: + player_2_action = ActionRPSMove.new(move) + if player_1_action: + match_manager.resolve(player_action_queue) + player_action_queue.clear() diff --git a/demo_game.tscn b/demo_game.tscn new file mode 100644 index 0000000..e5ae8d6 --- /dev/null +++ b/demo_game.tscn @@ -0,0 +1,169 @@ +[gd_scene load_steps=8 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"] +[ext_resource type="Script" path="res://tcg/card/card.gd" id="2_xuft0"] +[ext_resource type="PackedScene" uid="uid://cikstg43mudkn" path="res://tcg/match/match_manager.tscn" id="3_3yhrl"] +[ext_resource type="Resource" uid="uid://cs7q8i7bvohmj" path="res://data/cards/baraga.tres" id="3_we1tk"] +[ext_resource type="Resource" uid="uid://4eod3m0vc5a8" path="res://data/cards/potion.tres" id="4_kkhfk"] +[ext_resource type="Resource" uid="uid://di76avwc0gn8e" path="res://data/cards/taiman.tres" id="5_3cm5x"] + +[node name="DemoGame" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +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")]) +player_2_deck = Array[ExtResource("2_xuft0")]([ExtResource("5_3cm5x"), ExtResource("4_kkhfk"), ExtResource("4_kkhfk")]) + +[node name="Own" type="VBoxContainer" parent="." node_paths=PackedStringArray("deck", "monster_name_label", "monster_health_label", "incoming_damage_label", "energy_label")] +layout_mode = 1 +anchors_preset = 12 +anchor_top = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_top = -131.0 +grow_horizontal = 2 +grow_vertical = 0 +alignment = 2 +script = ExtResource("2_w4tnt") +deck = NodePath("Hand") +monster_name_label = NodePath("Monster/VBoxContainer/NameLabel") +monster_health_label = NodePath("Monster/VBoxContainer/HealthLabel") +incoming_damage_label = NodePath("Monster/VBoxContainer/IncomingDamageLabel") +energy_label = NodePath("HBoxContainer/EnergyLabel") + +[node name="Monster" type="HBoxContainer" parent="Own"] +custom_minimum_size = Vector2(0, 128) +layout_mode = 2 +size_flags_horizontal = 4 +alignment = 1 + +[node name="VBoxContainer" type="VBoxContainer" parent="Own/Monster"] +layout_mode = 2 + +[node name="NameLabel" type="Label" parent="Own/Monster/VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 3 +text = "Name:" + +[node name="HealthLabel" type="Label" parent="Own/Monster/VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 3 +text = "Health:" + +[node name="IncomingDamageLabel" type="Label" parent="Own/Monster/VBoxContainer"] +custom_minimum_size = Vector2(128, 0) +layout_mode = 2 +size_flags_vertical = 3 +text = "Incoming Damage:" +vertical_alignment = 2 + +[node name="HBoxContainer" type="HBoxContainer" parent="Own"] +layout_mode = 2 + +[node name="EnergyLabel" type="Label" parent="Own/HBoxContainer"] +layout_mode = 2 +text = "Energy:" + +[node name="Hand" type="HBoxContainer" parent="Own"] +layout_mode = 2 +alignment = 1 + +[node name="Button" type="Button" parent="Own/Hand"] +layout_mode = 2 +text = "CARD_1" + +[node name="Button2" type="Button" parent="Own/Hand"] +layout_mode = 2 +text = "CARD_2" + +[node name="Button3" type="Button" parent="Own/Hand"] +layout_mode = 2 +text = "CARD_3" + +[node name="Opponent" type="VBoxContainer" parent="." node_paths=PackedStringArray("deck", "monster_name_label", "monster_health_label", "incoming_damage_label", "energy_label")] +layout_mode = 1 +anchors_preset = 10 +anchor_right = 1.0 +offset_bottom = 190.0 +grow_horizontal = 2 +script = ExtResource("2_w4tnt") +player_id = 1 +deck = NodePath("Hand") +monster_name_label = NodePath("Monster/VBoxContainer/NameLabel") +monster_health_label = NodePath("Monster/VBoxContainer/HealthLabel") +incoming_damage_label = NodePath("Monster/VBoxContainer/IncomingDamageLabel") +energy_label = NodePath("EnergyLabel") + +[node name="Hand" type="HBoxContainer" parent="Opponent"] +layout_mode = 2 +alignment = 1 + +[node name="Button" type="Button" parent="Opponent/Hand"] +layout_mode = 2 +text = "CARD_1" + +[node name="Button2" type="Button" parent="Opponent/Hand"] +layout_mode = 2 +text = "CARD_2" + +[node name="Button3" type="Button" parent="Opponent/Hand"] +layout_mode = 2 +text = "CARD_3" + +[node name="EnergyLabel" type="Label" parent="Opponent"] +layout_mode = 2 +text = "Energy:" + +[node name="Monster" type="HBoxContainer" parent="Opponent"] +custom_minimum_size = Vector2(0, 128) +layout_mode = 2 +size_flags_horizontal = 4 +alignment = 1 + +[node name="VBoxContainer" type="VBoxContainer" parent="Opponent/Monster"] +layout_mode = 2 + +[node name="NameLabel" type="Label" parent="Opponent/Monster/VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 3 +text = "Name: " + +[node name="HealthLabel" type="Label" parent="Opponent/Monster/VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 3 +text = "Health:" + +[node name="IncomingDamageLabel" type="Label" parent="Opponent/Monster/VBoxContainer"] +custom_minimum_size = Vector2(128, 0) +layout_mode = 2 +size_flags_vertical = 3 +text = "Incoming Damage:" +vertical_alignment = 2 + +[node name="StartGameButton" type="Button" parent="."] +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -132.0 +offset_top = -59.5 +offset_right = 132.0 +offset_bottom = 59.5 +grow_horizontal = 2 +grow_vertical = 2 +text = "Start Game" + +[node name="MatchManager" parent="." instance=ExtResource("3_3yhrl")] + +[connection signal="play_card" from="Own" to="." method="_on_own_play_card"] +[connection signal="rps_move" from="Own" to="." method="_on_own_rps_move"] +[connection signal="play_card" from="Opponent" to="." method="_on_opponent_play_card"] +[connection signal="rps_move" from="Opponent" to="." method="_on_opponent_rps_move"] +[connection signal="button_up" from="StartGameButton" to="." method="_on_start_game_button_button_up"] diff --git a/player_side.gd b/player_side.gd new file mode 100644 index 0000000..1660986 --- /dev/null +++ b/player_side.gd @@ -0,0 +1,55 @@ +extends Control + +signal play_card(card: Card) +signal rps_move(move: String) +@export var player_id: int +@export var deck: Container +@export var monster_name_label: Label +@export var monster_health_label: Label +@export var incoming_damage_label: Label +@export var energy_label: Label + +var match_manager: MatchManager + +func attach(match_manager: MatchManager): + self.match_manager = match_manager + match_manager.state_transitioned.connect(_on_update) + +func _on_update(transition): + for child in deck.get_children(): + child.queue_free() + var player: MatchPlayer = match_manager.players.get(player_id) as MatchPlayer + if not player: + return + energy_label.text = "Energy: " + str(player.energy) + var monster = player.monster + if monster: + monster_name_label.text = "Name: " + monster.card.id + monster_health_label.text = "Health: " + str(monster.health) + incoming_damage_label.text = "Incoming Damage: " + str(monster.damage_incoming) + if match_manager.phase in [Match.Phase.SUMMON, Match.Phase.SUPPORT_1, Match.Phase.SUPPORT_2]: + for card: Card in player.hand: + if match_manager.phase == Match.Phase.SUMMON and card is not MonsterCard: + continue + if (match_manager.phase == Match.Phase.SUPPORT_1 or match_manager.phase == Match.Phase.SUPPORT_2) and card is not SupportCard: + continue + if match_manager.phase == Match.Phase.SUPPORT_1 and card.type == "red": + continue + var btn = Button.new() + btn.text = card.id + btn.button_up.connect(func (): play_card.emit(card)) + btn.disabled = ( + card is MonsterCard and match_manager.phase != Match.Phase.SUMMON + ) or ( + card is SupportCard and match_manager.phase != Match.Phase.SUPPORT_1 and match_manager.phase != Match.Phase.SUPPORT_2 + ) or ( + card is SupportCard and card.type == "red" and match_manager.phase != Match.Phase.SUPPORT_2 + ) + deck.add_child(btn) + if match_manager.phase == Match.Phase.RPS: + for move in ["rock", "paper", "scissors"]: + var btn = Button.new() + btn.text = move + btn.button_up.connect(func (): rps_move.emit(move)) + deck.add_child(btn) + diff --git a/tcg/card/card.gd b/tcg/card/card.gd new file mode 100644 index 0000000..5c8826b --- /dev/null +++ b/tcg/card/card.gd @@ -0,0 +1,6 @@ +extends Resource +class_name Card + +var id: String: + get: + return resource_path.rsplit(".", true, 1)[0].rsplit("/", true, 1)[1] diff --git a/tcg/card/monster_card.gd b/tcg/card/monster_card.gd new file mode 100644 index 0000000..0d5304e --- /dev/null +++ b/tcg/card/monster_card.gd @@ -0,0 +1,8 @@ +extends Card +class_name MonsterCard + +@export var rock: int = 0 +@export var paper: int = 0 +@export var scissors: int = 0 +@export var energy_cost: int = 1 +@export var base_health: int = 100 diff --git a/tcg/card/support_card.gd b/tcg/card/support_card.gd new file mode 100644 index 0000000..8ff5e3b --- /dev/null +++ b/tcg/card/support_card.gd @@ -0,0 +1,6 @@ +extends Card +class_name SupportCard + +@export_enum("red", "green") var type = "green" +@export var priority: int = 0 +@export var effects: Array[SupportCardEffectInstance] = [null] diff --git a/tcg/card/support_card_effect.gd b/tcg/card/support_card_effect.gd new file mode 100644 index 0000000..c841f1b --- /dev/null +++ b/tcg/card/support_card_effect.gd @@ -0,0 +1,6 @@ +extends Resource +class_name SupportCardEffect + +var id: String: + get: + return resource_path.rsplit(".", true, 1)[0].rsplit("/", true, 1)[1] diff --git a/tcg/card/support_card_effect_instance.gd b/tcg/card/support_card_effect_instance.gd new file mode 100644 index 0000000..e2ced1c --- /dev/null +++ b/tcg/card/support_card_effect_instance.gd @@ -0,0 +1,5 @@ +extends Resource +class_name SupportCardEffectInstance + +@export var magnitude: int +@export var effect: SupportCardEffect diff --git a/tcg/match/action/action.gd b/tcg/match/action/action.gd new file mode 100644 index 0000000..a701b75 --- /dev/null +++ b/tcg/match/action/action.gd @@ -0,0 +1,2 @@ +extends Resource +class_name Action diff --git a/tcg/match/action/action_play_card.gd b/tcg/match/action/action_play_card.gd new file mode 100644 index 0000000..5c74d64 --- /dev/null +++ b/tcg/match/action/action_play_card.gd @@ -0,0 +1,7 @@ +extends Action +class_name ActionPlayCard + +@export var card: Card + +func _init(card: Card) -> void: + self.card = card diff --git a/tcg/match/action/action_rps_move.gd b/tcg/match/action/action_rps_move.gd new file mode 100644 index 0000000..dd5d04b --- /dev/null +++ b/tcg/match/action/action_rps_move.gd @@ -0,0 +1,7 @@ +extends Action +class_name ActionRPSMove + +var move: String # rock | paper | scissors + +func _init(move: String) -> void: + self.move = move diff --git a/tcg/match/event/event.gd b/tcg/match/event/event.gd new file mode 100644 index 0000000..709aa85 --- /dev/null +++ b/tcg/match/event/event.gd @@ -0,0 +1,2 @@ +extends Resource +class_name Event diff --git a/tcg/match/event/event_damage_dealt.gd b/tcg/match/event/event_damage_dealt.gd new file mode 100644 index 0000000..e8b8f2a --- /dev/null +++ b/tcg/match/event/event_damage_dealt.gd @@ -0,0 +1,5 @@ +extends Event +class_name EventDamageDealt + +var target_player_id: int +var amount: int diff --git a/tcg/match/event/event_draw_card.gd b/tcg/match/event/event_draw_card.gd new file mode 100644 index 0000000..3e706d6 --- /dev/null +++ b/tcg/match/event/event_draw_card.gd @@ -0,0 +1,9 @@ +extends Event +class_name EventCardDrawn + +var player_id: int +var card: Card + +func _init(player_id: int, card: Card) -> void: + self.player_id = player_id + self.card = card diff --git a/tcg/match/event/event_monster_died.gd b/tcg/match/event/event_monster_died.gd new file mode 100644 index 0000000..1c6341c --- /dev/null +++ b/tcg/match/event/event_monster_died.gd @@ -0,0 +1,4 @@ +extends Event +class_name EventMonsterDied + +var player_id: int diff --git a/tcg/match/event/event_monster_summoned.gd b/tcg/match/event/event_monster_summoned.gd new file mode 100644 index 0000000..fe0aa32 --- /dev/null +++ b/tcg/match/event/event_monster_summoned.gd @@ -0,0 +1,7 @@ +extends Event +class_name EventMonsterSummoned + +var monster: MonsterCard + +func _init(monster: MonsterCard) -> void: + self.monster = monster diff --git a/tcg/match/event/event_support_effect_applied.gd b/tcg/match/event/event_support_effect_applied.gd new file mode 100644 index 0000000..a5c496d --- /dev/null +++ b/tcg/match/event/event_support_effect_applied.gd @@ -0,0 +1,9 @@ +extends Event +class_name EventSupportEffectApplied + +var player_id: int +var effect_instance: SupportCardEffectInstance + +func _init(player_id: int, effect_instance: SupportCardEffectInstance) -> void: + self.player_id = player_id + self.effect_instance = effect_instance diff --git a/tcg/match/match.gd b/tcg/match/match.gd new file mode 100644 index 0000000..1faf54f --- /dev/null +++ b/tcg/match/match.gd @@ -0,0 +1,10 @@ +extends Object +class_name Match + +enum Phase { + PREGAME = 0, + SUMMON = 1, + SUPPORT_1 = 2, + RPS = 3, + SUPPORT_2 = 4 +} diff --git a/tcg/match/match_manager.gd b/tcg/match/match_manager.gd new file mode 100644 index 0000000..799b712 --- /dev/null +++ b/tcg/match/match_manager.gd @@ -0,0 +1,112 @@ +extends Node +class_name MatchManager + +signal match_begun +signal state_transitioned(transition: PhaseTransition) + +const PLAYER_1_ID: int = 0 +const PLAYER_2_ID: int = 1 + +var rps_wins = { + "rock": "scissors", + "scissors": "paper", + "paper": "rock" +} + +var players: Dictionary +var player_1: MatchPlayer: + get: + return players[PLAYER_1_ID] as MatchPlayer +var player_2: MatchPlayer: + get: + return players[PLAYER_2_ID] as MatchPlayer +var phase: Match.Phase = Match.Phase.PREGAME + +func _ready() -> void: + cleanup() + +func init(decks: Dictionary): + cleanup() + for player_id in [PLAYER_1_ID, PLAYER_2_ID]: + var deck_shuffled = decks[player_id].duplicate() as Array[Card] + deck_shuffled.shuffle() + players[player_id] = MatchPlayer.new(player_id, deck_shuffled) + +func cleanup(): + for player_id in [PLAYER_1_ID, PLAYER_2_ID]: + var existing = players.get(player_id) + if existing: + existing.free() + phase = Match.Phase.PREGAME + +func resolve(action_by_player_id: Dictionary) -> PhaseTransition: + var initial_phase = phase + var events = [] as Array[Event] + var player_1_action = action_by_player_id.get(PLAYER_1_ID) as Action + var player_2_action = action_by_player_id.get(PLAYER_2_ID) as Action + match phase: + Match.Phase.PREGAME: + var CARDS_TO_DRAW: int = 3 + for player: MatchPlayer in [player_1, player_2]: + var n_cards_to_draw = min(player.deck.size(), CARDS_TO_DRAW) + var drawn_cards = range(n_cards_to_draw).map(func(_i): return player.deck.pop_back()) as Array[Card] + for card in drawn_cards: + player.hand.push_back(card) + var drawn_card_events = drawn_cards.map(func(card): return EventCardDrawn.new(player.id, card)) + events.append_array( + drawn_card_events + ) + phase = Match.Phase.SUMMON + Match.Phase.SUMMON: + for player_id in action_by_player_id.keys(): + var action = action_by_player_id[player_id] + if action is ActionPlayCard: + var card = action.card + if card is MonsterCard: + players[player_id].monster = _monster_from_card(card) + players[player_id].hand = players[player_id].hand.filter(func(card_in_hand): return card.id != card_in_hand.id) + events.append(EventMonsterSummoned.new(card)) + if players.values().all(func(player: MatchPlayer): return player.monster): + phase = Match.Phase.SUPPORT_1 + Match.Phase.SUPPORT_1: + var support_cards = [] + if player_1_action is ActionPlayCard and player_1_action.card is SupportCard: + support_cards.append({ + "player": player_1, + "card": player_1_action.card + }) + if player_2_action is ActionPlayCard and player_2_action.card is SupportCard: + support_cards.append({ + "player": player_2, + "card": 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 + events.append_array(_resolve_support_card_effects(player, card)) + phase = Match.Phase.RPS + Match.Phase.RPS: + 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 tie = not player_1_win and not player_2_win + + _: + pass + var transition = PhaseTransition.new(events, initial_phase, phase) + state_transitioned.emit(transition) + return transition + +func _monster_from_card(card: MonsterCard) -> MatchMonster: + return MatchMonster.new(card, card.base_health, 0) + +func _resolve_support_card_effects(player: MatchPlayer, card: SupportCard) -> Array[Event]: + var events: Array[Event] + for effect_instance in card.effects: + var effect = effect_instance.effect + var magnitude = effect_instance.magnitude + match effect.id: + "heal": + player.monster.health += magnitude + events.append(EventSupportEffectApplied.new(player.id, effect_instance)) + return events diff --git a/tcg/match/match_manager.tscn b/tcg/match/match_manager.tscn new file mode 100644 index 0000000..b88655b --- /dev/null +++ b/tcg/match/match_manager.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://cikstg43mudkn"] + +[ext_resource type="Script" path="res://tcg/match/match_manager.gd" id="1_tkhvw"] + +[node name="MatchManager" type="Node"] +script = ExtResource("1_tkhvw") diff --git a/tcg/match/match_monster.gd b/tcg/match/match_monster.gd new file mode 100644 index 0000000..e9dfb1c --- /dev/null +++ b/tcg/match/match_monster.gd @@ -0,0 +1,11 @@ +extends RefCounted +class_name MatchMonster + +var card: MonsterCard +var health: int +var damage_incoming: int + +func _init(card: MonsterCard, health: int, damage_incoming: int) -> void: + self.card = card + self.health = health + self.damage_incoming = damage_incoming diff --git a/tcg/match/match_player.gd b/tcg/match/match_player.gd new file mode 100644 index 0000000..48c7a9e --- /dev/null +++ b/tcg/match/match_player.gd @@ -0,0 +1,12 @@ +extends Object +class_name MatchPlayer + +var id: int +var hand: Array[Card] = [] +var deck: Array[Card] +var energy: int = 5 +var monster: MatchMonster = null + +func _init(id: int, deck: Array[Card]) -> void: + self.id = id + self.deck = deck diff --git a/tcg/match/match_player.tscn b/tcg/match/match_player.tscn new file mode 100644 index 0000000..0b909e3 --- /dev/null +++ b/tcg/match/match_player.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://bwkfogonbhq6r"] + +[ext_resource type="Script" path="res://tcg/match/match_player.gd" id="1_pdj3n"] + +[node name="MatchPlayer" type="Node"] +script = ExtResource("1_pdj3n") diff --git a/tcg/match/monster.tscn b/tcg/match/monster.tscn new file mode 100644 index 0000000..9e1d1a5 --- /dev/null +++ b/tcg/match/monster.tscn @@ -0,0 +1,17 @@ +[gd_scene load_steps=2 format=3 uid="uid://d3dm1bnooaxmu"] + +[sub_resource type="GDScript" id="GDScript_dtwp4"] +script/source = "extends Node +class_name Monster + +var health: int +var card: MonsterCard +var damage_incoming: int = 0 + +func from_card(card: MonsterCard): + self.card = card + health = card.base_health +" + +[node name="Monster" type="Node"] +script = SubResource("GDScript_dtwp4") diff --git a/tcg/match/phase_transition.gd b/tcg/match/phase_transition.gd new file mode 100644 index 0000000..0ca6e46 --- /dev/null +++ b/tcg/match/phase_transition.gd @@ -0,0 +1,11 @@ +extends RefCounted +class_name PhaseTransition + +var events: Array[Event] +var from: Match.Phase +var to: Match.Phase + +func _init(events: Array[Event], from: Match.Phase, to: Match.Phase) -> void: + self.events = events + self.from = from + self.to = to From 7d05df6e39d9f555ec41d81010d0367251d624ec Mon Sep 17 00:00:00 2001 From: istamarahsan Date: Sat, 25 Jan 2025 11:58:04 +0700 Subject: [PATCH 3/4] feat: delete trying to make game --- card/card.gd | 6 ------ card/monster_card.gd | 8 -------- card/support_card.gd | 5 ----- card/support_card_effect.gd | 7 ------- card/support_card_effect_instance.gd | 5 ----- data/cards/potion.tres | 22 +++++++++++----------- data/support_effects/heal.tres | 4 ++-- data/support_effects/swap_monst.er.tres | 7 ------- 8 files changed, 13 insertions(+), 51 deletions(-) delete mode 100644 card/card.gd delete mode 100644 card/monster_card.gd delete mode 100644 card/support_card.gd delete mode 100644 card/support_card_effect.gd delete mode 100644 card/support_card_effect_instance.gd delete mode 100644 data/support_effects/swap_monst.er.tres diff --git a/card/card.gd b/card/card.gd deleted file mode 100644 index 80e6c1b..0000000 --- a/card/card.gd +++ /dev/null @@ -1,6 +0,0 @@ -extends Resource -class_name Card - -var id: String: - get: - return resource_path.rsplit(".", true, 1)[0] diff --git a/card/monster_card.gd b/card/monster_card.gd deleted file mode 100644 index 0d5304e..0000000 --- a/card/monster_card.gd +++ /dev/null @@ -1,8 +0,0 @@ -extends Card -class_name MonsterCard - -@export var rock: int = 0 -@export var paper: int = 0 -@export var scissors: int = 0 -@export var energy_cost: int = 1 -@export var base_health: int = 100 diff --git a/card/support_card.gd b/card/support_card.gd deleted file mode 100644 index 23d736e..0000000 --- a/card/support_card.gd +++ /dev/null @@ -1,5 +0,0 @@ -extends Card -class_name SupportCard - -@export_enum("red", "green") var type = "green" -@export var effect: Array[SupportCardEffectInstance] = [null] diff --git a/card/support_card_effect.gd b/card/support_card_effect.gd deleted file mode 100644 index a03d17c..0000000 --- a/card/support_card_effect.gd +++ /dev/null @@ -1,7 +0,0 @@ -@tool -extends Resource -class_name SupportCardEffect - -var id: String: - get: - return resource_path.rsplit(".", true, 1)[0] diff --git a/card/support_card_effect_instance.gd b/card/support_card_effect_instance.gd deleted file mode 100644 index e2ced1c..0000000 --- a/card/support_card_effect_instance.gd +++ /dev/null @@ -1,5 +0,0 @@ -extends Resource -class_name SupportCardEffectInstance - -@export var magnitude: int -@export var effect: SupportCardEffect diff --git a/data/cards/potion.tres b/data/cards/potion.tres index dc1ae47..a68f262 100644 --- a/data/cards/potion.tres +++ b/data/cards/potion.tres @@ -1,16 +1,16 @@ -[gd_resource type="Resource" script_class="SupportCard" load_steps=5 format=3 uid="uid://bhk1nc02g0gtb"] +[gd_resource type="Resource" script_class="SupportCard" load_steps=5 format=3 uid="uid://4eod3m0vc5a8"] -[ext_resource type="Script" path="res://card/support_card_effect_instance.gd" id="1_fq8c7"] -[ext_resource type="Resource" uid="uid://h1ki1kya43v7" path="res://data/support_effects/heal.tres" id="2_3x5mu"] -[ext_resource type="Script" path="res://card/support_card.gd" id="2_44syi"] +[ext_resource type="Script" path="res://tcg/card/support_card_effect_instance.gd" id="1_alamh"] +[ext_resource type="Resource" uid="uid://cvu0rtt5nggf" path="res://data/support_effects/heal.tres" id="2_3x5mu"] +[ext_resource type="Script" path="res://tcg/card/support_card.gd" id="2_72hmi"] -[sub_resource type="Resource" id="Resource_l7fsx"] -script = ExtResource("1_fq8c7") -magnitude = 3 +[sub_resource type="Resource" id="Resource_88lmk"] +script = ExtResource("1_alamh") +magnitude = 5 effect = ExtResource("2_3x5mu") [resource] -script = ExtResource("2_44syi") -type = null -effect = Array[ExtResource("1_fq8c7")]([SubResource("Resource_l7fsx")]) -id = "" +script = ExtResource("2_72hmi") +type = "green" +priority = 0 +effects = Array[ExtResource("1_alamh")]([SubResource("Resource_88lmk")]) diff --git a/data/support_effects/heal.tres b/data/support_effects/heal.tres index 68f851e..2465305 100644 --- a/data/support_effects/heal.tres +++ b/data/support_effects/heal.tres @@ -1,6 +1,6 @@ -[gd_resource type="Resource" script_class="SupportCardEffect" load_steps=2 format=3 uid="uid://h1ki1kya43v7"] +[gd_resource type="Resource" script_class="SupportCardEffect" load_steps=2 format=3 uid="uid://cvu0rtt5nggf"] -[ext_resource type="Script" path="res://card/support_card_effect.gd" id="1_exmke"] +[ext_resource type="Script" path="res://tcg/card/support_card_effect.gd" id="1_exmke"] [resource] script = ExtResource("1_exmke") diff --git a/data/support_effects/swap_monst.er.tres b/data/support_effects/swap_monst.er.tres deleted file mode 100644 index b641e34..0000000 --- a/data/support_effects/swap_monst.er.tres +++ /dev/null @@ -1,7 +0,0 @@ -[gd_resource type="Resource" script_class="SupportCardEffect" load_steps=2 format=3 uid="uid://xinrslggye4"] - -[ext_resource type="Script" path="res://card/support_card_effect.gd" id="1_7awm5"] - -[resource] -script = ExtResource("1_7awm5") -id = "swap_monster" From d47c2e513bab849c7e946717d6f374b38a0c9623 Mon Sep 17 00:00:00 2001 From: istamarahsan Date: Sat, 25 Jan 2025 15:07:03 +0700 Subject: [PATCH 4/4] feat: game loop --- data/cards/baraga.tres | 10 +----- demo_game.gd | 1 + player_side.gd | 2 +- project.godot | 4 +++ tcg/card/monster_card.gd | 8 +++++ tcg/match/event/event_damage_dealt.gd | 4 +++ tcg/match/event/event_monster_died.gd | 3 ++ tcg/match/match.gd | 22 ++++++++++-- tcg/match/match_manager.gd | 51 ++++++++++++++++++++++++--- tcg/match/match_monster.gd | 6 ++-- tcg/match/match_monster.tscn | 6 ++++ tcg/match/monster.tscn | 17 --------- 12 files changed, 97 insertions(+), 37 deletions(-) create mode 100644 tcg/match/match_monster.tscn delete mode 100644 tcg/match/monster.tscn diff --git a/data/cards/baraga.tres b/data/cards/baraga.tres index 0b217a1..a979300 100644 --- a/data/cards/baraga.tres +++ b/data/cards/baraga.tres @@ -1,14 +1,7 @@ -[gd_resource type="Resource" script_class="MonsterCard" load_steps=4 format=3 uid="uid://cs7q8i7bvohmj"] +[gd_resource type="Resource" script_class="MonsterCard" load_steps=2 format=3 uid="uid://cs7q8i7bvohmj"] [ext_resource type="Script" path="res://tcg/card/monster_card.gd" id="1_v65bb"] -[sub_resource type="Gradient" id="Gradient_mubps"] -offsets = PackedFloat32Array(0, 0.510204, 1) -colors = PackedColorArray(0, 0, 0, 1, 0.159184, 0.159184, 0.159184, 1, 1, 1, 1, 1) - -[sub_resource type="GradientTexture1D" id="GradientTexture1D_784dy"] -gradient = SubResource("Gradient_mubps") - [resource] script = ExtResource("1_v65bb") rock = 100 @@ -16,4 +9,3 @@ paper = 100 scissors = 100 energy_cost = 3 base_health = 170 -art = SubResource("GradientTexture1D_784dy") diff --git a/demo_game.gd b/demo_game.gd index d7c041b..359338d 100644 --- a/demo_game.gd +++ b/demo_game.gd @@ -32,6 +32,7 @@ var transition_history: Array[PhaseTransition] = [] func _on_match_manager_state_transitioned(transition: PhaseTransition): start_game_btn.visible = match_manager.phase == Match.Phase.PREGAME transition_history.append(transition) + print("Phase: ", Match.phase_to_str(transition.from), " -> ", Match.phase_to_str(transition.to)) func _on_start_game_button_button_up() -> void: match_manager.resolve({}) diff --git a/player_side.gd b/player_side.gd index 1660986..03eddf3 100644 --- a/player_side.gd +++ b/player_side.gd @@ -26,7 +26,7 @@ func _on_update(transition): if monster: monster_name_label.text = "Name: " + monster.card.id monster_health_label.text = "Health: " + str(monster.health) - incoming_damage_label.text = "Incoming Damage: " + str(monster.damage_incoming) + incoming_damage_label.text = "Incoming Damage: " + str(monster.health_delta) if match_manager.phase in [Match.Phase.SUMMON, Match.Phase.SUPPORT_1, Match.Phase.SUPPORT_2]: for card: Card in player.hand: if match_manager.phase == Match.Phase.SUMMON and card is not MonsterCard: diff --git a/project.godot b/project.godot index 0bfa3d6..f8f23d6 100644 --- a/project.godot +++ b/project.godot @@ -15,6 +15,10 @@ run/main_scene="res://main.tscn" config/features=PackedStringArray("4.3", "Mobile") config/icon="res://icon.svg" +[autoload] + +Match="*res://tcg/match/match.gd" + [rendering] renderer/rendering_method="mobile" diff --git a/tcg/card/monster_card.gd b/tcg/card/monster_card.gd index 0d5304e..4b82987 100644 --- a/tcg/card/monster_card.gd +++ b/tcg/card/monster_card.gd @@ -6,3 +6,11 @@ class_name MonsterCard @export var scissors: int = 0 @export var energy_cost: int = 1 @export var base_health: int = 100 + +var damage: Dictionary: + get: + return { + "rock": rock, + "paper": paper, + "scissors": scissors + } \ No newline at end of file diff --git a/tcg/match/event/event_damage_dealt.gd b/tcg/match/event/event_damage_dealt.gd index e8b8f2a..bc342c7 100644 --- a/tcg/match/event/event_damage_dealt.gd +++ b/tcg/match/event/event_damage_dealt.gd @@ -3,3 +3,7 @@ class_name EventDamageDealt var target_player_id: int var amount: int + +func _init(target_player_id: int, amount: int) -> void: + self.target_player_id = target_player_id + self.amount = amount diff --git a/tcg/match/event/event_monster_died.gd b/tcg/match/event/event_monster_died.gd index 1c6341c..4a3ec4b 100644 --- a/tcg/match/event/event_monster_died.gd +++ b/tcg/match/event/event_monster_died.gd @@ -2,3 +2,6 @@ extends Event class_name EventMonsterDied var player_id: int + +func _init(player_id: int) -> void: + self.player_id = player_id diff --git a/tcg/match/match.gd b/tcg/match/match.gd index 1faf54f..64ec037 100644 --- a/tcg/match/match.gd +++ b/tcg/match/match.gd @@ -1,10 +1,26 @@ -extends Object -class_name Match +extends Node enum Phase { PREGAME = 0, SUMMON = 1, SUPPORT_1 = 2, RPS = 3, - SUPPORT_2 = 4 + SUPPORT_2 = 4, + END } + +func phase_to_str(phase: Phase): + match phase: + Phase.PREGAME: + return "Pregame" + Phase.SUMMON: + return "Summon" + Phase.SUPPORT_1: + return "Support 1" + Phase.RPS: + return "RPS" + Phase.SUPPORT_2: + return "Support 2" + Phase.END: + return "End" + diff --git a/tcg/match/match_manager.gd b/tcg/match/match_manager.gd index 799b712..19cfe87 100644 --- a/tcg/match/match_manager.gd +++ b/tcg/match/match_manager.gd @@ -70,12 +70,12 @@ func resolve(action_by_player_id: Dictionary) -> PhaseTransition: phase = Match.Phase.SUPPORT_1 Match.Phase.SUPPORT_1: var support_cards = [] - if player_1_action is ActionPlayCard and player_1_action.card is SupportCard: + if player_1_action is ActionPlayCard: support_cards.append({ "player": player_1, "card": player_1_action.card }) - if player_2_action is ActionPlayCard and player_2_action.card is SupportCard: + if player_2_action is ActionPlayCard: support_cards.append({ "player": player_2, "card": player_2_action.card @@ -87,10 +87,53 @@ func resolve(action_by_player_id: Dictionary) -> PhaseTransition: events.append_array(_resolve_support_card_effects(player, card)) phase = Match.Phase.RPS Match.Phase.RPS: + 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_2_win = rps_wins[player_2_action.move] == player_1_action.move - var tie = not player_1_win and not player_2_win + if tie or player_1_win: + player_2.monster.health_delta -= player_1.monster.card.damage[player_1_action.move] + if tie or player_2_win: + player_1.monster.health_delta -= player_2.monster.card.damage[player_2_action.move] + phase = Match.Phase.SUPPORT_2 + Match.Phase.SUPPORT_2: + var support_cards = [] + if player_1_action is ActionPlayCard: + support_cards.append({ + "player": player_1, + "card": player_1_action.card + }) + if player_2_action is ActionPlayCard: + support_cards.append({ + "player": player_2, + "card": 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 + events.append_array(_resolve_support_card_effects(player, card)) + for player: MatchPlayer in players.values(): + var monster_final_health = player.monster.health + player.monster.health_delta + if monster_final_health <= 0: + player.monster = null + events.append(EventMonsterDied.new(player.id)) + else: + player.monster.health += player.monster.health_delta + player.monster.health_delta = 0 + var drawn_card = player.deck.pop_back() + if drawn_card: + player.hand.append(drawn_card) + events.append(EventCardDrawn.new(player.id, drawn_card)) + var players_without_monster = players.values().filter(func (player): return player.monster == null) + if players_without_monster.size() == 0: + phase = Match.Phase.SUPPORT_1 + elif players_without_monster.all( + func (player): return player.hand.any(func (it): return it is MonsterCard and it.energy_cost <= player.energy) + ): + phase = Match.Phase.SUMMON + else: + phase = Match.Phase.END _: pass var transition = PhaseTransition.new(events, initial_phase, phase) @@ -107,6 +150,6 @@ func _resolve_support_card_effects(player: MatchPlayer, card: SupportCard) -> Ar var magnitude = effect_instance.magnitude match effect.id: "heal": - player.monster.health += magnitude + player.monster.health_delta += magnitude events.append(EventSupportEffectApplied.new(player.id, effect_instance)) return events diff --git a/tcg/match/match_monster.gd b/tcg/match/match_monster.gd index e9dfb1c..f35e889 100644 --- a/tcg/match/match_monster.gd +++ b/tcg/match/match_monster.gd @@ -3,9 +3,9 @@ class_name MatchMonster var card: MonsterCard var health: int -var damage_incoming: int +var health_delta: int -func _init(card: MonsterCard, health: int, damage_incoming: int) -> void: +func _init(card: MonsterCard, health: int, health_delta: int) -> void: self.card = card self.health = health - self.damage_incoming = damage_incoming + self.health_delta = health_delta diff --git a/tcg/match/match_monster.tscn b/tcg/match/match_monster.tscn new file mode 100644 index 0000000..1f7131e --- /dev/null +++ b/tcg/match/match_monster.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://d3dm1bnooaxmu"] + +[ext_resource type="Script" path="res://tcg/match/match_monster.gd" id="1_o6dlj"] + +[node name="Monster" type="Node"] +script = ExtResource("1_o6dlj") diff --git a/tcg/match/monster.tscn b/tcg/match/monster.tscn deleted file mode 100644 index 9e1d1a5..0000000 --- a/tcg/match/monster.tscn +++ /dev/null @@ -1,17 +0,0 @@ -[gd_scene load_steps=2 format=3 uid="uid://d3dm1bnooaxmu"] - -[sub_resource type="GDScript" id="GDScript_dtwp4"] -script/source = "extends Node -class_name Monster - -var health: int -var card: MonsterCard -var damage_incoming: int = 0 - -func from_card(card: MonsterCard): - self.card = card - health = card.base_health -" - -[node name="Monster" type="Node"] -script = SubResource("GDScript_dtwp4")