Skip to content
Open
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
5 changes: 5 additions & 0 deletions combat_manager.gd
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,8 @@ func _ready():
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass


# TODO: Implement this to interact with party manager
func steal_spell():
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have this here bc we want everything to first go through combat manager right? I wanna see if maybe we can abstract this into trigger_divine_gift and figure out the specific implementation it calls later?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we want things to go through the combat manager. I think that works too, having a function trigger_divine_gift that gets the correct function to call (for this case, it would just call steal_spell())?

pass
2 changes: 1 addition & 1 deletion player.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[ext_resource type="Script" uid="uid://bn30k0xs8ptdn" path="res://AnimatedSprite2D.gd" id="3_vc6mf"]
[ext_resource type="Script" uid="uid://kdor8udfe8ks" path="res://CollisionShape2D.gd" id="4_85fth"]
[ext_resource type="PackedScene" uid="uid://cdm43kunrogx" path="res://src/components/attack_component.tscn" id="5_xlubi"]
[ext_resource type="Script" uid="uid://dd1246q3kr7u8" path="res://resources/attack_rsc.gd" id="6_bcgn8"]
[ext_resource type="Script" uid="uid://dd1246q3kr7u8" path="res://resources/attacks/attack_rsc.gd" id="6_bcgn8"]
[ext_resource type="Resource" uid="uid://cs60ixhmh86wm" path="res://resources/attacks/normal_attack.tres" id="6_i87wm"]
[ext_resource type="Resource" uid="uid://hodugild11n5" path="res://resources/attacks/slash_attack.tres" id="7_u0ent"]

Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions resources/attacks/normal_attack.tres
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[gd_resource type="Resource" script_class="Attack" load_steps=2 format=3 uid="uid://cs60ixhmh86wm"]

[ext_resource type="Script" path="res://resources/attack_rsc.gd" id="1_u4bsk"]
[ext_resource type="Script" uid="uid://dd1246q3kr7u8" path="res://resources/attacks/attack_rsc.gd" id="1_56r1r"]

[resource]
script = ExtResource("1_u4bsk")
script = ExtResource("1_56r1r")
name = "Normal Attack"
description = "Basic attack for the character"
damage = 10.0
Expand Down
2 changes: 1 addition & 1 deletion resources/attacks/slash_attack.tres
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[gd_resource type="Resource" script_class="Attack" load_steps=2 format=3 uid="uid://hodugild11n5"]

[ext_resource type="Script" path="res://resources/attack_rsc.gd" id="1_gfnbq"]
[ext_resource type="Script" uid="uid://dd1246q3kr7u8" path="res://resources/attacks/attack_rsc.gd" id="1_gfnbq"]

[resource]
script = ExtResource("1_gfnbq")
Expand Down
16 changes: 16 additions & 0 deletions resources/divine_gifts/divine_gift.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
extends Resource
class_name DivineGift

enum DivineGiftType {
STEAL_SPELLS
}

# General Divine Gift Attributes
@export var name: String # Used to overwrite button name in combat
@export var description: String
@export var divine_gift: DivineGiftType

# Default function to override divine gift combat button, to be overwritten
# by resources to call the right combat_manager function
func _cast() -> void:
print("Divine Gift: ", name)
1 change: 1 addition & 0 deletions resources/divine_gifts/divine_gift.gd.uid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
uid://ufvmls6ohupj
4 changes: 4 additions & 0 deletions resources/divine_gifts/steal_spells.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
extends DivineGift

func _cast() -> void:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah i see what you're doing here. Do you think this current implementaiton is better or should we go with a "CombatManager is the only interface anything calls in combat"? i.e. the button will call CombatManager::cast_divine_gift() which then calls _cast() which then calls steal_gift() in this case (and steal_gift() implementation is in steal_spells.gd)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about that too, but then how do we map the button dynamically based on the divine gift the user has? I think keeping it strictly in CombatManager would involve some kind of hard coded map from DivineGiftType to func.

In my head I think this is kinda cleaner, since we'd abstract that "map" into these resource scripts. Each DivineGift resource script stores which CombatManager function will need to be called, instead of the CombatManager having to figure it out.

