Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing error in merge where old code in CardBase was readded #37

Merged
merged 4 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions #Scenes/TestingScene.tscn
Original file line number Diff line number Diff line change
@@ -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"]
Expand All @@ -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"]
Expand Down Expand Up @@ -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
Expand Down
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:
Turtyo marked this conversation as resolved.
Show resolved Hide resolved
_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")])
Loading