Welcome Guest, Not a member yet? Register   Sign In
Online Euchre - Schema Opinions
#1

[eluser]slowgary[/eluser]
Hi guys,

Ok, so this isn't homework because I dropped out of school a long time ago. I've written a web based Euchre game a while back, but never fully completed it. I've learned a lot since then (plus I'm using CI now) and I've decided to pick it back up and start fresh.

Where I have issues (as always) is creating the database schema, and I hope that maybe you or someone you know will be able to help. Euchre is a 4 player, 2 team, turn based card game for those that don't know. There's just so many ways to do this that I can't see through to what makes most sense.

This is what I had previously, although most of it is garbage:
Code:
games table      //stores data for active games
===========================================
game_id          //pk
options          //char field that stores 'flags' for options
score_x          //score of team east & west
score_y          //score of team north & south
trump            //suit that is trump - enum('h', 'd', 's', 'c')
called_trump     //player who called trump
is_loner         //boolean - did the player go it alone
dealer           //player who is dealer
leader           //player who led this throw
turn             //whose turn is it
tricks_x         //number of tricks won for east & west
tricks_y         //number of tricks won for north & south
player0          //id of player at north position
player1          //id of player at east position
player2          //id of player at south position
player3          //id of player at west position
n1               //cards in north player's hand
n2
n3
n4
n5
e1               //cards in east player's hand
e2
e3
e4
e5
s1               //cards in south player's hand
s2
s3
s4
s5
w1               //cards in west player's hand
w2
w3
w4
w5
kitty            //top card from kitty (which was either picked up or turned down)
show_trick       //once all 4 cards are tossed, this stores whether each player has seen the cards to allow for an animation where cards fly to winner. char(4), bool style flags, e.g. 0000 or 1111 or 0011 (two players still need to see the animation)
hit_count        //increments on every update to the table, just to know

The game did work for the most part, but I started having issues when it came time to create a lobby, and put players into a game. I planned to have a players table but when I originally wrote it I just passed a player id using JavaScript. So it did allow 4 people to play a game on different machines, but only 1 game at a time, no lobby, needed lots of work still.

When a player threw a card, I basically just put the cards in order in the database, so that once all players threw their first card, that card would be in n1/e1/s1/w1 and I used the leader and trump fields to determine which of those cards deserved the trick. Then I used the tricks_x + tricks_y to determine how many cards should still appear in each players hand (plus turn for the current round).

Now that I'm starting over I really need to revisit the database first, and that's where I'm at. I think I need to add a hash for each game, as well as one per player to assure that no one's throwing someone else's cards, or protect from CSRF cheating. I also think the rest of the schema needs a LOT of work. Reordering the cards seems silly but I don't see a better way at the moment.

So basically if you're familiar with Euchre, and you were writing a web-based version, how would you do it? I really appreciate that you've even taken the time to read all this, and I value your opinion. Thanks.




Theme © iAndrew 2016 - Forum software by © MyBB