So I feel like trying to make an automated card game prototype (like Hexaria) but based off YuGiOh (card games on motorbikes :omegalul:).
I want it to be efficient and someone suggested to me to use OOP. I thought I was already using it, but it turns out I wasn’t. I was just using a ModuleScript normally. I’ve understood the basics of OOP; but I really don’t understand how it’ll benefit me.
OOP seems to over complicate things, just using a Module Script normally seems easier.
Should I use OOP or not for an automated card game?
ps i’m sorry if this is a really dumb question I just can’t decide which way would be better.
OOP would definitely be useful in a game like this.
Really OOP’s value comes in through inheriting code from super classes.
So for your card game you would have an overarching “Card” class that would include all functions/values that all cards would share (e.g. Hexaria’s drawing animation where their hand goes in the air). Then from there you can create subclasses that could be used in attack/defence moves. From there you can start individually creating moves with their own specific attributes.
I highly recommend looking at java and experimenting around because OOP in java is very well documented and easy to grasp. It’ll help you get an understanding as to why OOP is very useful.
While I’ve know about OOP for a long time, I’ve never used it in Lua prior to my current project. I can say it’s one of the best decisions I’ve ever made from a programming standpoint, and I’ve been updating previous games to this system.
From my point of view, it makes manageability, understand-ability and upgrade-ability far easier, and it has allowed me to vastly speed up my development process.
In the example above, an object (a bank account in this instance) is created and given data members, and operations with the colon operator which has an implicit (hidden) parameter known as self (the bank account). If you can see why OOP is useful in this scenario, then you should understand that you can create a base class for your card game and then give your cards general operations and member variables. After that you can specify and diversify your card classes but still allow them to inherit their base or parent class in a module somewhere.
There have been some good points in this thread about why OOP would be good practice for this case, so a claim of it being a bad idea is pretty weak without any points to back it up. Can you elaborate on why it would be a bad idea?