Games [Idea] Universal Card Game Engine

wonder

Expert
Licensed User
Longtime User
Ever since I started to play Hearthstone I started to wonder if I could write a similar engine in B4A.
It would take a monumental effort, but I think we have all the tools to make it happen.

ss5-med-92881ebeaf06d59988b774a9726463c95f9d5985bd0c3391914b3bfc1050319b3430dc7d1b994615baa8777b15021d83509cf28c2168b7b0893a6301ad2c10b4.jpg


What do you guys think? :)
Is it doable? If so, I'm planning on making it open-source with some proprietary elements.
 

ilan

Expert
Licensed User
Longtime User
what do you mean with engine @wonder ?
i dont see the benefits of making an engine for such a game.

anyway the game is doable for sure with libgdx. you will need some shaders and particle effects but should be doable although it will need a lot of work and very good painting skills. what makes such game interesting is putting a lot special effects to it.

it would be more interesting to build an engine like SCUMM (https://en.wikipedia.org/wiki/SCUMM)
 

wonder

Expert
Licensed User
Longtime User
I already created a card game with B4A and libGDX (Dark Continent). It's pretty simple with Scene2D. The problem is to add 3D effects (e.g. the animated flipping of a card).
Card flipping and other 3D effects can easily be achieved with Decals. The 3D animation below, for example, is nothing more than 6 decals arranged into a "cube". :)


Regarding this hypothetical engine, I'm not so worried about the visual effect. I'm more concerned in taking the right approach, using a very well structured object-oriented paradigm.

My goal would be to create a "Universal Card Game Engine" where you could create any kind of card game, from Poker to Hearthstone, given you're able to provide the right textures and rules. The "game rules" would be defined by external scripts, so I would have to create a scripting language (with Python / JSON influences).
 

wonder

Expert
Licensed User
Longtime User
External scripting example:
B4X:
...
fromDeck = deck.top
...

#Defines generic rules for a single turn
def turn(player, opponent):
    newCard = player.takes(1, card, fromDeck)  
    if 'bomb' in newCard.properties:
        player.life = player.life - newCard.properties.damage
        newCard.destroy()
        return game.endofturn
    ...
    ...
    ...
 

Informatix

Expert
Licensed User
Longtime User
In modern card games, you have often a few cards that break the rules. For example: a red card has to be played always before a yellow card, except when you have a blue card in hand which allows to reverse the order, or a green card which allows to ignore the order. Another example: if you get the Mad King card, you can play any attack card as a Frenzy attack card (thus requiring a way for the user to choose between the two possibilities).
In my two card games, I had to write specific code for many cards so I'm not optimistic about a generic system. Anyway, if you succeed in solving most cases about rules with scripting, you will face a new Everest of complexity: the visual building of the cards. A poker card does not look like a Pokemon card. The easy solution is to load an image for each card. It's a very bad solution IMO because it takes a lot of memory. Imagine a game with 300 cards in two resolutions (eg. 1280x1024, 1920x1080). And it's a waste of resources when you have similar visuals with just a different element (like different attack cards with the same visual but a different attack value). Moreover, if you don't include a high resolution, it may be visually horrible on some devices. The "single image" solution was used in the Android version of Magic a few years ago (I did not test the recent versions). The application was obese and the result was horrible on my tablet (blurry image, text difficult to read). Zooming is of course not really possible as it just increases the bluriness.
 

ilan

Expert
Licensed User
Longtime User
In modern card games, you have often a few cards that break the rules. For example: a red card has to be played always before a yellow card, except when you have a blue card in hand which allows to reverse the order, or a green card which allows to ignore the order. Another example: if you get the Mad King card, you can play any attack card as a Frenzy attack card (thus requiring a way for the user to choose between the two possibilities).
In my two card games, I had to write specific code for many cards so I'm not optimistic about a generic system. Anyway, if you succeed in solving most cases about rules with scripting, you will face a new Everest of complexity: the visual building of the cards. A poker card does not look like a Pokemon card. The easy solution is to load an image for each card. It's a very bad solution IMO because it takes a lot of memory. Imagine a game with 300 cards in two resolutions (eg. 1280x1024, 1920x1080). And it's a waste of resources when you have similar visuals with just a different element (like different attack cards with the same visual but a different attack value). Moreover, if you don't include a high resolution, it may be visually horrible on some devices. The "single image" solution was used in the Android version of Magic a few years ago (I did not test the recent versions). The application was obese and the result was horrible on my tablet (blurry image, text difficult to read). Zooming is of course not really possible as it just increases the bluriness.

Is it possible to use vectors in android, like this u wont have any quality lost.
 

LucaMs

Expert
Licensed User
Longtime User
The problem is to add 3D effects
Card flipping and other 3D effects can easily be achieved with
https://www.b4x.com/android/forum/threads/nineoldandroids-or-designer.76535/#post-485519

I think that the more complex things to accomplish, such as "engine" (something reusable), are flexible classes to handle game rules (turns included) and the almost real-time communications.

Graphics of a card game have less difficulty than that for other games (I start thinking that graphic designers gain more than programmers and have more work).
 

wonder

Expert
Licensed User
Longtime User
I'm really starting to think this could be a lot of fun!! :)

Regarding the amount of textures, take a Hearthstone card, for example.
Notice that the template is reusable and the text elements can be added in real-time.
This way, you would only need to store the different illustrations, which are different for every card.

Using 2048x2048 textures, we could store 28 illustrations (280x500) per "page".
280 cards in 10 textures. Of course, there had to be some really good texture management,
some sort of dynamic in-game loading and disposing.

en-us-full-a1d944978c2a80b07714f15d0af796e76c19b6e6ac8cec7e2f64c1c252ffc05eae1012caf56792cd68f1a5dd37c882473a535288ec40e6c139aa4604edfada06.png
 

Informatix

Expert
Licensed User
Longtime User
(300? Usually they are max 54)
We're not talking of the same thing. Modern card games can have a lot more than 54 cards. They do not use spades, clovers, hearts... E.g., the well-known Uno game has 108 colored cards. Some games can have over 1000.

"little" for smartphones, "big" for tablets.
Having two different data sets for two different resolutions may be a solution, indeed, to avoid downloading useless content.
 

Informatix

Expert
Licensed User
Longtime User
This way, you would only need to store the different illustrations, which are different for every card.
It's the solution that I chose for my two card games. Depending on the game, I have between 5 and 9 assets for each card. Some of these assets are common to many cards (e.g. background, borders). Each card is built in real-time, layer by layer, by a dedicated drawing class where cards are designed by a number.

Note that you have to support any card layout. I think that will be a bit complicated if you don't create a card design tool like the B4x designer.
 

wonder

Expert
Licensed User
Longtime User
In my two card games, I had to write specific code for many cards so I'm not optimistic about a generic system.
I managed to embed a Python interpreter in a B4A library, in-game scripting will soon be very real!!! The dream is alive! :)
 
Top