Multiplayer Trading Card Game

Hey guys

I wanted to create a Trading Card Game (Multiplayer) like the YuGiOh ones or Hearthstone (without animations) for reference.

But I am really confused on how to do it with coronasdk

First of all the board.

Each player side will have 5 cards in hand and 5 cards in field to attack/defend.

Should I create the board along with the spots/placeholders to place cards in photoshop as a image and just use it as a background image in the scene ?

Then place the card objects above the placeholder images via code ?

Is that the proper way ?

Second, the AI/Opponent

How do I hide the cards in their hand and manage their play behaviour

Any more tips or suggestions on TCG creation ?

Can someone pretty please help me a bit in this ?

I want to avoid using Unity3d or cocoa2d/spritekit for this project as it is not 3d and I want to create it cross platform but a bit worried on how to lay it out with lua and do some small position/movement animation of cards without a GUI

Corona draws things in layers.  If you create a background first, it will be the bottom most layer.  Then if you draw a card next, it will be on top of the background.  Draw another card on top, and it hides the one below it, like stacking paper.

  1. Should the stats of cards (hp, mana cost, damage, etc.) be stored in a json file which be read via code as soon as game starts and used OR the stats etc should be saved in a table/array within the code ?

  2. What would be the most optimal solution to create a class for heroes so I can create things like heroes[‘hero_id’].hp = xx or heroes[‘id’].dmg = xx

My game will have cards of classes heroes, minions, usable_items, stats_heroes, unlock_skills

  1. Is there any premade class or asset available to create a AI/CPU for a turn based multiplayer game. AI for practice or solo duel mode.

