Jump to content

Recommended Posts

Heres what I did:

I made a game to pick the winners and find out potential heat draws (match ups) for surf contests. Basically, in round 1 there are 3 man heats and you pick one winner for each heat. The winner goes straight into round 3, and the 2 losers go into round 2. Then in round 2, there are 2 man heats where the winner goes into round 3 and the loser is eliminated. Based on your round 1 choices, the round 2 heat draw is calculated (heat draws are calculated by the surfers seed number (rankings).. ex: heat 1 is #10 vs #26 vs #39). And based on your round 2 choices, the round 3 heat draw is calculated.

 

Anyways, I have it working right now like this:

My database is set up where I have fields: surfer name, seed number (ranking), round 1, round 2, round 3. In round 1, if the surfer is competing in the event, the value is set to '1', if not, it's set to '0'. So, for round 1, first I reset all surfers round 2 and 3 values to '0'. Then, I call all the surfers with round 1 set to '1', sort them ASC according to their seed number and put them into a variable containing an array. From the array, I put them into their correct heats. On submit, When you pick your winners, that basically sets their round 3 = '1'.

 

When the round 2 page is loaded, I have scripting that first sets all surfers round 2 values = '1'. Then it gets all the surfers with round 3 values = '1' (your picked winners) and changes their round 2 = '0'. So it then gets the round 2 guys with '1', sorts them ASC and puts them into an array and from the array I put them into their respective heats. Then you pick your round 2 winners, and on submit, the winners round 3 = '1'. For the round 3 page, it calls all surfers with round 3='1', sorts them ASC, puts them into an array and distributes them into their respective heats for the final round 3 heat draw.

 

The problem:

Because of the way I have it set up, it only works for 1 person playing at a time. If I am playing and picking winners, its changing their values in the database. So if someone else tries to pick their winners, it's all screwed up. How can I get this going to where the client side is able to get the seed numbers from the database and things are manipulated client-side and heat draws are calculated that way? Any ideas?

 

Thanks guys, sorry for the newbie question.

Hi,

 

You have a problem with how you have conceptualized the database design, not with your client side coding.

 

You need a user table in your database, representing the user currently playing the game.  The round round 1, round 2, round 3 rows need to be associated with the user somehow, or you could even just store them in the session. A possible design for this in terms of the database is (I am presuming the seed stays constant here):

 

surfer

-------

id

seed

 

user

--------

email

password

 

game

-------

id

user_id

 

game_surfer

----------------

game_id (primary key)

surfer_id (joint primary key)

round1

round2

round3

 

Then just use the session to keep track of the users current game id.

 

Robin

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.