Godot Version
4.4
Question
So I have a card game that I’m working on, and even though many cards are simply “deal X damage”, “gain X mana”, many cards have special effects that can’t be streamlined. Things like “randomize the cost of your cards”, “place the next card you play on top of your deck”, etc…
Right now these cards are stored each as their own .gd file, inheriting from the base Card class. However, I don’t think this will scale very well, if in the future we want to have 100+ unique cards in the game.
I am trying to come up with a better, more scalable way to store all this. I have found some examples, but in other languages (like Android: Netrunner, stored in Clojure netrunner/src/clj/game/cards/agendas.clj at master · mtgred/netrunner · GitHub).
Which if I have to guess depends on a having a parser loading the entry according to the card’s name and going line by line parsing it and composing code to be called. Also it appears to be making some sort of binding or prerequisite functions at the start but they are probably defined elsewhere.
I haven’t done much work similar to this “meta” programming type of thing, so I have no idea how to start to approach it in Godot. Could there be an easier way than making my own custom parser?
I’m trying to write a prototype of this approach using a big file with a dictionary in it, somehow linking the cards-effects dictionary with the corresponding card’s resource (that contains the images, tooltip text, etc…). I can have an entry saying “card type: damage” and then a field “Damage: X” or similar, but that wouldn’t solve the case for the unique cards.