So I am running into a problem two people ran into in 2014 and I could not find a good answer on -- how to keep track of cards played in order
right now from the heart tutorial I have
And the cards play fine left to right on both clients side because of CSS
But once the person reloads the page the cards are out of order in the Deck class (I believe because of the cardId)
So I figured there are a couple of ways to design this but I not sure if one is better than the other
1) I can change the above line to
$this->cards->moveCard($card_id, 'cardsontable_'.$player_id, $orderOfPlay);
or even
insertCardOnExtremePosition($card_id, 'cardsontable_'.$player_id, false);
Then keep track of the location so I can pull them out later
$this->cards->getCardsInLocation( 'cardsontable'.$player_id );
for each player passed through a gameData array
And then moveAllCardsInLocation will be a little more challenging to clear the boards
2) I can add another field to the 'card' table but it looks like I will have to write custom sql for every deck operation. While the sql structure / sql is not a problem, it does seem like recreating the wheel for the addition of one field, plus I am unsure of any other actions the build in methods perform rather than just returning a collection
3) similar to 2 I can build my own sql table to keep track of the cards played
Is there a best practice to handle this type of game state?
right now from the heart tutorial I have
Code: Select all
$this->cards->moveCard($card_id, 'cardsontable', $player_id);
But once the person reloads the page the cards are out of order in the Deck class (I believe because of the cardId)
So I figured there are a couple of ways to design this but I not sure if one is better than the other
1) I can change the above line to
$this->cards->moveCard($card_id, 'cardsontable_'.$player_id, $orderOfPlay);
or even
insertCardOnExtremePosition($card_id, 'cardsontable_'.$player_id, false);
Then keep track of the location so I can pull them out later
$this->cards->getCardsInLocation( 'cardsontable'.$player_id );
for each player passed through a gameData array
And then moveAllCardsInLocation will be a little more challenging to clear the boards
2) I can add another field to the 'card' table but it looks like I will have to write custom sql for every deck operation. While the sql structure / sql is not a problem, it does seem like recreating the wheel for the addition of one field, plus I am unsure of any other actions the build in methods perform rather than just returning a collection
3) similar to 2 I can build my own sql table to keep track of the cards played
Is there a best practice to handle this type of game state?