Skip to content

Commit

Permalink
Merge branch 'main' into map-implementation-generator
Browse files Browse the repository at this point in the history
  • Loading branch information
xone-mi committed Jan 13, 2024
2 parents 96270d8 + 836dd3a commit 7754000
Show file tree
Hide file tree
Showing 18 changed files with 295 additions and 132 deletions.
56 changes: 56 additions & 0 deletions #Scenes/CardScrollUI.tscn
Original file line number Diff line number Diff line change
@@ -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"]
56 changes: 54 additions & 2 deletions #Scenes/TestingScene.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=17 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"]
Expand All @@ -11,13 +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")]

Expand All @@ -44,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("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("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
Expand Down Expand Up @@ -133,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"]
65 changes: 0 additions & 65 deletions Cards/CardBase.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
8 changes: 0 additions & 8 deletions Cards/Resource/Card_Damage.tres
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
9 changes: 2 additions & 7 deletions Cards/Resource/Card_DamageAll.tres
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 0 additions & 8 deletions Cards/Resource/Card_DamageHealth.tres
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
8 changes: 0 additions & 8 deletions Cards/Resource/Card_DrawCards.tres
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
9 changes: 1 addition & 8 deletions Cards/Resource/Card_EnemyAttack.tres
Original file line number Diff line number Diff line change
Expand Up @@ -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")]([])
19 changes: 12 additions & 7 deletions Cards/Resource/Card_Heal.tres
Original file line number Diff line number Diff line change
@@ -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")])
10 changes: 1 addition & 9 deletions Cards/Resource/Card_Poison.tres
Original file line number Diff line number Diff line change
Expand Up @@ -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")])
10 changes: 1 addition & 9 deletions Cards/Resource/Card_damage_and_poison.tres
Original file line number Diff line number Diff line change
Expand Up @@ -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")])
Binary file added Cards/deck_pile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions Cards/deck_pile.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://hqkt8t1v2f5h"
path="res://.godot/imported/deck_pile.png-5b9430f28b4997c3a4f718c6545a5013.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://Cards/deck_pile.png"
dest_files=["res://.godot/imported/deck_pile.png-5b9430f28b4997c3a4f718c6545a5013.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
Loading

0 comments on commit 7754000

Please sign in to comment.