Creating a database for multiplayer proposes?

Hey guys,

Lots of art was made, lots of code was written, next step is multiplayer…

Im making a multiplayer card game, and im struggling with how to approach the ‘multiplayer’ side.

I was thinking to make a database, each player that downloads the game and opens it, will create an account, the account will hold all of its cards data.

Then, when a user wants to battle, its device will search the database for a player, and will pick one randomly.

Once the opponent was picked, its cards data (a table) will be copied to a local table, and thats it basically.

Any tips on how to make this kind of thing? can services like NoobHub or AutoLAN do this?

Roy.

Take a look at parse.com

@nick_sherman

Ive been looking at parse for the past hour, it does offer lots of things and I think im gonna try it.

But ive tried to understand how to integrate it to corona sdk… what API’s do I use? is there a corona+parse tutorial out there? cause right now all I see is Xcode SDK tutorials only…

Roy.

This is what I used as a starting point for the multiplayer engine I’m working on. 

https://github.com/Dotnaught/Parse-for-Corona-SDK

I will try to explore whats going on in those files but it seems like there almost no explanations there :

Roy.

Anybody contemplating using Parse.com with Corona should check out Jen’s tutorial on the subject:

http://www.ladeezfirstmedia.com/2013/06/26/tutorial-part-1-cloud-code-integrate-parse-coms-rest-api-with-your-coronasdk-app/

Part of a 5-part series that will really get you going with Parse.com services.

@SegaBoy

Ive read the tutorial, and even started the parse implantation in my project, but I’m having some issues and no one, (not even parse.com) is answering so simple questions…

Like I said I wanted to create a database that holds each actor’s data, and for multiplayer purposes, when a player wants to battle, the device will give him some opponents from that database.

But HOW?! the only API we have to fetch data is getObj, which returns your own info, and findObj, which rely on userID (how can the device know the other users ID’s ?)

So even after playing with parse for few days now, I still don’t know how to do the most important things.

If you have any insights please share…

Roy.

So I imagine you’re trying to create random matches. The way I was implementing multiplayer was based on accepting a Facebook Friend request and storing that ID in the user’s table.

Hmmmm, I’ll have to dig a little further into Parse.com API and have a think about it.

@SegaBoy

I highly appreciate your time in answering in the thread.

Care to share your experience with your facebook method? did each Facebook Friend had his own stats? 

Or was it only the Facebook ID that was transferred? what im trying to ask is, except for the Facebook ID, what other data was transferred for the multiplayer purposes?

Roy.

This is completely unoptimsied and likely to be messy - but if you had a big database of people’s ids when they registered, couldn’t you just submit a Query, like so (this is from the REST Documentation page on Parse.com:

curl -X GET \
  -H “X-Parse-Application-Id: xxxxxxxxxx” \
  -H “X-Parse-REST-API-Key: xxxxxxxxxx” \
  https://api.parse.com/1/classes/GameScore

That would then return a JSON object containing an array of JSON Objects all listed in that table; in this case the object would return all entries listed in the GameScore table (or Class in Parse terminology).

It would then be up to you to work through this on the client side logic. It does seem as though you can impose constraints on the query, although I’m not 100% sure whether you can restrict this to 20 like you need.

@SegaBoy, thanks for the shout-out. Roy, you’re going to want to do a deep dive into Parse’s User table and the concept of Cloud Code. The best thing is to write up a few bullet points of the steps you want to take to make one actor interact with another, post them here, and let’s see if we can tackle them one by one. 

Good luck! 

best,

Jen

Roy - looking at the question I believe you posted on SO regarding this matter (http://stackoverflow.com/questions/18821281/parse-com-database-and-corona-sdk) I think you’re using the wrong Parse APIs. It looks as though you’re using the Javascript implementation, however Corona requires the REST approach.

Wow guys thanks a lot for trying to help!

@Jen.looper

Jen,

Great tutorial! it helped me very much and im probably gonna use what you covered for the push notifications.

Here are some bullet points for what im trying to do:

1)I have a new table in parse.com , called “cards”, this table has the following columns:

   objectID(string), name(string), email (string), createdAt(Date), updatedAt(Date), cardData (object).

   The cardData column is basically a table object, it has all the player’s card data in it.

   As you see there is no ‘password’ column, I verify the user’s password in the game itself rather then uploading it to the cloud.

  1. New user - opens the game for the first time, is asked to register to the ‘cards’ database I mentioned in (1).

The user’s input is:

name

email

password (stored and saved on the device only)

The device then creates a new user (via the signUp function) that means a new row was added to the ‘cards’ table in Parse.

  1. User wants to battle with his cards, he goes into the ‘battle scene’

  2. The device is connecting to Parse.com, and downloads 10 random opponents from the database.

by downloads 10 opponents I mean:

There are 10 local tables in the battleScene.lua file

[lua]

local player1={}

local player2={}

local player3={}

local player4={}

– you got the point

[/lua]

Each table will represent an opponent downloaded from the ‘cards’ table

  1. The downloaded opponents are presented to the user as buttons from which he can pick one to battle against.

6)Thats it, the rest of the battle is made by the logic on the device, after the battle ends, the device will update the user’s new statistics to the “cards” table. (A simple update to the cardData object that is in the table).

When I was first introduced to Parse, I though It was perfect for creating this type of database, but I dont want the device to download the whole database every time A user battles, I want only 10 random opponents to be downloaded.

Maybe Parse is not the right choice for this, but if so, what are the alternatives? Im sure im not the first dev whos looking for this type of thing lol

@SegaBoy

The stackoverflow question is when I was trying to mess around with ‘CloudCode’ , that supports javascript (I have zero knowledge in javascript)

Im interesting to know what was your approach with Facebook friends and multiplayer…

Roy.

It looks as if you are stuck on the actual querying of your Parse data, where you want to grab 10 random opponents out of your dataset. To do this, take a look at the documentation for Parse Queries. According to the forums in Parse, and because we’re dealing with noSQL rather than a relational database, Parse data doesn’t really handle random querying right now. You could write some cloud code and store it on Parse to grab the first ten opponents and then mark them as used by your user when the battle is done (so insert the user’s id in a column), then keep querying as needed for future battling, selecting the next ten opponents who are not marked as used. You’ll want to read thru:

https://parse.com/docs/js/symbols/Parse.Query.html

Alternately, there’s a new multiplayer plugin, ProtonCloud, might be useful?

best,

Jen

What about Facebook graph API? Can a user store his cards data in his account?

So when “fighting” a Facebook friend, He can grab the friend’s cards data?

 

Roy.

Sorry, on that topic I don’t know much…haven’t done much with Facebook (yet) since my apps are geared towards the younger set.

Take a look at parse.com

@nick_sherman

Ive been looking at parse for the past hour, it does offer lots of things and I think im gonna try it.

But ive tried to understand how to integrate it to corona sdk… what API’s do I use? is there a corona+parse tutorial out there? cause right now all I see is Xcode SDK tutorials only…

Roy.

This is what I used as a starting point for the multiplayer engine I’m working on. 

https://github.com/Dotnaught/Parse-for-Corona-SDK

I will try to explore whats going on in those files but it seems like there almost no explanations there :

Roy.