1.  Doesn’t matter, either works.  It’s going to end up a Lua table anyway.  The JSON method has the ability to be kept in an external file and updated (like adding more cards), but if it’s a fixed set, you may as well have a lua module that’s the hard coded table (and later you can download a JSON file and add it in.  They really mix and match well.

  1. Those are just Lua tables indexed by your hero_id.  Table records can contain functions as well as any data type.

  2. No.  You’re on your own there.  We do have plugins for various 3rd party services to handle the multi-player data exchange, but all the logic is on you.

Rob

@Rob can you help me a bit in explaining how classes in Lua works or created ? I am really getting confused in classes coming from C#/ObjC

What I want to do is have a hero class so I can load the hero cards from my json file to create those cards. My class needs the following

#Hero Class

  • ID
  • Name
  • Damage
  • HP
  • Mana Cost
  • Spells - Right Click (Damage, Type, Mana Cost)

                       Skill 1 (Damage, Type, Mana Cost)

                       Skill 2 (Damage, Type, Mana Cost)

                       Ultimate (Damage, Type, Mana Cost)

So if my understanding is right I create a main class Heroes and then create a sub-class of Heroes as “Spells” ?

Will the code be something like this ?

local Heroes = {} Heroes.new = function(data) local hero = display.newGroup() local name = data["name"] local id = data["id"] hero:insert(name) hero:insert(id) return hero end  

But how do I create a sub-class or skills list/variable in the heroes class and how can I use this class to create multiple hero cards ? Will I have to run a loop to create multiple objects with id_%1 to id_%40 in a loop to create 40 cards with diff objects or so ?

Maybe these tutorials will be helpful:
 

http://www.omidahourai.com/from-zero-to-oo-ardentkids-guide-to-object-oriented-lua-with-corona-sdk

http://www.develephant.net/an-rpg-themed-oop-design-pattern-for-corona-sdk-part-1/

https://coronalabs.com/blog/2011/09/29/tutorial-modular-classes-in-corona/

Rob

:insert method is for display objects, so you are inserting object into display group.

But fortunately display groups act as normal lua table too.

So you can assign you data

hero.name = name hero.id = id  

Additionally remember that you can assign any type of data…
 So your hero can have field with for example “utlimate skill”, for simplicity I will use function here, but you can write class for it and assign create object.

local superDuperUltimate = function( hero , target )    print( hero.name .. " swings his weapon at " .. target.name .. "head!") end hero.ultimate = superDuperUltimate -- somewhere else.. hero.ultimate( hero, target )  

Of course there are many more elegant way’s of doing this… but just to point out the idea :slight_smile:

Rob pointed out excellent tutorials, especially first one.

Additionally you may consider placing you data in SQLite table if it suits your needs.

You wrote: So if my understanding is right I create a main class Heroes and then create a sub-class of Heroes as “Spells”

I wouldn’t do it like that way. If you want inheritance think more of is-a rule…

So Spell is a Hero… WRONG! It’s not, so dont inherit spell from hero.

But Fireball is a Spell, so it’s logical to inherit Fireball from Spell class.
 

Can someone pretty please help me a bit in this ?

I want to avoid using Unity3d or cocoa2d/spritekit for this project as it is not 3d and I want to create it cross platform but a bit worried on how to lay it out with lua and do some small position/movement animation of cards without a GUI

Corona draws things in layers.  If you create a background first, it will be the bottom most layer.  Then if you draw a card next, it will be on top of the background.  Draw another card on top, and it hides the one below it, like stacking paper.

  1. Should the stats of cards (hp, mana cost, damage, etc.) be stored in a json file which be read via code as soon as game starts and used OR the stats etc should be saved in a table/array within the code ?

  2. What would be the most optimal solution to create a class for heroes so I can create things like heroes[‘hero_id’].hp = xx or heroes[‘id’].dmg = xx

My game will have cards of classes heroes, minions, usable_items, stats_heroes, unlock_skills

  1. Is there any premade class or asset available to create a AI/CPU for a turn based multiplayer game. AI for practice or solo duel mode.

1.  Doesn’t matter, either works.  It’s going to end up a Lua table anyway.  The JSON method has the ability to be kept in an external file and updated (like adding more cards), but if it’s a fixed set, you may as well have a lua module that’s the hard coded table (and later you can download a JSON file and add it in.  They really mix and match well.

  1. Those are just Lua tables indexed by your hero_id.  Table records can contain functions as well as any data type.

  2. No.  You’re on your own there.  We do have plugins for various 3rd party services to handle the multi-player data exchange, but all the logic is on you.

Rob

@Rob can you help me a bit in explaining how classes in Lua works or created ? I am really getting confused in classes coming from C#/ObjC

What I want to do is have a hero class so I can load the hero cards from my json file to create those cards. My class needs the following

#Hero Class

  • ID
  • Name
  • Damage
  • HP
  • Mana Cost
  • Spells - Right Click (Damage, Type, Mana Cost)

                       Skill 1 (Damage, Type, Mana Cost)

                       Skill 2 (Damage, Type, Mana Cost)

                       Ultimate (Damage, Type, Mana Cost)

So if my understanding is right I create a main class Heroes and then create a sub-class of Heroes as “Spells” ?

Will the code be something like this ?

local Heroes = {} Heroes.new = function(data) local hero = display.newGroup() local name = data["name"] local id = data["id"] hero:insert(name) hero:insert(id) return hero end  

But how do I create a sub-class or skills list/variable in the heroes class and how can I use this class to create multiple hero cards ? Will I have to run a loop to create multiple objects with id_%1 to id_%40 in a loop to create 40 cards with diff objects or so ?

Maybe these tutorials will be helpful:
 

http://www.omidahourai.com/from-zero-to-oo-ardentkids-guide-to-object-oriented-lua-with-corona-sdk

http://www.develephant.net/an-rpg-themed-oop-design-pattern-for-corona-sdk-part-1/

https://coronalabs.com/blog/2011/09/29/tutorial-modular-classes-in-corona/

Rob

:insert method is for display objects, so you are inserting object into display group.

But fortunately display groups act as normal lua table too.

So you can assign you data

hero.name = name hero.id = id  

Additionally remember that you can assign any type of data…
 So your hero can have field with for example “utlimate skill”, for simplicity I will use function here, but you can write class for it and assign create object.

local superDuperUltimate = function( hero , target )    print( hero.name .. " swings his weapon at " .. target.name .. "head!") end hero.ultimate = superDuperUltimate -- somewhere else.. hero.ultimate( hero, target )  

Of course there are many more elegant way’s of doing this… but just to point out the idea :slight_smile:

Rob pointed out excellent tutorials, especially first one.

Additionally you may consider placing you data in SQLite table if it suits your needs.

You wrote: So if my understanding is right I create a main class Heroes and then create a sub-class of Heroes as “Spells”

I wouldn’t do it like that way. If you want inheritance think more of is-a rule…

So Spell is a Hero… WRONG! It’s not, so dont inherit spell from hero.

But Fireball is a Spell, so it’s logical to inherit Fireball from Spell class.