From e40671ea91a47f51d3585eb9b61c22c0aebe57f1 Mon Sep 17 00:00:00 2001 From: Jona Lam <89871543+JonaLam@users.noreply.github.com> Date: Fri, 5 Jan 2024 18:09:57 +0100 Subject: [PATCH 1/2] Fixing error in merge where old code in CardBase was readded (#37) * Cut all of the unnecessary code in CardBase * Changes to the card resource to make sure they work * Removed unnecessarily _damage_entirt function * Removed cards that don't do anything --- #Scenes/TestingScene.tscn | 6 +- Cards/CardBase.gd | 65 ---------------------- Cards/Resource/Card_Damage.tres | 8 --- Cards/Resource/Card_DamageAll.tres | 9 +-- Cards/Resource/Card_DamageHealth.tres | 8 --- Cards/Resource/Card_DrawCards.tres | 8 --- Cards/Resource/Card_EnemyAttack.tres | 9 +-- Cards/Resource/Card_Heal.tres | 19 ++++--- Cards/Resource/Card_Poison.tres | 10 +--- Cards/Resource/Card_damage_and_poison.tres | 10 +--- 10 files changed, 19 insertions(+), 133 deletions(-) diff --git a/#Scenes/TestingScene.tscn b/#Scenes/TestingScene.tscn index d8c97bc4..e9ad8979 100644 --- a/#Scenes/TestingScene.tscn +++ b/#Scenes/TestingScene.tscn @@ -1,9 +1,8 @@ -[gd_scene load_steps=17 format=3 uid="uid://b60uabg68ra1l"] +[gd_scene load_steps=15 format=3 uid="uid://b60uabg68ra1l"] [ext_resource type="PackedScene" uid="uid://clmg3l3n28x38" path="res://Entity/Player/Player.tscn" id="3_4psp7"] [ext_resource type="PackedScene" uid="uid://dpjfy4pv0vxst" path="res://Cards/CardContainer.tscn" id="3_e7sws"] [ext_resource type="Resource" uid="uid://dxgoopi1roxu4" path="res://Cards/Resource/Card_Damage.tres" id="4_wvn3v"] -[ext_resource type="Resource" uid="uid://0x385c3nuq8f" path="res://Cards/Resource/Card_DamageAll.tres" id="5_j1lqt"] [ext_resource type="Resource" uid="uid://5yn4t13kwwoo" path="res://Cards/Resource/Card_DamageHealth.tres" id="6_4124l"] [ext_resource type="Resource" uid="uid://d4lugn62mmlep" path="res://Cards/Resource/Card_DrawCards.tres" id="7_smkw8"] [ext_resource type="PackedScene" uid="uid://bcpmrmofcilbn" path="res://Core/Battler.tscn" id="8_qtw1k"] @@ -12,7 +11,6 @@ [ext_resource type="Resource" uid="uid://d12g33rc6c3u5" path="res://Cards/Resource/Card_Heal.tres" id="9_ojxic"] [ext_resource type="Script" path="res://UI/DiscardPileUISetter.gd" id="10_pqly7"] [ext_resource type="Resource" uid="uid://3s4aet1ciesh" path="res://Cards/Resource/Card_damage_and_poison.tres" id="10_w0xgm"] -[ext_resource type="Resource" uid="uid://bsrdu33ukb1ym" path="res://Cards/Resource/Card_EnemyAttack.tres" id="11_3k5t2"] [ext_resource type="Texture2D" uid="uid://caemucaya30wh" path="res://Cards/draw_pile.png" id="11_pw70x"] [ext_resource type="Texture2D" uid="uid://d4muqvs3etnr8" path="res://Cards/discard_pile.png" id="12_kxw48"] [ext_resource type="Script" path="res://UI/EndTurnButton.gd" id="14_dpe64"] @@ -44,7 +42,7 @@ anchor_right = 0.5 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 0 -default_deck = Array[Resource("res://Cards/CardBase.gd")]([ExtResource("4_wvn3v"), ExtResource("5_j1lqt"), ExtResource("6_4124l"), ExtResource("7_smkw8"), ExtResource("9_ojxic"), ExtResource("8_x6t2k"), ExtResource("10_w0xgm"), ExtResource("11_3k5t2")]) +default_deck = Array[Resource("res://Cards/CardBase.gd")]([ExtResource("4_wvn3v"), ExtResource("6_4124l"), ExtResource("7_smkw8"), ExtResource("9_ojxic"), ExtResource("8_x6t2k"), ExtResource("10_w0xgm")]) starting_hand_size = 10 max_hand_width = 900.0 min_card_separation = 90.0 diff --git a/Cards/CardBase.gd b/Cards/CardBase.gd index e392f8d0..1a2baa7f 100644 --- a/Cards/CardBase.gd +++ b/Cards/CardBase.gd @@ -13,14 +13,6 @@ class_name CardBase ## wish to take damage in some contexts. ## For example, consider the card: "Deal 10 damage to all enemies, but take 3 damage" -@export var damage_to_apply_to_target: float = 0.0 -@export var damage_to_apply_to_caster: float = 0.0 -@export var status_to_apply_to_target: Array[StatusBase] -@export var status_to_apply_to_caster: Array[StatusBase] -@export var affect_all_targets: bool = false -@export var affect_all_casters: bool = false -@export var amount_of_cards_to_draw: int = 0 -@export var amount_of_cards_to_discard: int = 0 @export var application_type: Enums.ApplicationType = Enums.ApplicationType.ENEMY_ONLY @export var card_title: String = "NULL" @export var card_key_art: ImageTexture = null @@ -50,62 +42,5 @@ func can_play_card(caster: Entity, target: Entity) -> bool: func on_card_play(caster: Entity, target: Entity) -> void: _apply_all_effects(target) - _deal_damage(caster, target) - _apply_status(caster, target) - _draw_cards() - _discard_random_cards() CardManager.on_card_action_finished.emit(self) # TODO add other functionality that lots of cards may share (eg: restore AP) - - -# override in child cards if you want to deal damage in a unique way -func _deal_damage(caster: Entity, target: Entity) -> void: - # damage target - if damage_to_apply_to_target != 0.0: - _damage_entity(caster, target, damage_to_apply_to_target, affect_all_targets) - - #damage caster - if damage_to_apply_to_caster != 0.0: - _damage_entity(caster, caster, damage_to_apply_to_caster, affect_all_casters) - - -func _damage_entity(caster: Entity, target: Entity, damage_amount: float, damage_all: bool) -> void: - var target_damage_data: DealDamageData = DealDamageData.new() - target_damage_data.damage = damage_amount - target_damage_data.caster = caster - - # If damage_all is set, try to damage all the party members set in the party component - if damage_all: - var party: Array[Entity] = target.get_party_component().party - assert(party.size() > 0, "Entity has an empty party. Make sure you added party members.") - - for party_member: Entity in party: - party_member.get_health_component().deal_damage(target_damage_data) - else: - target.get_health_component().deal_damage(target_damage_data) - - -func _apply_status(caster: Entity, target: Entity) -> void: - # apply status to caster - for status: StatusBase in status_to_apply_to_caster: - if affect_all_casters: - for party_member: Entity in caster.get_party_component().party: - party_member.get_status_component().add_status(status, caster) - else: - caster.get_status_component().add_status(status, caster) - - # apply status to target - for status: StatusBase in status_to_apply_to_target: - if affect_all_targets: - for party_member: Entity in target.get_party_component().party: - party_member.get_status_component().add_status(status, caster) - else: - target.get_status_component().add_status(status, caster) - - -func _draw_cards() -> void: - CardManager.card_container.draw_cards(amount_of_cards_to_draw) - - -func _discard_random_cards() -> void: - CardManager.card_container.discard_random_card(amount_of_cards_to_discard) diff --git a/Cards/Resource/Card_Damage.tres b/Cards/Resource/Card_Damage.tres index 2930342e..b34bf796 100644 --- a/Cards/Resource/Card_Damage.tres +++ b/Cards/Resource/Card_Damage.tres @@ -14,14 +14,6 @@ value = 3 [resource] script = ExtResource("1_44g0o") -damage_to_apply_to_target = 0.0 -damage_to_apply_to_caster = 0.0 -status_to_apply_to_target = Array[Resource("res://Status/StatusBase.gd")]([]) -status_to_apply_to_caster = Array[Resource("res://Status/StatusBase.gd")]([]) -affect_all_targets = false -affect_all_casters = false -amount_of_cards_to_draw = 0 -amount_of_cards_to_discard = 0 application_type = 1 card_title = "Damage" card_description = "Deal 3 damage" diff --git a/Cards/Resource/Card_DamageAll.tres b/Cards/Resource/Card_DamageAll.tres index 24b79137..5aeab2fc 100644 --- a/Cards/Resource/Card_DamageAll.tres +++ b/Cards/Resource/Card_DamageAll.tres @@ -4,12 +4,7 @@ [resource] script = ExtResource("1_j02oq") -damage_to_apply_to_target = 2.0 -damage_to_apply_to_caster = 0.0 -status_to_apply_to_target = Array[Resource("res://Status/StatusBase.gd")]([]) -status_to_apply_to_caster = Array[Resource("res://Status/StatusBase.gd")]([]) -affect_all_targets = true -affect_all_casters = false -application_type = 1 +application_type = null card_title = "Damage All" card_description = "Deal 2 damage to all enemies" +card_effects_data = null diff --git a/Cards/Resource/Card_DamageHealth.tres b/Cards/Resource/Card_DamageHealth.tres index eb7e601f..22a3068c 100644 --- a/Cards/Resource/Card_DamageHealth.tres +++ b/Cards/Resource/Card_DamageHealth.tres @@ -14,14 +14,6 @@ value = 0 [resource] script = ExtResource("1_ighm7") -damage_to_apply_to_target = 0.0 -damage_to_apply_to_caster = 0.0 -status_to_apply_to_target = Array[Resource("res://Status/StatusBase.gd")]([]) -status_to_apply_to_caster = Array[Resource("res://Status/StatusBase.gd")]([]) -affect_all_targets = false -affect_all_casters = false -amount_of_cards_to_draw = 0 -amount_of_cards_to_discard = 0 application_type = 1 card_title = "Damage Health" card_description = "Deal damage equal to health lost." diff --git a/Cards/Resource/Card_DrawCards.tres b/Cards/Resource/Card_DrawCards.tres index ea874bc6..79df45bb 100644 --- a/Cards/Resource/Card_DrawCards.tres +++ b/Cards/Resource/Card_DrawCards.tres @@ -14,14 +14,6 @@ value = 2 [resource] script = ExtResource("1_bboy2") -damage_to_apply_to_target = 0.0 -damage_to_apply_to_caster = 0.0 -status_to_apply_to_target = Array[Resource("res://Status/StatusBase.gd")]([]) -status_to_apply_to_caster = Array[Resource("res://Status/StatusBase.gd")]([]) -affect_all_targets = false -affect_all_casters = false -amount_of_cards_to_draw = 0 -amount_of_cards_to_discard = 0 application_type = 0 card_title = "Draw 2" card_description = "Draw 2 cards" diff --git a/Cards/Resource/Card_EnemyAttack.tres b/Cards/Resource/Card_EnemyAttack.tres index 72a2dff4..872c7f93 100644 --- a/Cards/Resource/Card_EnemyAttack.tres +++ b/Cards/Resource/Card_EnemyAttack.tres @@ -4,14 +4,7 @@ [resource] script = ExtResource("1_5s3qc") -damage_to_apply_to_target = 1.0 -damage_to_apply_to_caster = 0.0 -status_to_apply_to_target = Array[Resource("res://Status/StatusBase.gd")]([]) -status_to_apply_to_caster = Array[Resource("res://Status/StatusBase.gd")]([]) -affect_all_targets = false -affect_all_casters = false -amount_of_cards_to_draw = 0 -amount_of_cards_to_discard = 0 application_type = 1 card_title = "NULL" card_description = "NULL" +card_effects_data = Array[Resource("res://Cards/Effects/EffectData.gd")]([]) diff --git a/Cards/Resource/Card_Heal.tres b/Cards/Resource/Card_Heal.tres index d622bdc6..5e73c32a 100644 --- a/Cards/Resource/Card_Heal.tres +++ b/Cards/Resource/Card_Heal.tres @@ -1,15 +1,20 @@ -[gd_resource type="Resource" script_class="CardBase" load_steps=2 format=3 uid="uid://d12g33rc6c3u5"] +[gd_resource type="Resource" script_class="CardBase" load_steps=6 format=3 uid="uid://d12g33rc6c3u5"] +[ext_resource type="Script" path="res://Cards/Effects/EffectDamage.gd" id="1_wmkvt"] [ext_resource type="Script" path="res://Cards/CardBase.gd" id="1_y1itd"] +[ext_resource type="Script" path="res://Cards/Effects/EffectData.gd" id="2_y7dlo"] + +[sub_resource type="Resource" id="Resource_hnan1"] +script = ExtResource("1_wmkvt") + +[sub_resource type="Resource" id="Resource_amxgq"] +script = ExtResource("2_y7dlo") +effect = SubResource("Resource_hnan1") +value = -1 [resource] script = ExtResource("1_y1itd") -damage_to_apply_to_target = 0.0 -damage_to_apply_to_caster = -1.0 -status_to_apply_to_target = Array[Resource("res://Status/StatusBase.gd")]([]) -status_to_apply_to_caster = Array[Resource("res://Status/StatusBase.gd")]([]) -affect_all_targets = false -affect_all_casters = false application_type = 0 card_title = "Heal" card_description = "Heal 1 damage" +card_effects_data = Array[ExtResource("2_y7dlo")]([SubResource("Resource_amxgq")]) diff --git a/Cards/Resource/Card_Poison.tres b/Cards/Resource/Card_Poison.tres index c09dc36f..a753b1d6 100644 --- a/Cards/Resource/Card_Poison.tres +++ b/Cards/Resource/Card_Poison.tres @@ -14,15 +14,7 @@ value = 3 [resource] script = ExtResource("1_u6k7h") -damage_to_apply_to_target = 0.0 -damage_to_apply_to_caster = 0.0 -status_to_apply_to_target = Array[Resource("res://Status/StatusBase.gd")]([]) -status_to_apply_to_caster = Array[Resource("res://Status/StatusBase.gd")]([]) -affect_all_targets = false -affect_all_casters = false -amount_of_cards_to_draw = 0 -amount_of_cards_to_discard = 0 -application_type = 1 +application_type = null card_title = "Poison" card_description = "Apply 3 poison" card_effects_data = Array[ExtResource("2_omhae")]([SubResource("Resource_bamld")]) diff --git a/Cards/Resource/Card_damage_and_poison.tres b/Cards/Resource/Card_damage_and_poison.tres index f147920d..fb90706f 100644 --- a/Cards/Resource/Card_damage_and_poison.tres +++ b/Cards/Resource/Card_damage_and_poison.tres @@ -23,15 +23,7 @@ value = 2 [resource] script = ExtResource("1_h8l2w") -damage_to_apply_to_target = 0.0 -damage_to_apply_to_caster = 0.0 -status_to_apply_to_target = Array[Resource("res://Status/StatusBase.gd")]([]) -status_to_apply_to_caster = Array[Resource("res://Status/StatusBase.gd")]([]) -affect_all_targets = false -affect_all_casters = false -amount_of_cards_to_draw = 0 -amount_of_cards_to_discard = 0 -application_type = 1 +application_type = null card_title = "Damage and poison" card_description = "Deals 1 damage and applies 2 poison" card_effects_data = Array[ExtResource("2_22qxd")]([SubResource("Resource_73uy7"), SubResource("Resource_tmm5r")]) From 836dd3a7887045a7e6bd2696415145f54d47a589 Mon Sep 17 00:00:00 2001 From: Paper-2 <65647380+Paper-2@users.noreply.github.com> Date: Tue, 9 Jan 2024 06:06:55 -0500 Subject: [PATCH 2/2] CardPileUicl (#40) * Added a WIP buttom that shows a new scene * The button now shows a new scene with a return button to go back to the game. The game cannot be played while the scene is present. * The button now shows a new scene with a return button to go back to the game. The game cannot be played while the scene is present. * added Typing * Added CardScrollUI to see the inside of a CardPile * Added CardScrollUI to see the inside of a CardPile * Changed event to input_event and added its type * Updated the the min size of the CardUI * Fixed the aftermath of merging * Added constant for the card. * Deleted a function that is irrelevant. * Moved the ShowCardPile into CardPileUISetter * Deck doesn't need to have a card count. * resized ScrollContainer to show 5 columns and 2 rows * Added a button to show cards inside the deck * Fixed the code that modifies the card and adds it to the container. * Whitespace be gone * Changed the settings of GridContainer so cards first show in the center * Print statement begone * added the "pile" after deck so it is consistent to the others pile * Added a test for cardscrollui * Fixed the test so it gets the proper gridcontainer * Changed _input function to use a key constant instead of a string. * Changed the settings of GridContainer so cards first show in the center part 2 * Addressed review feedback from Ty * Addressed review feedback from Turtyo * Changed the test so it compares Cardbases * added a comment to the input function. * potential fix to errors in test * amendment for the last commit * Fixed a function, fixed the test?, and cards not appearing in the UI. * Fixed the testing scene after the merge * whitespace be gone --------- Co-authored-by: Turtyo <49365680+Turtyo@users.noreply.github.com> --- #Scenes/CardScrollUI.tscn | 56 ++++++++++++++++++++++++++++++++ #Scenes/TestingScene.tscn | 58 +++++++++++++++++++++++++++++++-- Cards/deck_pile.png | Bin 0 -> 178 bytes Cards/deck_pile.png.import | 34 ++++++++++++++++++++ Tests/test_pile_ui.gd | 48 ++++++++++++++++++++++++++++ UI/CardPileUISetter.gd | 9 +++++- UI/CardScrollUI.gd | 64 +++++++++++++++++++++++++++++++++++++ UI/DeckPileUISetter.gd | 6 ++++ project.godot | 8 +++++ 9 files changed, 280 insertions(+), 3 deletions(-) create mode 100644 #Scenes/CardScrollUI.tscn create mode 100644 Cards/deck_pile.png create mode 100644 Cards/deck_pile.png.import create mode 100644 Tests/test_pile_ui.gd create mode 100644 UI/CardScrollUI.gd create mode 100644 UI/DeckPileUISetter.gd diff --git a/#Scenes/CardScrollUI.tscn b/#Scenes/CardScrollUI.tscn new file mode 100644 index 00000000..80886bd7 --- /dev/null +++ b/#Scenes/CardScrollUI.tscn @@ -0,0 +1,56 @@ +[gd_scene load_steps=2 format=3 uid="uid://bl3au25n1f8ld"] + +[ext_resource type="Script" path="res://UI/CardScrollUI.gd" id="1_sopxy"] + +[node name="CardScrollUI" 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_sopxy") + +[node name="ColorRect" type="ColorRect" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +color = Color(0, 0, 0, 0.309804) + +[node name="Button" type="Button" parent="."] +layout_mode = 2 +offset_left = 4.0 +offset_top = 550.0 +offset_right = 65.0 +offset_bottom = 581.0 +text = "Return" + +[node name="ScrollContainer" type="ScrollContainer" parent="."] +layout_mode = 1 +offset_left = 223.0 +offset_top = 142.0 +offset_right = 1049.0 +offset_bottom = 555.205 + +[node name="GridContainer" type="GridContainer" parent="ScrollContainer"] +custom_minimum_size = Vector2(186.475, 200) +layout_direction = 1 +layout_mode = 2 +size_flags_horizontal = 6 +size_flags_vertical = 6 +theme_override_constants/h_separation = 20 +theme_override_constants/v_separation = 10 +columns = 5 + +[node name="Label" type="Label" parent="."] +layout_mode = 0 +offset_left = 504.0 +offset_top = 573.0 +offset_right = 747.0 +offset_bottom = 631.0 +text = "Showing " + +[connection signal="pressed" from="Button" to="." method="_on_button_pressed"] diff --git a/#Scenes/TestingScene.tscn b/#Scenes/TestingScene.tscn index e9ad8979..914f050e 100644 --- a/#Scenes/TestingScene.tscn +++ b/#Scenes/TestingScene.tscn @@ -1,8 +1,9 @@ -[gd_scene load_steps=15 format=3 uid="uid://b60uabg68ra1l"] +[gd_scene load_steps=22 format=3 uid="uid://b60uabg68ra1l"] [ext_resource type="PackedScene" uid="uid://clmg3l3n28x38" path="res://Entity/Player/Player.tscn" id="3_4psp7"] [ext_resource type="PackedScene" uid="uid://dpjfy4pv0vxst" path="res://Cards/CardContainer.tscn" id="3_e7sws"] [ext_resource type="Resource" uid="uid://dxgoopi1roxu4" path="res://Cards/Resource/Card_Damage.tres" id="4_wvn3v"] +[ext_resource type="Resource" uid="uid://0x385c3nuq8f" path="res://Cards/Resource/Card_DamageAll.tres" id="5_j1lqt"] [ext_resource type="Resource" uid="uid://5yn4t13kwwoo" path="res://Cards/Resource/Card_DamageHealth.tres" id="6_4124l"] [ext_resource type="Resource" uid="uid://d4lugn62mmlep" path="res://Cards/Resource/Card_DrawCards.tres" id="7_smkw8"] [ext_resource type="PackedScene" uid="uid://bcpmrmofcilbn" path="res://Core/Battler.tscn" id="8_qtw1k"] @@ -10,12 +11,47 @@ [ext_resource type="Resource" uid="uid://ctx8jsvac84so" path="res://Cards/Resource/Card_Poison.tres" id="8_x6t2k"] [ext_resource type="Resource" uid="uid://d12g33rc6c3u5" path="res://Cards/Resource/Card_Heal.tres" id="9_ojxic"] [ext_resource type="Script" path="res://UI/DiscardPileUISetter.gd" id="10_pqly7"] +[ext_resource type="Script" path="res://Cards/Card_DamageHealth.gd" id="10_qowiy"] [ext_resource type="Resource" uid="uid://3s4aet1ciesh" path="res://Cards/Resource/Card_damage_and_poison.tres" id="10_w0xgm"] +[ext_resource type="Resource" uid="uid://bsrdu33ukb1ym" path="res://Cards/Resource/Card_EnemyAttack.tres" id="11_3k5t2"] [ext_resource type="Texture2D" uid="uid://caemucaya30wh" path="res://Cards/draw_pile.png" id="11_pw70x"] [ext_resource type="Texture2D" uid="uid://d4muqvs3etnr8" path="res://Cards/discard_pile.png" id="12_kxw48"] [ext_resource type="Script" path="res://UI/EndTurnButton.gd" id="14_dpe64"] +[ext_resource type="Texture2D" uid="uid://hqkt8t1v2f5h" path="res://Cards/deck_pile.png" id="18_b54hn"] +[ext_resource type="Script" path="res://UI/DeckPileUISetter.gd" id="19_ucc6f"] + +[sub_resource type="Resource" id="Resource_82ci8"] +script = ExtResource("10_qowiy") +damage_to_apply_to_target = 0.0 +damage_to_apply_to_caster = 0.0 +status_to_apply_to_target = Array[Resource("res://Status/StatusBase.gd")]([]) +status_to_apply_to_caster = Array[Resource("res://Status/StatusBase.gd")]([]) +affect_all_targets = false +affect_all_casters = false +amount_of_cards_to_draw = 0 +amount_of_cards_to_discard = 0 +application_type = 1 +card_title = "NULL" +card_description = "NULL" +card_effects_data = Array[Resource("res://Cards/Effects/EffectData.gd")]([]) + +[sub_resource type="Resource" id="Resource_bjuo7"] +script = ExtResource("10_qowiy") +damage_to_apply_to_target = 0.0 +damage_to_apply_to_caster = 0.0 +status_to_apply_to_target = Array[Resource("res://Status/StatusBase.gd")]([]) +status_to_apply_to_caster = Array[Resource("res://Status/StatusBase.gd")]([]) +affect_all_targets = false +affect_all_casters = false +amount_of_cards_to_draw = 0 +amount_of_cards_to_discard = 0 +application_type = 1 +card_title = "NULL" +card_description = "NULL" +card_effects_data = Array[Resource("res://Cards/Effects/EffectData.gd")]([]) [node name="TestingScene" type="Node2D"] +metadata/_edit_vertical_guides_ = [1216.0] [node name="Battler" parent="." instance=ExtResource("8_qtw1k")] @@ -42,7 +78,7 @@ anchor_right = 0.5 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 0 -default_deck = Array[Resource("res://Cards/CardBase.gd")]([ExtResource("4_wvn3v"), ExtResource("6_4124l"), ExtResource("7_smkw8"), ExtResource("9_ojxic"), ExtResource("8_x6t2k"), ExtResource("10_w0xgm")]) +default_deck = Array[Resource("res://Cards/CardBase.gd")]([ExtResource("4_wvn3v"), ExtResource("5_j1lqt"), ExtResource("6_4124l"), ExtResource("7_smkw8"), ExtResource("9_ojxic"), ExtResource("8_x6t2k"), ExtResource("10_w0xgm"), ExtResource("11_3k5t2"), ExtResource("4_wvn3v"), ExtResource("4_wvn3v"), ExtResource("4_wvn3v"), ExtResource("10_w0xgm"), SubResource("Resource_82ci8"), SubResource("Resource_bjuo7")]) starting_hand_size = 10 max_hand_width = 900.0 min_card_separation = 90.0 @@ -131,4 +167,22 @@ text = "0" horizontal_alignment = 1 vertical_alignment = 1 +[node name="DeckPile" type="TextureButton" parent="CanvasLayer/UIControl"] +layout_mode = 1 +anchors_preset = -1 +anchor_left = 1.00078 +anchor_right = 1.00078 +offset_left = -62.0 +offset_top = 35.0 +offset_right = -22.0 +offset_bottom = 75.0 +texture_normal = ExtResource("18_b54hn") +texture_pressed = ExtResource("18_b54hn") +texture_hover = ExtResource("18_b54hn") +texture_disabled = ExtResource("18_b54hn") +texture_focused = ExtResource("18_b54hn") +stretch_mode = 0 +script = ExtResource("19_ucc6f") +metadata/_edit_use_anchors_ = true + [connection signal="pressed" from="CanvasLayer/UIControl/EndTurnButton" to="CanvasLayer/UIControl/EndTurnButton" method="_on_pressed"] diff --git a/Cards/deck_pile.png b/Cards/deck_pile.png new file mode 100644 index 0000000000000000000000000000000000000000..df5f624b68e1fb7530c4c0fa3a5c65ede03ffe72 GIT binary patch literal 178 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!D3?x-;bCrM;V{wqX6XVU3I`u#fXMsm#F#`j) zFbFd;%$g$s6l4qV32_C|3|bGe*rv}1GMGw&{DK+&M^9AR3gnr4x;TbZ%wauf$j2bS z<8bkQm{0GG8FLP56waJ?m$S$1y`uQ*3`I`8lEqrVojxkl9?ve5V66_YPv5~REaSU= P1;}VmS3j3^P6 void: if CardManager.card_container != null: @@ -22,3 +22,10 @@ func _on_card_counts_updated() -> void: func _get_count() -> int: return CardManager.card_container.get_draw_pile_size() + +func _pressed() -> void: + var parent: Control = $".." + var uiPile: Control = cardUI.instantiate() + + uiPile.populate(get_name()) + parent.add_child(uiPile) \ No newline at end of file diff --git a/UI/CardScrollUI.gd b/UI/CardScrollUI.gd new file mode 100644 index 00000000..4381509c --- /dev/null +++ b/UI/CardScrollUI.gd @@ -0,0 +1,64 @@ +extends Control + +var card_scene: PackedScene = preload("res://Cards/Card.tscn") + +var discard_pile: Array[CardBase] = CardManager.card_container.discard_pile +var draw_pile: Array[CardBase] = CardManager.card_container.draw_pile +var deck_pile: Array[CardBase] = CardManager.card_container.default_deck +var cards_to_display: Array[CardBase] = [] +var card_worlds: Array[CardWorld] = [] +var cardworld: CardWorld = null +var cardui: Control = null + +const CARD_SCALE: Vector2 = Vector2(.7, .7) +const CARDUI_INDEX: int = 2 +const CARDUI_POS: Vector2 = Vector2(4,4) +const SIZE_OFFSET: Vector2 = Vector2(10,10) + + +#deletes the root node CardScrollUI with the on screen button +func _on_button_pressed() -> void: + queue_free() + + +#deletes the root node CardScrollUI with the escape key +func _input(_inputevent: InputEvent) -> void: + if Input.is_key_pressed(KEY_ESCAPE): + queue_free() + + + +func populate(parent_name: String) -> void: + + match parent_name: + "DiscardPile": + cards_to_display = discard_pile + $Label.text = "Showing the discard pile" + "DrawPile": + cards_to_display = draw_pile + $Label.text = "Showing the draw pile" + "DeckPile": + cards_to_display = deck_pile + $Label.text = "Showing the deck pile" + + cards_to_display.sort_custom(card_sort_by_title) + + for card: CardBase in cards_to_display: + + cardworld = card_scene.instantiate() + cardui = cardworld.get_child(CARDUI_INDEX) + + cardworld.custom_minimum_size = (cardui.size * CARD_SCALE) + SIZE_OFFSET + cardui.scale = CARD_SCALE + cardui.anchors_preset = CORNER_TOP_LEFT + cardui.position = CARDUI_POS + + $ScrollContainer/GridContainer.add_child(cardworld) + + cardworld.init_card(card) + +func card_sort_by_title(card_A: CardBase, card_B: CardBase) -> bool: + if card_A.card_title.to_lower() < card_B.card_title.to_lower(): + return true + return false + diff --git a/UI/DeckPileUISetter.gd b/UI/DeckPileUISetter.gd new file mode 100644 index 00000000..05a948d6 --- /dev/null +++ b/UI/DeckPileUISetter.gd @@ -0,0 +1,6 @@ +extends CardPileUISetter +class_name DeckPileUISetter + +# @override +func _on_card_counts_updated() -> void: + pass \ No newline at end of file diff --git a/project.godot b/project.godot index f7782fc3..7400f57b 100644 --- a/project.godot +++ b/project.godot @@ -32,3 +32,11 @@ window/stretch/aspect="expand" [editor_plugins] enabled=PackedStringArray("res://addons/gut/plugin.cfg") + +[input] + +escape={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194305,"key_label":0,"unicode":0,"echo":false,"script":null) +] +}