I'm working on a turn-based creature battler, but this is my first time using Lua and I'm a little confused on how to set up classes properly and use them later.
Currently, I'm setting up my monsters (referred to as familiars in game), as a class this way, but I feel like this isn't the correct way:
class('Familiar', { fstats = table.create(6, 0),
health = 100,
movesKnown = table.create(4, 0),
level = 1,
earnedXP = 0,
xpToLVL = 100 }).extends()
Then I created fstats
and movesKnown
as separate subclasses of Familiar
:
class('fstats', { HP = 10,
mATK = 10,
rATK = 10,
mDEF = 10,
rDEF = 10,
SPD = 10 }).extends(Familiar)
class('movesKnown', { move1, move2, move3, move4 }).extends(Familiar)
But this seems like it's not correct, but I'm struggling to parse how this works and then how I would go about implementing it for individual monsters?
Thanks ahead of time for your help!