tAssociate animals to players using color - hadarawgs - Hadara adaptation for boardgamearena.com
 (HTM) git clone git://git.z3bra.org/hadarawgs.git
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) LICENSE
       ---
 (DIR) commit 63d76016ebdff8d07bae289c6fe234ea29dd0279
 (DIR) parent 2f3e4f104493b3098264029129e6914c4e292f2d
 (HTM) Author: Willy Goiffon <dev@z3bra.org>
       Date:   Fri,  6 Mar 2020 11:50:36 +0100
       
       Associate animals to players using color
       
       Diffstat:
         M dbmodel.sql                         |       1 -
         M gameinfos.inc.php                   |       8 +++-----
         M hadarawgs.css                       |      11 ++++++-----
         M hadarawgs.game.php                  |      12 ++----------
         M hadarawgs.view.php                  |       2 --
         M hadarawgs_hadarawgs.tpl             |       2 +-
       
       6 files changed, 12 insertions(+), 24 deletions(-)
       ---
 (DIR) diff --git a/dbmodel.sql b/dbmodel.sql
       t@@ -11,7 +11,6 @@
        
        CREATE TABLE IF NOT EXISTS `playerboard` (
                `id` int(10) unsigned NOT NULL,
       -        `animal` varchar(255) NOT NULL,
                `coins`    int(10) DEFAULT 0,
                `income`   int(10) DEFAULT 0,
                `military` int(10) DEFAULT 0,
 (DIR) diff --git a/gameinfos.inc.php b/gameinfos.inc.php
       t@@ -87,11 +87,9 @@ $gameinfos = array(
        // Diplomacy of the game, from 0 (no interaction in this game) to 5 (totally based on interaction and discussion between players)
        'diplomacy' => 1,
        
       -// Colors attributed to players
       -'player_colors' => array( "ff0000", "008000", "0000ff", "ffa500", "773300" ),
       -
       -// Player board animals
       -'player_animals' => array( "dragon", "lion", "monkey", "pegasus", "scarab" ),
       +// Colors attributed to players - used for animals
       +'player_colors'  => array( "d80000", "ffb000", "804000", "ffffff", "408000" ),
       +'player_animals' => array( "dragon", "lion",   "monkey", "pegasus","scarab" ),
        
        // Favorite colors support : if set to "true", support attribution of favorite colors based on player's preferences (see reattributeColorsBasedOnPreferences PHP method)
        'favorite_colors_support' => true,
 (DIR) diff --git a/hadarawgs.css b/hadarawgs.css
       t@@ -22,11 +22,12 @@
                font-weight: bold;
        }
        
       -.player_dragon::after  { content: " - dragon";  }
       -.player_lion::after    { content: " - lion";    }
       -.player_monkey::after  { content: " - monkey";  }
       -.player_pegasus::after { content: " - pegasus"; }
       -.player_scarab::after  { content: " - scarab";  }
       +/* animals match player colors
       +.player_d80000::after { fond-size: 70%; content: " - dragon";  }
       +.player_ffb000::after { fond-size: 70%; content: " - lion";    }
       +.player_804000::after { fond-size: 70%; content: " - monkey";  }
       +.player_ffffff::after { fond-size: 70%; content: " - pegasus"; }
       +.player_408000::after { fond-size: 70%; content: " - scarab";  }
        
        .playerboard_resources {
                text-align: center;
 (DIR) diff --git a/hadarawgs.game.php b/hadarawgs.game.php
       t@@ -62,7 +62,6 @@ class hadarawgs extends Table
                {
                        $gameinfos = self::getGameinfos();
                        $default_colors = $gameinfos['player_colors'];
       -                $default_animals = $gameinfos['player_animals'];
        
                        // Create players
                        $sql = "INSERT INTO player (
       t@@ -98,19 +97,18 @@ class hadarawgs extends Table
                        //self::initStat( 'player', 'player_teststat1', 0 );  // Init a player statistics (for all players)
        
                        // TODO: setup the initial game situation here
       -                $sql = "INSERT INTO playerboard (id, animal, coins, income, military, culture, food) VALUES";
       +                $sql = "INSERT INTO playerboard (id, coins, income, military, culture, food) VALUES";
                        $values = array();
        
                        shuffle($this->initiative);
                        foreach( $players as $player_id => $player ) {
       -                        $animal = array_shift($default_animals);
                                $initiative = array_shift($this->initiative);
                                $income = $initiative['income'];
                                $military = $initiative['military'];
                                $culture = $initiative['culture'];
                                $food = $initiative['food'];
                                $coins = $income + $initiative['coins'];
       -                        $values[] = "($player_id, '$animal', $coins, $income, $military, $culture, $food)";
       +                        $values[] = "($player_id, $coins, $income, $military, $culture, $food)";
                        }
                        $sql .= implode( $values, ',' );
                        self::DbQuery( $sql );
       t@@ -191,12 +189,6 @@ class hadarawgs extends Table
                        In this space, you can put any utility methods useful for your game logic
                */
        
       -        function getPlayerBoard($player_id)
       -        {
       -                $sql = "SELECT id, animal FROM playerboard where id = $player_id";
       -                return self::getCollectionFromDb($sql);
       -        }
       -
        //////////////////////////////////////////////////////////////////////////////
        //////////// Player actions
        ////////////
 (DIR) diff --git a/hadarawgs.view.php b/hadarawgs.view.php
       t@@ -47,12 +47,10 @@ class view_hadarawgs_hadarawgs extends game_view
        
                        $this->page->begin_block( "hadarawgs_hadarawgs", "player" );
                        foreach( $players as $player_id=>$player ) {
       -                        $board = $this->game->getPlayerBoard($player_id);
                                $this->page->insert_block( "player", array(
                                        "PLAYER_ID" => $player_id,
                                        "PLAYER_NAME" => $player['player_name'],
                                        "PLAYER_COLOR" => $player['player_color'],
       -                                "PLAYER_ANIMAL" => $board[$player_id]['animal'],
                                        )
                                );
                        }
 (DIR) diff --git a/hadarawgs_hadarawgs.tpl b/hadarawgs_hadarawgs.tpl
       t@@ -3,7 +3,7 @@
        <div id="playerboards">
                <!-- BEGIN player -->
                <div id="board_p{PLAYER_ID}" class="playerboard whiteblock">
       -                <h3 style="color:#{PLAYER_COLOR}" class="player_{PLAYER_ANIMAL}">{PLAYER_NAME}</h3>
       +                <h3 style="color:#{PLAYER_COLOR}" class="player_{PLAYER_COLOR}">{PLAYER_NAME}</h3>
                        <div class="playerboard_resources">
                                <div class="playerboard_income"><span id="income_p{PLAYER_ID}">-</span></div>
                                <div class="playerboard_food"><span id="food_p{PLAYER_ID}">-</span></div>