Hello godoneers,
I’m new to Godot, and programming in general. As an exercise, I’m creating a slay-the-spire-like game. I have created most of the basic mechanics. Play cards, mana, deck and discard pile.
Now, my cards are formed by an interface and a custom-resource data container. How can I implement effects?
For simple effects I can just use bool and just manage the effect in the resolution, that is easy.
(es. if card is_posonus == true: apply X poison else: deal X damage)
But for more complex effects? Can I just attach a script at the card database level and call it instead of trying to build a flexible effect framework? (es. in the card I have an enum with the type of target, the type of effect, and so on. it sounds like a bit out of my reach now and a bit limited)
and also for different triggers? (I was trying to add cards that work like traps: they trigger based on a specific situation. the player takes damage, an enemy tries to build armor, etc.)
One way to approach it would be to have each card have an array of callable effect functions (That are defined at your database/autoloads level), and a dictionary of argument parameters to pass in.
For triggers, I would think that would be dynamic signals; so you’d like want an event bus that your cards sub to pub their own signals/actions and to register/listen for other triggers. Note that you CAN NOT rely on the built-in signals order. If that part is super important, then you’ll need to specify action order. (e.g. if your card does X damage to enemy A, X-1 damage to enemy B, and then X-3 damage. to the third enemy, you’ll want to not rely on signal [0…3]