From e304dd671b05baabd80a3eec44b1f672374a0ad6 Mon Sep 17 00:00:00 2001 From: istamarahsan Date: Fri, 24 Jan 2025 22:08:25 +0700 Subject: [PATCH 01/29] 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 02/29] 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 03/29] 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 04/29] 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") From 65dc02585e09dc008789fb3017f7287d36e24c5b Mon Sep 17 00:00:00 2001 From: istamarahsan Date: Sat, 25 Jan 2025 18:40:14 +0700 Subject: [PATCH 05/29] feat: red and green card templates --- assets/Bohemian Soul.otf | 3 + assets/Bohemian Soul.otf.import | 34 +++++ assets/Inter-Regular.otf | 3 + assets/Inter-Regular.otf.import | 34 +++++ assets/card_base/Frame.png | 3 + assets/card_base/Frame.png.import | 34 +++++ assets/card_base/G-OuterFill.png | 3 + assets/card_base/G-OuterFill.png.import | 34 +++++ assets/card_base/InnerFill.png | 3 + assets/card_base/InnerFill.png.import | 34 +++++ assets/card_base/Pill.png | 3 + assets/card_base/Pill.png.import | 34 +++++ assets/card_base/R-OuterFill.png | 3 + assets/card_base/R-OuterFill.png.import | 34 +++++ assets/card_base/Separator.png | 3 + assets/card_base/Separator.png.import | 34 +++++ assets/card_base/Stroke.png | 3 + assets/card_base/Stroke.png.import | 34 +++++ assets/energy.png | 3 + assets/energy.png.import | 34 +++++ cards.tres | 8 ++ data/cards/{ => monster}/baraga.tres | 0 data/cards/{ => monster}/taiman.tres | 0 data/cards/potion.tres | 16 --- data/cards/support/potion.tres | 20 +++ demo_game.tscn | 6 +- tcg/card/card.gd | 4 + test_card.gd | 7 + test_card.tscn | 28 ++++ ui/card/GreenCard.tscn | 165 +++++++++++++++++++++++ ui/card/RedCard.tscn | 167 ++++++++++++++++++++++++ ui/card/card_base.gd | 20 +++ 32 files changed, 792 insertions(+), 19 deletions(-) create mode 100644 assets/Bohemian Soul.otf create mode 100644 assets/Bohemian Soul.otf.import create mode 100644 assets/Inter-Regular.otf create mode 100644 assets/Inter-Regular.otf.import create mode 100644 assets/card_base/Frame.png create mode 100644 assets/card_base/Frame.png.import create mode 100644 assets/card_base/G-OuterFill.png create mode 100644 assets/card_base/G-OuterFill.png.import create mode 100644 assets/card_base/InnerFill.png create mode 100644 assets/card_base/InnerFill.png.import create mode 100644 assets/card_base/Pill.png create mode 100644 assets/card_base/Pill.png.import create mode 100644 assets/card_base/R-OuterFill.png create mode 100644 assets/card_base/R-OuterFill.png.import create mode 100644 assets/card_base/Separator.png create mode 100644 assets/card_base/Separator.png.import create mode 100644 assets/card_base/Stroke.png create mode 100644 assets/card_base/Stroke.png.import create mode 100644 assets/energy.png create mode 100644 assets/energy.png.import create mode 100644 cards.tres rename data/cards/{ => monster}/baraga.tres (100%) rename data/cards/{ => monster}/taiman.tres (100%) delete mode 100644 data/cards/potion.tres create mode 100644 data/cards/support/potion.tres create mode 100644 test_card.gd create mode 100644 test_card.tscn create mode 100644 ui/card/GreenCard.tscn create mode 100644 ui/card/RedCard.tscn create mode 100644 ui/card/card_base.gd diff --git a/assets/Bohemian Soul.otf b/assets/Bohemian Soul.otf new file mode 100644 index 0000000..6649ff1 --- /dev/null +++ b/assets/Bohemian Soul.otf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b387796a272c26c37ff918e48271cf139755a0ecb2398039103d79af2c91c850 +size 38880 diff --git a/assets/Bohemian Soul.otf.import b/assets/Bohemian Soul.otf.import new file mode 100644 index 0000000..7e974e0 --- /dev/null +++ b/assets/Bohemian Soul.otf.import @@ -0,0 +1,34 @@ +[remap] + +importer="font_data_dynamic" +type="FontFile" +uid="uid://ncoq4i61plvt" +path="res://.godot/imported/Bohemian Soul.otf-321180efeec0e46d48937761716dc66f.fontdata" + +[deps] + +source_file="res://assets/Bohemian Soul.otf" +dest_files=["res://.godot/imported/Bohemian Soul.otf-321180efeec0e46d48937761716dc66f.fontdata"] + +[params] + +Rendering=null +antialiasing=1 +generate_mipmaps=false +disable_embedded_bitmaps=true +multichannel_signed_distance_field=false +msdf_pixel_range=8 +msdf_size=48 +allow_system_fallback=true +force_autohinter=false +hinting=1 +subpixel_positioning=1 +oversampling=0.0 +Fallbacks=null +fallbacks=[] +Compress=null +compress=true +preload=[] +language_support={} +script_support={} +opentype_features={} diff --git a/assets/Inter-Regular.otf b/assets/Inter-Regular.otf new file mode 100644 index 0000000..4ed3a79 --- /dev/null +++ b/assets/Inter-Regular.otf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a7e791e8f5a0fb02b65663f7fca73e1d1ca9543f772ad480cbd76f4e3fe3f8cc +size 258992 diff --git a/assets/Inter-Regular.otf.import b/assets/Inter-Regular.otf.import new file mode 100644 index 0000000..6ec3561 --- /dev/null +++ b/assets/Inter-Regular.otf.import @@ -0,0 +1,34 @@ +[remap] + +importer="font_data_dynamic" +type="FontFile" +uid="uid://08q3kkwmd4u6" +path="res://.godot/imported/Inter-Regular.otf-e79282422267193643bc1266eabc7aef.fontdata" + +[deps] + +source_file="res://assets/Inter-Regular.otf" +dest_files=["res://.godot/imported/Inter-Regular.otf-e79282422267193643bc1266eabc7aef.fontdata"] + +[params] + +Rendering=null +antialiasing=1 +generate_mipmaps=false +disable_embedded_bitmaps=true +multichannel_signed_distance_field=false +msdf_pixel_range=8 +msdf_size=48 +allow_system_fallback=true +force_autohinter=false +hinting=1 +subpixel_positioning=1 +oversampling=0.0 +Fallbacks=null +fallbacks=[] +Compress=null +compress=true +preload=[] +language_support={} +script_support={} +opentype_features={} diff --git a/assets/card_base/Frame.png b/assets/card_base/Frame.png new file mode 100644 index 0000000..5c7b0da --- /dev/null +++ b/assets/card_base/Frame.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b2315fae148c1d73e139ad51d9d90c0dc69314de870596e52fb2b4274a2e51b1 +size 165111 diff --git a/assets/card_base/Frame.png.import b/assets/card_base/Frame.png.import new file mode 100644 index 0000000..930f4d0 --- /dev/null +++ b/assets/card_base/Frame.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://l2nxxhh0pvh8" +path="res://.godot/imported/Frame.png-2cc9ebde58565bbc3036395eb0041ae9.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/card_base/Frame.png" +dest_files=["res://.godot/imported/Frame.png-2cc9ebde58565bbc3036395eb0041ae9.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/card_base/G-OuterFill.png b/assets/card_base/G-OuterFill.png new file mode 100644 index 0000000..114bbb7 --- /dev/null +++ b/assets/card_base/G-OuterFill.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0e0e62d5e3d57866bfa09a4dbcd0a14a244bd704c94b8eeadb1eafb57f08562a +size 149729 diff --git a/assets/card_base/G-OuterFill.png.import b/assets/card_base/G-OuterFill.png.import new file mode 100644 index 0000000..0468b36 --- /dev/null +++ b/assets/card_base/G-OuterFill.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://liitr32ap646" +path="res://.godot/imported/G-OuterFill.png-08376930c432a32d81cb0c7a55fb089e.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/card_base/G-OuterFill.png" +dest_files=["res://.godot/imported/G-OuterFill.png-08376930c432a32d81cb0c7a55fb089e.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/card_base/InnerFill.png b/assets/card_base/InnerFill.png new file mode 100644 index 0000000..3beb15d --- /dev/null +++ b/assets/card_base/InnerFill.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:aedb750f04941c2337bdad6c73b73399ed8fb625eaa436d6588017db9c0bee45 +size 126446 diff --git a/assets/card_base/InnerFill.png.import b/assets/card_base/InnerFill.png.import new file mode 100644 index 0000000..11ff539 --- /dev/null +++ b/assets/card_base/InnerFill.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://blejyda8mendg" +path="res://.godot/imported/InnerFill.png-75781e681a40959b716289bec2b32336.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/card_base/InnerFill.png" +dest_files=["res://.godot/imported/InnerFill.png-75781e681a40959b716289bec2b32336.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/card_base/Pill.png b/assets/card_base/Pill.png new file mode 100644 index 0000000..fb2a20d --- /dev/null +++ b/assets/card_base/Pill.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e21a3903c649abe91077ed55440eed2cd7f563f17b9c37f50430d68d322c4909 +size 846 diff --git a/assets/card_base/Pill.png.import b/assets/card_base/Pill.png.import new file mode 100644 index 0000000..51de1d3 --- /dev/null +++ b/assets/card_base/Pill.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://0gxplli5krq2" +path="res://.godot/imported/Pill.png-f7a0d13f20f1ea9ba344cea7c095427a.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/card_base/Pill.png" +dest_files=["res://.godot/imported/Pill.png-f7a0d13f20f1ea9ba344cea7c095427a.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/card_base/R-OuterFill.png b/assets/card_base/R-OuterFill.png new file mode 100644 index 0000000..d546cac --- /dev/null +++ b/assets/card_base/R-OuterFill.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2dcca3e0a0b82a518b6f0e23496a446f7d0e102b41763d35d9b3cc8c37d62afc +size 149723 diff --git a/assets/card_base/R-OuterFill.png.import b/assets/card_base/R-OuterFill.png.import new file mode 100644 index 0000000..cdfb01f --- /dev/null +++ b/assets/card_base/R-OuterFill.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://ip7xjs20pd3d" +path="res://.godot/imported/R-OuterFill.png-f999c1a1aec742072b5689d6ee4573cf.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/card_base/R-OuterFill.png" +dest_files=["res://.godot/imported/R-OuterFill.png-f999c1a1aec742072b5689d6ee4573cf.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/card_base/Separator.png b/assets/card_base/Separator.png new file mode 100644 index 0000000..c722ba8 --- /dev/null +++ b/assets/card_base/Separator.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3f41f216767597470e7f2b0b5bbb1a28718e591ee3283ee100ec8ae7965b08f3 +size 1537 diff --git a/assets/card_base/Separator.png.import b/assets/card_base/Separator.png.import new file mode 100644 index 0000000..af841a8 --- /dev/null +++ b/assets/card_base/Separator.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://by7ws88pn4tvb" +path="res://.godot/imported/Separator.png-3ef36f6d9a7c45cb144c99255cbf2668.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/card_base/Separator.png" +dest_files=["res://.godot/imported/Separator.png-3ef36f6d9a7c45cb144c99255cbf2668.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/card_base/Stroke.png b/assets/card_base/Stroke.png new file mode 100644 index 0000000..aad94f9 --- /dev/null +++ b/assets/card_base/Stroke.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:041b63c0964cdd231d08d220cfc236e6fe4ee5643e7373701491ff5f3dc98f40 +size 3940 diff --git a/assets/card_base/Stroke.png.import b/assets/card_base/Stroke.png.import new file mode 100644 index 0000000..668eddd --- /dev/null +++ b/assets/card_base/Stroke.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://crgrple0uik7x" +path="res://.godot/imported/Stroke.png-9acc55e7647197941083043ac51c45a4.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/card_base/Stroke.png" +dest_files=["res://.godot/imported/Stroke.png-9acc55e7647197941083043ac51c45a4.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/energy.png b/assets/energy.png new file mode 100644 index 0000000..29479d0 --- /dev/null +++ b/assets/energy.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9d835c0519e95c077b5b4f681673b4672a0728ad47b86595726f07775993f3eb +size 482598 diff --git a/assets/energy.png.import b/assets/energy.png.import new file mode 100644 index 0000000..d8aecba --- /dev/null +++ b/assets/energy.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://rh3aswb0p7ri" +path="res://.godot/imported/energy.png-d31ae10deb2f267a25814b3eac80d643.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/energy.png" +dest_files=["res://.godot/imported/energy.png-d31ae10deb2f267a25814b3eac80d643.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/cards.tres b/cards.tres new file mode 100644 index 0000000..e4debd9 --- /dev/null +++ b/cards.tres @@ -0,0 +1,8 @@ +[gd_resource type="Theme" load_steps=2 format=3 uid="uid://cj3vs5hq2mcbp"] + +[ext_resource type="FontFile" uid="uid://ncoq4i61plvt" path="res://assets/Bohemian Soul.otf" id="1_yowck"] + +[resource] +default_font = ExtResource("1_yowck") +Label/font_sizes/font_size = 12 +Label/fonts/font = ExtResource("1_yowck") diff --git a/data/cards/baraga.tres b/data/cards/monster/baraga.tres similarity index 100% rename from data/cards/baraga.tres rename to data/cards/monster/baraga.tres diff --git a/data/cards/taiman.tres b/data/cards/monster/taiman.tres similarity index 100% rename from data/cards/taiman.tres rename to data/cards/monster/taiman.tres diff --git a/data/cards/potion.tres b/data/cards/potion.tres deleted file mode 100644 index a68f262..0000000 --- a/data/cards/potion.tres +++ /dev/null @@ -1,16 +0,0 @@ -[gd_resource type="Resource" script_class="SupportCard" load_steps=5 format=3 uid="uid://4eod3m0vc5a8"] - -[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_88lmk"] -script = ExtResource("1_alamh") -magnitude = 5 -effect = ExtResource("2_3x5mu") - -[resource] -script = ExtResource("2_72hmi") -type = "green" -priority = 0 -effects = Array[ExtResource("1_alamh")]([SubResource("Resource_88lmk")]) diff --git a/data/cards/support/potion.tres b/data/cards/support/potion.tres new file mode 100644 index 0000000..96ed2d7 --- /dev/null +++ b/data/cards/support/potion.tres @@ -0,0 +1,20 @@ +[gd_resource type="Resource" script_class="SupportCard" load_steps=6 format=3 uid="uid://4eod3m0vc5a8"] + +[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="Script" path="res://tcg/card/support_card.gd" id="3_6r4k4"] +[ext_resource type="Texture2D" uid="uid://rh3aswb0p7ri" path="res://assets/energy.png" id="3_kyx3v"] + +[sub_resource type="Resource" id="Resource_88lmk"] +script = ExtResource("1_ujm0o") +magnitude = 30 +effect = ExtResource("2_k1cnl") + +[resource] +script = ExtResource("3_6r4k4") +type = "green" +priority = 0 +effects = Array[ExtResource("1_ujm0o")]([SubResource("Resource_88lmk")]) +name = "Potion" +description = "Heal 30 HP" +icon = ExtResource("3_kyx3v") diff --git a/demo_game.tscn b/demo_game.tscn index e5ae8d6..b6c0ea6 100644 --- a/demo_game.tscn +++ b/demo_game.tscn @@ -4,9 +4,9 @@ [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"] +[ext_resource type="Resource" uid="uid://cs7q8i7bvohmj" path="res://data/cards/monster/baraga.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/taiman.tres" id="5_3cm5x"] [node name="DemoGame" type="Control"] layout_mode = 3 diff --git a/tcg/card/card.gd b/tcg/card/card.gd index 5c8826b..e14ff41 100644 --- a/tcg/card/card.gd +++ b/tcg/card/card.gd @@ -1,6 +1,10 @@ extends Resource class_name Card +@export var name: String +@export var description: String +@export var icon: Texture2D + var id: String: get: return resource_path.rsplit(".", true, 1)[0].rsplit("/", true, 1)[1] diff --git a/test_card.gd b/test_card.gd new file mode 100644 index 0000000..a0b8904 --- /dev/null +++ b/test_card.gd @@ -0,0 +1,7 @@ +extends Control + +@export var card: SupportCard + +func _ready() -> void: + $Green.card = card + $Red.card = card diff --git a/test_card.tscn b/test_card.tscn new file mode 100644 index 0000000..94b6965 --- /dev/null +++ b/test_card.tscn @@ -0,0 +1,28 @@ +[gd_scene load_steps=5 format=3 uid="uid://dhm4v4r7he0op"] + +[ext_resource type="Script" path="res://test_card.gd" id="1_tqmas"] +[ext_resource type="PackedScene" uid="uid://dg5amjm1gqi06" path="res://ui/card/GreenCard.tscn" id="2_22pto"] +[ext_resource type="Resource" uid="uid://4eod3m0vc5a8" path="res://data/cards/support/potion.tres" id="2_tbbjy"] +[ext_resource type="PackedScene" uid="uid://cds50kwwhlgam" path="res://ui/card/RedCard.tscn" id="3_7wd2e"] + +[node name="TestCard" 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_tqmas") +card = ExtResource("2_tbbjy") + +[node name="Green" parent="." instance=ExtResource("2_22pto")] +offset_left = 225.0 +offset_top = 165.0 +offset_right = 445.0 +offset_bottom = 485.0 + +[node name="Red" parent="." instance=ExtResource("3_7wd2e")] +offset_left = 699.0 +offset_top = 168.0 +offset_right = 919.0 +offset_bottom = 488.0 diff --git a/ui/card/GreenCard.tscn b/ui/card/GreenCard.tscn new file mode 100644 index 0000000..019163e --- /dev/null +++ b/ui/card/GreenCard.tscn @@ -0,0 +1,165 @@ +[gd_scene load_steps=11 format=3 uid="uid://dg5amjm1gqi06"] + +[ext_resource type="Texture2D" uid="uid://l2nxxhh0pvh8" path="res://assets/card_base/Frame.png" id="1_4ivbl"] +[ext_resource type="Script" path="res://ui/card/card_base.gd" id="1_rpopv"] +[ext_resource type="Texture2D" uid="uid://liitr32ap646" path="res://assets/card_base/G-OuterFill.png" id="2_c6lcl"] +[ext_resource type="Texture2D" uid="uid://crgrple0uik7x" path="res://assets/card_base/Stroke.png" id="3_qajq3"] +[ext_resource type="Texture2D" uid="uid://blejyda8mendg" path="res://assets/card_base/InnerFill.png" id="4_pgomu"] +[ext_resource type="Texture2D" uid="uid://by7ws88pn4tvb" path="res://assets/card_base/Separator.png" id="5_501uu"] +[ext_resource type="Texture2D" uid="uid://0gxplli5krq2" path="res://assets/card_base/Pill.png" id="6_ce7hm"] +[ext_resource type="Theme" uid="uid://cj3vs5hq2mcbp" path="res://cards.tres" id="7_va1d7"] +[ext_resource type="Texture2D" uid="uid://rh3aswb0p7ri" path="res://assets/energy.png" id="8_4yq42"] +[ext_resource type="FontFile" uid="uid://08q3kkwmd4u6" path="res://assets/Inter-Regular.otf" id="10_c2ugn"] + +[node name="CardBase" type="Control" node_paths=PackedStringArray("card_name_label", "card_desc_label", "icon_rect")] +layout_mode = 3 +anchors_preset = 0 +offset_right = 220.0 +offset_bottom = 320.0 +script = ExtResource("1_rpopv") +card_name_label = NodePath("MarginContainer/Label") +card_desc_label = NodePath("MarginContainer/DescriptionLabel") +icon_rect = NodePath("MarginContainer/Icon") + +[node name="Frame" type="TextureRect" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("1_4ivbl") +expand_mode = 1 + +[node name="MarginContainer" type="Control" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = 4.0 +offset_top = 3.0 +offset_right = -5.0 +offset_bottom = -4.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="TextureRect" type="TextureRect" parent="MarginContainer"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("2_c6lcl") +expand_mode = 1 + +[node name="OuterStroke" type="NinePatchRect" parent="MarginContainer"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("3_qajq3") + +[node name="TextureRect2" type="TextureRect" parent="MarginContainer"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_top = 62.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("4_pgomu") +expand_mode = 1 + +[node name="InnerStroke" type="NinePatchRect" parent="MarginContainer"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_top = 62.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("3_qajq3") + +[node name="TextureRect3" type="TextureRect" parent="MarginContainer"] +layout_mode = 1 +anchors_preset = -1 +anchor_left = 0.01 +anchor_top = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = -0.0100002 +offset_top = -112.0 +offset_right = -1.0 +offset_bottom = -110.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("5_501uu") +expand_mode = 1 +metadata/_edit_use_anchors_ = true + +[node name="TextureRect4" type="NinePatchRect" parent="MarginContainer"] +modulate = Color(0.356863, 0.54902, 0.243137, 1) +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = 4.5 +offset_top = 30.5 +offset_right = 90.5 +offset_bottom = 60.5 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("6_ce7hm") + +[node name="Label" type="Label" parent="MarginContainer"] +layout_mode = 1 +anchors_preset = 10 +anchor_right = 1.0 +offset_left = 2.0 +offset_top = 16.0 +offset_right = -3.0 +offset_bottom = 50.0 +grow_horizontal = 2 +theme = ExtResource("7_va1d7") +theme_override_colors/font_color = Color(0.576471, 0.788235, 0.819608, 1) +theme_override_font_sizes/font_size = 24 +text = "green card" +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="Label2" type="Label" parent="MarginContainer"] +layout_mode = 0 +offset_left = 118.0 +offset_top = 190.0 +offset_right = 188.0 +offset_bottom = 213.0 +theme = ExtResource("7_va1d7") +text = "Green card" +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="Icon" type="TextureRect" parent="MarginContainer"] +offset_left = 26.0 +offset_top = 74.0 +offset_right = 169.0 +offset_bottom = 179.0 +texture = ExtResource("8_4yq42") +expand_mode = 1 +stretch_mode = 6 + +[node name="DescriptionLabel" type="Label" parent="MarginContainer"] +offset_left = 11.0 +offset_top = 224.0 +offset_right = 200.0 +offset_bottom = 302.0 +theme = ExtResource("7_va1d7") +theme_override_fonts/font = ExtResource("10_c2ugn") +theme_override_font_sizes/font_size = 12 +text = "If your monster is supposed to be dead, keep it alive at 10 HP" +horizontal_alignment = 1 +autowrap_mode = 3 diff --git a/ui/card/RedCard.tscn b/ui/card/RedCard.tscn new file mode 100644 index 0000000..3744e13 --- /dev/null +++ b/ui/card/RedCard.tscn @@ -0,0 +1,167 @@ +[gd_scene load_steps=11 format=3 uid="uid://cds50kwwhlgam"] + +[ext_resource type="Script" path="res://ui/card/card_base.gd" id="1_d22a5"] +[ext_resource type="Texture2D" uid="uid://l2nxxhh0pvh8" path="res://assets/card_base/Frame.png" id="1_x5ex0"] +[ext_resource type="Texture2D" uid="uid://ip7xjs20pd3d" path="res://assets/card_base/R-OuterFill.png" id="2_xjg8y"] +[ext_resource type="Texture2D" uid="uid://crgrple0uik7x" path="res://assets/card_base/Stroke.png" id="3_q71h0"] +[ext_resource type="Texture2D" uid="uid://blejyda8mendg" path="res://assets/card_base/InnerFill.png" id="4_2fw8n"] +[ext_resource type="Texture2D" uid="uid://by7ws88pn4tvb" path="res://assets/card_base/Separator.png" id="5_n3v14"] +[ext_resource type="Texture2D" uid="uid://0gxplli5krq2" path="res://assets/card_base/Pill.png" id="6_wrd2a"] +[ext_resource type="Theme" uid="uid://cj3vs5hq2mcbp" path="res://cards.tres" id="7_fp6ys"] +[ext_resource type="FontFile" uid="uid://08q3kkwmd4u6" path="res://assets/Inter-Regular.otf" id="9_vilw6"] +[ext_resource type="Texture2D" uid="uid://rh3aswb0p7ri" path="res://assets/energy.png" id="10_2t0ey"] + +[node name="CardBase" type="Control" node_paths=PackedStringArray("card_name_label", "card_desc_label", "icon_rect")] +layout_mode = 3 +anchors_preset = 0 +offset_right = 220.0 +offset_bottom = 320.0 +script = ExtResource("1_d22a5") +card_name_label = NodePath("MarginContainer/Title") +card_desc_label = NodePath("MarginContainer/DescriptionLabel") +icon_rect = NodePath("MarginContainer/Icon") + +[node name="Frame" type="TextureRect" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("1_x5ex0") +expand_mode = 1 + +[node name="MarginContainer" type="Control" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = 4.0 +offset_top = 3.0 +offset_right = -5.0 +offset_bottom = -4.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="TextureRect" type="TextureRect" parent="MarginContainer"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("2_xjg8y") +expand_mode = 1 + +[node name="OuterStroke" type="NinePatchRect" parent="MarginContainer"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("3_q71h0") + +[node name="TextureRect2" type="TextureRect" parent="MarginContainer"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_top = 62.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("4_2fw8n") +expand_mode = 1 + +[node name="InnerStroke" type="NinePatchRect" parent="MarginContainer"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_top = 62.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("3_q71h0") + +[node name="TextureRect3" type="TextureRect" parent="MarginContainer"] +layout_mode = 1 +anchors_preset = -1 +anchor_left = 0.01 +anchor_top = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = -0.0100002 +offset_top = -112.0 +offset_right = -1.0 +offset_bottom = -110.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("5_n3v14") +expand_mode = 1 +metadata/_edit_use_anchors_ = true + +[node name="TextureRect4" type="NinePatchRect" parent="MarginContainer"] +modulate = Color(0.54902, 0.243137, 0.243137, 1) +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = 4.5 +offset_top = 30.5 +offset_right = 90.5 +offset_bottom = 60.5 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("6_wrd2a") + +[node name="Title" type="Label" parent="MarginContainer"] +layout_mode = 1 +anchors_preset = 10 +anchor_right = 1.0 +offset_left = 2.0 +offset_top = 16.0 +offset_right = -3.0 +offset_bottom = 50.0 +grow_horizontal = 2 +theme = ExtResource("7_fp6ys") +theme_override_colors/font_color = Color(0.819608, 0.576471, 0.576471, 1) +theme_override_font_sizes/font_size = 24 +text = "red card" +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="PillLabel" type="Label" parent="MarginContainer"] +layout_mode = 0 +offset_left = 118.0 +offset_top = 190.0 +offset_right = 188.0 +offset_bottom = 213.0 +theme = ExtResource("7_fp6ys") +text = "Red card" +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="DescriptionLabel" type="Label" parent="MarginContainer"] +layout_mode = 0 +offset_left = 11.0 +offset_top = 224.0 +offset_right = 200.0 +offset_bottom = 302.0 +theme = ExtResource("7_fp6ys") +theme_override_fonts/font = ExtResource("9_vilw6") +theme_override_font_sizes/font_size = 12 +text = "If your monster is supposed to be dead, keep it alive at 10 HP" +horizontal_alignment = 1 +autowrap_mode = 3 + +[node name="Icon" type="TextureRect" parent="MarginContainer"] +layout_mode = 0 +offset_left = 30.0 +offset_top = 77.0 +offset_right = 173.0 +offset_bottom = 182.0 +texture = ExtResource("10_2t0ey") +expand_mode = 1 +stretch_mode = 6 diff --git a/ui/card/card_base.gd b/ui/card/card_base.gd new file mode 100644 index 0000000..12acc63 --- /dev/null +++ b/ui/card/card_base.gd @@ -0,0 +1,20 @@ +extends Control + +@export var card_name_label: Label +@export var card_desc_label: Label +@export var icon_rect: TextureRect + +var _card: SupportCard +var card: SupportCard: + get: + return _card + set(value): + _update(value) + _card = value + +func _update(card: SupportCard): + card_name_label.text = card.name + card_desc_label.text = card.description + icon_rect.texture = card.icon + + From 5e3940b811ce0e586a69dba1cbd0b55abed203b1 Mon Sep 17 00:00:00 2001 From: istamarahsan Date: Sat, 25 Jan 2025 18:46:32 +0700 Subject: [PATCH 06/29] refactor: rename to card template --- test_card.tscn | 4 ++-- ui/{card => card_template}/card_base.gd | 0 ui/card_template/monster_card.tscn | 9 +++++++++ .../support_card_green.tscn} | 2 +- .../RedCard.tscn => card_template/support_card_red.tscn} | 2 +- 5 files changed, 13 insertions(+), 4 deletions(-) rename ui/{card => card_template}/card_base.gd (100%) create mode 100644 ui/card_template/monster_card.tscn rename ui/{card/GreenCard.tscn => card_template/support_card_green.tscn} (98%) rename ui/{card/RedCard.tscn => card_template/support_card_red.tscn} (98%) diff --git a/test_card.tscn b/test_card.tscn index 94b6965..ccbb6d6 100644 --- a/test_card.tscn +++ b/test_card.tscn @@ -1,9 +1,9 @@ [gd_scene load_steps=5 format=3 uid="uid://dhm4v4r7he0op"] [ext_resource type="Script" path="res://test_card.gd" id="1_tqmas"] -[ext_resource type="PackedScene" uid="uid://dg5amjm1gqi06" path="res://ui/card/GreenCard.tscn" id="2_22pto"] +[ext_resource type="PackedScene" uid="uid://dg5amjm1gqi06" path="res://ui/card_template/support_card_green.tscn" id="2_22pto"] [ext_resource type="Resource" uid="uid://4eod3m0vc5a8" path="res://data/cards/support/potion.tres" id="2_tbbjy"] -[ext_resource type="PackedScene" uid="uid://cds50kwwhlgam" path="res://ui/card/RedCard.tscn" id="3_7wd2e"] +[ext_resource type="PackedScene" uid="uid://cds50kwwhlgam" path="res://ui/card_template/support_card_red.tscn" id="3_7wd2e"] [node name="TestCard" type="Control"] layout_mode = 3 diff --git a/ui/card/card_base.gd b/ui/card_template/card_base.gd similarity index 100% rename from ui/card/card_base.gd rename to ui/card_template/card_base.gd diff --git a/ui/card_template/monster_card.tscn b/ui/card_template/monster_card.tscn new file mode 100644 index 0000000..3d9e3de --- /dev/null +++ b/ui/card_template/monster_card.tscn @@ -0,0 +1,9 @@ +[gd_scene format=3 uid="uid://bhrelvt51cbp2"] + +[node name="MonsterCard" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 diff --git a/ui/card/GreenCard.tscn b/ui/card_template/support_card_green.tscn similarity index 98% rename from ui/card/GreenCard.tscn rename to ui/card_template/support_card_green.tscn index 019163e..6bf7743 100644 --- a/ui/card/GreenCard.tscn +++ b/ui/card_template/support_card_green.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=11 format=3 uid="uid://dg5amjm1gqi06"] [ext_resource type="Texture2D" uid="uid://l2nxxhh0pvh8" path="res://assets/card_base/Frame.png" id="1_4ivbl"] -[ext_resource type="Script" path="res://ui/card/card_base.gd" id="1_rpopv"] +[ext_resource type="Script" path="res://ui/card_template/card_base.gd" id="1_rpopv"] [ext_resource type="Texture2D" uid="uid://liitr32ap646" path="res://assets/card_base/G-OuterFill.png" id="2_c6lcl"] [ext_resource type="Texture2D" uid="uid://crgrple0uik7x" path="res://assets/card_base/Stroke.png" id="3_qajq3"] [ext_resource type="Texture2D" uid="uid://blejyda8mendg" path="res://assets/card_base/InnerFill.png" id="4_pgomu"] diff --git a/ui/card/RedCard.tscn b/ui/card_template/support_card_red.tscn similarity index 98% rename from ui/card/RedCard.tscn rename to ui/card_template/support_card_red.tscn index 3744e13..d06b8dc 100644 --- a/ui/card/RedCard.tscn +++ b/ui/card_template/support_card_red.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=11 format=3 uid="uid://cds50kwwhlgam"] -[ext_resource type="Script" path="res://ui/card/card_base.gd" id="1_d22a5"] +[ext_resource type="Script" path="res://ui/card_template/card_base.gd" id="1_d22a5"] [ext_resource type="Texture2D" uid="uid://l2nxxhh0pvh8" path="res://assets/card_base/Frame.png" id="1_x5ex0"] [ext_resource type="Texture2D" uid="uid://ip7xjs20pd3d" path="res://assets/card_base/R-OuterFill.png" id="2_xjg8y"] [ext_resource type="Texture2D" uid="uid://crgrple0uik7x" path="res://assets/card_base/Stroke.png" id="3_q71h0"] From 6c6e1b328989d9ca8162c2957ac5b9a926bceb91 Mon Sep 17 00:00:00 2001 From: Kenshia <73539778+Kenshia@users.noreply.github.com> Date: Sat, 25 Jan 2025 18:47:56 +0700 Subject: [PATCH 07/29] feat: more multiplayer --- demo_game.gd | 112 +++++++++++++-- demo_game.tscn | 6 +- export_presets.cfg | 208 +++++++++++++++++++++++++++ main.gd | 87 ++++++----- main.tscn | 65 ++------- player_side.gd | 40 +++++- project.godot | 1 + tcg/match/action/action_skip_card.gd | 2 + tcg/match/match_manager.gd | 12 ++ 9 files changed, 429 insertions(+), 104 deletions(-) create mode 100644 tcg/match/action/action_skip_card.gd diff --git a/demo_game.gd b/demo_game.gd index 359338d..36c0914 100644 --- a/demo_game.gd +++ b/demo_game.gd @@ -1,4 +1,10 @@ extends Control +class_name DemoGame + +signal own_played_card(card: Card) +signal opponent_played_card(card: Card) +signal own_played_rts(move: String) +signal opponent_played_rts(move: String) @export var player_1_deck: Array[Card] @export var player_2_deck: Array[Card] @@ -7,6 +13,8 @@ extends Control @onready var opponent_side = $Opponent @onready var start_game_btn = $StartGameButton +var id_to_card: Dictionary = {} + var player_action_queue: Dictionary var player_1_action: Action: get: @@ -19,14 +27,30 @@ var player_2_action: Action: set(value): player_action_queue[MatchManager.PLAYER_2_ID] = value -func _ready() -> void: +var id +var signal_connected := false + +func init(player_id: int) -> void: + id = player_id + + id_to_card.clear() + + var cards = player_1_deck.duplicate() + cards.append_array(player_2_deck) + for card in cards: + if card.id not in id_to_card: + id_to_card[card.id] = card + 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) + own_side.attach(match_manager, player_id == MatchManager.PLAYER_1_ID) + opponent_side.attach(match_manager, player_id == MatchManager.PLAYER_2_ID) + + if !signal_connected: + match_manager.state_transitioned.connect(_on_match_manager_state_transitioned) + signal_connected = true var transition_history: Array[PhaseTransition] = [] func _on_match_manager_state_transitioned(transition: PhaseTransition): @@ -35,28 +59,100 @@ func _on_match_manager_state_transitioned(transition: PhaseTransition): 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({}) + pass + +func rpc_start_game() -> void: match_manager.resolve({}) -func _on_own_play_card(card: Card) -> void: - player_1_action = ActionPlayCard.new(card) +func rpc_own_play_card(id: String) -> void: + if !id.is_empty(): + var card = id_to_card[id] + player_1_action = ActionPlayCard.new(card) + else: + player_1_action = ActionSkipCard.new() + + print(self.id, " rpc_own_play_card", player_1_action, player_2_action) + 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) +func _on_own_play_card(card: Card) -> void: + if card: + player_1_action = ActionPlayCard.new(card) + own_played_card.emit(card) + else: + player_1_action = ActionSkipCard.new() + own_played_card.emit(null) + + print(id, " _on_own_play_card", player_1_action, player_2_action) + + if player_2_action: + match_manager.resolve(player_action_queue) + player_action_queue.clear() + +func rpc_opponent_play_card(id: String) -> void: + if !id.is_empty(): + var card = id_to_card[id] + player_2_action = ActionPlayCard.new(card) + else: + player_2_action = ActionSkipCard.new() + + print(self.id , " rpc_opponent_play_card", player_1_action, player_2_action) + if player_1_action: match_manager.resolve(player_action_queue) player_action_queue.clear() +func _on_opponent_play_card(card: Card) -> void: + if card: + player_2_action = ActionPlayCard.new(card) + opponent_played_card.emit(card) + else: + player_2_action = ActionSkipCard.new() + opponent_played_card.emit(null) + + print(id, " _on_opponent_play_card", player_1_action, player_2_action) + + if player_1_action: + match_manager.resolve(player_action_queue) + player_action_queue.clear() + +func rpc_own_rps_move(move: String) -> void: + player_1_action = ActionRPSMove.new(move) + + print(id, " rpc_own_rps_move", player_1_action, player_2_action, move) + + if player_2_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) + own_played_rts.emit(move) + + print(id, " _on_own_rps_move", player_1_action, player_2_action, move) + if player_2_action: match_manager.resolve(player_action_queue) player_action_queue.clear() +func rpc_opponent_rps_move(move: String) -> void: + player_2_action = ActionRPSMove.new(move) + + print(id, " rpc_opponent_rps_move", player_1_action, player_2_action, move) + + if player_1_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) + opponent_played_rts.emit(move) + + print(id, " rpc_opponent_rps_move", player_1_action, player_2_action, 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 index e5ae8d6..697dd3b 100644 --- a/demo_game.tscn +++ b/demo_game.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=8 format=3 uid="uid://bgc0u117jqyr1"] +[gd_scene load_steps=8 format=3 uid="uid://l2ehohbd1xhk"] [ext_resource type="Script" path="res://demo_game.gd" id="1_jn16u"] [ext_resource type="Script" path="res://player_side.gd" id="2_w4tnt"] @@ -16,8 +16,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")]) -player_2_deck = Array[ExtResource("2_xuft0")]([ExtResource("5_3cm5x"), ExtResource("4_kkhfk"), ExtResource("4_kkhfk")]) +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")]) [node name="Own" type="VBoxContainer" parent="." node_paths=PackedStringArray("deck", "monster_name_label", "monster_health_label", "incoming_damage_label", "energy_label")] layout_mode = 1 diff --git a/export_presets.cfg b/export_presets.cfg index 82e3d28..1c2b9dc 100644 --- a/export_presets.cfg +++ b/export_presets.cfg @@ -130,3 +130,211 @@ Unregister-ScheduledTask -TaskName godot_remote_debug -Confirm:$false -ErrorActi ssh_remote_deploy/cleanup_script="Stop-ScheduledTask -TaskName godot_remote_debug -ErrorAction:SilentlyContinue Unregister-ScheduledTask -TaskName godot_remote_debug -Confirm:$false -ErrorAction:SilentlyContinue Remove-Item -Recurse -Force '{temp_dir}'" + +[preset.2] + +name="Android" +platform="Android" +runnable=true +advanced_options=false +dedicated_server=false +custom_features="" +export_filter="all_resources" +include_filter="" +exclude_filter="" +export_path="" +encryption_include_filters="" +encryption_exclude_filters="" +encrypt_pck=false +encrypt_directory=false +script_export_mode=2 + +[preset.2.options] + +custom_template/debug="" +custom_template/release="" +gradle_build/use_gradle_build=false +gradle_build/gradle_build_directory="" +gradle_build/android_source_template="" +gradle_build/compress_native_libraries=false +gradle_build/export_format=0 +gradle_build/min_sdk="" +gradle_build/target_sdk="" +architectures/armeabi-v7a=false +architectures/arm64-v8a=true +architectures/x86=false +architectures/x86_64=false +version/code=1 +version/name="" +package/unique_name="com.example.$genname" +package/name="" +package/signed=true +package/app_category=2 +package/retain_data_on_uninstall=false +package/exclude_from_recents=false +package/show_in_android_tv=false +package/show_in_app_library=true +package/show_as_launcher_app=false +launcher_icons/main_192x192="" +launcher_icons/adaptive_foreground_432x432="" +launcher_icons/adaptive_background_432x432="" +graphics/opengl_debug=false +xr_features/xr_mode=0 +screen/immersive_mode=true +screen/support_small=true +screen/support_normal=true +screen/support_large=true +screen/support_xlarge=true +user_data_backup/allow=false +command_line/extra_args="" +apk_expansion/enable=false +apk_expansion/SALT="" +apk_expansion/public_key="" +permissions/custom_permissions=PackedStringArray() +permissions/access_checkin_properties=false +permissions/access_coarse_location=false +permissions/access_fine_location=false +permissions/access_location_extra_commands=false +permissions/access_mock_location=false +permissions/access_network_state=false +permissions/access_surface_flinger=false +permissions/access_wifi_state=false +permissions/account_manager=false +permissions/add_voicemail=false +permissions/authenticate_accounts=false +permissions/battery_stats=false +permissions/bind_accessibility_service=false +permissions/bind_appwidget=false +permissions/bind_device_admin=false +permissions/bind_input_method=false +permissions/bind_nfc_service=false +permissions/bind_notification_listener_service=false +permissions/bind_print_service=false +permissions/bind_remoteviews=false +permissions/bind_text_service=false +permissions/bind_vpn_service=false +permissions/bind_wallpaper=false +permissions/bluetooth=false +permissions/bluetooth_admin=false +permissions/bluetooth_privileged=false +permissions/brick=false +permissions/broadcast_package_removed=false +permissions/broadcast_sms=false +permissions/broadcast_sticky=false +permissions/broadcast_wap_push=false +permissions/call_phone=false +permissions/call_privileged=false +permissions/camera=false +permissions/capture_audio_output=false +permissions/capture_secure_video_output=false +permissions/capture_video_output=false +permissions/change_component_enabled_state=false +permissions/change_configuration=false +permissions/change_network_state=false +permissions/change_wifi_multicast_state=false +permissions/change_wifi_state=false +permissions/clear_app_cache=false +permissions/clear_app_user_data=false +permissions/control_location_updates=false +permissions/delete_cache_files=false +permissions/delete_packages=false +permissions/device_power=false +permissions/diagnostic=false +permissions/disable_keyguard=false +permissions/dump=false +permissions/expand_status_bar=false +permissions/factory_test=false +permissions/flashlight=false +permissions/force_back=false +permissions/get_accounts=false +permissions/get_package_size=false +permissions/get_tasks=false +permissions/get_top_activity_info=false +permissions/global_search=false +permissions/hardware_test=false +permissions/inject_events=false +permissions/install_location_provider=false +permissions/install_packages=false +permissions/install_shortcut=false +permissions/internal_system_window=false +permissions/internet=false +permissions/kill_background_processes=false +permissions/location_hardware=false +permissions/manage_accounts=false +permissions/manage_app_tokens=false +permissions/manage_documents=false +permissions/manage_external_storage=false +permissions/master_clear=false +permissions/media_content_control=false +permissions/modify_audio_settings=false +permissions/modify_phone_state=false +permissions/mount_format_filesystems=false +permissions/mount_unmount_filesystems=false +permissions/nfc=false +permissions/persistent_activity=false +permissions/post_notifications=false +permissions/process_outgoing_calls=false +permissions/read_calendar=false +permissions/read_call_log=false +permissions/read_contacts=false +permissions/read_external_storage=false +permissions/read_frame_buffer=false +permissions/read_history_bookmarks=false +permissions/read_input_state=false +permissions/read_logs=false +permissions/read_phone_state=false +permissions/read_profile=false +permissions/read_sms=false +permissions/read_social_stream=false +permissions/read_sync_settings=false +permissions/read_sync_stats=false +permissions/read_user_dictionary=false +permissions/reboot=false +permissions/receive_boot_completed=false +permissions/receive_mms=false +permissions/receive_sms=false +permissions/receive_wap_push=false +permissions/record_audio=false +permissions/reorder_tasks=false +permissions/restart_packages=false +permissions/send_respond_via_message=false +permissions/send_sms=false +permissions/set_activity_watcher=false +permissions/set_alarm=false +permissions/set_always_finish=false +permissions/set_animation_scale=false +permissions/set_debug_app=false +permissions/set_orientation=false +permissions/set_pointer_speed=false +permissions/set_preferred_applications=false +permissions/set_process_limit=false +permissions/set_time=false +permissions/set_time_zone=false +permissions/set_wallpaper=false +permissions/set_wallpaper_hints=false +permissions/signal_persistent_processes=false +permissions/status_bar=false +permissions/subscribed_feeds_read=false +permissions/subscribed_feeds_write=false +permissions/system_alert_window=false +permissions/transmit_ir=false +permissions/uninstall_shortcut=false +permissions/update_device_stats=false +permissions/use_credentials=false +permissions/use_sip=false +permissions/vibrate=false +permissions/wake_lock=false +permissions/write_apn_settings=false +permissions/write_calendar=false +permissions/write_call_log=false +permissions/write_contacts=false +permissions/write_external_storage=false +permissions/write_gservices=false +permissions/write_history_bookmarks=false +permissions/write_profile=false +permissions/write_secure_settings=false +permissions/write_settings=false +permissions/write_sms=false +permissions/write_social_stream=false +permissions/write_sync_settings=false +permissions/write_user_dictionary=false diff --git a/main.gd b/main.gd index 3f1095d..5ba3478 100644 --- a/main.gd +++ b/main.gd @@ -1,41 +1,41 @@ extends Node +class_name MainNode const PORT = 25565 const PORT_RANGE := 10 const MAX_CONNECTIONS = 20 -var counter = 0 - @onready var before_connect_container = get_node("BeforeConnect") as Container -@onready var host_text_edit = get_node("%HostTextEdit") as TextEdit @onready var connect_button = get_node("%ConnectButton") as Button @onready var host_button = get_node("%HostButton") as Button @onready var server_discovery = get_node("%ServerDiscovery") as ServerDiscovery -@onready var after_connect_container = get_node("%AfterConnect") as Container -@onready var counter_label = get_node("%CounterLabel") as Label -@onready var decrement_button = get_node("%DecrementButton") as Button -@onready var increment_button = get_node("%IncrementButton") as Button +@onready var after_connect_container = get_node("%AfterConnect") as Node @onready var disconnect_button = get_node("%DisconnectButton") as Button -@onready var start_game_button = get_node("%StartGameButton") as Button + +@onready var demo_game = get_node("AfterConnect/DemoGame") as DemoGame +@onready var start_game_button = (get_node("AfterConnect/DemoGame") as DemoGame).start_game_btn + var active_port: int var server_buttons: Dictionary = Dictionary() +var base_seed: int func _clean_room(): # this is if someone left the room and we will just clean the game room again # should only called on host - _set_counter(0) + # need to clean for server pass func _on_start_game_clicked(): if !multiplayer.multiplayer_peer: return - if !multiplayer.get_unique_id() != 1: + if !multiplayer.is_server(): return if (multiplayer.get_peers().size() == 0): return # do start game here, should only run on host + _start_game.rpc() pass func _ready() -> void: @@ -51,13 +51,45 @@ func _ready() -> void: #multiplayer.connection_failed.connect(_on_connected_fail) multiplayer.server_disconnected.connect(_on_server_disconnected) - increment_button.button_up.connect(func(): _increment.rpc()) - decrement_button.button_up.connect(func(): _decrement.rpc()) disconnect_button.button_up.connect(_on_disconnect_clicked) connect_button.get_parent().remove_child(connect_button) server_discovery.server_added.connect(_on_server_added) server_discovery.server_removed.connect(_on_server_removed) + + demo_game.own_played_card.connect(func (card): _on_own_played_card.rpc(card.id if card else "")) + demo_game.opponent_played_card.connect(func (card): _on_opponent_played_card.rpc(card.id if card else "")) + demo_game.own_played_rts.connect(func (move): _on_own_played_rts.rpc(move)) + demo_game.opponent_played_rts.connect(func (move): _on_opponent_played_rts.rpc(move)) + +@rpc("any_peer", "call_remote", "reliable") +func _on_own_played_card(card_id: String): + demo_game.rpc_own_play_card(card_id) + +@rpc("any_peer", "call_remote", "reliable") +func _on_opponent_played_card(card_id: String): + demo_game.rpc_opponent_play_card(card_id) + +@rpc("any_peer", "call_remote", "reliable") +func _on_own_played_rts(move: String): + demo_game.rpc_own_rps_move(move) + +@rpc("any_peer", "call_remote", "reliable") +func _on_opponent_played_rts(move: String): + demo_game.rpc_opponent_rps_move(move) + +@rpc("authority", "call_local", "reliable") +func _sync_seed(seed: int): + seed(seed) + +@rpc("authority", "call_local", "reliable") +func _start_game(): + if multiplayer.is_server(): + demo_game.init(MatchManager.PLAYER_1_ID) + else: + demo_game.init(MatchManager.PLAYER_2_ID) + + demo_game.rpc_start_game() func _on_disconnect_clicked(): if (multiplayer.is_server()): @@ -118,8 +150,12 @@ func _on_host_pressed(): _on_connected_ok() + start_game_button.disabled = true start_game_button.text = "Start Game (Not enough player)" + base_seed = randi() + _sync_seed.rpc(base_seed) + server_discovery.enable_server(active_port) func is_port_available(port: int) -> bool: @@ -133,26 +169,13 @@ func is_port_available(port: int) -> bool: else: return false -@rpc("any_peer", "call_local") -func _increment(): - counter += 1 - counter_label.text = str(counter) - -@rpc("any_peer", "call_local") -func _decrement(): - counter -= 1 - counter_label.text = str(counter) - -@rpc("authority", "call_remote") -func _set_counter(value: int): - counter = value - counter_label.text = str(counter) - func _on_player_connected(id: int): if multiplayer.get_unique_id() == 1: - _set_counter.rpc_id(id, counter) + + _sync_seed.rpc(base_seed) if (multiplayer.get_peers().size() > 0): + start_game_button.disabled = false start_game_button.text = "Start Game" server_discovery.disable_server() @@ -165,22 +188,20 @@ func _on_player_disconnected(id): if (id != 1 and multiplayer.get_unique_id() == 1): _clean_room() + start_game_button.disabled = true start_game_button.text = "Start Game (Not enough player)" server_discovery.enable_server(active_port) func _on_connected_ok(): $AfterConnect.visible = true $BeforeConnect.visible = false - counter_label.text = str(counter) if (multiplayer.is_server()): disconnect_button.text = "Disconnect (Host)" - if start_game_button.get_parent() != after_connect_container: - after_connect_container.add_child(start_game_button) + start_game_button.visible = true else: disconnect_button.text = "Disconnect" - if start_game_button.get_parent() == after_connect_container: - after_connect_container.remove_child(start_game_button) + start_game_button.visible = false func _on_connected_fail(): pass diff --git a/main.tscn b/main.tscn index d1043f9..523431c 100644 --- a/main.tscn +++ b/main.tscn @@ -1,7 +1,8 @@ -[gd_scene load_steps=3 format=3 uid="uid://c7gn46af6whf8"] +[gd_scene load_steps=4 format=3 uid="uid://c7gn46af6whf8"] [ext_resource type="Script" path="res://main.gd" id="1_e0ud3"] [ext_resource type="Script" path="res://server_discovery.gd" id="2_hed18"] +[ext_resource type="PackedScene" uid="uid://l2ehohbd1xhk" path="res://demo_game.tscn" id="3_2ln6b"] [node name="Main" type="Control"] layout_mode = 3 @@ -28,18 +29,6 @@ grow_horizontal = 2 grow_vertical = 2 alignment = 1 -[node name="HostTextEdit" type="TextEdit" parent="BeforeConnect"] -unique_name_in_owner = true -layout_mode = 2 -size_flags_vertical = 3 -placeholder_text = "192.168.*.*" - -[node name="RefreshButton" type="Button" parent="BeforeConnect"] -unique_name_in_owner = true -custom_minimum_size = Vector2(0, 64) -layout_mode = 2 -text = "Refresh" - [node name="HostButton" type="Button" parent="BeforeConnect"] unique_name_in_owner = true custom_minimum_size = Vector2(0, 64) @@ -59,54 +48,24 @@ unique_name_in_owner = true unique_name_in_owner = true script = ExtResource("2_hed18") -[node name="AfterConnect" type="VBoxContainer" parent="."] +[node name="AfterConnect" type="Control" parent="."] unique_name_in_owner = true visible = false layout_mode = 1 -anchors_preset = 8 -anchor_left = 0.5 -anchor_top = 0.5 -anchor_right = 0.5 -anchor_bottom = 0.5 -offset_left = -187.5 -offset_top = -88.5 -offset_right = 187.5 -offset_bottom = 88.5 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 -[node name="CounterLabel" type="Label" parent="AfterConnect"] -unique_name_in_owner = true -layout_mode = 2 -size_flags_vertical = 3 -theme_override_font_sizes/font_size = 64 -text = "1" -horizontal_alignment = 1 -vertical_alignment = 1 +[node name="DemoGame" parent="AfterConnect" instance=ExtResource("3_2ln6b")] +layout_mode = 1 [node name="DisconnectButton" type="Button" parent="AfterConnect"] unique_name_in_owner = true layout_mode = 2 -size_flags_horizontal = 3 +offset_left = 966.0 +offset_right = 1152.0 +offset_bottom = 31.0 +size_flags_horizontal = 8 text = "Disconnect" - -[node name="Actions" type="HBoxContainer" parent="AfterConnect"] -layout_mode = 2 - -[node name="DecrementButton" type="Button" parent="AfterConnect/Actions"] -unique_name_in_owner = true -layout_mode = 2 -size_flags_horizontal = 3 -text = "-" - -[node name="IncrementButton" type="Button" parent="AfterConnect/Actions"] -unique_name_in_owner = true -layout_mode = 2 -size_flags_horizontal = 3 -text = "+" - -[node name="StartGameButton" type="Button" parent="AfterConnect"] -unique_name_in_owner = true -layout_mode = 2 -size_flags_horizontal = 3 -text = "Start Game" diff --git a/player_side.gd b/player_side.gd index 03eddf3..d834319 100644 --- a/player_side.gd +++ b/player_side.gd @@ -10,10 +10,15 @@ signal rps_move(move: String) @export var energy_label: Label var match_manager: MatchManager +var show_buttons: bool +var signal_connected: bool -func attach(match_manager: MatchManager): +func attach(match_manager: MatchManager, show_buttons: bool = true): + self.show_buttons = show_buttons self.match_manager = match_manager - match_manager.state_transitioned.connect(_on_update) + if !signal_connected: + match_manager.state_transitioned.connect(_on_update) + signal_connected = true func _on_update(transition): for child in deck.get_children(): @@ -28,13 +33,28 @@ func _on_update(transition): monster_health_label.text = "Health: " + str(monster.health) 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]: + + if ( + match_manager.phase != Match.Phase.SUMMON && show_buttons + ) or ( + match_manager.phase == Match.Phase.SUMMON and player.monster and player.monster.health > 0 && show_buttons + ): + var skip_btn = Button.new() + skip_btn.text = "Skip" + skip_btn.button_up.connect(func (): play_card.emit(null)) + deck.add_child(skip_btn) + 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": + #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 + + if !show_buttons : continue + var btn = Button.new() btn.text = card.id btn.button_up.connect(func (): play_card.emit(card)) @@ -44,10 +64,16 @@ func _on_update(transition): 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 + ) or ( + card is MonsterCard and match_manager.phase == Match.Phase.SUMMON and player.monster and player.monster.health > 0 ) deck.add_child(btn) if match_manager.phase == Match.Phase.RPS: for move in ["rock", "paper", "scissors"]: + + if !show_buttons: + continue + var btn = Button.new() btn.text = move btn.button_up.connect(func (): rps_move.emit(move)) diff --git a/project.godot b/project.godot index f8f23d6..3f421a3 100644 --- a/project.godot +++ b/project.godot @@ -22,3 +22,4 @@ Match="*res://tcg/match/match.gd" [rendering] renderer/rendering_method="mobile" +textures/vram_compression/import_etc2_astc=true diff --git a/tcg/match/action/action_skip_card.gd b/tcg/match/action/action_skip_card.gd new file mode 100644 index 0000000..a0fdf46 --- /dev/null +++ b/tcg/match/action/action_skip_card.gd @@ -0,0 +1,2 @@ +extends Action +class_name ActionSkipCard diff --git a/tcg/match/match_manager.gd b/tcg/match/match_manager.gd index 19cfe87..814b138 100644 --- a/tcg/match/match_manager.gd +++ b/tcg/match/match_manager.gd @@ -29,6 +29,14 @@ 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] + + 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.shuffle() players[player_id] = MatchPlayer.new(player_id, deck_shuffled) @@ -75,11 +83,13 @@ func resolve(action_by_player_id: Dictionary) -> PhaseTransition: "player": player_1, "card": player_1_action.card }) + player_1.hand.erase(player_1_action.card) if player_2_action is ActionPlayCard: support_cards.append({ "player": player_2, "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 @@ -102,11 +112,13 @@ func resolve(action_by_player_id: Dictionary) -> PhaseTransition: "player": player_1, "card": player_1_action.card }) + player_1.hand.erase(player_1_action.card) if player_2_action is ActionPlayCard: support_cards.append({ "player": player_2, "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 From bebb7b467b52bceb3b8adb34a75b6145dacd6471 Mon Sep 17 00:00:00 2001 From: kennetha123 Date: Sat, 25 Jan 2025 22:00:20 +0700 Subject: [PATCH 08/29] wip: monster card --- assets/card_base/Illustrated BG.png | 3 + assets/card_base/Illustrated BG.png.import | 34 +++ assets/card_base/Monster-InnerFill.png | 3 + assets/card_base/Monster-InnerFill.png.import | 34 +++ assets/card_base/Pip.png | 3 + assets/card_base/Pip.png.import | 34 +++ assets/card_base/RPS Panel.png | 3 + assets/card_base/RPS Panel.png.import | 34 +++ .../Screenshot 2025-01-25 211435.png | 3 + .../Screenshot 2025-01-25 211435.png.import | 34 +++ assets/card_base/Star.png | 3 + assets/card_base/Star.png.import | 34 +++ assets/card_base/batu.png | 3 + assets/card_base/batu.png.import | 34 +++ assets/card_base/gunting.png | 3 + assets/card_base/gunting.png.import | 34 +++ assets/card_base/kertas.png | 3 + assets/card_base/kertas.png.import | 34 +++ assets/monster/froggo 1.png | 3 + assets/monster/froggo 1.png.import | 34 +++ .../monster/{taiman.tres => axoluna.tres} | 10 +- data/cards/monster/bunnaut.tres | 13 + .../monster/{baraga.tres => capytain.tres} | 10 +- data/cards/monster/cattogato.tres | 13 + data/cards/monster/froguvo.tres | 15 ++ data/cards/monster/gilli.tres | 13 + data/cards/monster/jellova.tres | 13 + data/cards/monster/orcava.tres | 13 + data/cards/monster/prankie.tres | 13 + data/cards/monster/quackle.tres | 13 + demo_game.tscn | 6 +- icon.svg | 4 +- main.gd | 3 +- main.tscn | 2 +- tcg/card/monster_card.gd | 12 +- test_card.tscn | 10 +- ui/card_template/monster_card.gd | 7 + ui/card_template/monster_card.tscn | 254 +++++++++++++++++- 38 files changed, 772 insertions(+), 22 deletions(-) create mode 100644 assets/card_base/Illustrated BG.png create mode 100644 assets/card_base/Illustrated BG.png.import create mode 100644 assets/card_base/Monster-InnerFill.png create mode 100644 assets/card_base/Monster-InnerFill.png.import create mode 100644 assets/card_base/Pip.png create mode 100644 assets/card_base/Pip.png.import create mode 100644 assets/card_base/RPS Panel.png create mode 100644 assets/card_base/RPS Panel.png.import create mode 100644 assets/card_base/Screenshot 2025-01-25 211435.png create mode 100644 assets/card_base/Screenshot 2025-01-25 211435.png.import create mode 100644 assets/card_base/Star.png create mode 100644 assets/card_base/Star.png.import create mode 100644 assets/card_base/batu.png create mode 100644 assets/card_base/batu.png.import create mode 100644 assets/card_base/gunting.png create mode 100644 assets/card_base/gunting.png.import create mode 100644 assets/card_base/kertas.png create mode 100644 assets/card_base/kertas.png.import create mode 100644 assets/monster/froggo 1.png create mode 100644 assets/monster/froggo 1.png.import rename data/cards/monster/{taiman.tres => axoluna.tres} (62%) create mode 100644 data/cards/monster/bunnaut.tres rename data/cards/monster/{baraga.tres => capytain.tres} (63%) create mode 100644 data/cards/monster/cattogato.tres create mode 100644 data/cards/monster/froguvo.tres create mode 100644 data/cards/monster/gilli.tres create mode 100644 data/cards/monster/jellova.tres create mode 100644 data/cards/monster/orcava.tres create mode 100644 data/cards/monster/prankie.tres create mode 100644 data/cards/monster/quackle.tres create mode 100644 ui/card_template/monster_card.gd diff --git a/assets/card_base/Illustrated BG.png b/assets/card_base/Illustrated BG.png new file mode 100644 index 0000000..13f506e --- /dev/null +++ b/assets/card_base/Illustrated BG.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e5db3ddf6b8519218ece058d4f169efc363d2aba02400b89b7eef1277c8e44ab +size 1973201 diff --git a/assets/card_base/Illustrated BG.png.import b/assets/card_base/Illustrated BG.png.import new file mode 100644 index 0000000..a704b8d --- /dev/null +++ b/assets/card_base/Illustrated BG.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dft4fbgoecbp4" +path="res://.godot/imported/Illustrated BG.png-181034664aa2e590183e18ee7ca1bfaa.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/card_base/Illustrated BG.png" +dest_files=["res://.godot/imported/Illustrated BG.png-181034664aa2e590183e18ee7ca1bfaa.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/card_base/Monster-InnerFill.png b/assets/card_base/Monster-InnerFill.png new file mode 100644 index 0000000..e625751 --- /dev/null +++ b/assets/card_base/Monster-InnerFill.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c98a835ac49a78d6cdc44f867372f5405c6e935fa651c55455ad54603cf7f6f6 +size 121678 diff --git a/assets/card_base/Monster-InnerFill.png.import b/assets/card_base/Monster-InnerFill.png.import new file mode 100644 index 0000000..f7d395a --- /dev/null +++ b/assets/card_base/Monster-InnerFill.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://c2qyx2k50v2vv" +path="res://.godot/imported/Monster-InnerFill.png-93b412d347601958a4d2176fe728b492.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/card_base/Monster-InnerFill.png" +dest_files=["res://.godot/imported/Monster-InnerFill.png-93b412d347601958a4d2176fe728b492.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/card_base/Pip.png b/assets/card_base/Pip.png new file mode 100644 index 0000000..e16ae38 --- /dev/null +++ b/assets/card_base/Pip.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8571a2dcc30f164a811adfe3ffd51ca631fe17bfa5bbae4b3bea4aefe0b7c038 +size 1179 diff --git a/assets/card_base/Pip.png.import b/assets/card_base/Pip.png.import new file mode 100644 index 0000000..1e6c48e --- /dev/null +++ b/assets/card_base/Pip.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cjmxetjq82rl2" +path="res://.godot/imported/Pip.png-de8c266f2e2c9cd5a4519b7d5df4868e.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/card_base/Pip.png" +dest_files=["res://.godot/imported/Pip.png-de8c266f2e2c9cd5a4519b7d5df4868e.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/card_base/RPS Panel.png b/assets/card_base/RPS Panel.png new file mode 100644 index 0000000..ce9a35a --- /dev/null +++ b/assets/card_base/RPS Panel.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e2d6582bca3acbce0bc3e7179ee8864c9bf2bb7ed8afe1cdbe64b8fc3d0e596c +size 11713 diff --git a/assets/card_base/RPS Panel.png.import b/assets/card_base/RPS Panel.png.import new file mode 100644 index 0000000..f1a9ba3 --- /dev/null +++ b/assets/card_base/RPS Panel.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://d0a2opcuwsko8" +path="res://.godot/imported/RPS Panel.png-ccba378cf0e54a7db466c513ef19441b.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/card_base/RPS Panel.png" +dest_files=["res://.godot/imported/RPS Panel.png-ccba378cf0e54a7db466c513ef19441b.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/card_base/Screenshot 2025-01-25 211435.png b/assets/card_base/Screenshot 2025-01-25 211435.png new file mode 100644 index 0000000..b3ed7e8 --- /dev/null +++ b/assets/card_base/Screenshot 2025-01-25 211435.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:694774dbbeaa32955325ca8159a81d21a6df10b9768e19dff254619f86a9e0af +size 242836 diff --git a/assets/card_base/Screenshot 2025-01-25 211435.png.import b/assets/card_base/Screenshot 2025-01-25 211435.png.import new file mode 100644 index 0000000..4347032 --- /dev/null +++ b/assets/card_base/Screenshot 2025-01-25 211435.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cqladcrximh6" +path="res://.godot/imported/Screenshot 2025-01-25 211435.png-7837967bcc49e81c793d612b9d970963.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/card_base/Screenshot 2025-01-25 211435.png" +dest_files=["res://.godot/imported/Screenshot 2025-01-25 211435.png-7837967bcc49e81c793d612b9d970963.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/card_base/Star.png b/assets/card_base/Star.png new file mode 100644 index 0000000..f1810d8 --- /dev/null +++ b/assets/card_base/Star.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:69c3d97e1726b30f476327786f41c60aa448445f49098e3092f267ec75fbbacf +size 1246 diff --git a/assets/card_base/Star.png.import b/assets/card_base/Star.png.import new file mode 100644 index 0000000..eeabaf5 --- /dev/null +++ b/assets/card_base/Star.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cqttp0i3vph37" +path="res://.godot/imported/Star.png-b9b4017ee1202aa95ea8c6ee772a751e.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/card_base/Star.png" +dest_files=["res://.godot/imported/Star.png-b9b4017ee1202aa95ea8c6ee772a751e.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/card_base/batu.png b/assets/card_base/batu.png new file mode 100644 index 0000000..7899aa9 --- /dev/null +++ b/assets/card_base/batu.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b3ebc26aaf3c87de9ce48e9a4f9e22db8944b9c304f9dbda9cf21c3636f013e9 +size 24379 diff --git a/assets/card_base/batu.png.import b/assets/card_base/batu.png.import new file mode 100644 index 0000000..bdef9d8 --- /dev/null +++ b/assets/card_base/batu.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bywa8qlwvcksd" +path="res://.godot/imported/batu.png-45758b8e11a9ea003a7865de11dc4441.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/card_base/batu.png" +dest_files=["res://.godot/imported/batu.png-45758b8e11a9ea003a7865de11dc4441.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/card_base/gunting.png b/assets/card_base/gunting.png new file mode 100644 index 0000000..553ae4d --- /dev/null +++ b/assets/card_base/gunting.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d5679d2d3e778ec2d3142eaf0f5603b3a144e87f7f26e1e2d78974462db69f75 +size 33308 diff --git a/assets/card_base/gunting.png.import b/assets/card_base/gunting.png.import new file mode 100644 index 0000000..24d6aac --- /dev/null +++ b/assets/card_base/gunting.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://ch04c20lkis6j" +path="res://.godot/imported/gunting.png-f8810080ad1e41ec3bcb0f8ff0d8b5f8.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/card_base/gunting.png" +dest_files=["res://.godot/imported/gunting.png-f8810080ad1e41ec3bcb0f8ff0d8b5f8.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/card_base/kertas.png b/assets/card_base/kertas.png new file mode 100644 index 0000000..6507ea0 --- /dev/null +++ b/assets/card_base/kertas.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3aa28478cb7241ff59fe191f1aca345eccd60d8a9cb8f9c1058874b3fc0606ff +size 17766 diff --git a/assets/card_base/kertas.png.import b/assets/card_base/kertas.png.import new file mode 100644 index 0000000..c48a956 --- /dev/null +++ b/assets/card_base/kertas.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b0pclmv0j0r12" +path="res://.godot/imported/kertas.png-fd031884ac9417a6b135672f3fcc1d7f.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/card_base/kertas.png" +dest_files=["res://.godot/imported/kertas.png-fd031884ac9417a6b135672f3fcc1d7f.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/monster/froggo 1.png b/assets/monster/froggo 1.png new file mode 100644 index 0000000..958fea7 --- /dev/null +++ b/assets/monster/froggo 1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2f7f76dda3d26c8b4ac1b88f6fa7b0d22da51f873ced793d7c6b666138445844 +size 102451 diff --git a/assets/monster/froggo 1.png.import b/assets/monster/froggo 1.png.import new file mode 100644 index 0000000..8f40732 --- /dev/null +++ b/assets/monster/froggo 1.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b8accn4e2ojau" +path="res://.godot/imported/froggo 1.png-9f147da84c624d2073b0c92236a84741.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/monster/froggo 1.png" +dest_files=["res://.godot/imported/froggo 1.png-9f147da84c624d2073b0c92236a84741.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/data/cards/monster/taiman.tres b/data/cards/monster/axoluna.tres similarity index 62% rename from data/cards/monster/taiman.tres rename to data/cards/monster/axoluna.tres index aa4681d..5ce7e9e 100644 --- a/data/cards/monster/taiman.tres +++ b/data/cards/monster/axoluna.tres @@ -1,11 +1,13 @@ [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"] +[ext_resource type="Script" path="res://tcg/card/monster_card.gd" id="1_s0p53"] [resource] -script = ExtResource("1_j4601") -rock = 50 -paper = 50 +script = ExtResource("1_s0p53") +rock = 20 +paper = 30 scissors = 50 energy_cost = 1 base_health = 120 +name = "Axoluna" +description = "Cute wanderer of the tank, Axoluna" diff --git a/data/cards/monster/bunnaut.tres b/data/cards/monster/bunnaut.tres new file mode 100644 index 0000000..15a678d --- /dev/null +++ b/data/cards/monster/bunnaut.tres @@ -0,0 +1,13 @@ +[gd_resource type="Resource" script_class="MonsterCard" load_steps=2 format=3 uid="uid://bynhiupm3e5fp"] + +[ext_resource type="Script" path="res://tcg/card/monster_card.gd" id="1_3jfyg"] + +[resource] +script = ExtResource("1_3jfyg") +rock = 10 +paper = 30 +scissors = 70 +energy_cost = 1 +base_health = 50 +name = "Bunnaut" +description = "Run faster than tortoise." diff --git a/data/cards/monster/baraga.tres b/data/cards/monster/capytain.tres similarity index 63% rename from data/cards/monster/baraga.tres rename to data/cards/monster/capytain.tres index a979300..d11bf4d 100644 --- a/data/cards/monster/baraga.tres +++ b/data/cards/monster/capytain.tres @@ -1,11 +1,13 @@ [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"] +[ext_resource type="Script" path="res://tcg/card/monster_card.gd" id="1_n3oql"] [resource] -script = ExtResource("1_v65bb") +script = ExtResource("1_n3oql") rock = 100 -paper = 100 -scissors = 100 +paper = 40 +scissors = 80 energy_cost = 3 base_health = 170 +name = "Capytain" +description = "A big, hungry capybara" diff --git a/data/cards/monster/cattogato.tres b/data/cards/monster/cattogato.tres new file mode 100644 index 0000000..7fee1c0 --- /dev/null +++ b/data/cards/monster/cattogato.tres @@ -0,0 +1,13 @@ +[gd_resource type="Resource" script_class="MonsterCard" load_steps=2 format=3 uid="uid://bmst884k0myvd"] + +[ext_resource type="Script" path="res://tcg/card/monster_card.gd" id="1_hblhq"] + +[resource] +script = ExtResource("1_hblhq") +rock = 10 +paper = 10 +scissors = 200 +energy_cost = 3 +base_health = 80 +name = "Cattogato" +description = "Lovely cat wandering in the space." diff --git a/data/cards/monster/froguvo.tres b/data/cards/monster/froguvo.tres new file mode 100644 index 0000000..f9f900c --- /dev/null +++ b/data/cards/monster/froguvo.tres @@ -0,0 +1,15 @@ +[gd_resource type="Resource" script_class="MonsterCard" load_steps=3 format=3 uid="uid://bt1ngixrq4sve"] + +[ext_resource type="Script" path="res://tcg/card/monster_card.gd" id="1_ayfld"] +[ext_resource type="Texture2D" uid="uid://b8accn4e2ojau" path="res://assets/monster/froggo 1.png" id="1_vlu3d"] + +[resource] +script = ExtResource("1_ayfld") +rock = 20 +paper = 30 +scissors = 50 +energy_cost = 1 +base_health = 80 +name = "Froguvo" +description = "Ribbit in space." +icon = ExtResource("1_vlu3d") diff --git a/data/cards/monster/gilli.tres b/data/cards/monster/gilli.tres new file mode 100644 index 0000000..30da6af --- /dev/null +++ b/data/cards/monster/gilli.tres @@ -0,0 +1,13 @@ +[gd_resource type="Resource" script_class="MonsterCard" load_steps=2 format=3 uid="uid://myxgsyerrdla"] + +[ext_resource type="Script" path="res://tcg/card/monster_card.gd" id="1_1j36c"] + +[resource] +script = ExtResource("1_1j36c") +rock = 40 +paper = 10 +scissors = 10 +energy_cost = 1 +base_health = 120 +name = "Gilli" +description = "There is a huge monster looking at me everyday." diff --git a/data/cards/monster/jellova.tres b/data/cards/monster/jellova.tres new file mode 100644 index 0000000..df0e747 --- /dev/null +++ b/data/cards/monster/jellova.tres @@ -0,0 +1,13 @@ +[gd_resource type="Resource" script_class="MonsterCard" load_steps=2 format=3 uid="uid://425ipxdapg8o"] + +[ext_resource type="Script" path="res://tcg/card/monster_card.gd" id="1_yvmeg"] + +[resource] +script = ExtResource("1_yvmeg") +rock = 40 +paper = 60 +scissors = 50 +energy_cost = 2 +base_health = 110 +name = "Jellova" +description = "I'm gonna whip you till' you .. nevermind." diff --git a/data/cards/monster/orcava.tres b/data/cards/monster/orcava.tres new file mode 100644 index 0000000..b1c212e --- /dev/null +++ b/data/cards/monster/orcava.tres @@ -0,0 +1,13 @@ +[gd_resource type="Resource" script_class="MonsterCard" load_steps=2 format=3 uid="uid://cakkx0o8mifmn"] + +[ext_resource type="Script" path="res://tcg/card/monster_card.gd" id="1_xcdwy"] + +[resource] +script = ExtResource("1_xcdwy") +rock = 30 +paper = 30 +scissors = 30 +energy_cost = 2 +base_health = 200 +name = "Orcava" +description = "Human try to communicate with me. I simply block them." diff --git a/data/cards/monster/prankie.tres b/data/cards/monster/prankie.tres new file mode 100644 index 0000000..5cea32c --- /dev/null +++ b/data/cards/monster/prankie.tres @@ -0,0 +1,13 @@ +[gd_resource type="Resource" script_class="MonsterCard" load_steps=2 format=3 uid="uid://shri5ne51s74"] + +[ext_resource type="Script" path="res://tcg/card/monster_card.gd" id="1_70s4q"] + +[resource] +script = ExtResource("1_70s4q") +rock = 60 +paper = 60 +scissors = 10 +energy_cost = 2 +base_health = 100 +name = "Prankie" +description = "I'm not pranking anyone. Yet." diff --git a/data/cards/monster/quackle.tres b/data/cards/monster/quackle.tres new file mode 100644 index 0000000..f774842 --- /dev/null +++ b/data/cards/monster/quackle.tres @@ -0,0 +1,13 @@ +[gd_resource type="Resource" script_class="MonsterCard" load_steps=2 format=3 uid="uid://dnf3gpji5prlr"] + +[ext_resource type="Script" path="res://tcg/card/monster_card.gd" id="1_a8rjn"] + +[resource] +script = ExtResource("1_a8rjn") +rock = 50 +paper = 20 +scissors = 40 +energy_cost = 1 +base_health = 70 +name = "Quackle" +description = "Quack! Quack! No one notice me." diff --git a/demo_game.tscn b/demo_game.tscn index 7120e03..b209cf1 100644 --- a/demo_game.tscn +++ b/demo_game.tscn @@ -1,12 +1,12 @@ -[gd_scene load_steps=8 format=3 uid="uid://l2ehohbd1xhk"] +[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/monster/baraga.tres" id="3_we1tk"] +[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/taiman.tres" id="5_3cm5x"] +[ext_resource type="Resource" uid="uid://di76avwc0gn8e" path="res://data/cards/monster/axoluna.tres" id="5_3cm5x"] [node name="DemoGame" type="Control"] layout_mode = 3 diff --git a/icon.svg b/icon.svg index 9d8b7fa..2ead0cd 100644 --- a/icon.svg +++ b/icon.svg @@ -1 +1,3 @@ - \ No newline at end of file +version https://git-lfs.github.com/spec/v1 +oid sha256:f6369bae7e12e6d16019cd6214cf27a2fdb6f3f6d024bd6f23c322be4804474f +size 994 diff --git a/main.gd b/main.gd index 5ba3478..6916288 100644 --- a/main.gd +++ b/main.gd @@ -130,7 +130,8 @@ func _on_server_removed(id, ip): func _do_connect(ip: String, port: int): var peer = ENetMultiplayerPeer.new() print("%s Connecting to %s:%d" % [server_discovery.id, ip, port]) - peer.create_client(ip, port) + var err = peer.create_client(ip, port) + print(err) multiplayer.multiplayer_peer = peer func _on_host_pressed(): diff --git a/main.tscn b/main.tscn index 523431c..f256ce5 100644 --- a/main.tscn +++ b/main.tscn @@ -2,7 +2,7 @@ [ext_resource type="Script" path="res://main.gd" id="1_e0ud3"] [ext_resource type="Script" path="res://server_discovery.gd" id="2_hed18"] -[ext_resource type="PackedScene" uid="uid://l2ehohbd1xhk" path="res://demo_game.tscn" id="3_2ln6b"] +[ext_resource type="PackedScene" uid="uid://bgc0u117jqyr1" path="res://demo_game.tscn" id="3_2ln6b"] [node name="Main" type="Control"] layout_mode = 3 diff --git a/tcg/card/monster_card.gd b/tcg/card/monster_card.gd index 4b82987..16174b1 100644 --- a/tcg/card/monster_card.gd +++ b/tcg/card/monster_card.gd @@ -8,9 +8,9 @@ class_name MonsterCard @export var base_health: int = 100 var damage: Dictionary: - get: - return { - "rock": rock, - "paper": paper, - "scissors": scissors - } \ No newline at end of file + get: + return { + "rock": rock, + "paper": paper, + "scissors": scissors + } diff --git a/test_card.tscn b/test_card.tscn index ccbb6d6..19770ef 100644 --- a/test_card.tscn +++ b/test_card.tscn @@ -1,9 +1,10 @@ -[gd_scene load_steps=5 format=3 uid="uid://dhm4v4r7he0op"] +[gd_scene load_steps=6 format=3 uid="uid://lrb86kqjqt4v"] [ext_resource type="Script" path="res://test_card.gd" id="1_tqmas"] [ext_resource type="PackedScene" uid="uid://dg5amjm1gqi06" path="res://ui/card_template/support_card_green.tscn" id="2_22pto"] [ext_resource type="Resource" uid="uid://4eod3m0vc5a8" path="res://data/cards/support/potion.tres" id="2_tbbjy"] [ext_resource type="PackedScene" uid="uid://cds50kwwhlgam" path="res://ui/card_template/support_card_red.tscn" id="3_7wd2e"] +[ext_resource type="PackedScene" uid="uid://bhrelvt51cbp2" path="res://ui/card_template/monster_card.tscn" id="5_8mwjl"] [node name="TestCard" type="Control"] layout_mode = 3 @@ -26,3 +27,10 @@ offset_left = 699.0 offset_top = 168.0 offset_right = 919.0 offset_bottom = 488.0 + +[node name="MonsterCard" parent="." instance=ExtResource("5_8mwjl")] +layout_mode = 1 +offset_left = 461.0 +offset_top = 162.0 +offset_right = -471.0 +offset_bottom = -166.0 diff --git a/ui/card_template/monster_card.gd b/ui/card_template/monster_card.gd new file mode 100644 index 0000000..30349e6 --- /dev/null +++ b/ui/card_template/monster_card.gd @@ -0,0 +1,7 @@ +extends Control + +@export var name_label: Label +@export var health_label: Label +@export var energy_pip_container: Container +@export var energy_pip: PackedScene +@export var art: Texture2D diff --git a/ui/card_template/monster_card.tscn b/ui/card_template/monster_card.tscn index 3d9e3de..cee06b2 100644 --- a/ui/card_template/monster_card.tscn +++ b/ui/card_template/monster_card.tscn @@ -1,9 +1,261 @@ -[gd_scene format=3 uid="uid://bhrelvt51cbp2"] +[gd_scene load_steps=15 format=3 uid="uid://bhrelvt51cbp2"] + +[ext_resource type="Texture2D" uid="uid://cqladcrximh6" path="res://assets/card_base/Screenshot 2025-01-25 211435.png" id="1_nvo50"] +[ext_resource type="Script" path="res://ui/card_template/monster_card.gd" id="1_xddej"] +[ext_resource type="Texture2D" uid="uid://l2nxxhh0pvh8" path="res://assets/card_base/Frame.png" id="2_lhxdu"] +[ext_resource type="Texture2D" uid="uid://crgrple0uik7x" path="res://assets/card_base/Stroke.png" id="4_kkcc6"] +[ext_resource type="Texture2D" uid="uid://c2qyx2k50v2vv" path="res://assets/card_base/Monster-InnerFill.png" id="5_a3gpd"] +[ext_resource type="Texture2D" uid="uid://b8accn4e2ojau" path="res://assets/monster/froggo 1.png" id="7_j2i0p"] +[ext_resource type="Texture2D" uid="uid://dft4fbgoecbp4" path="res://assets/card_base/Illustrated BG.png" id="7_qe8a1"] +[ext_resource type="Texture2D" uid="uid://cqttp0i3vph37" path="res://assets/card_base/Star.png" id="8_ophhb"] +[ext_resource type="Theme" path="res://cards.tres" id="9_6x2vq"] +[ext_resource type="Texture2D" uid="uid://cjmxetjq82rl2" path="res://assets/card_base/Pip.png" id="10_14hhn"] +[ext_resource type="FontFile" uid="uid://08q3kkwmd4u6" path="res://assets/Inter-Regular.otf" id="11_oy107"] +[ext_resource type="Texture2D" uid="uid://bywa8qlwvcksd" path="res://assets/card_base/batu.png" id="12_a4kkh"] +[ext_resource type="Texture2D" uid="uid://ch04c20lkis6j" path="res://assets/card_base/gunting.png" id="13_ifoc6"] +[ext_resource type="Texture2D" uid="uid://b0pclmv0j0r12" path="res://assets/card_base/kertas.png" id="14_gm7k7"] [node name="MonsterCard" type="Control"] layout_mode = 3 anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 +offset_right = -932.0 +offset_bottom = -328.0 grow_horizontal = 2 grow_vertical = 2 +script = ExtResource("1_xddej") + +[node name="Screenshot2025-01-25211435" type="Sprite2D" parent="."] +visible = false +position = Vector2(355, 157) +scale = Vector2(0.625, 0.625) +texture = ExtResource("1_nvo50") + +[node name="Frame" type="TextureRect" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("2_lhxdu") +expand_mode = 1 + +[node name="MarginContainer" type="Control" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = 4.0 +offset_top = 3.0 +offset_right = -5.0 +offset_bottom = -4.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="OuterStroke" type="NinePatchRect" parent="MarginContainer"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("4_kkcc6") + +[node name="InnerFill" type="TextureRect" parent="MarginContainer"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_top = 43.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("5_a3gpd") +expand_mode = 1 + +[node name="InnerStroke" type="NinePatchRect" parent="MarginContainer"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_top = 42.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("4_kkcc6") + +[node name="TextureRect2" type="TextureRect" parent="MarginContainer"] +layout_mode = 0 +offset_left = 9.0 +offset_top = 77.0 +offset_right = 199.0 +offset_bottom = 207.0 +pivot_offset = Vector2(95, 65) +texture = ExtResource("7_qe8a1") +expand_mode = 1 +stretch_mode = 5 + +[node name="TextureRect" type="TextureRect" parent="MarginContainer/TextureRect2"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("7_j2i0p") +expand_mode = 1 +stretch_mode = 5 + +[node name="EnergyStars" type="HBoxContainer" parent="MarginContainer"] +layout_mode = 0 +offset_left = 141.0 +offset_top = 55.0 +offset_right = 200.0 +offset_bottom = 70.0 + +[node name="TextureRect3" type="TextureRect" parent="MarginContainer/EnergyStars"] +layout_mode = 2 +texture = ExtResource("8_ophhb") +expand_mode = 3 +stretch_mode = 5 + +[node name="TextureRect2" type="TextureRect" parent="MarginContainer/EnergyStars"] +layout_mode = 2 +texture = ExtResource("8_ophhb") +expand_mode = 3 +stretch_mode = 5 + +[node name="TextureRect" type="TextureRect" parent="MarginContainer/EnergyStars"] +layout_mode = 2 +texture = ExtResource("8_ophhb") +expand_mode = 3 +stretch_mode = 5 + +[node name="HPNumber" type="Label" parent="MarginContainer"] +layout_mode = 1 +anchors_preset = 10 +anchor_right = 1.0 +offset_left = 14.0 +offset_top = 44.0 +offset_right = -99.0 +offset_bottom = 80.0 +grow_horizontal = 2 +theme = ExtResource("9_6x2vq") +theme_override_font_sizes/font_size = 16 +text = "HP 80" +vertical_alignment = 1 + +[node name="MonsterNameLabel" type="Label" parent="MarginContainer"] +layout_mode = 1 +anchors_preset = 10 +anchor_right = 1.0 +offset_left = 31.0 +offset_top = 11.0 +offset_right = 26.0 +offset_bottom = 47.0 +grow_horizontal = 2 +theme = ExtResource("9_6x2vq") +theme_override_font_sizes/font_size = 26 +text = "Cattogato" +vertical_alignment = 1 + +[node name="CardNumber" type="TextureRect" parent="MarginContainer"] +layout_mode = 0 +offset_left = 7.0 +offset_top = 17.0 +offset_right = 26.0 +offset_bottom = 36.0 +texture = ExtResource("10_14hhn") +expand_mode = 1 +stretch_mode = 5 + +[node name="Label" type="Label" parent="MarginContainer/CardNumber"] +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -9.5 +offset_top = -7.0 +offset_right = 9.5 +offset_bottom = 7.0 +grow_horizontal = 2 +grow_vertical = 2 +theme = ExtResource("9_6x2vq") +theme_override_colors/font_color = Color(0, 0, 0, 1) +theme_override_fonts/font = ExtResource("11_oy107") +theme_override_font_sizes/font_size = 6 +text = "#01" +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="Paper" type="TextureRect" parent="MarginContainer"] +offset_left = 109.0 +offset_top = 183.0 +offset_right = 222.0 +offset_bottom = 356.0 +texture = ExtResource("14_gm7k7") +expand_mode = 1 +stretch_mode = 5 + +[node name="HPNumber" type="Label" parent="MarginContainer/Paper"] +layout_mode = 1 +anchors_preset = 10 +anchor_right = 1.0 +offset_left = 48.0 +offset_top = 32.0 +offset_right = -32.0 +offset_bottom = 73.0 +grow_horizontal = 2 +theme = ExtResource("9_6x2vq") +theme_override_font_sizes/font_size = 20 +text = "10" +vertical_alignment = 1 + +[node name="Scissors" type="TextureRect" parent="MarginContainer"] +offset_left = 43.0 +offset_top = 182.0 +offset_right = 156.0 +offset_bottom = 355.0 +texture = ExtResource("13_ifoc6") +expand_mode = 1 +stretch_mode = 5 + +[node name="HPNumber" type="Label" parent="MarginContainer/Scissors"] +layout_mode = 1 +anchors_preset = 10 +anchor_right = 1.0 +offset_left = 48.0 +offset_top = 32.0 +offset_right = -32.0 +offset_bottom = 73.0 +grow_horizontal = 2 +theme = ExtResource("9_6x2vq") +theme_override_font_sizes/font_size = 20 +text = "10" +vertical_alignment = 1 + +[node name="Rock" type="TextureRect" parent="MarginContainer"] +layout_mode = 0 +offset_left = -23.0 +offset_top = 181.0 +offset_right = 90.0 +offset_bottom = 354.0 +texture = ExtResource("12_a4kkh") +expand_mode = 1 +stretch_mode = 5 + +[node name="HPNumber" type="Label" parent="MarginContainer/Rock"] +layout_mode = 1 +anchors_preset = 10 +anchor_right = 1.0 +offset_left = 48.0 +offset_top = 32.0 +offset_right = -32.0 +offset_bottom = 73.0 +grow_horizontal = 2 +theme = ExtResource("9_6x2vq") +theme_override_font_sizes/font_size = 20 +text = "10" +vertical_alignment = 1 From 2c4e9d90f329aaf411306ce88e5235ce4bb10eb2 Mon Sep 17 00:00:00 2001 From: Kenshia <73539778+Kenshia@users.noreply.github.com> Date: Sat, 25 Jan 2025 22:35:11 +0700 Subject: [PATCH 09/29] feat: user always play bottom --- demo_game.gd | 63 ++++++-------------------------------- demo_game.tscn | 6 ++-- main.gd | 10 ------ main.tscn | 2 +- tcg/match/match_manager.gd | 16 +++++++--- 5 files changed, 25 insertions(+), 72 deletions(-) diff --git a/demo_game.gd b/demo_game.gd index 36c0914..6266ca2 100644 --- a/demo_game.gd +++ b/demo_game.gd @@ -18,14 +18,14 @@ var id_to_card: Dictionary = {} var player_action_queue: Dictionary var player_1_action: Action: get: - return player_action_queue.get(MatchManager.PLAYER_1_ID) + return player_action_queue.get(own_side.player_id) set(value): - player_action_queue[MatchManager.PLAYER_1_ID] = value + player_action_queue[own_side.player_id] = value var player_2_action: Action: get: - return player_action_queue.get(MatchManager.PLAYER_2_ID) + return player_action_queue.get(opponent_side.player_id) set(value): - player_action_queue[MatchManager.PLAYER_2_ID] = value + player_action_queue[opponent_side.player_id] = value var id var signal_connected := false @@ -33,6 +33,9 @@ var signal_connected := false func init(player_id: int) -> void: id = player_id + own_side.player_id = player_id + opponent_side.player_id = MatchManager.PLAYER_2_ID if player_id == MatchManager.PLAYER_1_ID else MatchManager.PLAYER_1_ID + id_to_card.clear() var cards = player_1_deck.duplicate() @@ -44,9 +47,9 @@ func init(player_id: int) -> void: match_manager.init({ MatchManager.PLAYER_1_ID: player_1_deck, MatchManager.PLAYER_2_ID: player_2_deck - }) - own_side.attach(match_manager, player_id == MatchManager.PLAYER_1_ID) - opponent_side.attach(match_manager, player_id == MatchManager.PLAYER_2_ID) + }, own_side.player_id, opponent_side.player_id) + own_side.attach(match_manager, true) + opponent_side.attach(match_manager, false) if !signal_connected: match_manager.state_transitioned.connect(_on_match_manager_state_transitioned) @@ -65,19 +68,6 @@ func _on_start_game_button_button_up() -> void: func rpc_start_game() -> void: match_manager.resolve({}) -func rpc_own_play_card(id: String) -> void: - if !id.is_empty(): - var card = id_to_card[id] - player_1_action = ActionPlayCard.new(card) - else: - player_1_action = ActionSkipCard.new() - - print(self.id, " rpc_own_play_card", player_1_action, player_2_action) - - if player_2_action: - match_manager.resolve(player_action_queue) - player_action_queue.clear() - func _on_own_play_card(card: Card) -> void: if card: player_1_action = ActionPlayCard.new(card) @@ -105,29 +95,6 @@ func rpc_opponent_play_card(id: String) -> void: match_manager.resolve(player_action_queue) player_action_queue.clear() -func _on_opponent_play_card(card: Card) -> void: - if card: - player_2_action = ActionPlayCard.new(card) - opponent_played_card.emit(card) - else: - player_2_action = ActionSkipCard.new() - opponent_played_card.emit(null) - - print(id, " _on_opponent_play_card", player_1_action, player_2_action) - - if player_1_action: - match_manager.resolve(player_action_queue) - player_action_queue.clear() - -func rpc_own_rps_move(move: String) -> void: - player_1_action = ActionRPSMove.new(move) - - print(id, " rpc_own_rps_move", player_1_action, player_2_action, move) - - if player_2_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) own_played_rts.emit(move) @@ -146,13 +113,3 @@ func rpc_opponent_rps_move(move: String) -> void: if player_1_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) - opponent_played_rts.emit(move) - - print(id, " rpc_opponent_rps_move", player_1_action, player_2_action, 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 index b209cf1..0cac2fc 100644 --- a/demo_game.tscn +++ b/demo_game.tscn @@ -1,12 +1,12 @@ -[gd_scene load_steps=8 format=3 uid="uid://bgc0u117jqyr1"] +[gd_scene load_steps=8 format=3 uid="uid://l2ehohbd1xhk"] [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/monster/capytain.tres" id="3_we1tk"] +[ext_resource type="Resource" 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" path="res://data/cards/monster/axoluna.tres" id="5_3cm5x"] [node name="DemoGame" type="Control"] layout_mode = 3 diff --git a/main.gd b/main.gd index 6916288..2e7b500 100644 --- a/main.gd +++ b/main.gd @@ -58,24 +58,14 @@ func _ready() -> void: server_discovery.server_removed.connect(_on_server_removed) demo_game.own_played_card.connect(func (card): _on_own_played_card.rpc(card.id if card else "")) - demo_game.opponent_played_card.connect(func (card): _on_opponent_played_card.rpc(card.id if card else "")) demo_game.own_played_rts.connect(func (move): _on_own_played_rts.rpc(move)) - demo_game.opponent_played_rts.connect(func (move): _on_opponent_played_rts.rpc(move)) @rpc("any_peer", "call_remote", "reliable") func _on_own_played_card(card_id: String): - demo_game.rpc_own_play_card(card_id) - -@rpc("any_peer", "call_remote", "reliable") -func _on_opponent_played_card(card_id: String): demo_game.rpc_opponent_play_card(card_id) @rpc("any_peer", "call_remote", "reliable") func _on_own_played_rts(move: String): - demo_game.rpc_own_rps_move(move) - -@rpc("any_peer", "call_remote", "reliable") -func _on_opponent_played_rts(move: String): demo_game.rpc_opponent_rps_move(move) @rpc("authority", "call_local", "reliable") diff --git a/main.tscn b/main.tscn index f256ce5..523431c 100644 --- a/main.tscn +++ b/main.tscn @@ -2,7 +2,7 @@ [ext_resource type="Script" path="res://main.gd" id="1_e0ud3"] [ext_resource type="Script" path="res://server_discovery.gd" id="2_hed18"] -[ext_resource type="PackedScene" uid="uid://bgc0u117jqyr1" path="res://demo_game.tscn" id="3_2ln6b"] +[ext_resource type="PackedScene" uid="uid://l2ehohbd1xhk" path="res://demo_game.tscn" id="3_2ln6b"] [node name="Main" type="Control"] layout_mode = 3 diff --git a/tcg/match/match_manager.gd b/tcg/match/match_manager.gd index 814b138..994347a 100644 --- a/tcg/match/match_manager.gd +++ b/tcg/match/match_manager.gd @@ -16,16 +16,22 @@ var rps_wins = { var players: Dictionary var player_1: MatchPlayer: get: - return players[PLAYER_1_ID] as MatchPlayer + return players[actual_p1_id] as MatchPlayer var player_2: MatchPlayer: get: - return players[PLAYER_2_ID] as MatchPlayer + return players[actual_p2_id] as MatchPlayer var phase: Match.Phase = Match.Phase.PREGAME +var actual_p1_id: int +var actual_p2_id: int + func _ready() -> void: cleanup() -func init(decks: Dictionary): +func init(decks: Dictionary, actual_p1_id: int, actual_p2_id: int): + self.actual_p1_id = actual_p1_id + self.actual_p2_id = actual_p2_id + cleanup() for player_id in [PLAYER_1_ID, PLAYER_2_ID]: var deck_shuffled = decks[player_id].duplicate() as Array[Card] @@ -50,8 +56,8 @@ func cleanup(): 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 + var player_1_action = action_by_player_id.get(actual_p1_id) as Action + var player_2_action = action_by_player_id.get(actual_p2_id) as Action match phase: Match.Phase.PREGAME: var CARDS_TO_DRAW: int = 3 From 5af462e78ddfc0bab21897d43de8e814a159592e Mon Sep 17 00:00:00 2001 From: Kenshia <73539778+Kenshia@users.noreply.github.com> Date: Sun, 26 Jan 2025 01:58:35 +0700 Subject: [PATCH 10/29] feat: new cards in game --- data/cards/monster/axoluna.tres | 4 +- data/cards/monster/bunnaut.tres | 2 +- demo_game.gd | 2 +- demo_game.tscn | 276 ++++++++++++++++------- main.tscn | 9 +- player_side.gd | 94 ++++++-- project.godot | 6 + tcg/match/match_manager.gd | 13 ++ ui/card_template/card_base.gd | 26 ++- ui/card_template/monster_card.gd | 59 ++++- ui/card_template/monster_card.tscn | 44 +++- ui/card_template/skip_card.tscn | 274 ++++++++++++++++++++++ ui/card_template/support_card_green.tscn | 8 +- ui/card_template/support_card_red.tscn | 6 +- 14 files changed, 700 insertions(+), 123 deletions(-) create mode 100644 ui/card_template/skip_card.tscn diff --git a/data/cards/monster/axoluna.tres b/data/cards/monster/axoluna.tres index 5ce7e9e..1743622 100644 --- a/data/cards/monster/axoluna.tres +++ b/data/cards/monster/axoluna.tres @@ -1,5 +1,6 @@ -[gd_resource type="Resource" script_class="MonsterCard" load_steps=2 format=3 uid="uid://di76avwc0gn8e"] +[gd_resource type="Resource" script_class="MonsterCard" load_steps=3 format=3 uid="uid://deo8mj887rfx1"] +[ext_resource type="Texture2D" uid="uid://b8accn4e2ojau" path="res://assets/monster/froggo 1.png" id="1_dyw44"] [ext_resource type="Script" path="res://tcg/card/monster_card.gd" id="1_s0p53"] [resource] @@ -11,3 +12,4 @@ energy_cost = 1 base_health = 120 name = "Axoluna" description = "Cute wanderer of the tank, Axoluna" +icon = ExtResource("1_dyw44") diff --git a/data/cards/monster/bunnaut.tres b/data/cards/monster/bunnaut.tres index 15a678d..6d478e3 100644 --- a/data/cards/monster/bunnaut.tres +++ b/data/cards/monster/bunnaut.tres @@ -1,4 +1,4 @@ -[gd_resource type="Resource" script_class="MonsterCard" load_steps=2 format=3 uid="uid://bynhiupm3e5fp"] +[gd_resource type="Resource" script_class="MonsterCard" load_steps=2 format=3 uid="uid://tgju8eodyuk1"] [ext_resource type="Script" path="res://tcg/card/monster_card.gd" id="1_3jfyg"] diff --git a/demo_game.gd b/demo_game.gd index 6266ca2..fdf9321 100644 --- a/demo_game.gd +++ b/demo_game.gd @@ -60,7 +60,7 @@ 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({}) pass diff --git a/demo_game.tscn b/demo_game.tscn index 0cac2fc..fb4877e 100644 --- a/demo_game.tscn +++ b/demo_game.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=8 format=3 uid="uid://l2ehohbd1xhk"] +[gd_scene load_steps=12 format=3 uid="uid://l2ehohbd1xhk"] [ext_resource type="Script" path="res://demo_game.gd" id="1_jn16u"] [ext_resource type="Script" path="res://player_side.gd" id="2_w4tnt"] @@ -6,7 +6,11 @@ [ext_resource type="PackedScene" uid="uid://cikstg43mudkn" path="res://tcg/match/match_manager.tscn" id="3_3yhrl"] [ext_resource type="Resource" 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" path="res://data/cards/monster/axoluna.tres" id="5_3cm5x"] +[ext_resource type="Resource" uid="uid://deo8mj887rfx1" path="res://data/cards/monster/axoluna.tres" id="5_3cm5x"] +[ext_resource type="PackedScene" uid="uid://bhrelvt51cbp2" path="res://ui/card_template/monster_card.tscn" id="7_4ah45"] +[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="PackedScene" uid="uid://cds50kwwhlgam" path="res://ui/card_template/support_card_red.tscn" id="9_cabcc"] [node name="DemoGame" type="Control"] layout_mode = 3 @@ -19,88 +23,199 @@ 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")]) -[node name="Own" type="VBoxContainer" parent="." node_paths=PackedStringArray("deck", "monster_name_label", "monster_health_label", "incoming_damage_label", "energy_label")] +[node name="Own" type="Control" parent="." node_paths=PackedStringArray("deck", "energy_label")] +layout_mode = 1 +anchor_top = 0.5 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("2_w4tnt") +deck = NodePath("Hand") +energy_label = NodePath("EnergyLabel") +skip_card_prefab = ExtResource("7_skjyk") +support_red_card_prefab = ExtResource("9_cabcc") +support_green_card_prefab = ExtResource("8_dytl5") +monster_card_prefab = ExtResource("7_4ah45") + +[node name="MonsterCard" parent="Own" instance=ExtResource("7_4ah45")] +custom_minimum_size = Vector2(220, 330) +layout_mode = 1 +anchors_preset = 5 +anchor_left = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.0 +offset_left = -110.0 +offset_top = 20.0 +offset_right = 110.0 +offset_bottom = 350.0 +grow_vertical = 1 +pivot_offset = Vector2(110, 0) +size_flags_horizontal = 4 +size_flags_vertical = 4 + +[node name="Support1GreenCard" parent="Own" instance=ExtResource("8_dytl5")] +layout_mode = 1 +anchors_preset = 5 +anchor_left = 0.5 +anchor_right = 0.5 +offset_left = -310.0 +offset_top = 75.0 +offset_right = -90.0 +offset_bottom = 395.0 +grow_horizontal = 2 +pivot_offset = Vector2(110, 0) + +[node name="Support2GreenCard" parent="Own" instance=ExtResource("8_dytl5")] +layout_mode = 1 +anchors_preset = 5 +anchor_left = 0.5 +anchor_right = 0.5 +offset_left = 90.0 +offset_top = 75.0 +offset_right = 310.0 +offset_bottom = 395.0 +grow_horizontal = 2 +pivot_offset = Vector2(110, 0) + +[node name="Support2RedCard" parent="Own" instance=ExtResource("9_cabcc")] +layout_mode = 1 +anchors_preset = 5 +anchor_left = 0.5 +anchor_right = 0.5 +offset_left = 90.0 +offset_top = 75.0 +offset_right = 310.0 +offset_bottom = 395.0 +grow_horizontal = 2 +pivot_offset = Vector2(110, 0) + +[node name="EnergyLabel" type="Label" parent="Own"] +layout_mode = 1 +anchors_preset = 2 +anchor_top = 1.0 +anchor_bottom = 1.0 +offset_top = -23.0 +offset_right = 1152.0 +grow_vertical = 0 +text = "Energy:" + +[node name="Hand" type="HBoxContainer" parent="Own"] layout_mode = 1 anchors_preset = 12 anchor_top = 1.0 anchor_right = 1.0 anchor_bottom = 1.0 -offset_top = -131.0 +offset_top = -240.0 +offset_bottom = 130.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 +pivot_offset = Vector2(0, 150) alignment = 1 -[node name="VBoxContainer" type="VBoxContainer" parent="Own/Monster"] +[node name="SkipCard" parent="Own/Hand" instance=ExtResource("7_skjyk")] 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"] +[node name="MonsterCard" parent="Own/Hand" instance=ExtResource("7_4ah45")] layout_mode = 2 -[node name="EnergyLabel" type="Label" parent="Own/HBoxContainer"] +[node name="CardBase" parent="Own/Hand" instance=ExtResource("8_dytl5")] layout_mode = 2 -text = "Energy:" -[node name="Hand" type="HBoxContainer" parent="Own"] +[node name="CardBase2" parent="Own/Hand" instance=ExtResource("9_cabcc")] 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")] +[node name="IncomingDamageLabel" type="Label" parent="Own"] layout_mode = 1 -anchors_preset = 10 -anchor_right = 1.0 -offset_bottom = 190.0 +anchors_preset = 5 +anchor_left = 0.5 +anchor_right = 0.5 +offset_left = -83.5 +offset_top = 300.0 +offset_right = 83.5 +offset_bottom = 323.0 grow_horizontal = 2 +text = "Incoming Damage: 0" +horizontal_alignment = 1 + +[node name="Opponent" type="Control" parent="." node_paths=PackedStringArray("deck", "energy_label")] +layout_mode = 1 +anchor_right = 1.0 +anchor_bottom = 0.5 +grow_horizontal = 2 +grow_vertical = 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="MonsterCard" parent="Opponent" instance=ExtResource("7_4ah45")] +custom_minimum_size = Vector2(220, 330) +layout_mode = 1 +anchors_preset = 7 +anchor_left = 0.5 +anchor_top = 1.0 +anchor_right = 0.5 +offset_left = -110.0 +offset_top = -350.0 +offset_right = 110.0 +offset_bottom = -20.0 +grow_vertical = 0 +pivot_offset = Vector2(110, 330) +size_flags_horizontal = 4 +size_flags_vertical = 4 + +[node name="Support1GreenCard" parent="Opponent" instance=ExtResource("8_dytl5")] +layout_mode = 1 +anchors_preset = 7 +anchor_left = 0.5 +anchor_top = 1.0 +anchor_right = 0.5 +anchor_bottom = 1.0 +offset_left = -310.0 +offset_top = -465.0 +offset_right = -90.0 +offset_bottom = -145.0 +grow_horizontal = 2 +grow_vertical = 0 +pivot_offset = Vector2(110, 320) + +[node name="Support2GreenCard" parent="Opponent" instance=ExtResource("8_dytl5")] +layout_mode = 1 +anchors_preset = 7 +anchor_left = 0.5 +anchor_top = 1.0 +anchor_right = 0.5 +anchor_bottom = 1.0 +offset_left = 90.0 +offset_top = -465.0 +offset_right = 310.0 +offset_bottom = -145.0 +grow_horizontal = 2 +grow_vertical = 0 +pivot_offset = Vector2(110, 320) + +[node name="Support2RedCard" parent="Opponent" instance=ExtResource("9_cabcc")] +layout_mode = 1 +anchors_preset = 7 +anchor_left = 0.5 +anchor_top = 1.0 +anchor_right = 0.5 +anchor_bottom = 1.0 +offset_left = 90.0 +offset_top = -465.0 +offset_right = 310.0 +offset_bottom = -145.0 +grow_horizontal = 2 +grow_vertical = 0 +pivot_offset = Vector2(110, 320) + [node name="Hand" type="HBoxContainer" parent="Opponent"] -layout_mode = 2 +layout_mode = 1 +anchors_preset = 10 +anchor_right = 1.0 +offset_bottom = 31.0 +grow_horizontal = 2 alignment = 1 [node name="Button" type="Button" parent="Opponent/Hand"] @@ -117,33 +232,26 @@ text = "CARD_3" [node name="EnergyLabel" type="Label" parent="Opponent"] layout_mode = 2 +offset_top = 35.0 +offset_right = 1152.0 +offset_bottom = 58.0 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="IncomingDamageLabel" type="Label" parent="Opponent"] +layout_mode = 1 +anchors_preset = 7 +anchor_left = 0.5 +anchor_top = 1.0 +anchor_right = 0.5 +anchor_bottom = 1.0 +offset_left = -83.5 +offset_top = -325.0 +offset_right = 83.5 +offset_bottom = -302.0 +grow_horizontal = 2 +grow_vertical = 0 +text = "Incoming Damage: 0" +horizontal_alignment = 1 [node name="StartGameButton" type="Button" parent="."] layout_mode = 1 diff --git a/main.tscn b/main.tscn index 523431c..e0e520e 100644 --- a/main.tscn +++ b/main.tscn @@ -63,9 +63,12 @@ layout_mode = 1 [node name="DisconnectButton" type="Button" parent="AfterConnect"] unique_name_in_owner = true -layout_mode = 2 -offset_left = 966.0 -offset_right = 1152.0 +layout_mode = 1 +anchors_preset = 1 +anchor_left = 1.0 +anchor_right = 1.0 +offset_left = -186.0 offset_bottom = 31.0 +grow_horizontal = 0 size_flags_horizontal = 8 text = "Disconnect" diff --git a/player_side.gd b/player_side.gd index d834319..df76a72 100644 --- a/player_side.gd +++ b/player_side.gd @@ -4,14 +4,22 @@ 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 +@export var skip_card_prefab: PackedScene +@export var support_red_card_prefab: PackedScene +@export var support_green_card_prefab: PackedScene +@export var monster_card_prefab: PackedScene + +@onready var monster_card_ui := $"MonsterCard" +@onready var support1_green := $"Support1GreenCard" +@onready var support2_green := $"Support2GreenCard" +@onready var support2_red := $"Support2RedCard" +@onready var incoming_damage_label := $"IncomingDamageLabel" var match_manager: MatchManager var show_buttons: bool var signal_connected: bool +var selected_card: Control func attach(match_manager: MatchManager, show_buttons: bool = true): self.show_buttons = show_buttons @@ -20,18 +28,49 @@ func attach(match_manager: MatchManager, show_buttons: bool = true): match_manager.state_transitioned.connect(_on_update) signal_connected = true +func _ready(): + monster_card_ui.visible = false + support1_green.visible = false + support2_green.visible = false + support2_red.visible = false + func _on_update(transition): + selected_card = null + 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) + + if match_manager.support_cards_1.has(player): + support1_green.visible = true + support1_green.card = match_manager.support_cards_1[player] + else: + support1_green.visible = false + + if match_manager.support_cards_2.has(player): + var card: SupportCard = match_manager.support_cards_2[player] + if card.type == "green": + support2_green.visible = true + support2_green.card = card + else: + support2_red.visible = true + support2_red.card = card + else: + support2_green.visible = false + support2_red.visible = false + + var monster = player.monster + if monster: - monster_name_label.text = "Name: " + monster.card.id - monster_health_label.text = "Health: " + str(monster.health) + monster_card_ui.visible = true + monster_card_ui.show_monster(monster) incoming_damage_label.text = "Incoming Damage: " + str(monster.health_delta) + else: + monster_card_ui.visible = false if match_manager.phase in [Match.Phase.SUMMON, Match.Phase.SUPPORT_1, Match.Phase.SUPPORT_2]: if ( @@ -39,9 +78,10 @@ func _on_update(transition): ) or ( match_manager.phase == Match.Phase.SUMMON and player.monster and player.monster.health > 0 && show_buttons ): - var skip_btn = Button.new() - skip_btn.text = "Skip" - skip_btn.button_up.connect(func (): play_card.emit(null)) + var skip_btn:CardBase = skip_card_prefab.instantiate() + skip_btn.left_clicked.connect(func (): + _pop_this_card(skip_btn) + play_card.emit(null)) deck.add_child(skip_btn) for card: Card in player.hand: @@ -55,10 +95,7 @@ func _on_update(transition): if !show_buttons : continue - var btn = Button.new() - btn.text = card.id - btn.button_up.connect(func (): play_card.emit(card)) - btn.disabled = ( + var is_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 @@ -67,7 +104,32 @@ func _on_update(transition): ) or ( card is MonsterCard and match_manager.phase == Match.Phase.SUMMON and player.monster and player.monster.health > 0 ) - deck.add_child(btn) + + var btn: CardBase = null + if card is MonsterCard: + var monster_card:MonsterCardUI = monster_card_prefab.instantiate() + monster_card.show_monster(MatchMonster.new(card, card.base_health, 0)) + + if !is_disabled: + monster_card.left_clicked.connect(func (): + _pop_this_card(monster_card) + play_card.emit(card)) + deck.add_child(monster_card) + + elif card is SupportCard and card.type == "red": + btn = support_red_card_prefab.instantiate() + btn.card = card + deck.add_child(btn) + else: + btn = support_green_card_prefab.instantiate() + btn.card = card + deck.add_child(btn) + + if btn and !is_disabled: + btn.left_clicked.connect(func (): + _pop_this_card(btn) + play_card.emit(card)) + if match_manager.phase == Match.Phase.RPS: for move in ["rock", "paper", "scissors"]: @@ -78,4 +140,10 @@ func _on_update(transition): btn.text = move btn.button_up.connect(func (): rps_move.emit(move)) deck.add_child(btn) + +func _pop_this_card(control: Control): + if selected_card: + selected_card.size_flags_vertical = Control.SIZE_SHRINK_END + control.size_flags_vertical = Control.SIZE_SHRINK_BEGIN + selected_card = control diff --git a/project.godot b/project.godot index 3f421a3..c65b3ca 100644 --- a/project.godot +++ b/project.godot @@ -19,6 +19,12 @@ config/icon="res://icon.svg" Match="*res://tcg/match/match.gd" +[display] + +window/size/viewport_width=1920 +window/size/viewport_height=1080 +window/stretch/mode="viewport" + [rendering] renderer/rendering_method="mobile" diff --git a/tcg/match/match_manager.gd b/tcg/match/match_manager.gd index 994347a..12a1b7d 100644 --- a/tcg/match/match_manager.gd +++ b/tcg/match/match_manager.gd @@ -22,6 +22,9 @@ var player_2: MatchPlayer: return players[actual_p2_id] as MatchPlayer var phase: Match.Phase = Match.Phase.PREGAME +var support_cards_1: Dictionary = {} +var support_cards_2: Dictionary = {} + var actual_p1_id: int var actual_p2_id: int @@ -72,6 +75,9 @@ func resolve(action_by_player_id: Dictionary) -> PhaseTransition: ) phase = Match.Phase.SUMMON Match.Phase.SUMMON: + support_cards_1.clear() + support_cards_2.clear() + for player_id in action_by_player_id.keys(): var action = action_by_player_id[player_id] if action is ActionPlayCard: @@ -83,18 +89,23 @@ func resolve(action_by_player_id: Dictionary) -> PhaseTransition: if players.values().all(func(player: MatchPlayer): return player.monster): phase = Match.Phase.SUPPORT_1 Match.Phase.SUPPORT_1: + support_cards_1.clear() + support_cards_2.clear() + var support_cards = [] if player_1_action is ActionPlayCard: support_cards.append({ "player": player_1, "card": player_1_action.card }) + support_cards_1[player_1] = player_1_action.card player_1.hand.erase(player_1_action.card) if player_2_action is ActionPlayCard: support_cards.append({ "player": player_2, "card": player_2_action.card }) + support_cards_1[player_2] = 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: @@ -118,12 +129,14 @@ func resolve(action_by_player_id: Dictionary) -> PhaseTransition: "player": player_1, "card": player_1_action.card }) + support_cards_2[player_1] = player_1_action.card player_1.hand.erase(player_1_action.card) if player_2_action is ActionPlayCard: support_cards.append({ "player": player_2, "card": player_2_action.card }) + support_cards_2[player_2] = 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: diff --git a/ui/card_template/card_base.gd b/ui/card_template/card_base.gd index 12acc63..96bc2d1 100644 --- a/ui/card_template/card_base.gd +++ b/ui/card_template/card_base.gd @@ -1,4 +1,9 @@ extends Control +class_name CardBase + +signal left_clicked +signal right_clicked +signal hovering(delta: float) @export var card_name_label: Label @export var card_desc_label: Label @@ -17,4 +22,23 @@ func _update(card: SupportCard): card_desc_label.text = card.description icon_rect.texture = card.icon - +func _process(delta): + var mouse_position = get_global_mouse_position() + var rect = get_global_rect() + if rect.has_point(mouse_position): + hovering.emit(delta) + +func _input(event): + if event is InputEventMouseButton: + if !event.is_pressed(): + return + + var mouse_position = get_global_mouse_position() + var rect = get_global_rect() + if not rect.has_point(mouse_position): + return + + if event.button_index == MOUSE_BUTTON_LEFT: + left_clicked.emit() + elif event.button_index == MOUSE_BUTTON_RIGHT: + right_clicked.emit() diff --git a/ui/card_template/monster_card.gd b/ui/card_template/monster_card.gd index 30349e6..4e72542 100644 --- a/ui/card_template/monster_card.gd +++ b/ui/card_template/monster_card.gd @@ -1,7 +1,56 @@ extends Control +class_name MonsterCardUI -@export var name_label: Label -@export var health_label: Label -@export var energy_pip_container: Container -@export var energy_pip: PackedScene -@export var art: Texture2D +signal left_clicked +signal right_clicked +signal hovering(delta: float) + +@export var name_label : Label +@export var health_label : Label +@export var energy_pip_container :Container +@export var icon_texture_rect : TextureRect +@export var paper_damage : Label +@export var scissors_damage : Label +@export var rock_damage : Label + +func show_monster(monster: MatchMonster): + if !monster: + name_label.text = "" + health_label.text = "HP" + icon_texture_rect.texture = null + return + + name_label.text = monster.card.id + health_label.text = "HP %d" % [monster.health] + icon_texture_rect.texture = monster.card.icon + + paper_damage.text = str(monster.card.paper) + scissors_damage.text = str(monster.card.scissors) + rock_damage.text = str(monster.card.rock) + + var shown_stars = 0 + for child in energy_pip_container.get_children(): + var tr = child as TextureRect + tr.visible = shown_stars < monster.card.energy_cost + shown_stars += 1 + +func _process(delta): + var mouse_position = get_global_mouse_position() + var rect = get_global_rect() + if rect.has_point(mouse_position): + hovering.emit(delta) + +func _input(event): + if event is InputEventMouseButton: + if !event.is_pressed(): + return + + var mouse_position = get_global_mouse_position() + var rect = get_global_rect() + if not rect.has_point(mouse_position): + return + + if event.button_index == MOUSE_BUTTON_LEFT: + left_clicked.emit() + elif event.button_index == MOUSE_BUTTON_RIGHT: + right_clicked.emit() diff --git a/ui/card_template/monster_card.tscn b/ui/card_template/monster_card.tscn index cee06b2..9d8a797 100644 --- a/ui/card_template/monster_card.tscn +++ b/ui/card_template/monster_card.tscn @@ -15,16 +15,27 @@ [ext_resource type="Texture2D" uid="uid://ch04c20lkis6j" path="res://assets/card_base/gunting.png" id="13_ifoc6"] [ext_resource type="Texture2D" uid="uid://b0pclmv0j0r12" path="res://assets/card_base/kertas.png" id="14_gm7k7"] -[node name="MonsterCard" type="Control"] +[node name="MonsterCard" type="Control" node_paths=PackedStringArray("name_label", "health_label", "energy_pip_container", "icon_texture_rect", "paper_damage", "scissors_damage", "rock_damage")] +custom_minimum_size = Vector2(220, 320) layout_mode = 3 anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 -offset_right = -932.0 -offset_bottom = -328.0 +offset_right = -1700.0 +offset_bottom = -760.0 grow_horizontal = 2 grow_vertical = 2 +scale = Vector2(0.7, 0.7) +pivot_offset = Vector2(110, 160) +size_flags_vertical = 8 script = ExtResource("1_xddej") +name_label = NodePath("MarginContainer/MonsterNameLabel") +health_label = NodePath("MarginContainer/HealthLabel") +energy_pip_container = NodePath("MarginContainer/EnergyStarsContainer") +icon_texture_rect = NodePath("MarginContainer/TextureRect2/IconTextureRect") +paper_damage = NodePath("MarginContainer/Paper/PaperDamage") +scissors_damage = NodePath("MarginContainer/Scissors/ScissorsDamage") +rock_damage = NodePath("MarginContainer/Rock/RockDamage") [node name="Screenshot2025-01-25211435" type="Sprite2D" parent="."] visible = false @@ -95,7 +106,8 @@ texture = ExtResource("7_qe8a1") expand_mode = 1 stretch_mode = 5 -[node name="TextureRect" type="TextureRect" parent="MarginContainer/TextureRect2"] +[node name="IconTextureRect" type="TextureRect" parent="MarginContainer/TextureRect2"] +unique_name_in_owner = true layout_mode = 1 anchors_preset = 15 anchor_right = 1.0 @@ -106,32 +118,34 @@ texture = ExtResource("7_j2i0p") expand_mode = 1 stretch_mode = 5 -[node name="EnergyStars" type="HBoxContainer" parent="MarginContainer"] +[node name="EnergyStarsContainer" type="HBoxContainer" parent="MarginContainer"] +unique_name_in_owner = true layout_mode = 0 offset_left = 141.0 offset_top = 55.0 offset_right = 200.0 offset_bottom = 70.0 -[node name="TextureRect3" type="TextureRect" parent="MarginContainer/EnergyStars"] +[node name="TextureRect3" type="TextureRect" parent="MarginContainer/EnergyStarsContainer"] layout_mode = 2 texture = ExtResource("8_ophhb") expand_mode = 3 stretch_mode = 5 -[node name="TextureRect2" type="TextureRect" parent="MarginContainer/EnergyStars"] +[node name="TextureRect2" type="TextureRect" parent="MarginContainer/EnergyStarsContainer"] layout_mode = 2 texture = ExtResource("8_ophhb") expand_mode = 3 stretch_mode = 5 -[node name="TextureRect" type="TextureRect" parent="MarginContainer/EnergyStars"] +[node name="TextureRect" type="TextureRect" parent="MarginContainer/EnergyStarsContainer"] layout_mode = 2 texture = ExtResource("8_ophhb") expand_mode = 3 stretch_mode = 5 -[node name="HPNumber" type="Label" parent="MarginContainer"] +[node name="HealthLabel" type="Label" parent="MarginContainer"] +unique_name_in_owner = true layout_mode = 1 anchors_preset = 10 anchor_right = 1.0 @@ -146,6 +160,7 @@ text = "HP 80" vertical_alignment = 1 [node name="MonsterNameLabel" type="Label" parent="MarginContainer"] +unique_name_in_owner = true layout_mode = 1 anchors_preset = 10 anchor_right = 1.0 @@ -191,6 +206,7 @@ horizontal_alignment = 1 vertical_alignment = 1 [node name="Paper" type="TextureRect" parent="MarginContainer"] +layout_mode = 0 offset_left = 109.0 offset_top = 183.0 offset_right = 222.0 @@ -199,7 +215,8 @@ texture = ExtResource("14_gm7k7") expand_mode = 1 stretch_mode = 5 -[node name="HPNumber" type="Label" parent="MarginContainer/Paper"] +[node name="PaperDamage" type="Label" parent="MarginContainer/Paper"] +unique_name_in_owner = true layout_mode = 1 anchors_preset = 10 anchor_right = 1.0 @@ -214,6 +231,7 @@ text = "10" vertical_alignment = 1 [node name="Scissors" type="TextureRect" parent="MarginContainer"] +layout_mode = 0 offset_left = 43.0 offset_top = 182.0 offset_right = 156.0 @@ -222,7 +240,8 @@ texture = ExtResource("13_ifoc6") expand_mode = 1 stretch_mode = 5 -[node name="HPNumber" type="Label" parent="MarginContainer/Scissors"] +[node name="ScissorsDamage" type="Label" parent="MarginContainer/Scissors"] +unique_name_in_owner = true layout_mode = 1 anchors_preset = 10 anchor_right = 1.0 @@ -246,7 +265,8 @@ texture = ExtResource("12_a4kkh") expand_mode = 1 stretch_mode = 5 -[node name="HPNumber" type="Label" parent="MarginContainer/Rock"] +[node name="RockDamage" type="Label" parent="MarginContainer/Rock"] +unique_name_in_owner = true layout_mode = 1 anchors_preset = 10 anchor_right = 1.0 diff --git a/ui/card_template/skip_card.tscn b/ui/card_template/skip_card.tscn new file mode 100644 index 0000000..f5ff411 --- /dev/null +++ b/ui/card_template/skip_card.tscn @@ -0,0 +1,274 @@ +[gd_scene load_steps=14 format=3 uid="uid://b60vuykleugjn"] + +[ext_resource type="Script" path="res://ui/card_template/card_base.gd" id="1_ci66m"] +[ext_resource type="Texture2D" uid="uid://l2nxxhh0pvh8" path="res://assets/card_base/Frame.png" id="3_lbsr3"] +[ext_resource type="Texture2D" uid="uid://crgrple0uik7x" path="res://assets/card_base/Stroke.png" id="4_avv1r"] +[ext_resource type="Texture2D" uid="uid://c2qyx2k50v2vv" path="res://assets/card_base/Monster-InnerFill.png" id="5_3yv36"] +[ext_resource type="Texture2D" uid="uid://dft4fbgoecbp4" path="res://assets/card_base/Illustrated BG.png" id="6_cfl8c"] +[ext_resource type="Texture2D" uid="uid://b8accn4e2ojau" path="res://assets/monster/froggo 1.png" id="7_5xgn0"] +[ext_resource type="Texture2D" uid="uid://cqttp0i3vph37" path="res://assets/card_base/Star.png" id="8_gh78y"] +[ext_resource type="Theme" path="res://cards.tres" id="9_gwg6h"] +[ext_resource type="Texture2D" uid="uid://cjmxetjq82rl2" path="res://assets/card_base/Pip.png" id="10_kd76d"] +[ext_resource type="FontFile" uid="uid://08q3kkwmd4u6" path="res://assets/Inter-Regular.otf" id="11_ofcpo"] +[ext_resource type="Texture2D" uid="uid://b0pclmv0j0r12" path="res://assets/card_base/kertas.png" id="12_dql2x"] +[ext_resource type="Texture2D" uid="uid://ch04c20lkis6j" path="res://assets/card_base/gunting.png" id="13_0vsuw"] +[ext_resource type="Texture2D" uid="uid://bywa8qlwvcksd" path="res://assets/card_base/batu.png" id="14_o8cdd"] + +[node name="SkipCard" type="Control"] +custom_minimum_size = Vector2(220, 320) +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_right = -1700.0 +offset_bottom = -760.0 +grow_horizontal = 2 +grow_vertical = 2 +scale = Vector2(0.7, 0.7) +pivot_offset = Vector2(110, 160) +size_flags_vertical = 8 +script = ExtResource("1_ci66m") + +[node name="Frame" type="TextureRect" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("3_lbsr3") +expand_mode = 1 + +[node name="MarginContainer" type="Control" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = 4.0 +offset_top = 3.0 +offset_right = -5.0 +offset_bottom = -4.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="OuterStroke" type="NinePatchRect" parent="MarginContainer"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("4_avv1r") + +[node name="InnerFill" type="TextureRect" parent="MarginContainer"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_top = 43.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("5_3yv36") +expand_mode = 1 + +[node name="InnerStroke" type="NinePatchRect" parent="MarginContainer"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_top = 42.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("4_avv1r") + +[node name="TextureRect2" type="TextureRect" parent="MarginContainer"] +layout_mode = 0 +offset_left = 9.0 +offset_top = 77.0 +offset_right = 199.0 +offset_bottom = 207.0 +pivot_offset = Vector2(95, 65) +texture = ExtResource("6_cfl8c") +expand_mode = 1 +stretch_mode = 5 + +[node name="IconTextureRect" type="TextureRect" parent="MarginContainer/TextureRect2"] +unique_name_in_owner = true +visible = false +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("7_5xgn0") +expand_mode = 1 +stretch_mode = 5 + +[node name="EnergyStarsContainer" type="HBoxContainer" parent="MarginContainer"] +unique_name_in_owner = true +visible = false +layout_mode = 0 +offset_left = 141.0 +offset_top = 55.0 +offset_right = 200.0 +offset_bottom = 70.0 + +[node name="TextureRect3" type="TextureRect" parent="MarginContainer/EnergyStarsContainer"] +layout_mode = 2 +texture = ExtResource("8_gh78y") +expand_mode = 3 +stretch_mode = 5 + +[node name="TextureRect2" type="TextureRect" parent="MarginContainer/EnergyStarsContainer"] +layout_mode = 2 +texture = ExtResource("8_gh78y") +expand_mode = 3 +stretch_mode = 5 + +[node name="TextureRect" type="TextureRect" parent="MarginContainer/EnergyStarsContainer"] +layout_mode = 2 +texture = ExtResource("8_gh78y") +expand_mode = 3 +stretch_mode = 5 + +[node name="HealthLabel" type="Label" parent="MarginContainer"] +unique_name_in_owner = true +visible = false +layout_mode = 1 +anchors_preset = 10 +anchor_right = 1.0 +offset_left = 14.0 +offset_top = 44.0 +offset_right = -99.0 +offset_bottom = 80.0 +grow_horizontal = 2 +theme = ExtResource("9_gwg6h") +theme_override_font_sizes/font_size = 16 +text = "HP 80" +vertical_alignment = 1 + +[node name="MonsterNameLabel" type="Label" parent="MarginContainer"] +unique_name_in_owner = true +layout_mode = 1 +anchors_preset = 10 +anchor_right = 1.0 +offset_left = 63.1429 +offset_top = 118.429 +offset_right = 58.1429 +offset_bottom = 154.429 +grow_horizontal = 2 +theme = ExtResource("9_gwg6h") +theme_override_font_sizes/font_size = 26 +text = "SKIP" +vertical_alignment = 1 + +[node name="CardNumber" type="TextureRect" parent="MarginContainer"] +visible = false +layout_mode = 0 +offset_left = 7.0 +offset_top = 17.0 +offset_right = 26.0 +offset_bottom = 36.0 +texture = ExtResource("10_kd76d") +expand_mode = 1 +stretch_mode = 5 + +[node name="Label" type="Label" parent="MarginContainer/CardNumber"] +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -9.5 +offset_top = -7.0 +offset_right = 9.5 +offset_bottom = 7.0 +grow_horizontal = 2 +grow_vertical = 2 +theme = ExtResource("9_gwg6h") +theme_override_colors/font_color = Color(0, 0, 0, 1) +theme_override_fonts/font = ExtResource("11_ofcpo") +theme_override_font_sizes/font_size = 6 +text = "#01" +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="Paper" type="TextureRect" parent="MarginContainer"] +visible = false +layout_mode = 0 +offset_left = 109.0 +offset_top = 183.0 +offset_right = 222.0 +offset_bottom = 356.0 +texture = ExtResource("12_dql2x") +expand_mode = 1 +stretch_mode = 5 + +[node name="PaperDamage" type="Label" parent="MarginContainer/Paper"] +unique_name_in_owner = true +layout_mode = 1 +anchors_preset = 10 +anchor_right = 1.0 +offset_left = 48.0 +offset_top = 32.0 +offset_right = -32.0 +offset_bottom = 73.0 +grow_horizontal = 2 +theme = ExtResource("9_gwg6h") +theme_override_font_sizes/font_size = 20 +text = "10" +vertical_alignment = 1 + +[node name="Scissors" type="TextureRect" parent="MarginContainer"] +visible = false +layout_mode = 0 +offset_left = 43.0 +offset_top = 182.0 +offset_right = 156.0 +offset_bottom = 355.0 +texture = ExtResource("13_0vsuw") +expand_mode = 1 +stretch_mode = 5 + +[node name="ScissorsDamage" type="Label" parent="MarginContainer/Scissors"] +unique_name_in_owner = true +layout_mode = 1 +anchors_preset = 10 +anchor_right = 1.0 +offset_left = 48.0 +offset_top = 32.0 +offset_right = -32.0 +offset_bottom = 73.0 +grow_horizontal = 2 +theme = ExtResource("9_gwg6h") +theme_override_font_sizes/font_size = 20 +text = "10" +vertical_alignment = 1 + +[node name="Rock" type="TextureRect" parent="MarginContainer"] +visible = false +layout_mode = 0 +offset_left = -23.0 +offset_top = 181.0 +offset_right = 90.0 +offset_bottom = 354.0 +texture = ExtResource("14_o8cdd") +expand_mode = 1 +stretch_mode = 5 + +[node name="RockDamage" type="Label" parent="MarginContainer/Rock"] +unique_name_in_owner = true +layout_mode = 1 +anchors_preset = 10 +anchor_right = 1.0 +offset_left = 48.0 +offset_top = 32.0 +offset_right = -32.0 +offset_bottom = 73.0 +grow_horizontal = 2 +theme = ExtResource("9_gwg6h") +theme_override_font_sizes/font_size = 20 +text = "10" +vertical_alignment = 1 diff --git a/ui/card_template/support_card_green.tscn b/ui/card_template/support_card_green.tscn index 6bf7743..a367d4b 100644 --- a/ui/card_template/support_card_green.tscn +++ b/ui/card_template/support_card_green.tscn @@ -7,15 +7,19 @@ [ext_resource type="Texture2D" uid="uid://blejyda8mendg" path="res://assets/card_base/InnerFill.png" id="4_pgomu"] [ext_resource type="Texture2D" uid="uid://by7ws88pn4tvb" path="res://assets/card_base/Separator.png" id="5_501uu"] [ext_resource type="Texture2D" uid="uid://0gxplli5krq2" path="res://assets/card_base/Pill.png" id="6_ce7hm"] -[ext_resource type="Theme" uid="uid://cj3vs5hq2mcbp" path="res://cards.tres" id="7_va1d7"] +[ext_resource type="Theme" path="res://cards.tres" id="7_va1d7"] [ext_resource type="Texture2D" uid="uid://rh3aswb0p7ri" path="res://assets/energy.png" id="8_4yq42"] [ext_resource type="FontFile" uid="uid://08q3kkwmd4u6" path="res://assets/Inter-Regular.otf" id="10_c2ugn"] [node name="CardBase" type="Control" node_paths=PackedStringArray("card_name_label", "card_desc_label", "icon_rect")] +custom_minimum_size = Vector2(220, 320) layout_mode = 3 anchors_preset = 0 offset_right = 220.0 offset_bottom = 320.0 +scale = Vector2(0.7, 0.7) +pivot_offset = Vector2(110, 160) +size_flags_vertical = 8 script = ExtResource("1_rpopv") card_name_label = NodePath("MarginContainer/Label") card_desc_label = NodePath("MarginContainer/DescriptionLabel") @@ -144,6 +148,7 @@ horizontal_alignment = 1 vertical_alignment = 1 [node name="Icon" type="TextureRect" parent="MarginContainer"] +layout_mode = 0 offset_left = 26.0 offset_top = 74.0 offset_right = 169.0 @@ -153,6 +158,7 @@ expand_mode = 1 stretch_mode = 6 [node name="DescriptionLabel" type="Label" parent="MarginContainer"] +layout_mode = 0 offset_left = 11.0 offset_top = 224.0 offset_right = 200.0 diff --git a/ui/card_template/support_card_red.tscn b/ui/card_template/support_card_red.tscn index d06b8dc..c84cdc5 100644 --- a/ui/card_template/support_card_red.tscn +++ b/ui/card_template/support_card_red.tscn @@ -7,15 +7,19 @@ [ext_resource type="Texture2D" uid="uid://blejyda8mendg" path="res://assets/card_base/InnerFill.png" id="4_2fw8n"] [ext_resource type="Texture2D" uid="uid://by7ws88pn4tvb" path="res://assets/card_base/Separator.png" id="5_n3v14"] [ext_resource type="Texture2D" uid="uid://0gxplli5krq2" path="res://assets/card_base/Pill.png" id="6_wrd2a"] -[ext_resource type="Theme" uid="uid://cj3vs5hq2mcbp" path="res://cards.tres" id="7_fp6ys"] +[ext_resource type="Theme" path="res://cards.tres" id="7_fp6ys"] [ext_resource type="FontFile" uid="uid://08q3kkwmd4u6" path="res://assets/Inter-Regular.otf" id="9_vilw6"] [ext_resource type="Texture2D" uid="uid://rh3aswb0p7ri" path="res://assets/energy.png" id="10_2t0ey"] [node name="CardBase" type="Control" node_paths=PackedStringArray("card_name_label", "card_desc_label", "icon_rect")] +custom_minimum_size = Vector2(220, 320) layout_mode = 3 anchors_preset = 0 offset_right = 220.0 offset_bottom = 320.0 +scale = Vector2(0.7, 0.7) +pivot_offset = Vector2(110, 160) +size_flags_vertical = 8 script = ExtResource("1_d22a5") card_name_label = NodePath("MarginContainer/Title") card_desc_label = NodePath("MarginContainer/DescriptionLabel") From 3ac654af4f6036d1c5b542f5b0f40e4fe46a5dbb Mon Sep 17 00:00:00 2001 From: istamarahsan Date: Sun, 26 Jan 2025 02:32:21 +0700 Subject: [PATCH 11/29] fix: remove placeholder cards --- cards.tres | 2 +- demo_game.tscn | 2 +- player_side.gd | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cards.tres b/cards.tres index e4debd9..e5f7591 100644 --- a/cards.tres +++ b/cards.tres @@ -1,4 +1,4 @@ -[gd_resource type="Theme" load_steps=2 format=3 uid="uid://cj3vs5hq2mcbp"] +[gd_resource type="Theme" load_steps=2 format=3 uid="uid://qe383ytjm3v"] [ext_resource type="FontFile" uid="uid://ncoq4i61plvt" path="res://assets/Bohemian Soul.otf" id="1_yowck"] diff --git a/demo_game.tscn b/demo_game.tscn index fb4877e..d4c8e2d 100644 --- a/demo_game.tscn +++ b/demo_game.tscn @@ -4,7 +4,7 @@ [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" path="res://data/cards/monster/capytain.tres" id="3_we1tk"] +[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://deo8mj887rfx1" path="res://data/cards/monster/axoluna.tres" id="5_3cm5x"] [ext_resource type="PackedScene" uid="uid://bhrelvt51cbp2" path="res://ui/card_template/monster_card.tscn" id="7_4ah45"] diff --git a/player_side.gd b/player_side.gd index df76a72..5bfcd9e 100644 --- a/player_side.gd +++ b/player_side.gd @@ -33,6 +33,8 @@ func _ready(): support1_green.visible = false support2_green.visible = false support2_red.visible = false + for child in deck.get_children(): + child.queue_free() func _on_update(transition): selected_card = null From 6026a32429a1cbd7a93fe2f86652129d9c90fcd8 Mon Sep 17 00:00:00 2001 From: istamarahsan Date: Sun, 26 Jan 2025 02:48:27 +0700 Subject: [PATCH 12/29] 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 From 314106625856c60975c5a445a99c2d0082a029fc Mon Sep 17 00:00:00 2001 From: kennetha123 Date: Sun, 26 Jan 2025 02:50:21 +0700 Subject: [PATCH 13/29] feat: implement all support card tres --- data/cards/support/absorb.tres | 12 ++++++++++++ data/cards/support/all_out_attack.tres | 12 ++++++++++++ data/cards/support/attack_mode.tres | 12 ++++++++++++ data/cards/support/caller.tres | 12 ++++++++++++ data/cards/support/cash_back.tres | 12 ++++++++++++ data/cards/support/catcher.tres | 12 ++++++++++++ data/cards/support/energy_booster.tres | 12 ++++++++++++ data/cards/support/insurance.tres | 12 ++++++++++++ data/cards/support/invisibility.tres | 12 ++++++++++++ data/cards/support/lifesteal.tres | 12 ++++++++++++ data/cards/support/negate.tres | 12 ++++++++++++ data/cards/support/paper.tres | 12 ++++++++++++ data/cards/support/reflection.tres | 12 ++++++++++++ data/cards/support/retreat.tres | 12 ++++++++++++ data/cards/support/reviver.tres | 12 ++++++++++++ data/cards/support/rock.tres | 12 ++++++++++++ data/cards/support/scissor.tres | 12 ++++++++++++ data/cards/support/sword_mastery.tres | 18 ++++++++++++++++++ data/cards/support/tanker.tres | 12 ++++++++++++ data/support_effects/sword_mastery.tres | 6 ++++++ 20 files changed, 240 insertions(+) create mode 100644 data/cards/support/absorb.tres create mode 100644 data/cards/support/all_out_attack.tres create mode 100644 data/cards/support/attack_mode.tres create mode 100644 data/cards/support/caller.tres create mode 100644 data/cards/support/cash_back.tres create mode 100644 data/cards/support/catcher.tres create mode 100644 data/cards/support/energy_booster.tres create mode 100644 data/cards/support/insurance.tres create mode 100644 data/cards/support/invisibility.tres create mode 100644 data/cards/support/lifesteal.tres create mode 100644 data/cards/support/negate.tres create mode 100644 data/cards/support/paper.tres create mode 100644 data/cards/support/reflection.tres create mode 100644 data/cards/support/retreat.tres create mode 100644 data/cards/support/reviver.tres create mode 100644 data/cards/support/rock.tres create mode 100644 data/cards/support/scissor.tres create mode 100644 data/cards/support/sword_mastery.tres create mode 100644 data/cards/support/tanker.tres create mode 100644 data/support_effects/sword_mastery.tres diff --git a/data/cards/support/absorb.tres b/data/cards/support/absorb.tres new file mode 100644 index 0000000..705b320 --- /dev/null +++ b/data/cards/support/absorb.tres @@ -0,0 +1,12 @@ +[gd_resource type="Resource" script_class="SupportCard" 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/support_card.gd" id="2_x8k3o"] + +[resource] +script = ExtResource("2_x8k3o") +type = "red" +priority = 0 +effects = Array[ExtResource("1_mhxdy")]([null]) +name = "Absorb" +description = "Enemy damage converted to heal your Active Monster Field HP during this turn." diff --git a/data/cards/support/all_out_attack.tres b/data/cards/support/all_out_attack.tres new file mode 100644 index 0000000..d69f64b --- /dev/null +++ b/data/cards/support/all_out_attack.tres @@ -0,0 +1,12 @@ +[gd_resource type="Resource" script_class="SupportCard" 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.gd" id="2_1tjl7"] + +[resource] +script = ExtResource("2_1tjl7") +type = "green" +priority = 0 +effects = Array[ExtResource("1_fd50n")]([null]) +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." diff --git a/data/cards/support/attack_mode.tres b/data/cards/support/attack_mode.tres new file mode 100644 index 0000000..b3de463 --- /dev/null +++ b/data/cards/support/attack_mode.tres @@ -0,0 +1,12 @@ +[gd_resource type="Resource" script_class="SupportCard" load_steps=3 format=3 uid="uid://dcimexx4twoe2"] + +[ext_resource type="Script" path="res://tcg/card/support_card_effect_instance.gd" id="1_jl6i7"] +[ext_resource type="Script" path="res://tcg/card/support_card.gd" id="2_p06c1"] + +[resource] +script = ExtResource("2_p06c1") +type = "green" +priority = 0 +effects = Array[ExtResource("1_jl6i7")]([null]) +name = "Attack Mode" +description = "If you have Prankie in your Active Monster Field, set all Rock Paper Scissor to 100 permanently." diff --git a/data/cards/support/caller.tres b/data/cards/support/caller.tres new file mode 100644 index 0000000..397af59 --- /dev/null +++ b/data/cards/support/caller.tres @@ -0,0 +1,12 @@ +[gd_resource type="Resource" script_class="SupportCard" load_steps=3 format=3 uid="uid://5n2o4m7xqd13"] + +[ext_resource type="Script" path="res://tcg/card/support_card_effect_instance.gd" id="1_w4l0x"] +[ext_resource type="Script" path="res://tcg/card/support_card.gd" id="2_n7fiv"] + +[resource] +script = ExtResource("2_n7fiv") +type = "green" +priority = 0 +effects = Array[ExtResource("1_w4l0x")]([null]) +name = "Caller" +description = "Get 1 monster of your choice to your hand. Shuffle it afterwards." diff --git a/data/cards/support/cash_back.tres b/data/cards/support/cash_back.tres new file mode 100644 index 0000000..b13212f --- /dev/null +++ b/data/cards/support/cash_back.tres @@ -0,0 +1,12 @@ +[gd_resource type="Resource" script_class="SupportCard" load_steps=3 format=3 uid="uid://bk6myqvoklhqp"] + +[ext_resource type="Script" path="res://tcg/card/support_card_effect_instance.gd" id="1_7f5cd"] +[ext_resource type="Script" path="res://tcg/card/support_card.gd" id="2_prilx"] + +[resource] +script = ExtResource("2_prilx") +type = "red" +priority = 0 +effects = Array[ExtResource("1_7f5cd")]([null]) +name = "Cash Back" +description = "If your monster died during this turn, Refund all the energy being used by the monster sent to graveyard." diff --git a/data/cards/support/catcher.tres b/data/cards/support/catcher.tres new file mode 100644 index 0000000..ea9d5d8 --- /dev/null +++ b/data/cards/support/catcher.tres @@ -0,0 +1,12 @@ +[gd_resource type="Resource" script_class="SupportCard" load_steps=3 format=3 uid="uid://ca0fengr2xjps"] + +[ext_resource type="Script" path="res://tcg/card/support_card_effect_instance.gd" id="1_r7m0a"] +[ext_resource type="Script" path="res://tcg/card/support_card.gd" id="2_g1u6x"] + +[resource] +script = ExtResource("2_g1u6x") +type = "green" +priority = 0 +effects = Array[ExtResource("1_r7m0a")]([null]) +name = "Catcher" +description = "For one turn, swap your Active Enemy card with your Active Monster card. If the card you previously used died during this turn, you can keep the enemy monster card." diff --git a/data/cards/support/energy_booster.tres b/data/cards/support/energy_booster.tres new file mode 100644 index 0000000..c3e9de8 --- /dev/null +++ b/data/cards/support/energy_booster.tres @@ -0,0 +1,12 @@ +[gd_resource type="Resource" script_class="SupportCard" 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.gd" id="2_qqko6"] + +[resource] +script = ExtResource("2_qqko6") +type = "green" +priority = 0 +effects = Array[ExtResource("1_pkc1x")]([null]) +name = "Energy Booster" +description = "Add 1 additional Energy." diff --git a/data/cards/support/insurance.tres b/data/cards/support/insurance.tres new file mode 100644 index 0000000..4f53e44 --- /dev/null +++ b/data/cards/support/insurance.tres @@ -0,0 +1,12 @@ +[gd_resource type="Resource" script_class="SupportCard" 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.gd" id="2_286ne"] + +[resource] +script = ExtResource("2_286ne") +type = "red" +priority = 0 +effects = Array[ExtResource("1_gtyqr")]([null]) +name = "Insurance" +description = "If your monster supposed to be dead in this turn, keep it alive at 10 HP." diff --git a/data/cards/support/invisibility.tres b/data/cards/support/invisibility.tres new file mode 100644 index 0000000..c0a3499 --- /dev/null +++ b/data/cards/support/invisibility.tres @@ -0,0 +1,12 @@ +[gd_resource type="Resource" script_class="SupportCard" 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.gd" id="2_hsvj6"] + +[resource] +script = ExtResource("2_hsvj6") +type = "green" +priority = 0 +effects = Array[ExtResource("1_5tnpm")]([null]) +name = "Invisibility" +description = "Ignore any damage to your monster in this turn." diff --git a/data/cards/support/lifesteal.tres b/data/cards/support/lifesteal.tres new file mode 100644 index 0000000..26aa830 --- /dev/null +++ b/data/cards/support/lifesteal.tres @@ -0,0 +1,12 @@ +[gd_resource type="Resource" script_class="SupportCard" 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.gd" id="2_qww3m"] + +[resource] +script = ExtResource("2_qww3m") +type = "green" +priority = 0 +effects = Array[ExtResource("1_b33y4")]([null]) +name = "Lifesteal" +description = "During this turn your attack also heals your HP." diff --git a/data/cards/support/negate.tres b/data/cards/support/negate.tres new file mode 100644 index 0000000..1c634cd --- /dev/null +++ b/data/cards/support/negate.tres @@ -0,0 +1,12 @@ +[gd_resource type="Resource" script_class="SupportCard" 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.gd" id="2_v8fdj"] + +[resource] +script = ExtResource("2_v8fdj") +type = "red" +priority = 1 +effects = Array[ExtResource("1_awvxv")]([null]) +name = "Negate" +description = "Cancel 1 of the Support Card played by your opponent. This card will always be played last." diff --git a/data/cards/support/paper.tres b/data/cards/support/paper.tres new file mode 100644 index 0000000..71de883 --- /dev/null +++ b/data/cards/support/paper.tres @@ -0,0 +1,12 @@ +[gd_resource type="Resource" script_class="SupportCard" load_steps=3 format=3 uid="uid://crn3qovkygo6l"] + +[ext_resource type="Script" path="res://tcg/card/support_card_effect_instance.gd" id="1_gqbio"] +[ext_resource type="Script" path="res://tcg/card/support_card.gd" id="2_rr70q"] + +[resource] +script = ExtResource("2_rr70q") +type = "green" +priority = 0 +effects = Array[ExtResource("1_gqbio")]([null]) +name = "Force Paper" +description = "Forcing enemy to pick Paper during this turn." diff --git a/data/cards/support/reflection.tres b/data/cards/support/reflection.tres new file mode 100644 index 0000000..1833aad --- /dev/null +++ b/data/cards/support/reflection.tres @@ -0,0 +1,12 @@ +[gd_resource type="Resource" script_class="SupportCard" 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.gd" id="2_fliii"] + +[resource] +script = ExtResource("2_fliii") +type = "red" +priority = 0 +effects = Array[ExtResource("1_mk2or")]([null]) +name = "Reflection" +description = "Enemy got the same amount of damage as our monster in this turn." diff --git a/data/cards/support/retreat.tres b/data/cards/support/retreat.tres new file mode 100644 index 0000000..6582080 --- /dev/null +++ b/data/cards/support/retreat.tres @@ -0,0 +1,12 @@ +[gd_resource type="Resource" script_class="SupportCard" load_steps=3 format=3 uid="uid://cljmcpwa44j6b"] + +[ext_resource type="Script" path="res://tcg/card/support_card_effect_instance.gd" id="1_2w2ve"] +[ext_resource type="Script" path="res://tcg/card/support_card.gd" id="2_r3faa"] + +[resource] +script = ExtResource("2_r3faa") +type = "green" +priority = 0 +effects = Array[ExtResource("1_2w2ve")]([null]) +name = "Retreat" +description = "Swap your monster in Active Field with the one in your hand. The energy cost for summoning decreased by 1." diff --git a/data/cards/support/reviver.tres b/data/cards/support/reviver.tres new file mode 100644 index 0000000..8295ec0 --- /dev/null +++ b/data/cards/support/reviver.tres @@ -0,0 +1,12 @@ +[gd_resource type="Resource" script_class="SupportCard" load_steps=3 format=3 uid="uid://c3o6lxj0m6yod"] + +[ext_resource type="Script" path="res://tcg/card/support_card_effect_instance.gd" id="1_y5oux"] +[ext_resource type="Script" path="res://tcg/card/support_card.gd" id="2_7m5wu"] + +[resource] +script = ExtResource("2_7m5wu") +type = "red" +priority = 0 +effects = Array[ExtResource("1_y5oux")]([null]) +name = "Reviver" +description = "Revive 1 Monster of your choice from your graveyard, and move it into your hand." diff --git a/data/cards/support/rock.tres b/data/cards/support/rock.tres new file mode 100644 index 0000000..4237c53 --- /dev/null +++ b/data/cards/support/rock.tres @@ -0,0 +1,12 @@ +[gd_resource type="Resource" script_class="SupportCard" load_steps=3 format=3 uid="uid://defdobjmiloth"] + +[ext_resource type="Script" path="res://tcg/card/support_card_effect_instance.gd" id="1_hx76y"] +[ext_resource type="Script" path="res://tcg/card/support_card.gd" id="2_oinlp"] + +[resource] +script = ExtResource("2_oinlp") +type = "green" +priority = 0 +effects = Array[ExtResource("1_hx76y")]([null]) +name = "Force Rock" +description = "Forcing enemy to pick Rock during this turn." diff --git a/data/cards/support/scissor.tres b/data/cards/support/scissor.tres new file mode 100644 index 0000000..e9d5406 --- /dev/null +++ b/data/cards/support/scissor.tres @@ -0,0 +1,12 @@ +[gd_resource type="Resource" script_class="SupportCard" load_steps=3 format=3 uid="uid://d304v2sfewmp5"] + +[ext_resource type="Script" path="res://tcg/card/support_card_effect_instance.gd" id="1_q82mb"] +[ext_resource type="Script" path="res://tcg/card/support_card.gd" id="2_yklgt"] + +[resource] +script = ExtResource("2_yklgt") +type = "red" +priority = 0 +effects = Array[ExtResource("1_q82mb")]([null]) +name = "Force Scissor" +description = "Forcing enemy to pick Scissor during this turn." diff --git a/data/cards/support/sword_mastery.tres b/data/cards/support/sword_mastery.tres new file mode 100644 index 0000000..77eee88 --- /dev/null +++ b/data/cards/support/sword_mastery.tres @@ -0,0 +1,18 @@ +[gd_resource type="Resource" script_class="SupportCard" 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"] +[ext_resource type="Script" path="res://tcg/card/support_card.gd" id="2_vp8a3"] + +[sub_resource type="Resource" id="Resource_wwv02"] +script = ExtResource("1_y6yvj") +magnitude = 20 +effect = ExtResource("2_omhdb") + +[resource] +script = ExtResource("2_vp8a3") +type = "green" +priority = 0 +effects = Array[ExtResource("1_y6yvj")]([SubResource("Resource_wwv02")]) +name = "Sword Mastery" +description = "Permanently add 20 damage for all Rock Paper Scissor to 1 Active Monster." diff --git a/data/cards/support/tanker.tres b/data/cards/support/tanker.tres new file mode 100644 index 0000000..c51cbf2 --- /dev/null +++ b/data/cards/support/tanker.tres @@ -0,0 +1,12 @@ +[gd_resource type="Resource" script_class="SupportCard" 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.gd" id="2_m4ahe"] + +[resource] +script = ExtResource("2_m4ahe") +type = "red" +priority = 0 +effects = Array[ExtResource("1_1fvcb")]([null]) +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." diff --git a/data/support_effects/sword_mastery.tres b/data/support_effects/sword_mastery.tres new file mode 100644 index 0000000..1cb570e --- /dev/null +++ b/data/support_effects/sword_mastery.tres @@ -0,0 +1,6 @@ +[gd_resource type="Resource" script_class="SupportCardEffect" load_steps=2 format=3 uid="uid://bs4i85slalkgd"] + +[ext_resource type="Script" path="res://tcg/card/support_card_effect.gd" id="1_43nry"] + +[resource] +script = ExtResource("1_43nry") From fc70d205b3f479b0a46042370b1cb2bb70906b3c Mon Sep 17 00:00:00 2001 From: istamarahsan Date: Sun, 26 Jan 2025 05:00:37 +0700 Subject: [PATCH 14/29] feat: implement support cards - insurance - absorb - tanker - lifesteal - sword mastery - invisibility - potion - all out attack --- data/cards/support/absorb.tres | 11 ++-- data/cards/support/all_out_attack.tres | 9 +-- data/cards/support/energy_booster.tres | 9 +-- data/cards/support/insurance.tres | 9 +-- data/cards/support/invisibility.tres | 9 +-- data/cards/support/lifesteal.tres | 9 +-- data/cards/support/negate.tres | 9 +-- data/cards/support/potion.tres | 11 ++-- data/cards/support/reflection.tres | 9 +-- data/cards/support/sword_mastery.tres | 9 +-- data/cards/support/tanker.tres | 9 +-- tcg/card/card.gd | 2 +- tcg/card/implemented_support_card.gd | 4 ++ tcg/card/support_card.gd | 1 - tcg/match/match_manager.gd | 88 ++++++++++++++------------ 15 files changed, 110 insertions(+), 88 deletions(-) create mode 100644 tcg/card/implemented_support_card.gd diff --git a/data/cards/support/absorb.tres b/data/cards/support/absorb.tres index 705b320..8d7403c 100644 --- a/data/cards/support/absorb.tres +++ b/data/cards/support/absorb.tres @@ -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.gd" id="2_x8k3o"] +[ext_resource type="Script" path="res://tcg/card/implemented_support_card.gd" id="2_f6hay"] [resource] -script = ExtResource("2_x8k3o") +script = ExtResource("2_f6hay") +scope = "turn" +magnitude = 0 type = "red" -priority = 0 -effects = Array[ExtResource("1_mhxdy")]([null]) +effects = Array[ExtResource("1_mhxdy")]([]) name = "Absorb" description = "Enemy damage converted to heal your Active Monster Field HP during this turn." diff --git a/data/cards/support/all_out_attack.tres b/data/cards/support/all_out_attack.tres index d69f64b..ec8850c 100644 --- a/data/cards/support/all_out_attack.tres +++ b/data/cards/support/all_out_attack.tres @@ -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.gd" id="2_1tjl7"] +[ext_resource type="Script" path="res://tcg/card/implemented_support_card.gd" id="2_61mgn"] [resource] -script = ExtResource("2_1tjl7") +script = ExtResource("2_61mgn") +scope = "instant" +magnitude = 0 type = "green" -priority = 0 effects = Array[ExtResource("1_fd50n")]([null]) 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." diff --git a/data/cards/support/energy_booster.tres b/data/cards/support/energy_booster.tres index c3e9de8..ea24a0b 100644 --- a/data/cards/support/energy_booster.tres +++ b/data/cards/support/energy_booster.tres @@ -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.gd" id="2_qqko6"] +[ext_resource type="Script" path="res://tcg/card/implemented_support_card.gd" id="2_iq88n"] [resource] -script = ExtResource("2_qqko6") +script = ExtResource("2_iq88n") +scope = "turn" +magnitude = 0 type = "green" -priority = 0 effects = Array[ExtResource("1_pkc1x")]([null]) name = "Energy Booster" description = "Add 1 additional Energy." diff --git a/data/cards/support/insurance.tres b/data/cards/support/insurance.tres index 4f53e44..5183f9f 100644 --- a/data/cards/support/insurance.tres +++ b/data/cards/support/insurance.tres @@ -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.gd" id="2_286ne"] +[ext_resource type="Script" path="res://tcg/card/implemented_support_card.gd" id="2_3ixor"] [resource] -script = ExtResource("2_286ne") +script = ExtResource("2_3ixor") +scope = "turn" +magnitude = 10 type = "red" -priority = 0 effects = Array[ExtResource("1_gtyqr")]([null]) name = "Insurance" description = "If your monster supposed to be dead in this turn, keep it alive at 10 HP." diff --git a/data/cards/support/invisibility.tres b/data/cards/support/invisibility.tres index c0a3499..2b917fb 100644 --- a/data/cards/support/invisibility.tres +++ b/data/cards/support/invisibility.tres @@ -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.gd" id="2_hsvj6"] +[ext_resource type="Script" path="res://tcg/card/implemented_support_card.gd" id="2_6c2xo"] [resource] -script = ExtResource("2_hsvj6") +script = ExtResource("2_6c2xo") +scope = "turn" +magnitude = 0 type = "green" -priority = 0 effects = Array[ExtResource("1_5tnpm")]([null]) name = "Invisibility" description = "Ignore any damage to your monster in this turn." diff --git a/data/cards/support/lifesteal.tres b/data/cards/support/lifesteal.tres index 26aa830..726912d 100644 --- a/data/cards/support/lifesteal.tres +++ b/data/cards/support/lifesteal.tres @@ -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.gd" id="2_qww3m"] +[ext_resource type="Script" path="res://tcg/card/implemented_support_card.gd" id="2_khaf1"] [resource] -script = ExtResource("2_qww3m") +script = ExtResource("2_khaf1") +scope = "turn" +magnitude = 0 type = "green" -priority = 0 effects = Array[ExtResource("1_b33y4")]([null]) name = "Lifesteal" description = "During this turn your attack also heals your HP." diff --git a/data/cards/support/negate.tres b/data/cards/support/negate.tres index 1c634cd..38707fc 100644 --- a/data/cards/support/negate.tres +++ b/data/cards/support/negate.tres @@ -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.gd" id="2_v8fdj"] +[ext_resource type="Script" path="res://tcg/card/implemented_support_card.gd" id="2_tr5ug"] [resource] -script = ExtResource("2_v8fdj") +script = ExtResource("2_tr5ug") +scope = "turn" +magnitude = 0 type = "red" -priority = 1 effects = Array[ExtResource("1_awvxv")]([null]) name = "Negate" description = "Cancel 1 of the Support Card played by your opponent. This card will always be played last." diff --git a/data/cards/support/potion.tres b/data/cards/support/potion.tres index 96ed2d7..7137c77 100644 --- a/data/cards/support/potion.tres +++ b/data/cards/support/potion.tres @@ -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="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="Texture2D" uid="uid://rh3aswb0p7ri" path="res://assets/energy.png" id="3_kyx3v"] +[ext_resource type="Script" path="res://tcg/card/implemented_support_card.gd" id="3_at5nt"] [sub_resource type="Resource" id="Resource_88lmk"] script = ExtResource("1_ujm0o") @@ -11,10 +10,10 @@ magnitude = 30 effect = ExtResource("2_k1cnl") [resource] -script = ExtResource("3_6r4k4") +script = ExtResource("3_at5nt") +scope = "turn" +magnitude = 30 type = "green" -priority = 0 effects = Array[ExtResource("1_ujm0o")]([SubResource("Resource_88lmk")]) name = "Potion" description = "Heal 30 HP" -icon = ExtResource("3_kyx3v") diff --git a/data/cards/support/reflection.tres b/data/cards/support/reflection.tres index 1833aad..b87a630 100644 --- a/data/cards/support/reflection.tres +++ b/data/cards/support/reflection.tres @@ -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.gd" id="2_fliii"] +[ext_resource type="Script" path="res://tcg/card/implemented_support_card.gd" id="2_igbok"] [resource] -script = ExtResource("2_fliii") +script = ExtResource("2_igbok") +scope = "turn" +magnitude = 0 type = "red" -priority = 0 effects = Array[ExtResource("1_mk2or")]([null]) name = "Reflection" description = "Enemy got the same amount of damage as our monster in this turn." diff --git a/data/cards/support/sword_mastery.tres b/data/cards/support/sword_mastery.tres index 77eee88..1d48401 100644 --- a/data/cards/support/sword_mastery.tres +++ b/data/cards/support/sword_mastery.tres @@ -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="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"] script = ExtResource("1_y6yvj") @@ -10,9 +10,10 @@ magnitude = 20 effect = ExtResource("2_omhdb") [resource] -script = ExtResource("2_vp8a3") +script = ExtResource("3_37rh4") +scope = "monster" +magnitude = 20 type = "green" -priority = 0 effects = Array[ExtResource("1_y6yvj")]([SubResource("Resource_wwv02")]) name = "Sword Mastery" description = "Permanently add 20 damage for all Rock Paper Scissor to 1 Active Monster." diff --git a/data/cards/support/tanker.tres b/data/cards/support/tanker.tres index c51cbf2..7a207b4 100644 --- a/data/cards/support/tanker.tres +++ b/data/cards/support/tanker.tres @@ -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.gd" id="2_m4ahe"] +[ext_resource type="Script" path="res://tcg/card/implemented_support_card.gd" id="2_d0adk"] [resource] -script = ExtResource("2_m4ahe") +script = ExtResource("2_d0adk") +scope = "turn" +magnitude = 0 type = "red" -priority = 0 effects = Array[ExtResource("1_1fvcb")]([null]) 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." diff --git a/tcg/card/card.gd b/tcg/card/card.gd index e14ff41..6fd69f3 100644 --- a/tcg/card/card.gd +++ b/tcg/card/card.gd @@ -2,7 +2,7 @@ extends Resource class_name Card @export var name: String -@export var description: String +@export_multiline var description: String @export var icon: Texture2D var id: String: diff --git a/tcg/card/implemented_support_card.gd b/tcg/card/implemented_support_card.gd new file mode 100644 index 0000000..9806f1c --- /dev/null +++ b/tcg/card/implemented_support_card.gd @@ -0,0 +1,4 @@ +extends SupportCard +class_name ImplementedSupportCard + +@export_enum("instant", "turn", "monster", "match") var scope = "instant" diff --git a/tcg/card/support_card.gd b/tcg/card/support_card.gd index 8ff5e3b..68eeba4 100644 --- a/tcg/card/support_card.gd +++ b/tcg/card/support_card.gd @@ -2,5 +2,4 @@ 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/match/match_manager.gd b/tcg/match/match_manager.gd index 1bff5e2..1a12147 100644 --- a/tcg/match/match_manager.gd +++ b/tcg/match/match_manager.gd @@ -22,9 +22,6 @@ var player_2: MatchPlayer: return players[actual_p2_id] as MatchPlayer var phase: Match.Phase = Match.Phase.PREGAME -var support_cards_1: Dictionary = {} -var support_cards_2: Dictionary = {} - var actual_p1_id: int var actual_p2_id: int @@ -38,8 +35,7 @@ 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] - - 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) deck_shuffled.pop_at(first_monster_idx) var zero_idx_card = deck_shuffled.pop_at(0) @@ -49,6 +45,7 @@ func init(decks: Dictionary, actual_p1_id: int, actual_p2_id: int): 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) @@ -75,8 +72,6 @@ func resolve(action_by_player_id: Dictionary) -> PhaseTransition: ) phase = Match.Phase.SUMMON Match.Phase.SUMMON: - support_cards_1.clear() - support_cards_2.clear() for player_id in action_by_player_id.keys(): 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): phase = Match.Phase.SUPPORT_1 Match.Phase.SUPPORT_1: - support_cards_1.clear() - support_cards_2.clear() - var support_cards = [] if player_1_action is ActionPlayCard: support_cards.append({ "player": player_1, "card": player_1_action.card }) - support_cards_1[player_1] = player_1_action.card player_1.hand.erase(player_1_action.card) if player_2_action is ActionPlayCard: support_cards.append({ "player": player_2, "card": player_2_action.card }) - support_cards_1[player_2] = 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 - 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 Match.Phase.RPS: + var damage_pairs = [] 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 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: - 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 Match.Phase.SUPPORT_2: var support_cards = [] @@ -129,26 +134,32 @@ func resolve(action_by_player_id: Dictionary) -> PhaseTransition: "player": player_1, "card": player_1_action.card }) - support_cards_2[player_1] = player_1_action.card player_1.hand.erase(player_1_action.card) if player_2_action is ActionPlayCard: support_cards.append({ "player": player_2, "card": player_2_action.card }) - support_cards_2[player_2] = 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 - 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(): + 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 + 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: 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)) else: player.monster.health += player.monster.health_delta @@ -157,11 +168,15 @@ func resolve(action_by_player_id: Dictionary) -> PhaseTransition: 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) + + 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) 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) + func(player): return player.hand.any(func(it): return it is MonsterCard and it.energy_cost <= player.energy) ): phase = Match.Phase.SUMMON else: @@ -175,24 +190,19 @@ func resolve(action_by_player_id: Dictionary) -> PhaseTransition: 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]: +func _execute_support_card_immediate_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_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)) + if card is ImplementedSupportCard: + match card.id: + "potion": + player.monster.health_delta += card.magnitude + "energy_booster": + player.energy += card.magnitude + # events.append(Event) 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 +func _player_has_active_support_card(player: MatchPlayer, card_id: String) -> bool: + return player.active_support_cards.any(func (card): return card.id == card_id) + +func _player_opponent(player: MatchPlayer) -> MatchPlayer: + return player_2 if player.id == PLAYER_1_ID else player_1 \ No newline at end of file From 064559130c92f89061f70ec2703ecea92bbce153 Mon Sep 17 00:00:00 2001 From: istamarahsan Date: Sun, 26 Jan 2025 05:05:45 +0700 Subject: [PATCH 15/29] fix: add support card only if not instant --- tcg/match/match_manager.gd | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tcg/match/match_manager.gd b/tcg/match/match_manager.gd index 1a12147..4eb4128 100644 --- a/tcg/match/match_manager.gd +++ b/tcg/match/match_manager.gd @@ -101,8 +101,9 @@ func resolve(action_by_player_id: Dictionary) -> PhaseTransition: for played_card in support_cards: var player: MatchPlayer = played_card.player var card: SupportCard = played_card.card - var executed_instant_effects_events = _execute_support_card_immediate_effects(player, card) - player.active_support_cards.append(card) + if played_card is ImplementedSupportCard and played_card.scope != 'instant' + player.active_support_cards.append(played_card) + var executed_instant_effects_events = _execute_support_card_instant_effects(player, card) events.append_array(executed_instant_effects_events) phase = Match.Phase.RPS Match.Phase.RPS: @@ -145,8 +146,9 @@ func resolve(action_by_player_id: Dictionary) -> PhaseTransition: for played_card in support_cards: var player: MatchPlayer = played_card.player var card: SupportCard = played_card.card - player.active_support_cards.append(played_card) - events.append_array(_execute_support_card_immediate_effects(player, card)) + if played_card is ImplementedSupportCard and played_card.scope != 'instant' + player.active_support_cards.append(played_card) + events.append_array(_execute_support_card_instant_effects(player, card)) for player: MatchPlayer in players.values(): if _player_has_active_support_card(player, "absorb") and player.monster.health_delta < 0: @@ -190,7 +192,7 @@ func resolve(action_by_player_id: Dictionary) -> PhaseTransition: func _monster_from_card(card: MonsterCard) -> MatchMonster: return MatchMonster.new(card, card.base_health, 0) -func _execute_support_card_immediate_effects(player: MatchPlayer, card: SupportCard) -> Array[Event]: +func _execute_support_card_instant_effects(player: MatchPlayer, card: SupportCard) -> Array[Event]: var events: Array[Event] if card is ImplementedSupportCard: match card.id: From ca9c7b8e50f048d5f1df4dc086fd75171cdcdf76 Mon Sep 17 00:00:00 2001 From: kennetha123 Date: Sun, 26 Jan 2025 06:31:06 +0700 Subject: [PATCH 16/29] fix: minor spelling mistake --- cards.tres | 2 +- data/cards/support/potion.tres | 3 +-- demo_game.tscn | 4 ++-- tcg/match/match_manager.gd | 6 +++--- ui/card_template/monster_card.tscn | 2 +- ui/card_template/support_card_red.tscn | 2 +- 6 files changed, 9 insertions(+), 10 deletions(-) diff --git a/cards.tres b/cards.tres index e5f7591..6222ae9 100644 --- a/cards.tres +++ b/cards.tres @@ -1,4 +1,4 @@ -[gd_resource type="Theme" load_steps=2 format=3 uid="uid://qe383ytjm3v"] +[gd_resource type="Theme" load_steps=2 format=3 uid="uid://is34t82g4jg"] [ext_resource type="FontFile" uid="uid://ncoq4i61plvt" path="res://assets/Bohemian Soul.otf" id="1_yowck"] diff --git a/data/cards/support/potion.tres b/data/cards/support/potion.tres index 7137c77..926535b 100644 --- a/data/cards/support/potion.tres +++ b/data/cards/support/potion.tres @@ -1,4 +1,4 @@ -[gd_resource type="Resource" script_class="SimpleSupportCard" load_steps=5 format=3 uid="uid://4eod3m0vc5a8"] +[gd_resource type="Resource" script_class="ImplementedSupportCard" 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="Resource" uid="uid://cvu0rtt5nggf" path="res://data/support_effects/heal.tres" id="2_k1cnl"] @@ -12,7 +12,6 @@ effect = ExtResource("2_k1cnl") [resource] script = ExtResource("3_at5nt") scope = "turn" -magnitude = 30 type = "green" effects = Array[ExtResource("1_ujm0o")]([SubResource("Resource_88lmk")]) name = "Potion" diff --git a/demo_game.tscn b/demo_game.tscn index d4c8e2d..83eaf33 100644 --- a/demo_game.tscn +++ b/demo_game.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=12 format=3 uid="uid://l2ehohbd1xhk"] +[gd_scene load_steps=12 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"] @@ -6,7 +6,7 @@ [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/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://deo8mj887rfx1" path="res://data/cards/monster/axoluna.tres" id="5_3cm5x"] +[ext_resource type="Resource" uid="uid://di76avwc0gn8e" path="res://data/cards/monster/axoluna.tres" id="5_3cm5x"] [ext_resource type="PackedScene" uid="uid://bhrelvt51cbp2" path="res://ui/card_template/monster_card.tscn" id="7_4ah45"] [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"] diff --git a/tcg/match/match_manager.gd b/tcg/match/match_manager.gd index 4eb4128..fa6e724 100644 --- a/tcg/match/match_manager.gd +++ b/tcg/match/match_manager.gd @@ -101,7 +101,7 @@ func resolve(action_by_player_id: Dictionary) -> PhaseTransition: 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' + if played_card is ImplementedSupportCard and played_card.scope != 'instant': player.active_support_cards.append(played_card) var executed_instant_effects_events = _execute_support_card_instant_effects(player, card) events.append_array(executed_instant_effects_events) @@ -146,7 +146,7 @@ func resolve(action_by_player_id: Dictionary) -> PhaseTransition: 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' + if played_card is ImplementedSupportCard and played_card.scope != 'instant': player.active_support_cards.append(played_card) events.append_array(_execute_support_card_instant_effects(player, card)) @@ -207,4 +207,4 @@ func _player_has_active_support_card(player: MatchPlayer, card_id: String) -> bo return player.active_support_cards.any(func (card): return card.id == card_id) func _player_opponent(player: MatchPlayer) -> MatchPlayer: - return player_2 if player.id == PLAYER_1_ID else player_1 \ No newline at end of file + return player_2 if player.id == PLAYER_1_ID else player_1 diff --git a/ui/card_template/monster_card.tscn b/ui/card_template/monster_card.tscn index 9d8a797..04522b1 100644 --- a/ui/card_template/monster_card.tscn +++ b/ui/card_template/monster_card.tscn @@ -8,7 +8,7 @@ [ext_resource type="Texture2D" uid="uid://b8accn4e2ojau" path="res://assets/monster/froggo 1.png" id="7_j2i0p"] [ext_resource type="Texture2D" uid="uid://dft4fbgoecbp4" path="res://assets/card_base/Illustrated BG.png" id="7_qe8a1"] [ext_resource type="Texture2D" uid="uid://cqttp0i3vph37" path="res://assets/card_base/Star.png" id="8_ophhb"] -[ext_resource type="Theme" path="res://cards.tres" id="9_6x2vq"] +[ext_resource type="Theme" uid="uid://is34t82g4jg" path="res://cards.tres" id="9_6x2vq"] [ext_resource type="Texture2D" uid="uid://cjmxetjq82rl2" path="res://assets/card_base/Pip.png" id="10_14hhn"] [ext_resource type="FontFile" uid="uid://08q3kkwmd4u6" path="res://assets/Inter-Regular.otf" id="11_oy107"] [ext_resource type="Texture2D" uid="uid://bywa8qlwvcksd" path="res://assets/card_base/batu.png" id="12_a4kkh"] diff --git a/ui/card_template/support_card_red.tscn b/ui/card_template/support_card_red.tscn index c84cdc5..60c9770 100644 --- a/ui/card_template/support_card_red.tscn +++ b/ui/card_template/support_card_red.tscn @@ -7,7 +7,7 @@ [ext_resource type="Texture2D" uid="uid://blejyda8mendg" path="res://assets/card_base/InnerFill.png" id="4_2fw8n"] [ext_resource type="Texture2D" uid="uid://by7ws88pn4tvb" path="res://assets/card_base/Separator.png" id="5_n3v14"] [ext_resource type="Texture2D" uid="uid://0gxplli5krq2" path="res://assets/card_base/Pill.png" id="6_wrd2a"] -[ext_resource type="Theme" path="res://cards.tres" id="7_fp6ys"] +[ext_resource type="Theme" uid="uid://is34t82g4jg" path="res://cards.tres" id="7_fp6ys"] [ext_resource type="FontFile" uid="uid://08q3kkwmd4u6" path="res://assets/Inter-Regular.otf" id="9_vilw6"] [ext_resource type="Texture2D" uid="uid://rh3aswb0p7ri" path="res://assets/energy.png" id="10_2t0ey"] From 64e79704bf832a9241839a13b5d36992311bbe97 Mon Sep 17 00:00:00 2001 From: kennetha123 Date: Sun, 26 Jan 2025 07:15:58 +0700 Subject: [PATCH 17/29] 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 From 3220f4937f7d5cd028d58453907d7bc323c66372 Mon Sep 17 00:00:00 2001 From: istamarahsan Date: Sun, 26 Jan 2025 07:31:48 +0700 Subject: [PATCH 18/29] fix: grammar issue --- main.tscn | 2 +- tcg/match/match_manager.gd | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/main.tscn b/main.tscn index e0e520e..46481fe 100644 --- a/main.tscn +++ b/main.tscn @@ -2,7 +2,7 @@ [ext_resource type="Script" path="res://main.gd" id="1_e0ud3"] [ext_resource type="Script" path="res://server_discovery.gd" id="2_hed18"] -[ext_resource type="PackedScene" uid="uid://l2ehohbd1xhk" path="res://demo_game.tscn" id="3_2ln6b"] +[ext_resource type="PackedScene" uid="uid://bgc0u117jqyr1" path="res://demo_game.tscn" id="3_2ln6b"] [node name="Main" type="Control"] layout_mode = 3 diff --git a/tcg/match/match_manager.gd b/tcg/match/match_manager.gd index 6ec765d..647f4ce 100644 --- a/tcg/match/match_manager.gd +++ b/tcg/match/match_manager.gd @@ -117,11 +117,11 @@ func resolve(action_by_player_id: Dictionary) -> PhaseTransition: 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() + pair.from.monster.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.from.monster.health_delta += computed_damage pair.to.monster.health_delta -= computed_damage phase = Match.Phase.SUPPORT_2 From 46e4ba0fbbd843b78cc461d81ee6498319b6b70f Mon Sep 17 00:00:00 2001 From: istamarahsan Date: Sun, 26 Jan 2025 09:48:01 +0700 Subject: [PATCH 19/29] feat: monster card --- assets/card_base/batu.png | 4 +- assets/card_base/gunting.png | 4 +- assets/card_base/kertas.png | 4 +- ui/card_template/monster_card.gd | 2 +- ui/card_template/monster_card.tscn | 196 +++++++++++++++++------------ 5 files changed, 125 insertions(+), 85 deletions(-) diff --git a/assets/card_base/batu.png b/assets/card_base/batu.png index 7899aa9..8d1dc40 100644 --- a/assets/card_base/batu.png +++ b/assets/card_base/batu.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b3ebc26aaf3c87de9ce48e9a4f9e22db8944b9c304f9dbda9cf21c3636f013e9 -size 24379 +oid sha256:3073496f2b5cb651d0d6d03351a6f8392a23924d01472ab5d175ef150667e17e +size 25869 diff --git a/assets/card_base/gunting.png b/assets/card_base/gunting.png index 553ae4d..c069201 100644 --- a/assets/card_base/gunting.png +++ b/assets/card_base/gunting.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d5679d2d3e778ec2d3142eaf0f5603b3a144e87f7f26e1e2d78974462db69f75 -size 33308 +oid sha256:4d14202c9b5043bdf561e8b9e6e899b0d964eed347f5d7fdb71cb5f6286a1561 +size 24283 diff --git a/assets/card_base/kertas.png b/assets/card_base/kertas.png index 6507ea0..c49b7e1 100644 --- a/assets/card_base/kertas.png +++ b/assets/card_base/kertas.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3aa28478cb7241ff59fe191f1aca345eccd60d8a9cb8f9c1058874b3fc0606ff -size 17766 +oid sha256:52a0024d95f80cda1eea5a8dcdf7cd9f2204f73409ce8ae4999f75dfd402f3a3 +size 20378 diff --git a/ui/card_template/monster_card.gd b/ui/card_template/monster_card.gd index 4e72542..8c1ca87 100644 --- a/ui/card_template/monster_card.gd +++ b/ui/card_template/monster_card.gd @@ -21,7 +21,7 @@ func show_monster(monster: MatchMonster): return name_label.text = monster.card.id - health_label.text = "HP %d" % [monster.health] + health_label.text = "HP %d/%d" % [monster.health, monster.card.base_health] icon_texture_rect.texture = monster.card.icon paper_damage.text = str(monster.card.paper) diff --git a/ui/card_template/monster_card.tscn b/ui/card_template/monster_card.tscn index 04522b1..d373404 100644 --- a/ui/card_template/monster_card.tscn +++ b/ui/card_template/monster_card.tscn @@ -1,6 +1,5 @@ -[gd_scene load_steps=15 format=3 uid="uid://bhrelvt51cbp2"] +[gd_scene load_steps=14 format=3 uid="uid://bhrelvt51cbp2"] -[ext_resource type="Texture2D" uid="uid://cqladcrximh6" path="res://assets/card_base/Screenshot 2025-01-25 211435.png" id="1_nvo50"] [ext_resource type="Script" path="res://ui/card_template/monster_card.gd" id="1_xddej"] [ext_resource type="Texture2D" uid="uid://l2nxxhh0pvh8" path="res://assets/card_base/Frame.png" id="2_lhxdu"] [ext_resource type="Texture2D" uid="uid://crgrple0uik7x" path="res://assets/card_base/Stroke.png" id="4_kkcc6"] @@ -33,15 +32,9 @@ name_label = NodePath("MarginContainer/MonsterNameLabel") health_label = NodePath("MarginContainer/HealthLabel") energy_pip_container = NodePath("MarginContainer/EnergyStarsContainer") icon_texture_rect = NodePath("MarginContainer/TextureRect2/IconTextureRect") -paper_damage = NodePath("MarginContainer/Paper/PaperDamage") -scissors_damage = NodePath("MarginContainer/Scissors/ScissorsDamage") -rock_damage = NodePath("MarginContainer/Rock/RockDamage") - -[node name="Screenshot2025-01-25211435" type="Sprite2D" parent="."] -visible = false -position = Vector2(355, 157) -scale = Vector2(0.625, 0.625) -texture = ExtResource("1_nvo50") +paper_damage = NodePath("MarginContainer/HBoxContainer/Rock2/PaperLabel") +scissors_damage = NodePath("MarginContainer/HBoxContainer/Rock3/ScissorsLabel") +rock_damage = NodePath("MarginContainer/HBoxContainer/Rock/RockLabel") [node name="Frame" type="TextureRect" parent="."] layout_mode = 1 @@ -121,12 +114,13 @@ stretch_mode = 5 [node name="EnergyStarsContainer" type="HBoxContainer" parent="MarginContainer"] unique_name_in_owner = true layout_mode = 0 -offset_left = 141.0 -offset_top = 55.0 -offset_right = 200.0 -offset_bottom = 70.0 +offset_left = 100.0 +offset_top = 54.0 +offset_right = 197.0 +offset_bottom = 69.0 +alignment = 2 -[node name="TextureRect3" type="TextureRect" parent="MarginContainer/EnergyStarsContainer"] +[node name="TextureRect" type="TextureRect" parent="MarginContainer/EnergyStarsContainer"] layout_mode = 2 texture = ExtResource("8_ophhb") expand_mode = 3 @@ -138,7 +132,19 @@ texture = ExtResource("8_ophhb") expand_mode = 3 stretch_mode = 5 -[node name="TextureRect" type="TextureRect" parent="MarginContainer/EnergyStarsContainer"] +[node name="TextureRect3" type="TextureRect" parent="MarginContainer/EnergyStarsContainer"] +layout_mode = 2 +texture = ExtResource("8_ophhb") +expand_mode = 3 +stretch_mode = 5 + +[node name="TextureRect4" type="TextureRect" parent="MarginContainer/EnergyStarsContainer"] +layout_mode = 2 +texture = ExtResource("8_ophhb") +expand_mode = 3 +stretch_mode = 5 + +[node name="TextureRect5" type="TextureRect" parent="MarginContainer/EnergyStarsContainer"] layout_mode = 2 texture = ExtResource("8_ophhb") expand_mode = 3 @@ -156,7 +162,7 @@ offset_bottom = 80.0 grow_horizontal = 2 theme = ExtResource("9_6x2vq") theme_override_font_sizes/font_size = 16 -text = "HP 80" +text = "HP 80/100" vertical_alignment = 1 [node name="MonsterNameLabel" type="Label" parent="MarginContainer"] @@ -185,6 +191,7 @@ expand_mode = 1 stretch_mode = 5 [node name="Label" type="Label" parent="MarginContainer/CardNumber"] +visible = false layout_mode = 1 anchors_preset = 8 anchor_left = 0.5 @@ -205,77 +212,110 @@ text = "#01" horizontal_alignment = 1 vertical_alignment = 1 -[node name="Paper" type="TextureRect" parent="MarginContainer"] -layout_mode = 0 -offset_left = 109.0 -offset_top = 183.0 -offset_right = 222.0 -offset_bottom = 356.0 -texture = ExtResource("14_gm7k7") -expand_mode = 1 -stretch_mode = 5 - -[node name="PaperDamage" type="Label" parent="MarginContainer/Paper"] -unique_name_in_owner = true +[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer"] layout_mode = 1 -anchors_preset = 10 -anchor_right = 1.0 -offset_left = 48.0 -offset_top = 32.0 -offset_right = -32.0 -offset_bottom = 73.0 +anchors_preset = 7 +anchor_left = 0.5 +anchor_top = 1.0 +anchor_right = 0.5 +anchor_bottom = 1.0 +offset_left = -100.0 +offset_top = -102.143 +offset_right = 100.0 +offset_bottom = -7.1427 +grow_horizontal = 2 +grow_vertical = 0 +alignment = 1 + +[node name="Rock" type="Control" parent="MarginContainer/HBoxContainer"] +custom_minimum_size = Vector2(64, 0) +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="RockLabel" type="Label" parent="MarginContainer/HBoxContainer/Rock"] +layout_mode = 1 +anchors_preset = 5 +anchor_left = 0.5 +anchor_right = 0.5 +offset_left = -32.0 +offset_right = 32.0 +offset_bottom = 26.0 grow_horizontal = 2 theme = ExtResource("9_6x2vq") -theme_override_font_sizes/font_size = 20 -text = "10" -vertical_alignment = 1 +theme_override_font_sizes/font_size = 24 +text = "100" +horizontal_alignment = 1 +vertical_alignment = 2 -[node name="Scissors" type="TextureRect" parent="MarginContainer"] -layout_mode = 0 -offset_left = 43.0 -offset_top = 182.0 -offset_right = 156.0 -offset_bottom = 355.0 -texture = ExtResource("13_ifoc6") -expand_mode = 1 -stretch_mode = 5 - -[node name="ScissorsDamage" type="Label" parent="MarginContainer/Scissors"] -unique_name_in_owner = true -layout_mode = 1 -anchors_preset = 10 +[node name="Rock" type="TextureRect" parent="MarginContainer/HBoxContainer/Rock"] +layout_mode = 2 anchor_right = 1.0 -offset_left = 48.0 -offset_top = 32.0 -offset_right = -32.0 -offset_bottom = 73.0 +anchor_bottom = 1.0 +offset_top = 30.0 grow_horizontal = 2 -theme = ExtResource("9_6x2vq") -theme_override_font_sizes/font_size = 20 -text = "10" -vertical_alignment = 1 - -[node name="Rock" type="TextureRect" parent="MarginContainer"] -layout_mode = 0 -offset_left = -23.0 -offset_top = 181.0 -offset_right = 90.0 -offset_bottom = 354.0 +grow_vertical = 2 texture = ExtResource("12_a4kkh") expand_mode = 1 stretch_mode = 5 -[node name="RockDamage" type="Label" parent="MarginContainer/Rock"] -unique_name_in_owner = true +[node name="Rock2" type="Control" parent="MarginContainer/HBoxContainer"] +custom_minimum_size = Vector2(64, 0) +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="PaperLabel" type="Label" parent="MarginContainer/HBoxContainer/Rock2"] layout_mode = 1 -anchors_preset = 10 -anchor_right = 1.0 -offset_left = 48.0 -offset_top = 32.0 -offset_right = -32.0 -offset_bottom = 73.0 +anchors_preset = 5 +anchor_left = 0.5 +anchor_right = 0.5 +offset_left = -32.0 +offset_right = 32.0 +offset_bottom = 26.0 grow_horizontal = 2 theme = ExtResource("9_6x2vq") -theme_override_font_sizes/font_size = 20 +theme_override_font_sizes/font_size = 24 text = "10" -vertical_alignment = 1 +horizontal_alignment = 1 +vertical_alignment = 2 + +[node name="Paper" type="TextureRect" parent="MarginContainer/HBoxContainer/Rock2"] +layout_mode = 2 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_top = 30.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("14_gm7k7") +expand_mode = 1 +stretch_mode = 5 + +[node name="Rock3" type="Control" parent="MarginContainer/HBoxContainer"] +custom_minimum_size = Vector2(64, 0) +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="ScissorsLabel" type="Label" parent="MarginContainer/HBoxContainer/Rock3"] +layout_mode = 1 +anchors_preset = 5 +anchor_left = 0.5 +anchor_right = 0.5 +offset_left = -32.0 +offset_right = 32.0 +offset_bottom = 26.0 +grow_horizontal = 2 +theme = ExtResource("9_6x2vq") +theme_override_font_sizes/font_size = 24 +text = "10" +horizontal_alignment = 1 +vertical_alignment = 2 + +[node name="Scissors" type="TextureRect" parent="MarginContainer/HBoxContainer/Rock3"] +layout_mode = 2 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_top = 30.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("13_ifoc6") +expand_mode = 1 +stretch_mode = 5 From 5395f971cb3fc6b20d195b47e46eaba4fa88d241 Mon Sep 17 00:00:00 2001 From: kennetha123 Date: Sun, 26 Jan 2025 10:36:55 +0700 Subject: [PATCH 20/29] feat: rps button with texture --- demo_game.tscn | 42 ++++++++++++++++++++++++++++++++++++------ player_side.gd | 42 ++++++++++++++++++++++++++++++------------ 2 files changed, 66 insertions(+), 18 deletions(-) diff --git a/demo_game.tscn b/demo_game.tscn index bfff989..0d96d3a 100644 --- a/demo_game.tscn +++ b/demo_game.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=19 format=3 uid="uid://bgc0u117jqyr1"] +[gd_scene load_steps=22 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"] @@ -18,6 +18,9 @@ [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"] +[ext_resource type="Texture2D" uid="uid://b0pclmv0j0r12" path="res://assets/card_base/kertas.png" id="18_gwpy8"] +[ext_resource type="Texture2D" uid="uid://ch04c20lkis6j" path="res://assets/card_base/gunting.png" id="19_clnw6"] +[ext_resource type="Texture2D" uid="uid://bywa8qlwvcksd" path="res://assets/card_base/batu.png" id="20_672ya"] [node name="DemoGame" type="Control"] layout_mode = 3 @@ -30,7 +33,7 @@ script = ExtResource("1_jn16u") 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")] +[node name="Own" type="Control" parent="." node_paths=PackedStringArray("deck", "energy_label", "rps_button_container")] layout_mode = 1 anchor_top = 0.5 anchor_right = 1.0 @@ -44,6 +47,8 @@ skip_card_prefab = ExtResource("7_skjyk") support_red_card_prefab = ExtResource("9_cabcc") support_green_card_prefab = ExtResource("8_dytl5") monster_card_prefab = ExtResource("7_4ah45") +rps_button_container = NodePath("HBoxContainer") +rps_grayed_color = Color(0.439216, 0.439216, 0.439216, 1) [node name="MonsterCard" parent="Own" instance=ExtResource("7_4ah45")] custom_minimum_size = Vector2(220, 330) @@ -109,12 +114,14 @@ text = "Energy:" [node name="Hand" type="HBoxContainer" parent="Own"] layout_mode = 1 -anchors_preset = 12 +anchors_preset = 7 +anchor_left = 0.5 anchor_top = 1.0 -anchor_right = 1.0 +anchor_right = 0.5 anchor_bottom = 1.0 -offset_top = -240.0 -offset_bottom = 130.0 +offset_left = -446.0 +offset_top = -370.0 +offset_right = 446.0 grow_horizontal = 2 grow_vertical = 0 pivot_offset = Vector2(0, 150) @@ -145,6 +152,26 @@ grow_horizontal = 2 text = "Incoming Damage: 0" horizontal_alignment = 1 +[node name="HBoxContainer" type="HBoxContainer" parent="Own"] +visible = false +layout_mode = 0 +offset_left = 665.0 +offset_top = 299.0 +offset_right = 1326.0 +offset_bottom = 548.0 + +[node name="KertasButton" type="TextureButton" parent="Own/HBoxContainer"] +layout_mode = 2 +texture_normal = ExtResource("18_gwpy8") + +[node name="GuntingButton" type="TextureButton" parent="Own/HBoxContainer"] +layout_mode = 2 +texture_normal = ExtResource("19_clnw6") + +[node name="BatuButton" type="TextureButton" parent="Own/HBoxContainer"] +layout_mode = 2 +texture_normal = ExtResource("20_672ya") + [node name="Opponent" type="Control" parent="." node_paths=PackedStringArray("deck", "energy_label")] layout_mode = 1 anchor_right = 1.0 @@ -279,6 +306,9 @@ text = "Start Game" [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="button_down" from="Own/HBoxContainer/KertasButton" to="Own" method="_on_kertas_button_button_down"] +[connection signal="button_down" from="Own/HBoxContainer/GuntingButton" to="Own" method="_on_gunting_button_button_down"] +[connection signal="button_down" from="Own/HBoxContainer/BatuButton" to="Own" method="_on_batu_button_button_down"] [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 index 21b4a04..227ae3b 100644 --- a/player_side.gd +++ b/player_side.gd @@ -9,6 +9,8 @@ signal rps_move(move: String) @export var support_red_card_prefab: PackedScene @export var support_green_card_prefab: PackedScene @export var monster_card_prefab: PackedScene +@export var rps_button_container: Container +@export var rps_grayed_color: Color @onready var monster_card_ui := $"MonsterCard" @onready var support1_green := $"Support1GreenCard" @@ -131,21 +133,37 @@ func _on_update(transition): btn.left_clicked.connect(func (): _pop_this_card(btn) play_card.emit(card)) - - if match_manager.phase == Match.Phase.RPS: - for move in ["rock", "paper", "scissors"]: - - if !show_buttons: - continue - - var btn = Button.new() - btn.text = move - btn.button_up.connect(func (): rps_move.emit(move)) - deck.add_child(btn) - + + if rps_button_container: + rps_button_container.visible = match_manager.phase == Match.Phase.RPS + for button: TextureButton in rps_button_container.get_children(): + button.modulate = rps_grayed_color + + func _pop_this_card(control: Control): if selected_card: selected_card.size_flags_vertical = Control.SIZE_SHRINK_END control.size_flags_vertical = Control.SIZE_SHRINK_BEGIN selected_card = control + + +func _on_kertas_button_button_down() -> void: + rps_move.emit("paper") + for button: TextureButton in rps_button_container.get_children(): + button.modulate = rps_grayed_color + rps_button_container.get_node("KertasButton").modulate = Color.WHITE + + +func _on_gunting_button_button_down() -> void: + rps_move.emit("scissors") + for button: TextureButton in rps_button_container.get_children(): + button.modulate = rps_grayed_color + rps_button_container.get_node("GuntingButton").modulate = Color.WHITE + + +func _on_batu_button_button_down() -> void: + rps_move.emit("rock") + for button: TextureButton in rps_button_container.get_children(): + button.modulate = rps_grayed_color + rps_button_container.get_node("BatuButton").modulate = Color.WHITE From a0475c85887413729809d68dcc34dab1840688a7 Mon Sep 17 00:00:00 2001 From: istamarahsan Date: Sun, 26 Jan 2025 10:59:39 +0700 Subject: [PATCH 21/29] feat: phase info on right hand side of the board --- demo_game.gd | 17 +++++++++++++- demo_game.tscn | 61 ++++++++++++++++++++++++++++++++++++++------------ 2 files changed, 63 insertions(+), 15 deletions(-) diff --git a/demo_game.gd b/demo_game.gd index fdf9321..10c92e5 100644 --- a/demo_game.gd +++ b/demo_game.gd @@ -8,7 +8,8 @@ signal opponent_played_rts(move: String) @export var player_1_deck: Array[Card] @export var player_2_deck: Array[Card] -@onready var match_manager = $MatchManager + +@onready var match_manager: MatchManager = $MatchManager @onready var own_side = $Own @onready var opponent_side = $Opponent @onready var start_game_btn = $StartGameButton @@ -30,6 +31,9 @@ var player_2_action: Action: var id var signal_connected := false +func _ready() -> void: + _update_phase_info(Match.Phase.PREGAME) + func init(player_id: int) -> void: id = player_id @@ -44,6 +48,7 @@ func init(player_id: int) -> void: if card.id not in id_to_card: id_to_card[card.id] = card + print(match_manager.phase) match_manager.init({ MatchManager.PLAYER_1_ID: player_1_deck, MatchManager.PLAYER_2_ID: player_2_deck @@ -59,6 +64,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) + _update_phase_info(transition.to) print("Phase: ", Match.phase_to_str(transition.from), " -> ", Match.phase_to_str(transition.to)) func _on_start_game_button_button_up() -> void: @@ -113,3 +119,12 @@ func rpc_opponent_rps_move(move: String) -> void: if player_1_action: match_manager.resolve(player_action_queue) player_action_queue.clear() + +func _update_phase_info(phase: Match.Phase): + var phaseHeaders: Container = get_node("%PhaseInfo/PhaseHeader") + for child: Label in phaseHeaders.get_children(): + child.modulate = Color.DIM_GRAY + var target = phaseHeaders.get_node(Match.phase_to_str(phase)) + phaseHeaders.visible = target != null + if target: + target.modulate = Color.WHITE diff --git a/demo_game.tscn b/demo_game.tscn index bfff989..42e110d 100644 --- a/demo_game.tscn +++ b/demo_game.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=19 format=3 uid="uid://bgc0u117jqyr1"] +[gd_scene load_steps=20 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"] @@ -6,7 +6,7 @@ [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/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://deo8mj887rfx1" 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"] @@ -18,6 +18,7 @@ [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"] +[ext_resource type="Theme" uid="uid://is34t82g4jg" path="res://cards.tres" id="19_3iovu"] [node name="DemoGame" type="Control"] layout_mode = 3 @@ -225,18 +226,6 @@ offset_bottom = 31.0 grow_horizontal = 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 offset_top = 35.0 @@ -277,6 +266,50 @@ text = "Start Game" [node name="MatchManager" parent="." instance=ExtResource("3_3yhrl")] +[node name="PhaseInfo" type="VBoxContainer" parent="."] +unique_name_in_owner = true +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = 347.0 +offset_top = -102.0 +offset_right = 864.0 +offset_bottom = 106.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="PhaseHeader" type="VBoxContainer" parent="PhaseInfo"] +layout_mode = 2 +theme_override_constants/separation = 24 +alignment = 2 + +[node name="Summon" type="Label" parent="PhaseInfo/PhaseHeader"] +layout_mode = 2 +theme = ExtResource("19_3iovu") +theme_override_font_sizes/font_size = 24 +text = "Summon" + +[node name="Support 1" type="Label" parent="PhaseInfo/PhaseHeader"] +layout_mode = 2 +theme = ExtResource("19_3iovu") +theme_override_font_sizes/font_size = 24 +text = "Support (1)" + +[node name="RPS" type="Label" parent="PhaseInfo/PhaseHeader"] +layout_mode = 2 +theme = ExtResource("19_3iovu") +theme_override_font_sizes/font_size = 24 +text = "Rock, Paper, Scissors" + +[node name="Support 2" type="Label" parent="PhaseInfo/PhaseHeader"] +layout_mode = 2 +theme = ExtResource("19_3iovu") +theme_override_font_sizes/font_size = 24 +text = "Support (2)" + [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"] From 0d261242b3263d9eae35be8d07cb8cc7dd389b53 Mon Sep 17 00:00:00 2001 From: kennetha123 Date: Sun, 26 Jan 2025 11:01:55 +0700 Subject: [PATCH 22/29] feat: energy decrease --- demo_game.tscn | 3 ++- player_side.gd | 2 +- tcg/match/match_manager.gd | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/demo_game.tscn b/demo_game.tscn index 0d96d3a..7f9d67d 100644 --- a/demo_game.tscn +++ b/demo_game.tscn @@ -107,8 +107,9 @@ layout_mode = 1 anchors_preset = 2 anchor_top = 1.0 anchor_bottom = 1.0 -offset_top = -23.0 +offset_top = -90.0 offset_right = 1152.0 +offset_bottom = -67.0 grow_vertical = 0 text = "Energy:" diff --git a/player_side.gd b/player_side.gd index 227ae3b..aec31f2 100644 --- a/player_side.gd +++ b/player_side.gd @@ -73,6 +73,7 @@ func _on_update(transition): monster_card_ui.visible = true monster_card_ui.show_monster(monster) incoming_damage_label.text = "Incoming Damage: " + str(monster.health_delta) + else: monster_card_ui.visible = false if match_manager.phase in [Match.Phase.SUMMON, Match.Phase.SUPPORT_1, Match.Phase.SUPPORT_2]: @@ -113,7 +114,6 @@ func _on_update(transition): if card is MonsterCard: var monster_card:MonsterCardUI = monster_card_prefab.instantiate() monster_card.show_monster(MatchMonster.new(card, card.base_health, 0)) - if !is_disabled: monster_card.left_clicked.connect(func (): _pop_this_card(monster_card) diff --git a/tcg/match/match_manager.gd b/tcg/match/match_manager.gd index 647f4ce..f77d424 100644 --- a/tcg/match/match_manager.gd +++ b/tcg/match/match_manager.gd @@ -79,6 +79,7 @@ func resolve(action_by_player_id: Dictionary) -> PhaseTransition: 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)) + players[player_id].energy = players[player_id].energy - card.energy_cost if players.values().all(func(player: MatchPlayer): return player.monster): phase = Match.Phase.SUPPORT_1 Match.Phase.SUPPORT_1: From 02ee129b42c4b8b5c55f25465d5e1a70445f3d51 Mon Sep 17 00:00:00 2001 From: istamarahsan Date: Sun, 26 Jan 2025 11:07:08 +0700 Subject: [PATCH 23/29] merge: script changes --- player_side.gd | 44 +++++++++++++++++++++++++++----------- tcg/match/match_manager.gd | 1 + 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/player_side.gd b/player_side.gd index 21b4a04..aec31f2 100644 --- a/player_side.gd +++ b/player_side.gd @@ -9,6 +9,8 @@ signal rps_move(move: String) @export var support_red_card_prefab: PackedScene @export var support_green_card_prefab: PackedScene @export var monster_card_prefab: PackedScene +@export var rps_button_container: Container +@export var rps_grayed_color: Color @onready var monster_card_ui := $"MonsterCard" @onready var support1_green := $"Support1GreenCard" @@ -71,6 +73,7 @@ func _on_update(transition): monster_card_ui.visible = true monster_card_ui.show_monster(monster) incoming_damage_label.text = "Incoming Damage: " + str(monster.health_delta) + else: monster_card_ui.visible = false if match_manager.phase in [Match.Phase.SUMMON, Match.Phase.SUPPORT_1, Match.Phase.SUPPORT_2]: @@ -111,7 +114,6 @@ func _on_update(transition): if card is MonsterCard: var monster_card:MonsterCardUI = monster_card_prefab.instantiate() monster_card.show_monster(MatchMonster.new(card, card.base_health, 0)) - if !is_disabled: monster_card.left_clicked.connect(func (): _pop_this_card(monster_card) @@ -131,21 +133,37 @@ func _on_update(transition): btn.left_clicked.connect(func (): _pop_this_card(btn) play_card.emit(card)) - - if match_manager.phase == Match.Phase.RPS: - for move in ["rock", "paper", "scissors"]: - - if !show_buttons: - continue - - var btn = Button.new() - btn.text = move - btn.button_up.connect(func (): rps_move.emit(move)) - deck.add_child(btn) - + + if rps_button_container: + rps_button_container.visible = match_manager.phase == Match.Phase.RPS + for button: TextureButton in rps_button_container.get_children(): + button.modulate = rps_grayed_color + + func _pop_this_card(control: Control): if selected_card: selected_card.size_flags_vertical = Control.SIZE_SHRINK_END control.size_flags_vertical = Control.SIZE_SHRINK_BEGIN selected_card = control + + +func _on_kertas_button_button_down() -> void: + rps_move.emit("paper") + for button: TextureButton in rps_button_container.get_children(): + button.modulate = rps_grayed_color + rps_button_container.get_node("KertasButton").modulate = Color.WHITE + + +func _on_gunting_button_button_down() -> void: + rps_move.emit("scissors") + for button: TextureButton in rps_button_container.get_children(): + button.modulate = rps_grayed_color + rps_button_container.get_node("GuntingButton").modulate = Color.WHITE + + +func _on_batu_button_button_down() -> void: + rps_move.emit("rock") + for button: TextureButton in rps_button_container.get_children(): + button.modulate = rps_grayed_color + rps_button_container.get_node("BatuButton").modulate = Color.WHITE diff --git a/tcg/match/match_manager.gd b/tcg/match/match_manager.gd index 647f4ce..f77d424 100644 --- a/tcg/match/match_manager.gd +++ b/tcg/match/match_manager.gd @@ -79,6 +79,7 @@ func resolve(action_by_player_id: Dictionary) -> PhaseTransition: 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)) + players[player_id].energy = players[player_id].energy - card.energy_cost if players.values().all(func(player: MatchPlayer): return player.monster): phase = Match.Phase.SUPPORT_1 Match.Phase.SUPPORT_1: From 41a72709df3cdeb279399a9a4e260e35c6ff3b5c Mon Sep 17 00:00:00 2001 From: Kenshia <73539778+Kenshia@users.noreply.github.com> Date: Sun, 26 Jan 2025 11:14:32 +0700 Subject: [PATCH 24/29] feat: card hover --- player_side.gd | 53 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 2 deletions(-) diff --git a/player_side.gd b/player_side.gd index aec31f2..1075011 100644 --- a/player_side.gd +++ b/player_side.gd @@ -23,6 +23,13 @@ var show_buttons: bool var signal_connected: bool var selected_card: Control +var hovering_cards_this_frame: Array[Control] = [] +var hovering_cards_duration: Dictionary = {} +const original_hover_position = 50 # hard coded idk what's a good way to find this value +const hover_animation_time = 0.1 +const hover_height_offset = -50 +const selected_height_offset = -100 + func attach(match_manager: MatchManager, show_buttons: bool = true): self.show_buttons = show_buttons self.match_manager = match_manager @@ -39,6 +46,7 @@ func _ready(): child.queue_free() func _on_update(transition): + hovering_cards_duration.clear() selected_card = null for child in deck.get_children(): @@ -87,6 +95,7 @@ func _on_update(transition): skip_btn.left_clicked.connect(func (): _pop_this_card(skip_btn) play_card.emit(null)) + skip_btn.hovering.connect(func (delta): _do_hover(skip_btn, delta)) deck.add_child(skip_btn) for card: Card in player.hand: @@ -118,6 +127,7 @@ func _on_update(transition): monster_card.left_clicked.connect(func (): _pop_this_card(monster_card) play_card.emit(card)) + monster_card.hovering.connect(func (delta): _do_hover(monster_card, delta)) deck.add_child(monster_card) elif card is SupportCard and card.type == "red": @@ -133,6 +143,7 @@ func _on_update(transition): btn.left_clicked.connect(func (): _pop_this_card(btn) play_card.emit(card)) + btn.hovering.connect(func (delta): _do_hover(btn, delta)) if rps_button_container: rps_button_container.visible = match_manager.phase == Match.Phase.RPS @@ -142,10 +153,48 @@ func _on_update(transition): func _pop_this_card(control: Control): if selected_card: - selected_card.size_flags_vertical = Control.SIZE_SHRINK_END + selected_card.position = Vector2(selected_card.position.x, original_hover_position) - control.size_flags_vertical = Control.SIZE_SHRINK_BEGIN selected_card = control + selected_card.position = Vector2(selected_card.position.x, original_hover_position + selected_height_offset) + +func _do_hover(control: Control, delta: float): + if control == selected_card: + if control in hovering_cards_duration: + hovering_cards_duration.erase(control) + return + + var duration: float + if control in hovering_cards_duration: + duration = hovering_cards_duration[control] + duration = clampf(duration + delta, 0, hover_animation_time) + hovering_cards_duration[control] = duration + else: + hovering_cards_duration[control] = delta + duration = delta + + var height = lerpf(0, hover_height_offset, duration / hover_animation_time) + original_hover_position + control.position = Vector2(control.position.x, height) + + hovering_cards_this_frame.append(control) + +func _process(delta): + for card in hovering_cards_duration.keys(): + if !card or card in hovering_cards_this_frame: + continue + + var duration = hovering_cards_duration[card] + duration = maxf(0, duration - delta) + + var height = lerpf(0, hover_height_offset, duration / hover_animation_time) + original_hover_position + card.position = Vector2(card.position.x, height) + + if duration == 0: + hovering_cards_duration.erase(card) + else: + hovering_cards_duration[card] = duration + + hovering_cards_this_frame.clear() func _on_kertas_button_button_down() -> void: From abd2feaab8f2f9de669d3b791b2540161a83045e Mon Sep 17 00:00:00 2001 From: istamarahsan Date: Sun, 26 Jan 2025 11:26:09 +0700 Subject: [PATCH 25/29] feat: win-lose-tie at game end --- demo_game.gd | 5 +++++ demo_game.tscn | 20 ++++++++++++++++++++ tcg/match/event/event_game_ended.gd | 7 +++++++ tcg/match/match_manager.gd | 5 +++++ 4 files changed, 37 insertions(+) create mode 100644 tcg/match/event/event_game_ended.gd diff --git a/demo_game.gd b/demo_game.gd index 10c92e5..b3d2308 100644 --- a/demo_game.gd +++ b/demo_game.gd @@ -13,6 +13,7 @@ signal opponent_played_rts(move: String) @onready var own_side = $Own @onready var opponent_side = $Opponent @onready var start_game_btn = $StartGameButton +@onready var win_lose_tie_label: Label = $"Win-Lose-Tie" var id_to_card: Dictionary = {} @@ -65,6 +66,10 @@ func _on_match_manager_state_transitioned(transition: PhaseTransition): start_game_btn.visible = match_manager.phase == Match.Phase.PREGAME transition_history.append(transition) _update_phase_info(transition.to) + if transition.to == Match.Phase.END: + var game_ended_event: EventGameEnded = transition.events.filter(func (it): return it is EventGameEnded)[0] + win_lose_tie_label.text = "TIE" if game_ended_event.winner_player_id == -1 else "YOU WON!" if game_ended_event.winner_player_id == id else "YOU LOST!" + win_lose_tie_label.visible = true print("Phase: ", Match.phase_to_str(transition.from), " -> ", Match.phase_to_str(transition.to)) func _on_start_game_button_button_up() -> void: diff --git a/demo_game.tscn b/demo_game.tscn index a76e523..65b3c81 100644 --- a/demo_game.tscn +++ b/demo_game.tscn @@ -338,6 +338,26 @@ theme = ExtResource("19_3iovu") theme_override_font_sizes/font_size = 24 text = "Support (2)" +[node name="Win-Lose-Tie" type="Label" parent="."] +visible = false +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -365.0 +offset_top = -215.0 +offset_right = 365.0 +offset_bottom = 215.0 +grow_horizontal = 2 +grow_vertical = 2 +theme = ExtResource("19_3iovu") +theme_override_font_sizes/font_size = 52 +text = "YOU WON!" +horizontal_alignment = 1 +vertical_alignment = 1 + [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="button_down" from="Own/HBoxContainer/KertasButton" to="Own" method="_on_kertas_button_button_down"] diff --git a/tcg/match/event/event_game_ended.gd b/tcg/match/event/event_game_ended.gd new file mode 100644 index 0000000..f9db6cc --- /dev/null +++ b/tcg/match/event/event_game_ended.gd @@ -0,0 +1,7 @@ +extends Event +class_name EventGameEnded + +var winner_player_id: int + +func _init(winner_player_id: int) -> void: + self.winner_player_id = winner_player_id diff --git a/tcg/match/match_manager.gd b/tcg/match/match_manager.gd index f77d424..9a25959 100644 --- a/tcg/match/match_manager.gd +++ b/tcg/match/match_manager.gd @@ -172,6 +172,7 @@ func resolve(action_by_player_id: Dictionary) -> PhaseTransition: 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) + var players_without_monster_ids = players_without_monster.map(func (it): return it.id) if players_without_monster.size() == 0: phase = Match.Phase.SUPPORT_1 elif players_without_monster.all( @@ -179,7 +180,11 @@ func resolve(action_by_player_id: Dictionary) -> PhaseTransition: ): phase = Match.Phase.SUMMON else: + var player_1_lost = players_without_monster_ids.has(player_1.id) + var player_2_lost = players_without_monster_ids.has(player_2.id) + var winner_id = -1 if player_1_lost and player_2_lost else player_1.id if player_2_lost else player_2.id phase = Match.Phase.END + events.append(EventGameEnded.new(winner_id)) _: pass var transition = PhaseTransition.new(events, initial_phase, phase) From 7b6be434a86f5e55b7c5405e598187e1d2fbac6f Mon Sep 17 00:00:00 2001 From: kennetha123 Date: Sun, 26 Jan 2025 11:30:35 +0700 Subject: [PATCH 26/29] feat: add card images --- assets/card_base/illust bg 1.png | 3 +++ assets/card_base/illust bg 1.png.import | 34 ++++++++++++++++++++++++ assets/monster/Goldfish 2.png | 3 +++ assets/monster/Goldfish 2.png.import | 34 ++++++++++++++++++++++++ assets/monster/axolotl 3.png | 3 +++ assets/monster/axolotl 3.png.import | 34 ++++++++++++++++++++++++ assets/monster/capybara 1.png | 3 +++ assets/monster/capybara 1.png.import | 34 ++++++++++++++++++++++++ assets/monster/cat 3.png | 3 +++ assets/monster/cat 3.png.import | 34 ++++++++++++++++++++++++ assets/monster/duck 1.png | 3 +++ assets/monster/duck 1.png.import | 34 ++++++++++++++++++++++++ assets/monster/jellyfish 2.png | 3 +++ assets/monster/jellyfish 2.png.import | 34 ++++++++++++++++++++++++ assets/monster/penguing 2.png | 3 +++ assets/monster/penguing 2.png.import | 34 ++++++++++++++++++++++++ assets/monster/rabbit 1.png | 3 +++ assets/monster/rabbit 1.png.import | 34 ++++++++++++++++++++++++ assets/monster/whale 2.png | 3 +++ assets/monster/whale 2.png.import | 34 ++++++++++++++++++++++++ assets/support/Invisibility.png | 3 +++ assets/support/Invisibility.png.import | 34 ++++++++++++++++++++++++ assets/support/absorb.png | 3 +++ assets/support/absorb.png.import | 34 ++++++++++++++++++++++++ assets/support/all out attack.png | 3 +++ assets/support/all out attack.png.import | 34 ++++++++++++++++++++++++ assets/support/energy booster.png | 3 +++ assets/support/energy booster.png.import | 34 ++++++++++++++++++++++++ assets/support/insurance.png | 3 +++ assets/support/insurance.png.import | 34 ++++++++++++++++++++++++ assets/support/lifesteal.png | 3 +++ assets/support/lifesteal.png.import | 34 ++++++++++++++++++++++++ assets/support/potion.png | 3 +++ assets/support/potion.png.import | 34 ++++++++++++++++++++++++ assets/support/reflection.png | 3 +++ assets/support/reflection.png.import | 34 ++++++++++++++++++++++++ assets/support/sword mastery.png | 3 +++ assets/support/sword mastery.png.import | 34 ++++++++++++++++++++++++ assets/support/tanker.png | 3 +++ assets/support/tanker.png.import | 34 ++++++++++++++++++++++++ data/cards/monster/axoluna.tres | 6 ++--- data/cards/monster/bunnaut.tres | 4 ++- data/cards/monster/capytain.tres | 4 ++- data/cards/monster/cattogato.tres | 4 ++- data/cards/monster/gilli.tres | 4 ++- data/cards/monster/jellova.tres | 4 ++- data/cards/monster/orcava.tres | 4 ++- data/cards/monster/prankie.tres | 4 ++- data/cards/monster/quackle.tres | 4 ++- data/cards/support/absorb.tres | 4 ++- data/cards/support/all_out_attack.tres | 4 ++- data/cards/support/energy_booster.tres | 4 ++- data/cards/support/insurance.tres | 4 ++- data/cards/support/invisibility.tres | 5 ++-- data/cards/support/lifesteal.tres | 4 ++- data/cards/support/potion.tres | 4 ++- data/cards/support/reflection.tres | 5 ++-- data/cards/support/sword_mastery.tres | 4 ++- data/cards/support/tanker.tres | 5 ++-- demo_game.tscn | 10 ++++++- ui/card_template/support_card_green.tscn | 25 ++++++++--------- 61 files changed, 819 insertions(+), 37 deletions(-) create mode 100644 assets/card_base/illust bg 1.png create mode 100644 assets/card_base/illust bg 1.png.import create mode 100644 assets/monster/Goldfish 2.png create mode 100644 assets/monster/Goldfish 2.png.import create mode 100644 assets/monster/axolotl 3.png create mode 100644 assets/monster/axolotl 3.png.import create mode 100644 assets/monster/capybara 1.png create mode 100644 assets/monster/capybara 1.png.import create mode 100644 assets/monster/cat 3.png create mode 100644 assets/monster/cat 3.png.import create mode 100644 assets/monster/duck 1.png create mode 100644 assets/monster/duck 1.png.import create mode 100644 assets/monster/jellyfish 2.png create mode 100644 assets/monster/jellyfish 2.png.import create mode 100644 assets/monster/penguing 2.png create mode 100644 assets/monster/penguing 2.png.import create mode 100644 assets/monster/rabbit 1.png create mode 100644 assets/monster/rabbit 1.png.import create mode 100644 assets/monster/whale 2.png create mode 100644 assets/monster/whale 2.png.import create mode 100644 assets/support/Invisibility.png create mode 100644 assets/support/Invisibility.png.import create mode 100644 assets/support/absorb.png create mode 100644 assets/support/absorb.png.import create mode 100644 assets/support/all out attack.png create mode 100644 assets/support/all out attack.png.import create mode 100644 assets/support/energy booster.png create mode 100644 assets/support/energy booster.png.import create mode 100644 assets/support/insurance.png create mode 100644 assets/support/insurance.png.import create mode 100644 assets/support/lifesteal.png create mode 100644 assets/support/lifesteal.png.import create mode 100644 assets/support/potion.png create mode 100644 assets/support/potion.png.import create mode 100644 assets/support/reflection.png create mode 100644 assets/support/reflection.png.import create mode 100644 assets/support/sword mastery.png create mode 100644 assets/support/sword mastery.png.import create mode 100644 assets/support/tanker.png create mode 100644 assets/support/tanker.png.import diff --git a/assets/card_base/illust bg 1.png b/assets/card_base/illust bg 1.png new file mode 100644 index 0000000..712628d --- /dev/null +++ b/assets/card_base/illust bg 1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f4f66245934d9cb584395b647eab454b3e74351c3086b720bfaf3837c95d1dd2 +size 1744521 diff --git a/assets/card_base/illust bg 1.png.import b/assets/card_base/illust bg 1.png.import new file mode 100644 index 0000000..22253c2 --- /dev/null +++ b/assets/card_base/illust bg 1.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://6trhu2r7h6g3" +path="res://.godot/imported/illust bg 1.png-7d6e961f3fef1ad5d8dcf698718d9c23.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/card_base/illust bg 1.png" +dest_files=["res://.godot/imported/illust bg 1.png-7d6e961f3fef1ad5d8dcf698718d9c23.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/monster/Goldfish 2.png b/assets/monster/Goldfish 2.png new file mode 100644 index 0000000..ec6bc6e --- /dev/null +++ b/assets/monster/Goldfish 2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:53c37fd23a318f64cdc2951918f4f4b06fa3a4d05ddb2b15c9fc722e4f217519 +size 108879 diff --git a/assets/monster/Goldfish 2.png.import b/assets/monster/Goldfish 2.png.import new file mode 100644 index 0000000..e14f3bd --- /dev/null +++ b/assets/monster/Goldfish 2.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b0f5rg5eqyym1" +path="res://.godot/imported/Goldfish 2.png-20495c3132cec5d0b0f2eb9e1b6f168f.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/monster/Goldfish 2.png" +dest_files=["res://.godot/imported/Goldfish 2.png-20495c3132cec5d0b0f2eb9e1b6f168f.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/monster/axolotl 3.png b/assets/monster/axolotl 3.png new file mode 100644 index 0000000..940328c --- /dev/null +++ b/assets/monster/axolotl 3.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fe4eaa932ae0e0f7363269bd39412aaaa3796dfcbcf2e5054b9d6f9d2aa4b8b8 +size 116315 diff --git a/assets/monster/axolotl 3.png.import b/assets/monster/axolotl 3.png.import new file mode 100644 index 0000000..8658cea --- /dev/null +++ b/assets/monster/axolotl 3.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://wdyu7txs2ijg" +path="res://.godot/imported/axolotl 3.png-66300d813b5cc2dfc432414b14c1f8bc.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/monster/axolotl 3.png" +dest_files=["res://.godot/imported/axolotl 3.png-66300d813b5cc2dfc432414b14c1f8bc.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/monster/capybara 1.png b/assets/monster/capybara 1.png new file mode 100644 index 0000000..8eeddf2 --- /dev/null +++ b/assets/monster/capybara 1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ae0ced57dd24cc221bd9f4b161aef907bf17962294167e6817e60017d484f76e +size 130901 diff --git a/assets/monster/capybara 1.png.import b/assets/monster/capybara 1.png.import new file mode 100644 index 0000000..74346a4 --- /dev/null +++ b/assets/monster/capybara 1.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://c72q2py2vj6j4" +path="res://.godot/imported/capybara 1.png-98187c93d8c784ac26a4fe6cdc81e3f0.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/monster/capybara 1.png" +dest_files=["res://.godot/imported/capybara 1.png-98187c93d8c784ac26a4fe6cdc81e3f0.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/monster/cat 3.png b/assets/monster/cat 3.png new file mode 100644 index 0000000..dcf2e11 --- /dev/null +++ b/assets/monster/cat 3.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4ad0cffd46c57d81ee56f43a2adf5d9a6e154a6dc9b76ed7a876ebd5bf19ef3d +size 123755 diff --git a/assets/monster/cat 3.png.import b/assets/monster/cat 3.png.import new file mode 100644 index 0000000..9b1df2e --- /dev/null +++ b/assets/monster/cat 3.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bcusdaqfhlv1b" +path="res://.godot/imported/cat 3.png-a083e2d16032d32908b04a46259e2c6a.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/monster/cat 3.png" +dest_files=["res://.godot/imported/cat 3.png-a083e2d16032d32908b04a46259e2c6a.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/monster/duck 1.png b/assets/monster/duck 1.png new file mode 100644 index 0000000..e4710d0 --- /dev/null +++ b/assets/monster/duck 1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4db0c8f285a1523ea1d3fa2e3e18c834d70b215930f7139fee3efa25ac4aeedd +size 100811 diff --git a/assets/monster/duck 1.png.import b/assets/monster/duck 1.png.import new file mode 100644 index 0000000..86cfcf2 --- /dev/null +++ b/assets/monster/duck 1.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://ujke0x73f77b" +path="res://.godot/imported/duck 1.png-e7d6d398a984b9ae6ba8f33dfe27e9dd.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/monster/duck 1.png" +dest_files=["res://.godot/imported/duck 1.png-e7d6d398a984b9ae6ba8f33dfe27e9dd.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/monster/jellyfish 2.png b/assets/monster/jellyfish 2.png new file mode 100644 index 0000000..04ae99f --- /dev/null +++ b/assets/monster/jellyfish 2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bfd0f4cab6a3ed737816635416c9bb822e2b53028e35ea5cd79ba7e226a216ce +size 81602 diff --git a/assets/monster/jellyfish 2.png.import b/assets/monster/jellyfish 2.png.import new file mode 100644 index 0000000..6cd471a --- /dev/null +++ b/assets/monster/jellyfish 2.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cstwubbj8l8fr" +path="res://.godot/imported/jellyfish 2.png-d36c6543a46308145decdddd5ae9a63d.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/monster/jellyfish 2.png" +dest_files=["res://.godot/imported/jellyfish 2.png-d36c6543a46308145decdddd5ae9a63d.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/monster/penguing 2.png b/assets/monster/penguing 2.png new file mode 100644 index 0000000..2598f19 --- /dev/null +++ b/assets/monster/penguing 2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0a328047682a27c1b548405a2adf82738093c9a842e0c76defd7970cd178a5ac +size 101016 diff --git a/assets/monster/penguing 2.png.import b/assets/monster/penguing 2.png.import new file mode 100644 index 0000000..8f8858f --- /dev/null +++ b/assets/monster/penguing 2.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://deneyvmke3qyl" +path="res://.godot/imported/penguing 2.png-80094e4bcdb64d08cfd28547f5dd45c7.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/monster/penguing 2.png" +dest_files=["res://.godot/imported/penguing 2.png-80094e4bcdb64d08cfd28547f5dd45c7.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/monster/rabbit 1.png b/assets/monster/rabbit 1.png new file mode 100644 index 0000000..023327d --- /dev/null +++ b/assets/monster/rabbit 1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:415cbcdf4136ad6a07b63f5aa055f84443f8909876858667708e0229b4795b68 +size 93375 diff --git a/assets/monster/rabbit 1.png.import b/assets/monster/rabbit 1.png.import new file mode 100644 index 0000000..ac94ff9 --- /dev/null +++ b/assets/monster/rabbit 1.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cu0ivvtvryq64" +path="res://.godot/imported/rabbit 1.png-53666927d04c30fffb92370a7482b673.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/monster/rabbit 1.png" +dest_files=["res://.godot/imported/rabbit 1.png-53666927d04c30fffb92370a7482b673.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/monster/whale 2.png b/assets/monster/whale 2.png new file mode 100644 index 0000000..cbf8df0 --- /dev/null +++ b/assets/monster/whale 2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a704a38238c3991e1f0f3e250a988430393aa4b506ff7c72122a516c6dc0b139 +size 67821 diff --git a/assets/monster/whale 2.png.import b/assets/monster/whale 2.png.import new file mode 100644 index 0000000..29f0c19 --- /dev/null +++ b/assets/monster/whale 2.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dw8cnu3lfblig" +path="res://.godot/imported/whale 2.png-8dca9b32eca20cb2feb31734e55de3f6.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/monster/whale 2.png" +dest_files=["res://.godot/imported/whale 2.png-8dca9b32eca20cb2feb31734e55de3f6.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/support/Invisibility.png b/assets/support/Invisibility.png new file mode 100644 index 0000000..1c77364 --- /dev/null +++ b/assets/support/Invisibility.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f65e230ede853aeba1650e8d569220585f3aa3a9d27f006e5a82ae300877b92b +size 135764 diff --git a/assets/support/Invisibility.png.import b/assets/support/Invisibility.png.import new file mode 100644 index 0000000..39e7e7a --- /dev/null +++ b/assets/support/Invisibility.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b8hkgi1r8wpri" +path="res://.godot/imported/Invisibility.png-b1f5b6e24b6db1d63402e75c2d90b9f4.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/support/Invisibility.png" +dest_files=["res://.godot/imported/Invisibility.png-b1f5b6e24b6db1d63402e75c2d90b9f4.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/support/absorb.png b/assets/support/absorb.png new file mode 100644 index 0000000..fc4ee91 --- /dev/null +++ b/assets/support/absorb.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:22ec3e0529bc2fef18223f893b2960a87b9b9ce827871a9d1440c9ac2d30d462 +size 238847 diff --git a/assets/support/absorb.png.import b/assets/support/absorb.png.import new file mode 100644 index 0000000..9a60646 --- /dev/null +++ b/assets/support/absorb.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cv5hjphfixv3o" +path="res://.godot/imported/absorb.png-e8458d89a69818053d3209e7228c83cd.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/support/absorb.png" +dest_files=["res://.godot/imported/absorb.png-e8458d89a69818053d3209e7228c83cd.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/support/all out attack.png b/assets/support/all out attack.png new file mode 100644 index 0000000..f6eeb9e --- /dev/null +++ b/assets/support/all out attack.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:06c2538f1c5f8a0e101f4b00a729279baa211ebfdc99707880135a02360f776f +size 177931 diff --git a/assets/support/all out attack.png.import b/assets/support/all out attack.png.import new file mode 100644 index 0000000..3e0cb0c --- /dev/null +++ b/assets/support/all out attack.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bpmr8pa8cq3w0" +path="res://.godot/imported/all out attack.png-2872fd363fbff1bf0b089ac317139b0e.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/support/all out attack.png" +dest_files=["res://.godot/imported/all out attack.png-2872fd363fbff1bf0b089ac317139b0e.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/support/energy booster.png b/assets/support/energy booster.png new file mode 100644 index 0000000..9d8ff7f --- /dev/null +++ b/assets/support/energy booster.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ae23af87934d3d3057e00f7bc7e1576a87416bbe7a499048add4d9acbe9bc5b8 +size 88074 diff --git a/assets/support/energy booster.png.import b/assets/support/energy booster.png.import new file mode 100644 index 0000000..786ca67 --- /dev/null +++ b/assets/support/energy booster.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cd1mxacc3gfcy" +path="res://.godot/imported/energy booster.png-f846d83c962a9e077788e0d0ed5252dd.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/support/energy booster.png" +dest_files=["res://.godot/imported/energy booster.png-f846d83c962a9e077788e0d0ed5252dd.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/support/insurance.png b/assets/support/insurance.png new file mode 100644 index 0000000..e92bb13 --- /dev/null +++ b/assets/support/insurance.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e0e2ff619969c6fff98cecbd63ec954010298e434a5079c06d81e0afa5fd4d5e +size 213996 diff --git a/assets/support/insurance.png.import b/assets/support/insurance.png.import new file mode 100644 index 0000000..88ac73a --- /dev/null +++ b/assets/support/insurance.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bwo6dfe1kpxhe" +path="res://.godot/imported/insurance.png-fa2ae7ef8a239dc0e4a4bd2c8f0b477b.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/support/insurance.png" +dest_files=["res://.godot/imported/insurance.png-fa2ae7ef8a239dc0e4a4bd2c8f0b477b.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/support/lifesteal.png b/assets/support/lifesteal.png new file mode 100644 index 0000000..74f4fb4 --- /dev/null +++ b/assets/support/lifesteal.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fa02a72c7208802bcf5882d4925add9707c281b0420ef823302674468b522ada +size 133540 diff --git a/assets/support/lifesteal.png.import b/assets/support/lifesteal.png.import new file mode 100644 index 0000000..ecf73eb --- /dev/null +++ b/assets/support/lifesteal.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bni2wr2vrg0fe" +path="res://.godot/imported/lifesteal.png-1fcf74a2a74d8a4381ce6310ccb999d8.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/support/lifesteal.png" +dest_files=["res://.godot/imported/lifesteal.png-1fcf74a2a74d8a4381ce6310ccb999d8.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/support/potion.png b/assets/support/potion.png new file mode 100644 index 0000000..1072f04 --- /dev/null +++ b/assets/support/potion.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f2c6b61399220a4d5ed8a702737654d1465b1c1e1d02cdc015702575002f6c5b +size 271057 diff --git a/assets/support/potion.png.import b/assets/support/potion.png.import new file mode 100644 index 0000000..b7657e2 --- /dev/null +++ b/assets/support/potion.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://48hblv72emyr" +path="res://.godot/imported/potion.png-1339ae9737d6625a795e518c852db261.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/support/potion.png" +dest_files=["res://.godot/imported/potion.png-1339ae9737d6625a795e518c852db261.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/support/reflection.png b/assets/support/reflection.png new file mode 100644 index 0000000..bc699d4 --- /dev/null +++ b/assets/support/reflection.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:22ca0b3919d5eb76eac7e7437285d3bbc508be3f354a9a310fb1727c7c5fae69 +size 217825 diff --git a/assets/support/reflection.png.import b/assets/support/reflection.png.import new file mode 100644 index 0000000..bf38332 --- /dev/null +++ b/assets/support/reflection.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b3uq5b2x2oacn" +path="res://.godot/imported/reflection.png-2ae705bc1d7282dacca1272db53a447a.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/support/reflection.png" +dest_files=["res://.godot/imported/reflection.png-2ae705bc1d7282dacca1272db53a447a.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/support/sword mastery.png b/assets/support/sword mastery.png new file mode 100644 index 0000000..8c14dd4 --- /dev/null +++ b/assets/support/sword mastery.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ee9f3905c0ba6be4b0d609157d8008435c393b5529dfae45290cc69ce65fae88 +size 102278 diff --git a/assets/support/sword mastery.png.import b/assets/support/sword mastery.png.import new file mode 100644 index 0000000..a420ef0 --- /dev/null +++ b/assets/support/sword mastery.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://ha5p3vpqn5jv" +path="res://.godot/imported/sword mastery.png-67026928e9b242f46437e6cfb6d95bee.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/support/sword mastery.png" +dest_files=["res://.godot/imported/sword mastery.png-67026928e9b242f46437e6cfb6d95bee.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/support/tanker.png b/assets/support/tanker.png new file mode 100644 index 0000000..c9edcbb --- /dev/null +++ b/assets/support/tanker.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:487368fdb954eae97166906014ab24f92e100e4f34bf7498395ae5dd99ea8d54 +size 295201 diff --git a/assets/support/tanker.png.import b/assets/support/tanker.png.import new file mode 100644 index 0000000..361c8d1 --- /dev/null +++ b/assets/support/tanker.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://hiswkj2stt4l" +path="res://.godot/imported/tanker.png-de127e279370081587c7a5243fff4d1c.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/support/tanker.png" +dest_files=["res://.godot/imported/tanker.png-de127e279370081587c7a5243fff4d1c.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/data/cards/monster/axoluna.tres b/data/cards/monster/axoluna.tres index 1743622..a6f88da 100644 --- a/data/cards/monster/axoluna.tres +++ b/data/cards/monster/axoluna.tres @@ -1,6 +1,6 @@ -[gd_resource type="Resource" script_class="MonsterCard" load_steps=3 format=3 uid="uid://deo8mj887rfx1"] +[gd_resource type="Resource" script_class="MonsterCard" load_steps=3 format=3 uid="uid://di76avwc0gn8e"] -[ext_resource type="Texture2D" uid="uid://b8accn4e2ojau" path="res://assets/monster/froggo 1.png" id="1_dyw44"] +[ext_resource type="Texture2D" uid="uid://wdyu7txs2ijg" path="res://assets/monster/axolotl 3.png" id="1_j0l6n"] [ext_resource type="Script" path="res://tcg/card/monster_card.gd" id="1_s0p53"] [resource] @@ -12,4 +12,4 @@ energy_cost = 1 base_health = 120 name = "Axoluna" description = "Cute wanderer of the tank, Axoluna" -icon = ExtResource("1_dyw44") +icon = ExtResource("1_j0l6n") diff --git a/data/cards/monster/bunnaut.tres b/data/cards/monster/bunnaut.tres index 6d478e3..a70008a 100644 --- a/data/cards/monster/bunnaut.tres +++ b/data/cards/monster/bunnaut.tres @@ -1,6 +1,7 @@ -[gd_resource type="Resource" script_class="MonsterCard" load_steps=2 format=3 uid="uid://tgju8eodyuk1"] +[gd_resource type="Resource" script_class="MonsterCard" load_steps=3 format=3 uid="uid://tgju8eodyuk1"] [ext_resource type="Script" path="res://tcg/card/monster_card.gd" id="1_3jfyg"] +[ext_resource type="Texture2D" uid="uid://cu0ivvtvryq64" path="res://assets/monster/rabbit 1.png" id="1_xibsw"] [resource] script = ExtResource("1_3jfyg") @@ -11,3 +12,4 @@ energy_cost = 1 base_health = 50 name = "Bunnaut" description = "Run faster than tortoise." +icon = ExtResource("1_xibsw") diff --git a/data/cards/monster/capytain.tres b/data/cards/monster/capytain.tres index d11bf4d..712ab1e 100644 --- a/data/cards/monster/capytain.tres +++ b/data/cards/monster/capytain.tres @@ -1,5 +1,6 @@ -[gd_resource type="Resource" script_class="MonsterCard" load_steps=2 format=3 uid="uid://cs7q8i7bvohmj"] +[gd_resource type="Resource" script_class="MonsterCard" load_steps=3 format=3 uid="uid://cs7q8i7bvohmj"] +[ext_resource type="Texture2D" uid="uid://c72q2py2vj6j4" path="res://assets/monster/capybara 1.png" id="1_mulam"] [ext_resource type="Script" path="res://tcg/card/monster_card.gd" id="1_n3oql"] [resource] @@ -11,3 +12,4 @@ energy_cost = 3 base_health = 170 name = "Capytain" description = "A big, hungry capybara" +icon = ExtResource("1_mulam") diff --git a/data/cards/monster/cattogato.tres b/data/cards/monster/cattogato.tres index 7fee1c0..7b4e72c 100644 --- a/data/cards/monster/cattogato.tres +++ b/data/cards/monster/cattogato.tres @@ -1,6 +1,7 @@ -[gd_resource type="Resource" script_class="MonsterCard" load_steps=2 format=3 uid="uid://bmst884k0myvd"] +[gd_resource type="Resource" script_class="MonsterCard" load_steps=3 format=3 uid="uid://bmst884k0myvd"] [ext_resource type="Script" path="res://tcg/card/monster_card.gd" id="1_hblhq"] +[ext_resource type="Texture2D" uid="uid://bcusdaqfhlv1b" path="res://assets/monster/cat 3.png" id="1_xles7"] [resource] script = ExtResource("1_hblhq") @@ -11,3 +12,4 @@ energy_cost = 3 base_health = 80 name = "Cattogato" description = "Lovely cat wandering in the space." +icon = ExtResource("1_xles7") diff --git a/data/cards/monster/gilli.tres b/data/cards/monster/gilli.tres index 30da6af..fe574ca 100644 --- a/data/cards/monster/gilli.tres +++ b/data/cards/monster/gilli.tres @@ -1,6 +1,7 @@ -[gd_resource type="Resource" script_class="MonsterCard" load_steps=2 format=3 uid="uid://myxgsyerrdla"] +[gd_resource type="Resource" script_class="MonsterCard" load_steps=3 format=3 uid="uid://myxgsyerrdla"] [ext_resource type="Script" path="res://tcg/card/monster_card.gd" id="1_1j36c"] +[ext_resource type="Texture2D" uid="uid://b0f5rg5eqyym1" path="res://assets/monster/Goldfish 2.png" id="1_62dnj"] [resource] script = ExtResource("1_1j36c") @@ -11,3 +12,4 @@ energy_cost = 1 base_health = 120 name = "Gilli" description = "There is a huge monster looking at me everyday." +icon = ExtResource("1_62dnj") diff --git a/data/cards/monster/jellova.tres b/data/cards/monster/jellova.tres index df0e747..ef9567f 100644 --- a/data/cards/monster/jellova.tres +++ b/data/cards/monster/jellova.tres @@ -1,5 +1,6 @@ -[gd_resource type="Resource" script_class="MonsterCard" load_steps=2 format=3 uid="uid://425ipxdapg8o"] +[gd_resource type="Resource" script_class="MonsterCard" load_steps=3 format=3 uid="uid://425ipxdapg8o"] +[ext_resource type="Texture2D" uid="uid://cstwubbj8l8fr" path="res://assets/monster/jellyfish 2.png" id="1_t6381"] [ext_resource type="Script" path="res://tcg/card/monster_card.gd" id="1_yvmeg"] [resource] @@ -11,3 +12,4 @@ energy_cost = 2 base_health = 110 name = "Jellova" description = "I'm gonna whip you till' you .. nevermind." +icon = ExtResource("1_t6381") diff --git a/data/cards/monster/orcava.tres b/data/cards/monster/orcava.tres index b1c212e..b45cafd 100644 --- a/data/cards/monster/orcava.tres +++ b/data/cards/monster/orcava.tres @@ -1,5 +1,6 @@ -[gd_resource type="Resource" script_class="MonsterCard" load_steps=2 format=3 uid="uid://cakkx0o8mifmn"] +[gd_resource type="Resource" script_class="MonsterCard" load_steps=3 format=3 uid="uid://cakkx0o8mifmn"] +[ext_resource type="Texture2D" uid="uid://dw8cnu3lfblig" path="res://assets/monster/whale 2.png" id="1_4dsvt"] [ext_resource type="Script" path="res://tcg/card/monster_card.gd" id="1_xcdwy"] [resource] @@ -11,3 +12,4 @@ energy_cost = 2 base_health = 200 name = "Orcava" description = "Human try to communicate with me. I simply block them." +icon = ExtResource("1_4dsvt") diff --git a/data/cards/monster/prankie.tres b/data/cards/monster/prankie.tres index 5cea32c..4d64b66 100644 --- a/data/cards/monster/prankie.tres +++ b/data/cards/monster/prankie.tres @@ -1,6 +1,7 @@ -[gd_resource type="Resource" script_class="MonsterCard" load_steps=2 format=3 uid="uid://shri5ne51s74"] +[gd_resource type="Resource" script_class="MonsterCard" load_steps=3 format=3 uid="uid://shri5ne51s74"] [ext_resource type="Script" path="res://tcg/card/monster_card.gd" id="1_70s4q"] +[ext_resource type="Texture2D" uid="uid://deneyvmke3qyl" path="res://assets/monster/penguing 2.png" id="1_75ppb"] [resource] script = ExtResource("1_70s4q") @@ -11,3 +12,4 @@ energy_cost = 2 base_health = 100 name = "Prankie" description = "I'm not pranking anyone. Yet." +icon = ExtResource("1_75ppb") diff --git a/data/cards/monster/quackle.tres b/data/cards/monster/quackle.tres index f774842..0fe4658 100644 --- a/data/cards/monster/quackle.tres +++ b/data/cards/monster/quackle.tres @@ -1,5 +1,6 @@ -[gd_resource type="Resource" script_class="MonsterCard" load_steps=2 format=3 uid="uid://dnf3gpji5prlr"] +[gd_resource type="Resource" script_class="MonsterCard" load_steps=3 format=3 uid="uid://dnf3gpji5prlr"] +[ext_resource type="Texture2D" uid="uid://ujke0x73f77b" path="res://assets/monster/duck 1.png" id="1_4f7pv"] [ext_resource type="Script" path="res://tcg/card/monster_card.gd" id="1_a8rjn"] [resource] @@ -11,3 +12,4 @@ energy_cost = 1 base_health = 70 name = "Quackle" description = "Quack! Quack! No one notice me." +icon = ExtResource("1_4f7pv") diff --git a/data/cards/support/absorb.tres b/data/cards/support/absorb.tres index ef6568c..72c5c4a 100644 --- a/data/cards/support/absorb.tres +++ b/data/cards/support/absorb.tres @@ -1,7 +1,8 @@ -[gd_resource type="Resource" script_class="ImplementedSupportCard" load_steps=3 format=3 uid="uid://be01tdq1fxlct"] +[gd_resource type="Resource" script_class="ImplementedSupportCard" load_steps=4 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"] +[ext_resource type="Texture2D" uid="uid://cv5hjphfixv3o" path="res://assets/support/absorb.png" id="2_i2lgf"] [resource] script = ExtResource("2_f6hay") @@ -10,3 +11,4 @@ type = "red" effects = Array[ExtResource("1_mhxdy")]([]) name = "Absorb" description = "Enemy damage converted to heal your Active Monster Field HP during this turn." +icon = ExtResource("2_i2lgf") diff --git a/data/cards/support/all_out_attack.tres b/data/cards/support/all_out_attack.tres index 35814a9..0269e6f 100644 --- a/data/cards/support/all_out_attack.tres +++ b/data/cards/support/all_out_attack.tres @@ -1,7 +1,8 @@ -[gd_resource type="Resource" script_class="ImplementedSupportCard" load_steps=3 format=3 uid="uid://dgxcvdo6x6kst"] +[gd_resource type="Resource" script_class="ImplementedSupportCard" load_steps=4 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"] +[ext_resource type="Texture2D" uid="uid://bpmr8pa8cq3w0" path="res://assets/support/all out attack.png" id="2_a1iip"] [resource] script = ExtResource("2_61mgn") @@ -10,3 +11,4 @@ type = "green" effects = Array[ExtResource("1_fd50n")]([null]) 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." +icon = ExtResource("2_a1iip") diff --git a/data/cards/support/energy_booster.tres b/data/cards/support/energy_booster.tres index bf64881..7a16144 100644 --- a/data/cards/support/energy_booster.tres +++ b/data/cards/support/energy_booster.tres @@ -1,7 +1,8 @@ -[gd_resource type="Resource" script_class="ImplementedSupportCard" load_steps=3 format=3 uid="uid://c0grh1y65e0f3"] +[gd_resource type="Resource" script_class="ImplementedSupportCard" load_steps=4 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"] +[ext_resource type="Texture2D" uid="uid://cd1mxacc3gfcy" path="res://assets/support/energy booster.png" id="2_lxctl"] [resource] script = ExtResource("2_iq88n") @@ -10,3 +11,4 @@ type = "green" effects = Array[ExtResource("1_pkc1x")]([null]) name = "Energy Booster" description = "Add 1 additional Energy." +icon = ExtResource("2_lxctl") diff --git a/data/cards/support/insurance.tres b/data/cards/support/insurance.tres index e63e98f..f9211a0 100644 --- a/data/cards/support/insurance.tres +++ b/data/cards/support/insurance.tres @@ -1,7 +1,8 @@ -[gd_resource type="Resource" script_class="ImplementedSupportCard" load_steps=3 format=3 uid="uid://dfocg5yfh22e8"] +[gd_resource type="Resource" script_class="ImplementedSupportCard" load_steps=4 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"] +[ext_resource type="Texture2D" uid="uid://bwo6dfe1kpxhe" path="res://assets/support/insurance.png" id="2_f7jjv"] [resource] script = ExtResource("2_3ixor") @@ -10,3 +11,4 @@ type = "red" effects = Array[ExtResource("1_gtyqr")]([null]) name = "Insurance" description = "If your monster supposed to be dead in this turn, keep it alive at 10 HP." +icon = ExtResource("2_f7jjv") diff --git a/data/cards/support/invisibility.tres b/data/cards/support/invisibility.tres index 2b917fb..3fb4c4e 100644 --- a/data/cards/support/invisibility.tres +++ b/data/cards/support/invisibility.tres @@ -1,13 +1,14 @@ -[gd_resource type="Resource" script_class="SimpleSupportCard" load_steps=3 format=3 uid="uid://by4yg81uqti3u"] +[gd_resource type="Resource" script_class="ImplementedSupportCard" load_steps=4 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/implemented_support_card.gd" id="2_6c2xo"] +[ext_resource type="Texture2D" uid="uid://b8hkgi1r8wpri" path="res://assets/support/Invisibility.png" id="2_6occh"] [resource] script = ExtResource("2_6c2xo") scope = "turn" -magnitude = 0 type = "green" effects = Array[ExtResource("1_5tnpm")]([null]) name = "Invisibility" description = "Ignore any damage to your monster in this turn." +icon = ExtResource("2_6occh") diff --git a/data/cards/support/lifesteal.tres b/data/cards/support/lifesteal.tres index 79a4497..2a0d994 100644 --- a/data/cards/support/lifesteal.tres +++ b/data/cards/support/lifesteal.tres @@ -1,6 +1,7 @@ -[gd_resource type="Resource" script_class="ImplementedSupportCard" load_steps=3 format=3 uid="uid://bcrlaam8uq6xt"] +[gd_resource type="Resource" script_class="ImplementedSupportCard" load_steps=4 format=3 uid="uid://bcrlaam8uq6xt"] [ext_resource type="Script" path="res://tcg/card/support_card_effect_instance.gd" id="1_b33y4"] +[ext_resource type="Texture2D" uid="uid://bni2wr2vrg0fe" path="res://assets/support/lifesteal.png" id="2_arrkb"] [ext_resource type="Script" path="res://tcg/card/implemented_support_card.gd" id="2_khaf1"] [resource] @@ -10,3 +11,4 @@ type = "green" effects = Array[ExtResource("1_b33y4")]([null]) name = "Lifesteal" description = "During this turn your attack also heals your HP." +icon = ExtResource("2_arrkb") diff --git a/data/cards/support/potion.tres b/data/cards/support/potion.tres index 926535b..36ea162 100644 --- a/data/cards/support/potion.tres +++ b/data/cards/support/potion.tres @@ -1,8 +1,9 @@ -[gd_resource type="Resource" script_class="ImplementedSupportCard" load_steps=5 format=3 uid="uid://4eod3m0vc5a8"] +[gd_resource type="Resource" script_class="ImplementedSupportCard" load_steps=6 format=3 uid="uid://4eod3m0vc5a8"] [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="Script" path="res://tcg/card/implemented_support_card.gd" id="3_at5nt"] +[ext_resource type="Texture2D" uid="uid://48hblv72emyr" path="res://assets/support/potion.png" id="3_hk8kx"] [sub_resource type="Resource" id="Resource_88lmk"] script = ExtResource("1_ujm0o") @@ -16,3 +17,4 @@ type = "green" effects = Array[ExtResource("1_ujm0o")]([SubResource("Resource_88lmk")]) name = "Potion" description = "Heal 30 HP" +icon = ExtResource("3_hk8kx") diff --git a/data/cards/support/reflection.tres b/data/cards/support/reflection.tres index b87a630..2e6e1eb 100644 --- a/data/cards/support/reflection.tres +++ b/data/cards/support/reflection.tres @@ -1,13 +1,14 @@ -[gd_resource type="Resource" script_class="SimpleSupportCard" load_steps=3 format=3 uid="uid://c1gsrru1wa6ao"] +[gd_resource type="Resource" script_class="ImplementedSupportCard" load_steps=4 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/implemented_support_card.gd" id="2_igbok"] +[ext_resource type="Texture2D" uid="uid://b3uq5b2x2oacn" path="res://assets/support/reflection.png" id="2_jrr8g"] [resource] script = ExtResource("2_igbok") scope = "turn" -magnitude = 0 type = "red" effects = Array[ExtResource("1_mk2or")]([null]) name = "Reflection" description = "Enemy got the same amount of damage as our monster in this turn." +icon = ExtResource("2_jrr8g") diff --git a/data/cards/support/sword_mastery.tres b/data/cards/support/sword_mastery.tres index fdb68c0..1eb0399 100644 --- a/data/cards/support/sword_mastery.tres +++ b/data/cards/support/sword_mastery.tres @@ -1,8 +1,9 @@ -[gd_resource type="Resource" script_class="ImplementedSupportCard" load_steps=5 format=3 uid="uid://2xeb6keaoabo"] +[gd_resource type="Resource" script_class="ImplementedSupportCard" load_steps=6 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"] [ext_resource type="Script" path="res://tcg/card/implemented_support_card.gd" id="3_37rh4"] +[ext_resource type="Texture2D" uid="uid://ha5p3vpqn5jv" path="res://assets/support/sword mastery.png" id="3_rrvpt"] [sub_resource type="Resource" id="Resource_wwv02"] script = ExtResource("1_y6yvj") @@ -16,3 +17,4 @@ type = "green" effects = Array[ExtResource("1_y6yvj")]([SubResource("Resource_wwv02")]) name = "Sword Mastery" description = "Permanently add 20 damage for all Rock Paper Scissor to 1 Active Monster." +icon = ExtResource("3_rrvpt") diff --git a/data/cards/support/tanker.tres b/data/cards/support/tanker.tres index 7a207b4..817bd89 100644 --- a/data/cards/support/tanker.tres +++ b/data/cards/support/tanker.tres @@ -1,13 +1,14 @@ -[gd_resource type="Resource" script_class="SimpleSupportCard" load_steps=3 format=3 uid="uid://dsmrqyxt8mdp5"] +[gd_resource type="Resource" script_class="ImplementedSupportCard" load_steps=4 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/implemented_support_card.gd" id="2_d0adk"] +[ext_resource type="Texture2D" uid="uid://hiswkj2stt4l" path="res://assets/support/tanker.png" id="2_hqv06"] [resource] script = ExtResource("2_d0adk") scope = "turn" -magnitude = 0 type = "red" effects = Array[ExtResource("1_1fvcb")]([null]) 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." +icon = ExtResource("2_hqv06") diff --git a/demo_game.tscn b/demo_game.tscn index 7f9d67d..22935eb 100644 --- a/demo_game.tscn +++ b/demo_game.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=22 format=3 uid="uid://bgc0u117jqyr1"] +[gd_scene load_steps=23 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"] @@ -18,6 +18,7 @@ [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"] +[ext_resource type="Texture2D" uid="uid://6trhu2r7h6g3" path="res://assets/card_base/illust bg 1.png" id="13_bdgfp"] [ext_resource type="Texture2D" uid="uid://b0pclmv0j0r12" path="res://assets/card_base/kertas.png" id="18_gwpy8"] [ext_resource type="Texture2D" uid="uid://ch04c20lkis6j" path="res://assets/card_base/gunting.png" id="19_clnw6"] [ext_resource type="Texture2D" uid="uid://bywa8qlwvcksd" path="res://assets/card_base/batu.png" id="20_672ya"] @@ -33,6 +34,13 @@ script = ExtResource("1_jn16u") 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="TextureRect" type="TextureRect" parent="."] +layout_mode = 0 +offset_right = 1804.0 +offset_bottom = 1224.0 +scale = Vector2(1.1, 1.1) +texture = ExtResource("13_bdgfp") + [node name="Own" type="Control" parent="." node_paths=PackedStringArray("deck", "energy_label", "rps_button_container")] layout_mode = 1 anchor_top = 0.5 diff --git a/ui/card_template/support_card_green.tscn b/ui/card_template/support_card_green.tscn index a367d4b..39569c0 100644 --- a/ui/card_template/support_card_green.tscn +++ b/ui/card_template/support_card_green.tscn @@ -6,9 +6,9 @@ [ext_resource type="Texture2D" uid="uid://crgrple0uik7x" path="res://assets/card_base/Stroke.png" id="3_qajq3"] [ext_resource type="Texture2D" uid="uid://blejyda8mendg" path="res://assets/card_base/InnerFill.png" id="4_pgomu"] [ext_resource type="Texture2D" uid="uid://by7ws88pn4tvb" path="res://assets/card_base/Separator.png" id="5_501uu"] +[ext_resource type="Texture2D" uid="uid://bwo6dfe1kpxhe" path="res://assets/support/insurance.png" id="6_bpwac"] [ext_resource type="Texture2D" uid="uid://0gxplli5krq2" path="res://assets/card_base/Pill.png" id="6_ce7hm"] -[ext_resource type="Theme" path="res://cards.tres" id="7_va1d7"] -[ext_resource type="Texture2D" uid="uid://rh3aswb0p7ri" path="res://assets/energy.png" id="8_4yq42"] +[ext_resource type="Theme" uid="uid://is34t82g4jg" path="res://cards.tres" id="7_va1d7"] [ext_resource type="FontFile" uid="uid://08q3kkwmd4u6" path="res://assets/Inter-Regular.otf" id="10_c2ugn"] [node name="CardBase" type="Control" node_paths=PackedStringArray("card_name_label", "card_desc_label", "icon_rect")] @@ -77,6 +77,17 @@ grow_vertical = 2 texture = ExtResource("4_pgomu") expand_mode = 1 +[node name="Icon" type="TextureRect" parent="MarginContainer"] +layout_mode = 0 +offset_left = 2.0 +offset_top = 63.0 +offset_right = 209.0 +offset_bottom = 203.0 +pivot_offset = Vector2(304.286, 120.143) +texture = ExtResource("6_bpwac") +expand_mode = 1 +stretch_mode = 6 + [node name="InnerStroke" type="NinePatchRect" parent="MarginContainer"] layout_mode = 1 anchors_preset = 15 @@ -147,16 +158,6 @@ text = "Green card" horizontal_alignment = 1 vertical_alignment = 1 -[node name="Icon" type="TextureRect" parent="MarginContainer"] -layout_mode = 0 -offset_left = 26.0 -offset_top = 74.0 -offset_right = 169.0 -offset_bottom = 179.0 -texture = ExtResource("8_4yq42") -expand_mode = 1 -stretch_mode = 6 - [node name="DescriptionLabel" type="Label" parent="MarginContainer"] layout_mode = 0 offset_left = 11.0 From 728d848e5bda90f1b7d1ff38fb12362de35cb804 Mon Sep 17 00:00:00 2001 From: istamarahsan Date: Sun, 26 Jan 2025 11:32:17 +0700 Subject: [PATCH 27/29] feat: damage incoming -> HP +- --- demo_game.tscn | 22 ++++++++++------------ player_side.gd | 2 +- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/demo_game.tscn b/demo_game.tscn index 65b3c81..3269b11 100644 --- a/demo_game.tscn +++ b/demo_game.tscn @@ -146,13 +146,12 @@ layout_mode = 1 anchors_preset = 5 anchor_left = 0.5 anchor_right = 0.5 -offset_left = -83.5 -offset_top = 300.0 -offset_right = 83.5 -offset_bottom = 323.0 +offset_left = 84.0 +offset_top = 24.0 +offset_right = 251.0 +offset_bottom = 47.0 grow_horizontal = 2 -text = "Incoming Damage: 0" -horizontal_alignment = 1 +text = "HP: +0" [node name="HBoxContainer" type="HBoxContainer" parent="Own"] visible = false @@ -268,14 +267,13 @@ anchor_left = 0.5 anchor_top = 1.0 anchor_right = 0.5 anchor_bottom = 1.0 -offset_left = -83.5 -offset_top = -325.0 -offset_right = 83.5 -offset_bottom = -302.0 +offset_left = 84.0 +offset_top = -52.0 +offset_right = 251.0 +offset_bottom = -29.0 grow_horizontal = 2 grow_vertical = 0 -text = "Incoming Damage: 0" -horizontal_alignment = 1 +text = "HP: +0" [node name="StartGameButton" type="Button" parent="."] layout_mode = 1 diff --git a/player_side.gd b/player_side.gd index 1075011..169c355 100644 --- a/player_side.gd +++ b/player_side.gd @@ -80,7 +80,7 @@ func _on_update(transition): if monster: monster_card_ui.visible = true monster_card_ui.show_monster(monster) - incoming_damage_label.text = "Incoming Damage: " + str(monster.health_delta) + incoming_damage_label.text = "HP " + ("+0" if monster.health_delta == 0 else str(monster.health_delta)) else: monster_card_ui.visible = false From 72a14189149fdcba3b7a0f8f3ac20465d9e5d8c7 Mon Sep 17 00:00:00 2001 From: istamarahsan Date: Sun, 26 Jan 2025 11:36:53 +0700 Subject: [PATCH 28/29] fix: all out attack scope fix: HP placeholder --- data/cards/support/all_out_attack.tres | 2 +- demo_game.tscn | 6 +++--- player_side.gd | 2 ++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/data/cards/support/all_out_attack.tres b/data/cards/support/all_out_attack.tres index 0269e6f..660a217 100644 --- a/data/cards/support/all_out_attack.tres +++ b/data/cards/support/all_out_attack.tres @@ -6,7 +6,7 @@ [resource] script = ExtResource("2_61mgn") -scope = "instant" +scope = "turn" type = "green" effects = Array[ExtResource("1_fd50n")]([null]) name = "All-Out Attack" diff --git a/demo_game.tscn b/demo_game.tscn index ee48333..b4261af 100644 --- a/demo_game.tscn +++ b/demo_game.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=23 format=3 uid="uid://bgc0u117jqyr1"] +[gd_scene load_steps=24 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"] @@ -159,7 +159,7 @@ offset_top = 24.0 offset_right = 251.0 offset_bottom = 47.0 grow_horizontal = 2 -text = "HP: +0" +text = "HP +0" [node name="HBoxContainer" type="HBoxContainer" parent="Own"] visible = false @@ -281,7 +281,7 @@ offset_right = 251.0 offset_bottom = -29.0 grow_horizontal = 2 grow_vertical = 0 -text = "HP: +0" +text = "HP +0" [node name="StartGameButton" type="Button" parent="."] layout_mode = 1 diff --git a/player_side.gd b/player_side.gd index 169c355..291f1a7 100644 --- a/player_side.gd +++ b/player_side.gd @@ -42,12 +42,14 @@ func _ready(): support1_green.visible = false support2_green.visible = false support2_red.visible = false + incoming_damage_label.visible = false for child in deck.get_children(): child.queue_free() func _on_update(transition): hovering_cards_duration.clear() selected_card = null + incoming_damage_label.visible = true for child in deck.get_children(): child.queue_free() From 83df3047f7d46f9443395ad428202c9f220f36ee Mon Sep 17 00:00:00 2001 From: Kenshia <73539778+Kenshia@users.noreply.github.com> Date: Sun, 26 Jan 2025 11:49:25 +0700 Subject: [PATCH 29/29] feat: card zoom --- player_side.gd | 23 +++++++++++++++++++++-- ui/card_template/card_base.gd | 14 ++++++-------- ui/card_template/monster_card.gd | 14 ++++++-------- 3 files changed, 33 insertions(+), 18 deletions(-) diff --git a/player_side.gd b/player_side.gd index 1075011..ad2df07 100644 --- a/player_side.gd +++ b/player_side.gd @@ -22,6 +22,7 @@ var match_manager: MatchManager var show_buttons: bool var signal_connected: bool var selected_card: Control +var focused_card: Control var hovering_cards_this_frame: Array[Control] = [] var hovering_cards_duration: Dictionary = {} @@ -128,6 +129,8 @@ func _on_update(transition): _pop_this_card(monster_card) play_card.emit(card)) monster_card.hovering.connect(func (delta): _do_hover(monster_card, delta)) + monster_card.right_clicked.connect(func(): _do_zoom(monster_card)) + monster_card.un_right_clicked.connect(_do_unzoom) deck.add_child(monster_card) elif card is SupportCard and card.type == "red": @@ -144,13 +147,29 @@ func _on_update(transition): _pop_this_card(btn) play_card.emit(card)) btn.hovering.connect(func (delta): _do_hover(btn, delta)) + btn.right_clicked.connect(func(): _do_zoom(btn)) + btn.un_right_clicked.connect(_do_unzoom) if rps_button_container: rps_button_container.visible = match_manager.phase == Match.Phase.RPS for button: TextureButton in rps_button_container.get_children(): button.modulate = rps_grayed_color - - + +func _do_zoom(card: Control): + if focused_card: + _do_unzoom() + + var new_card: Control = card.duplicate() + get_parent().add_child(new_card) + new_card.set_anchors_and_offsets_preset(Control.PRESET_CENTER) + new_card.scale = Vector2(2,2) + focused_card = new_card + +func _do_unzoom(): + if focused_card: + focused_card.queue_free() + focused_card = null + func _pop_this_card(control: Control): if selected_card: selected_card.position = Vector2(selected_card.position.x, original_hover_position) diff --git a/ui/card_template/card_base.gd b/ui/card_template/card_base.gd index 96bc2d1..2e623c6 100644 --- a/ui/card_template/card_base.gd +++ b/ui/card_template/card_base.gd @@ -3,6 +3,7 @@ class_name CardBase signal left_clicked signal right_clicked +signal un_right_clicked signal hovering(delta: float) @export var card_name_label: Label @@ -25,20 +26,17 @@ func _update(card: SupportCard): func _process(delta): var mouse_position = get_global_mouse_position() var rect = get_global_rect() - if rect.has_point(mouse_position): + if rect.has_point(mouse_position) and get_window().has_focus(): hovering.emit(delta) func _input(event): if event is InputEventMouseButton: - if !event.is_pressed(): - return - var mouse_position = get_global_mouse_position() var rect = get_global_rect() - if not rect.has_point(mouse_position): - return - if event.button_index == MOUSE_BUTTON_LEFT: + if rect.has_point(mouse_position) and event.button_index == MOUSE_BUTTON_LEFT and event.is_pressed() and get_window().has_focus(): left_clicked.emit() - elif event.button_index == MOUSE_BUTTON_RIGHT: + elif rect.has_point(mouse_position) and event.button_index == MOUSE_BUTTON_RIGHT and event.is_pressed() and get_window().has_focus(): right_clicked.emit() + elif event.button_index == MOUSE_BUTTON_RIGHT and !event.is_pressed(): + un_right_clicked.emit() diff --git a/ui/card_template/monster_card.gd b/ui/card_template/monster_card.gd index 8c1ca87..1c154f6 100644 --- a/ui/card_template/monster_card.gd +++ b/ui/card_template/monster_card.gd @@ -3,6 +3,7 @@ class_name MonsterCardUI signal left_clicked signal right_clicked +signal un_right_clicked signal hovering(delta: float) @export var name_label : Label @@ -37,20 +38,17 @@ func show_monster(monster: MatchMonster): func _process(delta): var mouse_position = get_global_mouse_position() var rect = get_global_rect() - if rect.has_point(mouse_position): + if rect.has_point(mouse_position) and get_window().has_focus(): hovering.emit(delta) func _input(event): if event is InputEventMouseButton: - if !event.is_pressed(): - return - var mouse_position = get_global_mouse_position() var rect = get_global_rect() - if not rect.has_point(mouse_position): - return - if event.button_index == MOUSE_BUTTON_LEFT: + if rect.has_point(mouse_position) and event.button_index == MOUSE_BUTTON_LEFT and event.is_pressed() and get_window().has_focus(): left_clicked.emit() - elif event.button_index == MOUSE_BUTTON_RIGHT: + elif rect.has_point(mouse_position) and event.button_index == MOUSE_BUTTON_RIGHT and event.is_pressed() and get_window().has_focus(): right_clicked.emit() + elif event.button_index == MOUSE_BUTTON_RIGHT and !event.is_pressed(): + un_right_clicked.emit()