Also allows us to extend these _cast() functions in case we want to have divine gifts do things outside of combat (maybe some overworld benefits).

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't "what divine gift X character has" defined by their divine gift component?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah each characters divine gift component holds the divine gift they have, represented as a resource- and the divine gift resource stores whatever config we need (name, description, what CombatManager func to call, etc)

CombatManager.steal_spell()
1 change: 1 addition & 0 deletions resources/divine_gifts/steal_spells.gd.uid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
uid://c4of6cad0gjxd
10 changes: 10 additions & 0 deletions resources/divine_gifts/steal_spells.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[gd_resource type="Resource" script_class="DivineGift" load_steps=2 format=3 uid="uid://cpll3f8nqjv27"]

[ext_resource type="Script" uid="uid://ufvmls6ohupj" path="res://resources/divine_gifts/divine_gift.gd" id="1_1ec7g"]

[resource]
script = ExtResource("1_1ec7g")
name = "Steal"
description = "Allows the player to steal an enemy spells that persists outside of combat"
divine_gift = 0
metadata/_custom_type_script = "uid://ufvmls6ohupj"
6 changes: 3 additions & 3 deletions resources/spells/spell_database.tres
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[gd_resource type="Resource" load_steps=5 format=3 uid="uid://dwtsb7cb6wt6d"]
[gd_resource type="Resource" script_class="SpellDatabase" load_steps=5 format=3 uid="uid://dwtsb7cb6wt6d"]

[ext_resource type="Script" path="res://resources/spells/spell_database.gd" id="1_sfgwt"]
[ext_resource type="Script" path="res://resources/spells/spell.gd" id="2_lrf77"]
[ext_resource type="Script" uid="uid://clt5x8c7nj0mu" path="res://resources/spells/spell_database.gd" id="1_sfgwt"]
[ext_resource type="Script" uid="uid://b4308qcr0gk0a" path="res://resources/spells/spell.gd" id="2_lrf77"]
[ext_resource type="Resource" uid="uid://bhidthvpqenlc" path="res://resources/spells/grass_whip.tres" id="3_ykmwl"]
[ext_resource type="Resource" uid="uid://cc65m1tmobhat" path="res://resources/spells/starlight.tres" id="4_gd5w5"]

Expand Down
2 changes: 1 addition & 1 deletion src/components/attack_component.tscn
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://cdm43kunrogx"]

[ext_resource type="Script" path="res://src/components/attack_component.gd" id="1_10dg0"]
[ext_resource type="Script" uid="uid://cvmbgnm58dvx7" path="res://src/components/attack_component.gd" id="1_10dg0"]

[node name="AttackComponent" type="Node"]
script = ExtResource("1_10dg0")
4 changes: 4 additions & 0 deletions src/components/divine_gift_component.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
extends Node

# Store divine gift resource that this character has
@export var divine_gift : DivineGift
1 change: 1 addition & 0 deletions src/components/divine_gift_component.gd.uid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
uid://t037q272etvh
6 changes: 6 additions & 0 deletions src/components/divine_gift_component.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://coepmnkl23pdw"]

[ext_resource type="Script" uid="uid://t037q272etvh" path="res://src/components/divine_gift_component.gd" id="1_271up"]

[node name="DivineGiftComponent" type="Node"]
script = ExtResource("1_271up")
2 changes: 1 addition & 1 deletion src/components/spells_component.gd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
extends Node2D
extends Node

# Current unit's spells
@export var MAX_SPELLS = 4
Expand Down
4 changes: 2 additions & 2 deletions src/components/spells_component.tscn
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://dprvni6fde6dc"]

[ext_resource type="Script" path="res://src/components/spells_component.gd" id="1_xm8yn"]
[ext_resource type="Script" uid="uid://dpat2vlglhmvs" path="res://src/components/spells_component.gd" id="1_xm8yn"]

[node name="SpellsComponent" type="Node2D" groups=["has_spells"]]
[node name="SpellsComponent" type="Node" groups=["has_spells"]]
script = ExtResource("1_xm8yn")