From 3a49717afed8183df643f1490c2253a31312b930 Mon Sep 17 00:00:00 2001 From: Jeff Raymakers Date: Tue, 7 Jul 2020 22:13:47 -0700 Subject: [PATCH] db init and materials --- heartsjephly.game.php | 15 ++++++++++++++- material.inc.php | 35 +++++++++++++++++++++++++++++++++-- 2 files changed, 47 insertions(+), 3 deletions(-) diff --git a/heartsjephly.game.php b/heartsjephly.game.php index 62cc1e7..11871a1 100644 --- a/heartsjephly.game.php +++ b/heartsjephly.game.php @@ -34,7 +34,7 @@ function __construct( ) self::initGameStateLabels( array( 'roundType' => 10, // 0, 1, 2, 3 = pass left, pass right, pass opposite, no pass - 'trickSuit' => 11, // 1, 2, 3, 4 = Spades, Hearts, Clubs, Diamonds + 'trickSuit' => 11, // 0, 1, 2, 3, 4 = none, Spades, Hearts, Clubs, Diamonds 'heartsBroken' => 12, // 0 or 1 = false, true // "my_first_global_variable" => 10, // "my_second_global_variable" => 11, @@ -87,6 +87,10 @@ protected function setupNewGame( $players, $options = array() ) // Init global values with their initial values //self::setGameStateInitialValue( 'my_first_global_variable', 0 ); + + self::setGameStateInitialValue( 'roundType', 0 ); + self::setGameStateInitialValue( 'trickSuit', 0 ); + self::setGameStateInitialValue( 'heartsBroken', 0 ); // Init game statistics // (note: statistics used in this file must be defined in your stats.inc.php file) @@ -94,6 +98,15 @@ protected function setupNewGame( $players, $options = array() ) //self::initStat( 'player', 'player_teststat1', 0 ); // Init a player statistics (for all players) // TODO: setup the initial game situation here + + $cards = array(); + foreach ( $this->suits as $suit_id => $suit ) { + for ($rank = 2; $rank <= 14; $rank++) { + $cards[] = array( 'type' => $suit_id, 'type_arg' => $rank, 'nbr' => 1 ); + } + } + + $this->cards->createCards( $cards, 'deck' ); // Activate first player (which is in general a good idea :) ) diff --git a/material.inc.php b/material.inc.php index 64c3bb6..3d542c2 100644 --- a/material.inc.php +++ b/material.inc.php @@ -32,6 +32,37 @@ */ +$this->suits = array( + 1 => array( + 'name' => clienttranslate('spade'), + 'nametr' => self::_('spade'), + ), + 2 => array( + 'name' => clienttranslate('heart'), + 'nametr' => self::_('heart'), + ), + 3 => array( + 'name' => clienttranslate('club'), + 'nametr' => self::_('club'), + ), + 4 => array( + 'name' => clienttranslate('diamond'), + 'nametr' => self::_('diamond'), + ), +); - - +$this->rank_labels = array( + 2 => '2', + 3 => '3', + 4 => '4', + 5 => '5', + 6 => '6', + 7 => '7', + 8 => '8', + 9 => '9', + 10 => '10', + 11 => clienttranslate('J'), + 12 => clienttranslate('Q'), + 13 => clienttranslate('K'), + 14 => clienttranslate('A'), +);