Bonsoir,
I need to better understand the rule of 'deck' componant.
To present the game: I need to show 21 cards in 3 rows of 7 columns. The first and the last row are hidden.
I use an array to initiate Occurancy relative to card picture (0 is back, so appears 0 times, then yellow fighter appers 3 times, red fighter 4 times, ..., empty plain 3 times)
this gives:
I suppose that I have to feel my $location 'Plain' like this using only 'nbr' in game.php?
this will create 21 cards shuffled, even I enter only 8 times in array? (else I donot understand the goal of nbr)
Other thing, to be sure player cannot cheat in code to see what is id under back of card, i replace id when I get the data form the DB...
Is it correct to do like this?
And Last thing, I would like to know in my case, how I can get from $location 'plain', an indexed card...
for example I would like to know what is the id (between 1 and 8) of the card indexed 17 (between 0 and 20)...
I suppose I have to use $this->cards->getCard()... but I don't really understand how to manage it in this case?
could you explain more?
thanks
I need to better understand the rule of 'deck' componant.
To present the game: I need to show 21 cards in 3 rows of 7 columns. The first and the last row are hidden.
I use an array to initiate Occurancy relative to card picture (0 is back, so appears 0 times, then yellow fighter appers 3 times, red fighter 4 times, ..., empty plain 3 times)
this gives:
Code: Select all
$this->PlainCardOccurence = array( 0, 3, 4, 5, 3, 1, 1 , 1, 3 );
$this->cardtypes =
array
(
0 => array( 'name' => clienttranslate('back'),
'nametr' => self::_('BACK') ),
1 => array( 'name' => clienttranslate('yellow fighter'),
'nametr' => self::_('YELF') ),
2 => array( 'name' => clienttranslate('red fighter'),
'nametr' => self::_('REDF') ),
3 => array( 'name' => clienttranslate('green fighter'),
'nametr' => self::_('GREF') ),
4 => array( 'name' => clienttranslate('buffalo'),
'nametr' => self::_('BUFFALO') ),
5 => array( 'name' => clienttranslate('totem'),
'nametr' => self::_('TOTEM') ),
6 => array( 'name' => clienttranslate('shaman'),
'nametr' => self::_('SHAMAN') ),
7 => array( 'name' => clienttranslate('white buffalo'),
'nametr' => self::_('SPIRIT') ),
8 => array( 'name' => clienttranslate('plain'),
'nametr' => self::_('EMPTY') )
);
Code: Select all
protected function ShufflePlain()
{
// Create cards
$cards = array();
for( $j=1;$j<$this->PlainCardOccurence.length;$j++)
{
$cards[] = array(
'type' => $j,
'type_arg' =>$this->cardtypes[$j] ,
'nbr' => $this->PlainCardOccurence[$j]
);
}
$this->cards->createCards( $cards, 'plain' );
$this->cards->shuffle( 'plain' );
}
Other thing, to be sure player cannot cheat in code to see what is id under back of card, i replace id when I get the data form the DB...
Is it correct to do like this?
Code: Select all
protected function getAllDatas()
{
$result = array( 'players' => array(), 'plaincards'=>array() );
$current_player_id = self::getCurrentPlayerId(); // !! We must only return informations visible by this player !!
// Get information about players
// Note: you can retrieve some extra field you added for "player" table in "dbmodel.sql" if you need it.
$sql = "SELECT player_id id, player_score score FROM player ";
$result['players'] = self::getCollectionFromDb( $sql );
$sql = "SELECT plain_index [index], plain_card card, plain_status [status] FROM plain";
$result['plaincards'] = self::getCollectionFromDb( $sql );
// hide the id of cards hidden!
for ($i=0; $i<21; $i++)
{
//check status if hidden, id=back of card.
if( !($result['plaincards'][$i][2])) $result['plaincards'][$i][1]=0;
}
return $result;
}
for example I would like to know what is the id (between 1 and 8) of the card indexed 17 (between 0 and 20)...
I suppose I have to use $this->cards->getCard()... but I don't really understand how to manage it in this case?
could you explain more?
thanks