Should I use OOP for an automated card game?

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.

2 Likes

What does ‘OOP’ stand for?

OOP stands for Object-Oriented Programming.

2 Likes

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.

3 Likes

Use whatever is the easiest. Preferably the Module Script

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.

2 Likes

OOP is most effective in modules because it promotes code reuse and effectively gives you a template/blueprint for many features which need to be programmed later in the project.

Pros: Organization, code reuse, encapsulation, inheritance, and usually less major programming bugs/flaws.

Cons: Extensive planning and perhaps you need to learn about this topic more extensively.

This OOP in lua tutorial should help you conceptualize its usefulness: Programming in Lua : 16

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.

3 Likes

Although at first it seems like a good idea

My simple question is
when have i ever need oop in a roblox project

Honestly using OOP to create cards is both a good idea and a bad idea

1 Like

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?