Hi Everyone,
I'm working on a roguelike DeckBuilder Tutorial series for Godot 4.
Since these games are quite data-heavy, I created a custom resource type to store all card-related data.
To keep things decoupled and flexible, I want to export a card's effect as a variable as well (see image)
An effect looks something like this:
func apply_effect(targets: Array[Node2D]) -> void:
var damage_action := DamageAction.new()
damage_action.amount = 6
damage_action.execute(targets)
I came up with two solutions:
- export card_effect as its own resource. The problem with that is that I would need to create a .tres file and a .gd file for effects and I feel like having two files to implement one function is an overkill and produces a lot of unnecessary files.
- export card_effect as a GDScript resource. The problem with this solution is that I cannot write a pseudo-interface with inheritance, which means you always need to remember to use the exact same function signature as in the example above.
Are there any cleaner solutions to this? Can you give some alternatives? Is it possible to export an anonymous function or something like this?
I keep hitting walls with a clean architecture for this, so any tips are highly appreciated! 😊