<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://en.doc.boardgamearena.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Fenadoruk</id>
	<title>Board Game Arena - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://en.doc.boardgamearena.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Fenadoruk"/>
	<link rel="alternate" type="text/html" href="https://en.doc.boardgamearena.com/Special:Contributions/Fenadoruk"/>
	<updated>2026-09-21T17:19:51Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.0</generator>
	<entry>
		<id>https://en.doc.boardgamearena.com/index.php?title=BGA_Studio_Cookbook&amp;diff=26457</id>
		<title>BGA Studio Cookbook</title>
		<link rel="alternate" type="text/html" href="https://en.doc.boardgamearena.com/index.php?title=BGA_Studio_Cookbook&amp;diff=26457"/>
		<updated>2025-09-11T16:14:22Z</updated>

		<summary type="html">&lt;p&gt;Fenadoruk: /* Animation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;br /&gt;
This page is a cookbook of design and implementation recipes for BGA Studio framework.&lt;br /&gt;
For tooling and usage recipes see [[Tools and tips of BGA Studio]].&lt;br /&gt;
If you have your own recipes feel free to edit this page.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Visual Effects, Layout and Animation ==&lt;br /&gt;
&lt;br /&gt;
=== DOM manipulatons ===&lt;br /&gt;
&lt;br /&gt;
==== Create pieces dynamically (using template) ====&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Ingredients:&#039;&#039;&#039; ggg_ggg.tpl, ggg.js&lt;br /&gt;
&lt;br /&gt;
Note: this method is recommended by BGA guildlines&lt;br /&gt;
&lt;br /&gt;
Declared js template with variables in .tpl file, like this&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
    // Javascript HTML templates&lt;br /&gt;
    var jstpl_ipiece = &#039;&amp;lt;div class=&amp;quot;${type} ${type}_${color} inlineblock&amp;quot; aria-label=&amp;quot;${name}&amp;quot; title=&amp;quot;${name}&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&#039;;&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use it like this in .js file&lt;br /&gt;
  div = this.format_block(&#039;jstpl_ipiece&#039;, {&lt;br /&gt;
                                type : &#039;meeple&#039;,&lt;br /&gt;
                                color : &#039;ff0000&#039;,&lt;br /&gt;
                                name : &#039;Bob&#039;,&lt;br /&gt;
                            });&lt;br /&gt;
  &lt;br /&gt;
Then you do whatever you need to do with that div, this one specifically design to go to log entries, because it has embedded title (otherwise its a picture only) and no id.&lt;br /&gt;
&lt;br /&gt;
Note: you could have place this variable in js itself, but keeping it in .tpl allows you to have your js code be free of HTML. Normally it never happens but&lt;br /&gt;
it is good to strive for it.&lt;br /&gt;
Note: you can also use string concatenation, its less readable. You can also use dojo dom object creation api&#039;s but its brutally verbose and its more unreadable.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Create pieces dynamically (using string concatenation) ====&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Ingredients:&#039;&#039;&#039; ggg.js&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  div = &amp;quot;&amp;lt;div class=&#039;meeple_&amp;quot;+color+&amp;quot;&#039;&amp;gt;&amp;lt;/div&amp;gt;&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or modern way&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  div = `&amp;lt;div class=&#039;meeple_${color}&#039;&amp;gt;&amp;lt;/div&amp;gt;`;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Create all pieces statically ====&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Ingredients:&#039;&#039;&#039; ggg_ggg.tpl, ggg.css, ggg.view.php (optional) &lt;br /&gt;
&lt;br /&gt;
* Create ALL game pieces in html template (.tpl)&lt;br /&gt;
* ALL pieces should have unique id, and it should be meaningful, i.e. meeple_red_1&lt;br /&gt;
* Do not use inline styling&lt;br /&gt;
* Id of player&#039;s specific pieces should use some sort of &#039;color&#039; identification, since player id cannot be used in static layout, you can use english color name, hex 6 char value, or color &amp;quot;number&amp;quot; (1,2,3...)&lt;br /&gt;
* Pieces should have separated class for its color, type, etc, so it can be easily styled in groups. In example below you now can style all meeples, all red meeples or all red tokens, or all &amp;quot;first&amp;quot; meeples&lt;br /&gt;
&lt;br /&gt;
ggg.tpl:&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
  &amp;lt;div id=&amp;quot;home_red&amp;quot; class=&amp;quot;home_red home&amp;quot;&amp;gt;&lt;br /&gt;
     &amp;lt;div id=&amp;quot;meeple_red_1&amp;quot; class=&amp;quot;meeple red n1&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
     &amp;lt;div id=&amp;quot;meeple_red_2&amp;quot; class=&amp;quot;meeple red n2&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
  &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ggg.css:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
.meeple {&lt;br /&gt;
	width: 32px;&lt;br /&gt;
	height: 39px;&lt;br /&gt;
	background-image: url(img/78_64_stand_meeples.png);&lt;br /&gt;
	background-size: 352px;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.meeple.red {&lt;br /&gt;
	background-position: 30% 0%;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* There should be straight forward mapping between server id and js id (or 1:1)&lt;br /&gt;
* You place objects in different zones of the layout, and setup css to take care of layout&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
.home .meeple{&lt;br /&gt;
   display: inline-block;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* If you need to have a temporary object that look like original you can use dojo.clone (and change id to some temp id)&lt;br /&gt;
* If there is lots of repetition or zone grid you can use template generator, but inject style declaration in css instead of inline style for flexibility&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
* If you use this model you cannot use premade js components such as Stock and Zone&lt;br /&gt;
* You have to use alternative methods of animation (slightly altered) since default method will leave object with inline style attributes which you don&#039;t need&lt;br /&gt;
&lt;br /&gt;
==== Use player color in template ====&lt;br /&gt;
&lt;br /&gt;
NOTE: view.php is deprecated, its best to generate html from .js&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Ingredients:&#039;&#039;&#039; ggg_ggg.tpl, ggg.view.php&lt;br /&gt;
&lt;br /&gt;
.view.php:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    function build_page($viewArgs) {&lt;br /&gt;
        // Get players &amp;amp; players number&lt;br /&gt;
        $players = $this-&amp;gt;game-&amp;gt;loadPlayersBasicInfos();&lt;br /&gt;
        $players_nbr = count($players);&lt;br /&gt;
        /**&lt;br /&gt;
         * ********* Place your code below: ***********&lt;br /&gt;
         */&lt;br /&gt;
        &lt;br /&gt;
        // Set PCOLOR to the current player color hex&lt;br /&gt;
        $cplayer = $this-&amp;gt;getCurrentPlayerId();&lt;br /&gt;
        if (array_key_exists($cplayer, $players)) { // may be not set if spectator&lt;br /&gt;
            $player_color = $players [$cplayer] [&#039;player_color&#039;];&lt;br /&gt;
        } else {&lt;br /&gt;
            $player_color = &#039;ffffff&#039;; // spectator&lt;br /&gt;
        }&lt;br /&gt;
        $this-&amp;gt;tpl [&#039;PCOLOR&#039;] = $player_color;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Status bar ===&lt;br /&gt;
&lt;br /&gt;
==== Changing state prompt ====&lt;br /&gt;
&lt;br /&gt;
State prompt is message displayed for player which usually comes from state description.&lt;br /&gt;
Sometimes you want to change it without changing state (one way is change state but locally, see client states above).&lt;br /&gt;
&lt;br /&gt;
Simple way just change the html&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
        setMainTitle: function(text) {&lt;br /&gt;
            $(&#039;pagemaintitletext&#039;).innerHTML = text;&lt;br /&gt;
        },&lt;br /&gt;
         // usage&lt;br /&gt;
        onMeeple: function(event) {&lt;br /&gt;
              //... &lt;br /&gt;
              this.setMainTitle(_(&#039;You must select where meeple is going&#039;));&lt;br /&gt;
        },&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This however will not work with parameters and will not draw You in color, if you want this its more sophisticated:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
        setDescriptionOnMyTurn : function(text) {&lt;br /&gt;
            this.gamedatas.gamestate.descriptionmyturn = text;&lt;br /&gt;
            var tpl = dojo.clone(this.gamedatas.gamestate.args);&lt;br /&gt;
            if (tpl === null) {&lt;br /&gt;
                tpl = {};&lt;br /&gt;
            }&lt;br /&gt;
            var title = &amp;quot;&amp;quot;;&lt;br /&gt;
            if (this.isCurrentPlayerActive() &amp;amp;&amp;amp; text !== null) {&lt;br /&gt;
                tpl.you = this.divYou(); &lt;br /&gt;
            }&lt;br /&gt;
            title = this.format_string_recursive(text, tpl);&lt;br /&gt;
&lt;br /&gt;
            if (!title) {&lt;br /&gt;
                this.setMainTitle(&amp;quot;&amp;amp;nbsp;&amp;quot;);&lt;br /&gt;
            } else {&lt;br /&gt;
                this.setMainTitle(title);&lt;br /&gt;
            }&lt;br /&gt;
        },&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: this method uses &#039;&#039;&#039;setMainTitle&#039;&#039;&#039; defined above and &#039;&#039;&#039;divYou&#039;&#039;&#039; defined in another section of this wiki.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Animation ===&lt;br /&gt;
&lt;br /&gt;
==== Attach to new parent without destroying the object ====&lt;br /&gt;
&lt;br /&gt;
BGA function attachToNewParent for some reason destroys the original, if you want similar function that does not you can use this&lt;br /&gt;
ggg.js&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
        /**&lt;br /&gt;
         * This method will attach mobile to a new_parent without destroying, unlike original attachToNewParent which destroys mobile and&lt;br /&gt;
         * all its connectors (onClick, etc)&lt;br /&gt;
         */&lt;br /&gt;
        attachToNewParentNoDestroy: function (mobile_in, new_parent_in, relation, place_position) {&lt;br /&gt;
&lt;br /&gt;
            const mobile = $(mobile_in);&lt;br /&gt;
            const new_parent = $(new_parent_in);&lt;br /&gt;
&lt;br /&gt;
            var src = dojo.position(mobile);&lt;br /&gt;
            if (place_position)&lt;br /&gt;
                mobile.style.position = place_position;&lt;br /&gt;
            dojo.place(mobile, new_parent, relation);&lt;br /&gt;
            mobile.offsetTop;//force re-flow&lt;br /&gt;
            var tgt = dojo.position(mobile);&lt;br /&gt;
            var box = dojo.marginBox(mobile);&lt;br /&gt;
            var cbox = dojo.contentBox(mobile);&lt;br /&gt;
            var left = box.l + src.x - tgt.x;&lt;br /&gt;
            var top = box.t + src.y - tgt.y;&lt;br /&gt;
&lt;br /&gt;
            mobile.style.position = &amp;quot;absolute&amp;quot;;&lt;br /&gt;
            mobile.style.left = left + &amp;quot;px&amp;quot;;&lt;br /&gt;
            mobile.style.top = top + &amp;quot;px&amp;quot;;&lt;br /&gt;
            box.l += box.w - cbox.w;&lt;br /&gt;
            box.t += box.h - cbox.h;&lt;br /&gt;
            mobile.offsetTop;//force re-flow&lt;br /&gt;
            return box;&lt;br /&gt;
        },&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Animation on oversurface ====&lt;br /&gt;
If you use non-absolute position for your game elements (i.e you use layouts) - you cannot really use BGA animation functions. After years of fidding with different options I use&lt;br /&gt;
techique which I call animation on oversurface that works when parents use different zoom, rotation, etc&lt;br /&gt;
&lt;br /&gt;
* You need another layer on top of everything - oversurface&lt;br /&gt;
* We create copy of the object on oversurface - to move&lt;br /&gt;
* We move the real object on final position - but make it invisible for now&lt;br /&gt;
* We move the phantom to final position applying required zoom and rotation (using css animation), then destroy it&lt;br /&gt;
* When animation is done we make original object visible in new position&lt;br /&gt;
&lt;br /&gt;
The code is bit complex it can be found here&lt;br /&gt;
&lt;br /&gt;
https://codepen.io/VictoriaLa/pen/gORvdJo&lt;br /&gt;
&lt;br /&gt;
Game using it: century, ultimaterailroads&lt;br /&gt;
&lt;br /&gt;
==== Scroll element into view ====&lt;br /&gt;
Ingredients: game.js&lt;br /&gt;
&lt;br /&gt;
This function will scroll given node (div) into view and respect replays and archive mode&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    scrollIntoViewAfter: function (node, delay) {&lt;br /&gt;
      if (this.instantaneousMode || this.inSetup) {&lt;br /&gt;
        return;&lt;br /&gt;
      }&lt;br /&gt;
      if (typeof g_replayFrom != &amp;quot;undefined&amp;quot;) {&lt;br /&gt;
        $(node).scrollIntoView();&lt;br /&gt;
        return;&lt;br /&gt;
      }&lt;br /&gt;
      if (!delay) delay = 0;&lt;br /&gt;
      setTimeout(() =&amp;gt; {&lt;br /&gt;
        $(node).scrollIntoView({ behavior: &amp;quot;smooth&amp;quot;, block: &amp;quot;center&amp;quot; });&lt;br /&gt;
      }, delay);&lt;br /&gt;
    },&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Set Auto-click timer for buttons (setAutoClick) ====&lt;br /&gt;
&lt;br /&gt;
Sets up auto-click for a button after a timeout, with the new progress-bar animation. Works in both JS and TS. You can pass the optional parameters (see code comments) or simply call as:&lt;br /&gt;
&amp;lt;pre&amp;gt;this.setAutoClick(document.getElementById(&#039;someID&#039;);&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;JavaScript&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/**&lt;br /&gt;
* Sets up auto-click functionality for a button after a timeout period&lt;br /&gt;
* @param button - The button HTML element to auto-click&lt;br /&gt;
* @param timeoutDuration - Optional base duration in ms before auto-click occurs (default: 5000)&lt;br /&gt;
* @param randomIncrement - Optional random additional ms to add to timeout (default: 2000)&lt;br /&gt;
* @param autoClickID - Optional ID for the auto-click events, multiple buttons can therefore point to the same autoClick event&lt;br /&gt;
* @param onAnimationEnd - Optional callback that returns boolean to control if click should occur (default: true)&lt;br /&gt;
*/&lt;br /&gt;
setAutoClick: function(button, timeoutDuration = 5000, randomIncrement = 2000, autoClickID = null, onAnimationEnd = () =&amp;gt; true) {&lt;br /&gt;
    const totalDuration = timeoutDuration + Math.random() * randomIncrement;&lt;br /&gt;
    this.setAutoClick.timeouts = this.setAutoClick.timeouts || {};&lt;br /&gt;
            &lt;br /&gt;
    if(!autoClickID){&lt;br /&gt;
        this.setAutoClick.autoClickIncrement = this.setAutoClick.autoClickIncrement || 1;&lt;br /&gt;
        autoClickID = &#039;auto-click-&#039; + this.setAutoClick.autoClickIncrement++;&lt;br /&gt;
    }&lt;br /&gt;
    this.setAutoClick.timeouts[autoClickID] = this.setAutoClick.timeouts[autoClickID] || [];&lt;br /&gt;
&lt;br /&gt;
    button.style.setProperty(&#039;--bga-autoclick-timeout-duration&#039;, `${totalDuration}ms`);&lt;br /&gt;
    button.classList.add(&#039;bga-autoclick-button&#039;);&lt;br /&gt;
&lt;br /&gt;
    const stopDoubleTrigger = () =&amp;gt; {&lt;br /&gt;
        if(!this.setAutoClick.timeouts[autoClickID]) return;&lt;br /&gt;
        this.setAutoClick.timeouts[autoClickID].forEach(timeout =&amp;gt; clearTimeout(timeout));&lt;br /&gt;
        delete this.setAutoClick.timeouts[autoClickID];&lt;br /&gt;
    }&lt;br /&gt;
    button.addEventListener(&#039;click&#039;, stopDoubleTrigger, true);&lt;br /&gt;
               &lt;br /&gt;
    this.setAutoClick.timeouts[autoClickID].push(&lt;br /&gt;
        setTimeout(() =&amp;gt; {&lt;br /&gt;
            stopDoubleTrigger();&lt;br /&gt;
            if (!document.body.contains(button)) return;&lt;br /&gt;
            const customEventResult = onAnimationEnd();&lt;br /&gt;
            if (customEventResult) button.click();&lt;br /&gt;
        }, totalDuration)&lt;br /&gt;
    );&lt;br /&gt;
},&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;TypeScript&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/**&lt;br /&gt;
* Sets up auto-click functionality for a button after a timeout period&lt;br /&gt;
* @param button - The button HTML element to auto-click&lt;br /&gt;
* @param timeoutDuration - Optional base duration in ms before auto-click occurs (default: 5000)&lt;br /&gt;
* @param randomIncrement - Optional random additional ms to add to timeout (default: 2000)&lt;br /&gt;
* @param autoClickID - Optional ID for the auto-click events, multiple buttons can therefore point to the same autoClick event&lt;br /&gt;
* @param onAnimationEnd - Optional callback that returns boolean to control if click should occur (default: true)&lt;br /&gt;
*/&lt;br /&gt;
public setAutoClick(button: HTMLDivElement, timeoutDuration: number = 5000, randomIncrement: number = 2000, autoClickID: string = null, onAnimationEnd: () =&amp;gt; boolean = () =&amp;gt; true){&lt;br /&gt;
    const fn = this.setAutoClick as typeof this.setAutoClick &amp;amp; {&lt;br /&gt;
        timeouts?: Record&amp;lt;string, number[]&amp;gt;;&lt;br /&gt;
        autoClickIncrement?: number;&lt;br /&gt;
    };&lt;br /&gt;
    fn.timeouts = fn.timeouts || {};&lt;br /&gt;
        &lt;br /&gt;
    const totalDuration = timeoutDuration + Math.random() * randomIncrement;&lt;br /&gt;
&lt;br /&gt;
    if(!autoClickID){&lt;br /&gt;
        fn.autoClickIncrement = fn.autoClickIncrement || 1;&lt;br /&gt;
        autoClickID = &#039;auto-click-&#039; + fn.autoClickIncrement++;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    fn.timeouts[autoClickID] = fn.timeouts[autoClickID] || [];&lt;br /&gt;
&lt;br /&gt;
    button.style.setProperty(&#039;--bga-autoclick-timeout-duration&#039;, `${totalDuration}ms`);&lt;br /&gt;
    button.classList.add(&#039;bga-autoclick-button&#039;);&lt;br /&gt;
&lt;br /&gt;
    const stopDoubleTrigger = () =&amp;gt; {&lt;br /&gt;
        if(!fn.timeouts[autoClickID]) return;&lt;br /&gt;
        fn.timeouts[autoClickID].forEach(timeout =&amp;gt; clearTimeout(timeout));&lt;br /&gt;
        delete fn.timeouts[autoClickID];&lt;br /&gt;
    }&lt;br /&gt;
    button.addEventListener(&#039;click&#039;, stopDoubleTrigger, true);&lt;br /&gt;
            &lt;br /&gt;
    fn.timeouts[autoClickID].push(&lt;br /&gt;
        setTimeout(() =&amp;gt; {&lt;br /&gt;
            stopDoubleTrigger();&lt;br /&gt;
            if (!document.body.contains(button)) return;&lt;br /&gt;
            const customEventResult = onAnimationEnd();&lt;br /&gt;
            if (customEventResult) button.click();&lt;br /&gt;
        }, totalDuration)&lt;br /&gt;
    );&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Logs ===&lt;br /&gt;
&lt;br /&gt;
==== Inject icon images in the log ====&lt;br /&gt;
&lt;br /&gt;
Here is an example of what was done for Terra Mystica which is simple and straightforward:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//Define the proper message&lt;br /&gt;
		$message = clienttranslate(&#039;${player_name} gets ${power_income} via Structures&#039;);&lt;br /&gt;
		if ($price &amp;gt; 0) {&lt;br /&gt;
			$this-&amp;gt;DbQuery(&amp;quot;UPDATE player SET player_score = player_score - $price WHERE player_id = $player_id&amp;quot;);&lt;br /&gt;
			$message = clienttranslate(&#039;${player_name} pays ${vp_price} and gets ${power_income} via Structures&#039;);&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
// Notify&lt;br /&gt;
		$this-&amp;gt;notify-&amp;gt;all( &amp;quot;powerViaStructures&amp;quot;, $message, array(&lt;br /&gt;
			&#039;i18n&#039; =&amp;gt; array( ),&lt;br /&gt;
			&#039;player_id&#039; =&amp;gt; $player_id,&lt;br /&gt;
			&#039;player_name&#039; =&amp;gt; $this-&amp;gt;getUniqueValueFromDb( &amp;quot;SELECT player_name FROM player WHERE player_id = $player_id&amp;quot; ),&lt;br /&gt;
			&#039;power_tokens&#039; =&amp;gt; $power_tokens,&lt;br /&gt;
			&#039;vp_price&#039; =&amp;gt; $this-&amp;gt;getLogsVPAmount($price),&lt;br /&gt;
			&#039;power_income&#039; =&amp;gt; $this-&amp;gt;getLogsPowerAmount($power_income),&lt;br /&gt;
			&#039;newScore&#039; =&amp;gt; $this-&amp;gt;getUniqueValueFromDb( &amp;quot;SELECT player_score FROM player WHERE player_id = $player_id&amp;quot; ),&lt;br /&gt;
			&#039;counters&#039; =&amp;gt; $this-&amp;gt;getGameCounters(null),&lt;br /&gt;
		) );&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With some functions to have the needed html added inside the substitution variable, such as:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function getLogsPowerAmount( $amount ) {&lt;br /&gt;
		return &amp;quot;&amp;lt;div class=&#039;tmlogs_icon&#039; title=&#039;Power&#039;&amp;gt;&amp;lt;div class=&#039;power_amount&#039;&amp;gt;$amount&amp;lt;/div&amp;gt;&amp;lt;/div&amp;gt;&amp;quot;;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Note: injecting html from php is not ideal but easy, if you want more clean solution, use method below but it is a lot more sophisticated.&lt;br /&gt;
&lt;br /&gt;
==== Inject images and styled html in the log ====&lt;br /&gt;
&lt;br /&gt;
{{InfoBox|title=Warning — Translation|maxWidth=500|color=#c00|body=&#039;&#039;&#039;In order to prevent interference with the translation process, keep in mind that you must only apply modifications to the args object, and not try to substitute the keys (the &amp;lt;code&amp;gt;${player_name}&amp;lt;/code&amp;gt; parts of your string) in the log string.&#039;&#039;&#039;}}&lt;br /&gt;
&lt;br /&gt;
So you want nice pictures in the game log. What do you do? The first idea that comes to mind is to send html from php in notifications (see method above). &lt;br /&gt;
&lt;br /&gt;
This is a bad idea for many reasons:&lt;br /&gt;
&lt;br /&gt;
* It&#039;s bad architecture. ui elements leak into the server, and now you have to manage the ui in multiple places.&lt;br /&gt;
* If you decided to change something in the ui in future version, replay logs for old games and tutorials may not work, since they use stored notifications.&lt;br /&gt;
* Log previews for old games become unreadable. (This is the log state before you enter the game replay, which is useful for troubleshooting and game analysis.)&lt;br /&gt;
* It&#039;s more data to transfer and store in the db.&lt;br /&gt;
* It&#039;s a nightmare for translators.&lt;br /&gt;
&lt;br /&gt;
So what else can you do? You can use client side log injection to intercept log arguments (which come from the server) and replace them with html on the client side. Here are three different method you can use to achieve this.&lt;br /&gt;
&lt;br /&gt;
===== Define &amp;lt;code&amp;gt;this.bgaFormatText()&amp;lt;/code&amp;gt; method =====&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Ingredients:&#039;&#039;&#039; ggg.js, ggg.game.php&lt;br /&gt;
&lt;br /&gt;
I use this recipe for &#039;&#039;&#039;client side log injection&#039;&#039;&#039; to intercept log arguments (which come from the server) and replace them with html on the client side.&lt;br /&gt;
&lt;br /&gt;
[[File:clientloginjection.png|left]] &lt;br /&gt;
&lt;br /&gt;
ggg.js&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
        /** Declare this function to inject html into log items. */&lt;br /&gt;
&lt;br /&gt;
        bgaFormatText : function(log, args) {&lt;br /&gt;
            try {&lt;br /&gt;
                if (log &amp;amp;&amp;amp; args &amp;amp;&amp;amp; !args.processed) {&lt;br /&gt;
                    args.processed = true;&lt;br /&gt;
                    &lt;br /&gt;
&lt;br /&gt;
                    // list of special keys we want to replace with images&lt;br /&gt;
                    const keys = [&#039;place_name&#039;,&#039;token_name&#039;];&lt;br /&gt;
                    &lt;br /&gt;
                  &lt;br /&gt;
                    for (let i in keys) {&lt;br /&gt;
                        const key = keys[i];&lt;br /&gt;
                        if (args[key]) args[key] = this.getTokenDiv(key, args);                            &lt;br /&gt;
&lt;br /&gt;
                    }&lt;br /&gt;
                }&lt;br /&gt;
            } catch (e) {&lt;br /&gt;
                console.error(log,args,&amp;quot;Exception thrown&amp;quot;, e.stack);&lt;br /&gt;
            }&lt;br /&gt;
            return { log, args };&lt;br /&gt;
        },&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Important:&#039;&#039;&#039; In the &#039;&#039;bgaFormatText&#039;&#039; method, the &#039;args&#039; parameter will only contain arguments passed to it from the notify method in Game.php (see below).&lt;br /&gt;
&lt;br /&gt;
The &#039;log&#039; parameter is the actual string that is inserted into the logs. You can perform additional js string manipulation on it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
        getTokenDiv : function(key, args) {&lt;br /&gt;
            // ... implement whatever html you want here, example from sharedcode.js&lt;br /&gt;
            var token_id = args[key];&lt;br /&gt;
            var item_type = getPart(token_id,0);&lt;br /&gt;
            var logid = &amp;quot;log&amp;quot; + (this.globalid++) + &amp;quot;_&amp;quot; + token_id;&lt;br /&gt;
            switch (item_type) {&lt;br /&gt;
                case &#039;wcube&#039;:&lt;br /&gt;
                    var tokenDiv = this.format_block(&#039;jstpl_resource_log&#039;, {&lt;br /&gt;
                        &amp;quot;id&amp;quot; : logid,&lt;br /&gt;
                        &amp;quot;type&amp;quot; : &amp;quot;wcube&amp;quot;,&lt;br /&gt;
                        &amp;quot;color&amp;quot; : getPart(token_id,1),&lt;br /&gt;
                    });&lt;br /&gt;
                    return tokenDiv;&lt;br /&gt;
             &lt;br /&gt;
                case &#039;meeple&#039;:&lt;br /&gt;
                    if ($(token_id)) {&lt;br /&gt;
                        var clone = dojo.clone($(token_id));&lt;br /&gt;
    &lt;br /&gt;
                        dojo.attr(clone, &amp;quot;id&amp;quot;, logid);&lt;br /&gt;
                        this.stripPosition(clone);&lt;br /&gt;
                        dojo.addClass(clone, &amp;quot;logitem&amp;quot;);&lt;br /&gt;
                        return clone.outerHTML;&lt;br /&gt;
                    }&lt;br /&gt;
                    break;&lt;br /&gt;
     &lt;br /&gt;
                default:&lt;br /&gt;
                    break;&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            return &amp;quot;&#039;&amp;quot; + this.clienttranslate_string(this.getTokenName(token_id)) + &amp;quot;&#039;&amp;quot;;&lt;br /&gt;
       },&lt;br /&gt;
       getTokenName : function(key) {&lt;br /&gt;
           return this.gamedatas.token_types[key].name; // get name for the key, from static table for example&lt;br /&gt;
       },&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that in this case the server simply injects token_id as a name, and the client substitutes it for the translated name or the picture.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Game.php:&lt;br /&gt;
&lt;br /&gt;
           $this-&amp;gt;notify-&amp;gt;all(&#039;playerLog&#039;, clienttranslate(&#039;Game moves ${token_name}&#039;), [&#039;token_name&#039;=&amp;gt;$token_id]);&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Important:&#039;&#039;&#039; As noted above, only arguments actually passed by this method are available to the args parameter received in the client-side &#039;&#039;bgaFormatText&#039;&#039; method.&lt;br /&gt;
&lt;br /&gt;
Sometimes it is the case that you want to pass arguments that are not actually included in the output message. For example, suppose we have a method like this:&lt;br /&gt;
&lt;br /&gt;
           $this-&amp;gt;notify-&amp;gt;all(&#039;tokenPlaced&#039;, clienttranslate(&#039;Player placed ${token_name}&#039;), array(&lt;br /&gt;
              &#039;token_name&#039; =&amp;gt; $token_id,&lt;br /&gt;
              &#039;zone_played&#039; =&amp;gt; $zone);&lt;br /&gt;
&lt;br /&gt;
This will output &amp;quot;Player placed ${token_name}&amp;quot; in the log, and if we subscribe to a notification method activated by the &amp;quot;tokenPlaced&amp;quot; event in the client-side code, that method can make use of the &#039;zone_played&#039; argument. &lt;br /&gt;
&lt;br /&gt;
Now if you want to make some really cool things with game log, most probably you would need more arguments than are included in log message. The problem with that,&lt;br /&gt;
it will work at first, but if you reload game using F5 or when the game loads in turn based mode, you will loose your additional parameters, why? Because when game reloads it does not actually send same notifications, it sends special &amp;quot;hitstorical_log&amp;quot; notification where all  parameters not listed in the message are removed. In example above, field zone_played would be removed from historical log as it is not included in message of the notification. You can till preserve specific arguments in historical log by adding special field preserve to notification arguments like this:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
           $this-&amp;gt;notify-&amp;gt;all(&#039;tokenPlaced&#039;, clienttranslate(&#039;Player placed ${token_name}&#039;), array(&lt;br /&gt;
              &#039;token_name&#039; =&amp;gt; $token_id,&lt;br /&gt;
              &#039;zone_played&#039; =&amp;gt; $zone,&lt;br /&gt;
              &#039;preserve&#039; =&amp;gt; [ &#039;zone_played&#039; ]&lt;br /&gt;
           );&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you can use zone_played in bgaFormatText even in historical logs.&lt;br /&gt;
&lt;br /&gt;
===== Use &amp;lt;code&amp;gt;:formatFunction&amp;lt;/code&amp;gt; option provided by &amp;lt;code&amp;gt;dojo.string.substitute&amp;lt;/code&amp;gt; =====&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Ingredients:&#039;&#039;&#039; ggg.js, ggg.game.php, ggg_ggg.tpl, ggg.css&lt;br /&gt;
&lt;br /&gt;
The above method will work in most of the cases, but if you use dotted keys such as &amp;lt;code&amp;gt;${card.name}&amp;lt;/code&amp;gt; (which is supported by the framework, for private state args), the key won&#039;t be substituted because the &amp;lt;code&amp;gt;key in arg&amp;lt;/code&amp;gt; test will fail. If so you need to rely either on this way, or the one after.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING:&#039;&#039;&#039; using this method on an already advanced project will require you to go through all your notifications to change keys !&lt;br /&gt;
&lt;br /&gt;
Under the hood, the &#039;&#039;&#039;this.format_string_recursive()&#039;&#039;&#039; function calls the &#039;&#039;&#039;dojo.string.substitute&#039;&#039;&#039; method which substitutes &amp;lt;code&amp;gt;${keys}&amp;lt;/code&amp;gt; with the value provided. If you take a look at the [https://dojotoolkit.org/reference-guide/1.7/dojo/string.html#substitute documentation] and [https://github.com/dojo/dojo/blob/c3ceb017cfa25b703f5662dc83d1c8aae9bc5d81/string.js#L163 source code] you can notice that the key can be suffixed with a colon (&amp;lt;code&amp;gt;:&amp;lt;/code&amp;gt;) followed by a function name. This will allow you to specify directly in the substitution string which keys need HTML injection.&lt;br /&gt;
&lt;br /&gt;
First of all, you need to define your formatting function in the ggg.js file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[[ggg.js]]&lt;br /&gt;
        getTokenDiv : function(value, key) {&lt;br /&gt;
            //This is only an example implementation, you need to write your own.&lt;br /&gt;
            //The method should return HTML code&lt;br /&gt;
            switch (key) {&lt;br /&gt;
                case &#039;html_injected_argument1&#039;:&lt;br /&gt;
                    return this.format_block(&#039;jstpl_HTMLLogElement1&#039;,{value: value});&lt;br /&gt;
                case &#039;html_injected_argument2&#039;:&lt;br /&gt;
                    return this.format_block(&#039;jstpl_HTMLLogElement2&#039;,{value: value});&lt;br /&gt;
                ...&lt;br /&gt;
            }&lt;br /&gt;
       }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Obviously you need to define the appropriate templates in the ggg_ggg.tpl file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[[ggg_ggg.tpl]]&lt;br /&gt;
let jstpl_HTMLLogElement1 = &#039;&amp;lt;div class=&amp;quot;log-element log-element-1-${value}&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&#039;;&lt;br /&gt;
let jstpl_HTMLLogElement2 = &#039;&amp;lt;div class=&amp;quot;log-element log-element-2-${value}&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&#039;;&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
And the appropriate classes in ggg.css.&lt;br /&gt;
&lt;br /&gt;
Then you need to add the &amp;lt;code&amp;gt;dojo/aspect&amp;lt;/code&amp;gt; module at the top of the ggg.js file:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;[[ggg.js]]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 define([&lt;br /&gt;
     &amp;quot;dojo&amp;quot;, &amp;quot;dojo/_base/declare&amp;quot;,&lt;br /&gt;
     &#039;&#039;&#039;&amp;lt;span style=&amp;quot;color:green;&amp;quot;&amp;gt;&amp;quot;dojo/aspect&amp;quot;,&amp;lt;/span&amp;gt;                 //MUST BE IN THIRD POSITION&#039;&#039;&#039; (see [[#Including your own JavaScript module (II)|below]])&lt;br /&gt;
     &amp;quot;ebg/core/gamegui&amp;quot;,&lt;br /&gt;
     &amp;quot;ebg/counter&amp;quot;,&lt;br /&gt;
 ], function (dojo, declare, &amp;lt;span style=&amp;quot;color:green;&amp;quot;&amp;gt;&#039;&#039;&#039;aspect&#039;&#039;&#039;&amp;lt;/span&amp;gt;) {&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
And you also need to add the following code in your &amp;lt;code&amp;gt;contructor&amp;lt;/code&amp;gt; method in the ggg.js:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;[[ggg.js]]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
         constructor: function(){&lt;br /&gt;
&lt;br /&gt;
             // ... skipped code ...&lt;br /&gt;
             let gameObject = this;            //Needed as the this object in aspect.before will not refer to the game object in which the formatting function resides&lt;br /&gt;
             aspect.before(dojo.string, &amp;quot;substitute&amp;quot;, function(template, map, transform) {      //This allows you to modify the arguments of the dojo.string.substitute method before they&#039;re actually passed to it&lt;br /&gt;
                 return [template, map, transform, gameObject];&lt;br /&gt;
             });&lt;br /&gt;
&lt;br /&gt;
Now you&#039;re all set to inject HTML in your logs. To actually achieve this, you must specify the function name with the key like so:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;[[ggg.game.php]]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 $this-&amp;gt;notify-&amp;gt;all(&amp;quot;notificationName&amp;quot;, clienttranslate(&amp;quot;This log message contains ${plainTextArgument} and the following will receive HTML injection: ${html_injected_argument1:getTokenDiv}&amp;quot;), [&lt;br /&gt;
     &amp;quot;plainTextArgument&amp;quot; =&amp;gt; &amp;quot;some plain text here&amp;quot;,&lt;br /&gt;
     &amp;quot;html_injected_argument1&amp;quot; =&amp;gt; &amp;quot;some value used by getTokenDiv&amp;quot;,&lt;br /&gt;
 ]);&lt;br /&gt;
&lt;br /&gt;
You&#039;re not limited writing only one function, you can write as many functions as you like, and have them each inject a specific type of HTML. You just need to specify the relevant function name after the column in the substitution key.&lt;br /&gt;
&lt;br /&gt;
===== Use &amp;lt;code&amp;gt;transform&amp;lt;/code&amp;gt; argument of &amp;lt;code&amp;gt;dojo.string.substitute&amp;lt;/code&amp;gt; =====&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Ingredients:&#039;&#039;&#039; ggg.js, ggg.game.php, ggg_ggg.tpl, ggg.css&lt;br /&gt;
&lt;br /&gt;
This method is also relying on the use of &amp;lt;code&amp;gt;dojo.string.substitute&amp;lt;/code&amp;gt; by the framework, and will use the &amp;lt;code&amp;gt;transform&amp;lt;/code&amp;gt; argument, which, accordting to [https://github.com/dojo/dojo/blob/c3ceb017cfa25b703f5662dc83d1c8aae9bc5d81/string.js#L163 source code] and [https://dojotoolkit.org/reference-guide/1.7/dojo/string.html#substitute documentation] will be run on all the messages going through dojo.string.substitute.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;WARNING:&#039;&#039;&#039; This method will be applied to all strings that go through dojo.string.substitute. As such you must take extra care not to substitute keys that may be used by the framework (i.e. ${id}). In order to do so, a good practise would be to prefix all keys that need substitution with a trigram of the game name.&lt;br /&gt;
&lt;br /&gt;
Since all the keys will be fed to the tranform function, by default, it must return the value, substituted or not per your needs. You can define the function like this in the ggg.js file:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;[[ggg.js]]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
         getTokenDiv : function(value, key) {&lt;br /&gt;
             //This is only an example implementation, you need to write your own.&lt;br /&gt;
             //The method should return HTML code&lt;br /&gt;
             switch (key) {&lt;br /&gt;
                 case &#039;html_injected_argument1&#039;:&lt;br /&gt;
                     return this.format_block(&#039;jstpl_HTMLLogElement1&#039;,{value: value});&lt;br /&gt;
                 case &#039;html_injected_argument2&#039;:&lt;br /&gt;
                     return this.format_block(&#039;jstpl_HTMLLogElement2&#039;,{value: value});&lt;br /&gt;
                 ...&lt;br /&gt;
                 default:&lt;br /&gt;
                     return value; //Needed otherwise regular strings won&#039;t appear since since the value isn&#039;t returned by the function&lt;br /&gt;
             }&lt;br /&gt;
         }&lt;br /&gt;
&lt;br /&gt;
The templates must be defined in the ggg_ggg.tpl file and the corresponding CSS classes in the ggg.css file.&lt;br /&gt;
&lt;br /&gt;
You need to add the following code at the beginning of the ggg.js file:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;[[ggg.js]]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 define([&lt;br /&gt;
     &amp;quot;dojo&amp;quot;, &amp;quot;dojo/_base/declare&amp;quot;,&lt;br /&gt;
     &#039;&#039;&#039;&amp;lt;span style=&amp;quot;color:green;&amp;quot;&amp;gt;&amp;quot;dojo/aspect&amp;quot;,&amp;lt;/span&amp;gt;                 //MUST BE IN THIRD POSITION&#039;&#039;&#039; (see [[#Including your own JavaScript module (II)|below]])&lt;br /&gt;
     &amp;quot;ebg/core/gamegui&amp;quot;,&lt;br /&gt;
     &amp;quot;ebg/counter&amp;quot;,&lt;br /&gt;
 ], function (dojo, declare, &amp;lt;span style=&amp;quot;color:green;&amp;quot;&amp;gt;&#039;&#039;&#039;aspect&#039;&#039;&#039;&amp;lt;/span&amp;gt;) {&lt;br /&gt;
 ...&lt;br /&gt;
And the following code to the &amp;lt;code&amp;gt;constructor&amp;lt;/code&amp;gt; method in ggg.js:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;[[ggg.js]]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
         constructor: function(){&lt;br /&gt;
             // ... skipped code ...&lt;br /&gt;
             let transformFunction = dojo.hitch(this, &amp;quot;getTokenDiv&amp;quot;);          //Needed as the this object in aspect.before will not refer to the game object in which the formatting function resides&lt;br /&gt;
             aspect.before(dojo.string, &amp;quot;substitute&amp;quot;, function(template, map, transform) {&lt;br /&gt;
                 if (undefined === transform) {    //Check for a transform function presence, just in case&lt;br /&gt;
                     return [template, map, transformFunction];&lt;br /&gt;
                 }&lt;br /&gt;
             });&lt;br /&gt;
Then you&#039;re all set for log injection, no need to change anything on the PHP side.&lt;br /&gt;
&lt;br /&gt;
==== Processing logs on re-loading ====&lt;br /&gt;
&lt;br /&gt;
You rarely need to process logs when reloading, but if you want to do something fancy you may have to do it after logs are loaded. &lt;br /&gt;
Logs are loaded asyncronously so you have to listen for logs to be fully loaded.&lt;br /&gt;
Unfortunately there is no direct way of doing it so this is the hack.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Hack alert&#039;&#039;&#039; - this extends undocumented function and may be broken when framework is updated&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Ingredients:&#039;&#039;&#039; ggg.js&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
			/*&lt;br /&gt;
  			* [Undocumented] Override BGA framework functions to call onLoadingLogsComplete when loading is done&lt;br /&gt;
                        @Override&lt;br /&gt;
   			*/&lt;br /&gt;
			setLoader: function(image_progress, logs_progress) {&lt;br /&gt;
				this.inherited(arguments); // required, this is &amp;quot;super()&amp;quot; call, do not remove&lt;br /&gt;
				//console.log(&amp;quot;loader&amp;quot;, image_progress, logs_progress)&lt;br /&gt;
				if (!this.isLoadingLogsComplete &amp;amp;&amp;amp; logs_progress &amp;gt;= 100) {&lt;br /&gt;
					this.isLoadingLogsComplete = true; // this is to prevent from calling this more then once&lt;br /&gt;
					this.onLoadingLogsComplete();&lt;br /&gt;
				}&lt;br /&gt;
			},&lt;br /&gt;
&lt;br /&gt;
			onLoadingLogsComplete: function() {&lt;br /&gt;
				console.log(&#039;Loading logs complete&#039;);&lt;br /&gt;
				// do something here&lt;br /&gt;
			},&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Overriding format_string_recursive to inject HTML into log, including adding tooltips to log====&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Ingredients:&#039;&#039;&#039; ggg.js&lt;br /&gt;
&lt;br /&gt;
I&#039;m using cards as an example but this will work with any type of resource or game element. The first step is to override format_string_recursive. You can find info about this in this [https://bga-devs.github.io/blog/posts/translations-summary/ excellent guide]. We will replace the return line from the guide with this:&lt;br /&gt;
 return this.logInject(text);&lt;br /&gt;
The purpose of logInject() is to catch pre-coded text from your notifications, siphon out the meaningful info so that you can manipulate it on the front end, and then replace that pre-coded text in the log with whatever html you desire, as well as adding a tooltip to the element you&#039;re injecting. Here is a simplified version of logInject():&lt;br /&gt;
 logInject: function (log_entry) {&lt;br /&gt;
     const card_regex = /\[\w+-*\w* *\w*\(\d+\)\]/g;    // this will catch a card name in the log formatted like so: [card_name(card_type_arg)] -You may need to adjust the regex to catch your card names&lt;br /&gt;
     const cards_to_replace = log_entry.matchAll(card_regex);&lt;br /&gt;
     for (let card of cards_to_replace) {&lt;br /&gt;
         const match = card[0];&lt;br /&gt;
         const left_parenthesis = match.indexOf(&#039;(&#039;);&lt;br /&gt;
         const card_type_arg = match.slice(left_parenthesis+1, match.length-2);&lt;br /&gt;
         const card_span = this.getHTMLForLog(card_type_arg, &#039;card&#039;);&lt;br /&gt;
         log_entry = log_entry.replace(match, card_span);&lt;br /&gt;
     }&lt;br /&gt;
     return log_entry;&lt;br /&gt;
 }&lt;br /&gt;
getHTMLForLog() takes the card_type_arg and uses it to create the &amp;lt;nowiki&amp;gt;&amp;lt;span&amp;gt; to be injected into the log that you can then attach a tooltip to:&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 getHTMLForLog: function (item, type) {   // in this example, item refers to the card_type_arg&lt;br /&gt;
     switch(type) {&lt;br /&gt;
         case &#039;card&#039;:&lt;br /&gt;
             this.log_span_num++; // adds a unique num to the span id so that duplicate card names in the log have unique ids&lt;br /&gt;
             const card_name = this.gamedatas[&#039;cards&#039;][item][&#039;description&#039;];  // or wherever you store your translated card name&lt;br /&gt;
             const item_type = &#039;card_tt&#039;;&lt;br /&gt;
             return `&amp;lt;nowiki&amp;gt;&amp;lt;span id=&amp;quot;${this.log_span_num}_item_${item}&amp;quot; class=&amp;quot;${item_type} item_tooltip&amp;quot;&amp;gt;${card_name}&amp;lt;/span&amp;gt;&amp;lt;/nowiki&amp;gt;`;&lt;br /&gt;
     }&lt;br /&gt;
 }&lt;br /&gt;
If you only want to add some HTML to your log and don&#039;t care about the tooltips, you can remove the item_tooltip class from the above and stop here. If you want tooltips, you&#039;ll need a function to add them:&lt;br /&gt;
 addTooltipsToLog: function() {&lt;br /&gt;
 &amp;lt;nowiki&amp;gt; &amp;lt;/nowiki&amp;gt;   const item_elements = dojo.query(&#039;.item_tooltip:not(.tt_processed)&#039;);&lt;br /&gt;
 &amp;lt;nowiki&amp;gt; &amp;lt;/nowiki&amp;gt;   Array.from(item_elements).forEach(ele =&amp;gt; {&lt;br /&gt;
 &amp;lt;nowiki&amp;gt; &amp;lt;/nowiki&amp;gt;       const ele_id = ele.id;&lt;br /&gt;
 &amp;lt;nowiki&amp;gt; &amp;lt;/nowiki&amp;gt;       ele.classList.add(&#039;tt_processed&#039;);  // prevents tooltips being re-added to previous log entries&lt;br /&gt;
 &amp;lt;nowiki&amp;gt; &amp;lt;/nowiki&amp;gt;       if (ele.classList.contains(&#039;card_tt&#039;)) {&lt;br /&gt;
 &amp;lt;nowiki&amp;gt; &amp;lt;/nowiki&amp;gt;           const card_type_arg = ele_id.slice(-3).replace(/^\D+/g, &amp;lt;nowiki&amp;gt;&#039;&#039;&amp;lt;/nowiki&amp;gt;);  // extracts the card_type_arg from the span id&lt;br /&gt;
 &amp;lt;nowiki&amp;gt; &amp;lt;/nowiki&amp;gt;           this.cardTooltip(ele_id, card_type_arg)&lt;br /&gt;
 &amp;lt;nowiki&amp;gt; &amp;lt;/nowiki&amp;gt;       }&lt;br /&gt;
 &amp;lt;nowiki&amp;gt; &amp;lt;/nowiki&amp;gt;   });&lt;br /&gt;
 }&lt;br /&gt;
cardTooltip() is just however you want to create and add your tooltip. Mine is below:&lt;br /&gt;
 cardTooltip: function (ele, card_type_arg) {&lt;br /&gt;
     const card = this.gamedatas.cards[card_type_arg];&lt;br /&gt;
     const bg_pos = card[&#039;x_y&#039;];&lt;br /&gt;
     const skill = dojo.string.substitute(&amp;quot;${skill}&amp;quot;, { skill: card[&#039;skill&#039;] });&lt;br /&gt;
     const description = dojo.string.substitute(&amp;quot;${description}&amp;quot;, { description: card[&#039;description&#039;] });&lt;br /&gt;
     const html = `&amp;lt;nowiki&amp;gt;&amp;lt;div style=&amp;quot;margin-bottom: 5px; display: inline;&amp;quot;&amp;gt;&amp;lt;strong&amp;gt;${description}&amp;lt;/strong&amp;gt;&amp;lt;/nowiki&amp;gt;&amp;lt;nowiki&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
                   &amp;lt;nowiki&amp;gt;&amp;lt;span style=&amp;quot;font-size: 10px; margin-left: 5px;&amp;quot;&amp;gt;${skill}&amp;lt;/span&amp;gt;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
                   &amp;lt;nowiki&amp;gt;&amp;lt;div class=&amp;quot;asset asset_tt&amp;quot; style=&amp;quot;background-position: -${bg_pos[0]}% -${bg_pos[1]}%; margin-bottom: 5px;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;/nowiki&amp;gt;`;&lt;br /&gt;
     this.addTooltipHTML(ele, html, 1000);&lt;br /&gt;
 }&lt;br /&gt;
And finally, you need to connect addTooltipsToLog to the notifqueue so it is called whenever the log is updated. This is in my JS setup:&lt;br /&gt;
 dojo.connect(this.notifqueue, &#039;addToLog&#039;, () =&amp;gt; {&lt;br /&gt;
     this.addTooltipsToLog();&lt;br /&gt;
 });&lt;br /&gt;
You can expand this to cover multiple types of tooltips. For example, I have it set up for cards: formatted in log as [card_name(card_type_arg)], hexes: formatted as {pitch_name(pitch_type_arg)}, objectives: formatted as ==objective_name(objective_type_arg)==, etc.&lt;br /&gt;
&lt;br /&gt;
===Player Panel===&lt;br /&gt;
&lt;br /&gt;
====Inserting non-player panel====&lt;br /&gt;
&#039;&#039;&#039;This should be avoided. The new guideline is to avoid it in new games and remove it from old games.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Ingredients:&#039;&#039;&#039; ggg.js, ggg_ggg.tpl&lt;br /&gt;
&lt;br /&gt;
If you want to insert non-player panel on the right side (for example to hold extra preferences, zooming controls, etc)&lt;br /&gt;
&lt;br /&gt;
this can go pretty much anywhere in template it will be moved later&lt;br /&gt;
&lt;br /&gt;
ggg_ggg.tpl:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
	&amp;lt;div class=&#039;player_board_config&#039; id=&amp;quot;player_board_config&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;!-- here is whatever you want, buttons just example --&amp;gt;&lt;br /&gt;
		&amp;lt;button id=&amp;quot;zoom-out&amp;quot; class=&amp;quot; fa fa-search-minus fa-2x config-control&amp;quot;&amp;gt;&amp;lt;/button&amp;gt;&lt;br /&gt;
		&amp;lt;button id=&amp;quot;zoom-in&amp;quot; class=&amp;quot; fa fa-search-plus fa-2x config-control&amp;quot;&amp;gt;&amp;lt;/button&amp;gt;&lt;br /&gt;
		&amp;lt;button id=&amp;quot;show-settings&amp;quot; class=&amp;quot;fa fa-cog fa-2x config-control &amp;quot;&amp;gt;&amp;lt;/button&amp;gt;&lt;br /&gt;
        &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
some hackery required in js&lt;br /&gt;
&lt;br /&gt;
ggg.js:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/* @Override */&lt;br /&gt;
	updatePlayerOrdering() {&lt;br /&gt;
		this.inherited(arguments);&lt;br /&gt;
		dojo.place(&#039;player_board_config&#039;, &#039;player_boards&#039;, &#039;first&#039;);&lt;br /&gt;
	},&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Images and Icons ===&lt;br /&gt;
&lt;br /&gt;
==== Accessing images from js ====&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Ingredients:&#039;&#039;&#039; ggg.js&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; &lt;br /&gt;
     // your game resources&lt;br /&gt;
     &lt;br /&gt;
     var my_img = &#039;&amp;lt;img src=&amp;quot;&#039;+g_gamethemeurl+&#039;img/cards.jpg&amp;quot;/&amp;gt;&#039;;&lt;br /&gt;
     &lt;br /&gt;
     // shared resources&lt;br /&gt;
     var my_help_img = &amp;quot;&amp;lt;img class=&#039;imgtext&#039; src=&#039;&amp;quot; + g_themeurl + &amp;quot;img/layout/help_click.png&#039; alt=&#039;action&#039; /&amp;gt; &amp;lt;span class=&#039;tooltiptext&#039;&amp;gt;&amp;quot; +&lt;br /&gt;
                    text + &amp;quot;&amp;lt;/span&amp;gt;&amp;quot;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====High-Definition Graphics====&lt;br /&gt;
&lt;br /&gt;
Some users will have screens which can display text and images at a greater resolution than the usual 72 dpi, e.g. the &amp;quot;Retina&amp;quot; screens on the 5k iMac, all iPads, and high-DPI screens on laptops from many manufacturers. If you can get art assets at this size, they will make your game look extra beautiful. You &#039;&#039;could&#039;&#039; just use large graphics and scale them down, but that would increase the download time and bandwidth for users who can&#039;t display them. Instead, a good way is to prepare a separate graphics file at exactly twice the size you would use otherwise, and add &amp;quot;@2x&amp;quot; at the end of the filename, e.g. if pieces.png is 240x320, then pieces@2x.png is 480x640.&lt;br /&gt;
&lt;br /&gt;
There are two changes required in order to use the separate graphics files. First in your css, where you use a file, add a media query which overrides the original definition and uses the bigger version on devices which can display them. Ensuring that the &amp;quot;background-size&amp;quot; attribute is set means that the size of the displayed object doesn&#039;t change, but only is drawn at the improved dot pitch.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
.piece {&lt;br /&gt;
    position: absolute;&lt;br /&gt;
    background-image: url(&#039;img/pieces.png&#039;);&lt;br /&gt;
    background-size:240px 320px;&lt;br /&gt;
    z-index: 10;&lt;br /&gt;
}&lt;br /&gt;
@media (-webkit-min-device-pixel-ratio: 2), (min-device-pixel-ratio: 2), (min-resolution: 192dpi)&lt;br /&gt;
{&lt;br /&gt;
    .piece {&lt;br /&gt;
        background-image: url(&#039;img/pieces@2x.png&#039;);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Secondly, in your setup function in javascript, you must ensure than only the appropriate one version of the file gets pre-loaded (otherwise you more than waste the bandwidth saved by maintaining the standard-resolution file). Note that the media query is the same in both cases:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
            var isRetina = &amp;quot;(-webkit-min-device-pixel-ratio: 2), (min-device-pixel-ratio: 2), (min-resolution: 192dpi)&amp;quot;;&lt;br /&gt;
            if (window.matchMedia(isRetina).matches)&lt;br /&gt;
            {&lt;br /&gt;
                this.dontPreloadImage( &#039;pieces.png&#039; );&lt;br /&gt;
                this.dontPreloadImage( &#039;board.jpg&#039; );&lt;br /&gt;
            }&lt;br /&gt;
            else&lt;br /&gt;
            {&lt;br /&gt;
                this.dontPreloadImage( &#039;pieces@2x.png&#039; );&lt;br /&gt;
                this.dontPreloadImage( &#039;board@2x.jpg&#039; );&lt;br /&gt;
            }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Using CSS to create different colors of game pieces if you have only white piece====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
background-color: #${color}; &lt;br /&gt;
background-blend-mode: multiply;&lt;br /&gt;
background-image: url( &#039;img/mypiece.png&#039;);&lt;br /&gt;
mask: url(&#039;img/mypiece.png&#039;);&lt;br /&gt;
-webkit-mask: url(&#039;img/mypiece.png&#039;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where ${color} - is color you want&lt;br /&gt;
&lt;br /&gt;
Note: piece has to be white (shades of gray). Sprite can be used too, just add add background-position as usual.&lt;br /&gt;
&lt;br /&gt;
==== Accessing player avatar URLs ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
      getPlayerAvatar(playerId) {&lt;br /&gt;
         let avatarURL = &#039;&#039;;&lt;br /&gt;
&lt;br /&gt;
         if (null != $(&#039;avatar_&#039; + playerId)) {&lt;br /&gt;
            let smallAvatarURL = dojo.attr(&#039;avatar_&#039; + playerId, &#039;src&#039;);&lt;br /&gt;
            avatarURL = smallAvatarURL.replace(&#039;_32.&#039;, &#039;_184.&#039;);&lt;br /&gt;
         }&lt;br /&gt;
         else {&lt;br /&gt;
            avatarURL = &#039;https://x.boardgamearena.net/data/data/avatar/default_184.jpg&#039;;&lt;br /&gt;
         }&lt;br /&gt;
&lt;br /&gt;
         return avatarURL;&lt;br /&gt;
      },&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note:  This gets avatar URLs at 184x184 resolution.  You can also use 92, 50, and 32 depending on which resolution you want.&lt;br /&gt;
&lt;br /&gt;
====Adding Image buttons====&lt;br /&gt;
&lt;br /&gt;
Its pretty trivial but just in case you need a working function:&lt;br /&gt;
&lt;br /&gt;
ggg.js:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
                addImageActionButton: function (id, div_html, handler) { // div_html is string not node&lt;br /&gt;
                    this.addActionButton(id, div_html, handler, &#039;&#039;, false, &#039;gray&#039;); &lt;br /&gt;
                    dojo.style(id, &amp;quot;border&amp;quot;, &amp;quot;none&amp;quot;); // remove ugly border&lt;br /&gt;
                    dojo.addClass(id, &amp;quot;bgaimagebutton&amp;quot;); // add css class to do more styling&lt;br /&gt;
                    return $(id); // return node for chaining&lt;br /&gt;
                },&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Example of usage:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    this.addImageActionButton(&#039;button_coin&#039;,&amp;quot;&amp;lt;div class=&#039;coin&#039;&amp;gt;&amp;lt;/div&amp;gt;&amp;quot;, ()=&amp;gt;{ alert(&#039;Ha!&#039;); });&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Other Fluff===&lt;br /&gt;
&lt;br /&gt;
====Use thematic fonts====&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Ingredients:&#039;&#039;&#039; ggg.css&lt;br /&gt;
&lt;br /&gt;
Sometime game elements use specific fonts of text, if you want to match it up you can load some specific font (IMPORTANT: from some &#039;&#039;&#039;free font&#039;&#039;&#039; source. See notes below).&lt;br /&gt;
&lt;br /&gt;
[[File:Dragonline_font.png]]&lt;br /&gt;
&lt;br /&gt;
.css&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/* latin-ext */&lt;br /&gt;
@font-face {&lt;br /&gt;
  font-family: &#039;Qwigley&#039;;&lt;br /&gt;
  font-style: normal;&lt;br /&gt;
  font-weight: 400;&lt;br /&gt;
  src: local(&#039;Qwigley&#039;), local(&#039;Qwigley-Regular&#039;), url(https://fonts.gstatic.com/s/qwigley/v6/2Dy1Unur1HJoklbsg4iPJ_Y6323mHUZFJMgTvxaG2iE.woff2) format(&#039;woff2&#039;);&lt;br /&gt;
  unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF;&lt;br /&gt;
}&lt;br /&gt;
/* latin */&lt;br /&gt;
@font-face {&lt;br /&gt;
  font-family: &#039;Qwigley&#039;;&lt;br /&gt;
  font-style: normal;&lt;br /&gt;
  font-weight: normal;&lt;br /&gt;
  src: local(&#039;Qwigley&#039;), local(&#039;Qwigley-Regular&#039;), url(https://fonts.gstatic.com/s/qwigley/v6/gThgNuQB0o5ITpgpLi4Zpw.woff2) format(&#039;woff2&#039;);&lt;br /&gt;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;&lt;br /&gt;
}&lt;br /&gt;
@font-face {&lt;br /&gt;
  font-family: &#039;Qwigley&#039;;&lt;br /&gt;
  font-style: normal;&lt;br /&gt;
  font-weight: normal;&lt;br /&gt;
  src: local(&#039;Qwigley&#039;), local(&#039;Qwigley-Regular&#039;), url(http://ff.static.1001fonts.net/q/w/qwigley.regular.ttf) format(&#039;ttf&#039;);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.zone_title {&lt;br /&gt;
	display: inline-block;&lt;br /&gt;
	position: absolute;&lt;br /&gt;
	font: italic 32px/32px &amp;quot;Qwigley&amp;quot;, cursive;	   &lt;br /&gt;
	height: 32px;&lt;br /&gt;
	width: auto;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NB:&#039;&#039;&#039; if you need to include a font that&#039;s not available online, an extra action will be needed from an admin. Please include the font file(s) in your img directory, and mention it to admins when requesting your game to be moved to alpha. &#039;&#039;&#039;Please remember that the font has to be free, and include a .txt with all appropriate license information about the font.&#039;&#039;&#039;&lt;br /&gt;
You can look for free fonts (for example) on https://fonts.google.com or https://www.fontsquirrel.com/)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Content Security Policy&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
BGA runs a Content Security Policy which will limit the origins from which you can load external fonts, in order to prevent license abuse.&lt;br /&gt;
&lt;br /&gt;
The CSP is a whitelist of allowed origins. To see the list, view the response headers of any page on Studio, and look for the &amp;quot;Content-Security-Policy&amp;quot; header.&lt;br /&gt;
&lt;br /&gt;
You will specifically want to check for the font-src token within these headers, and limit any external fonts to these sources.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;This list is subject to change&#039;&#039;&#039; but as of the time of writing, the only acceptabled external sites are use.typekit.net and fonts.gstatic.com.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Scale to fit for big boards===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Ingredients:&#039;&#039;&#039; ggg_ggg.tpl, ggg.js&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lets say you have huge game board, and lets say you want it to be 1400px wide. Besides the board there will be side bar which is 240 and trim. &lt;br /&gt;
My display is 1920 wide so it fits, but there is big chance other people won&#039;t have that width. What do you do?&lt;br /&gt;
&lt;br /&gt;
You have to decide:&lt;br /&gt;
* If board does not fit you want scale whole thing down, the best way is probably use viewport (see https://en.doc.boardgamearena.com/Your_game_mobile_version)&lt;br /&gt;
*You can leave the board as is and make sure it is scrollable horizonatally&lt;br /&gt;
*You add custom scale just for the board (can add user controls  - and hook to transform: scale())&lt;br /&gt;
&lt;br /&gt;
I tried to auto-scale but this just does work, too many variables - browser zoom, 3d mode, viewport, custom bga scaling, devicePixelRatio - all create some impossible coctail of zooming...&lt;br /&gt;
Here is scaling functing for custom user scaling&lt;br /&gt;
&lt;br /&gt;
ggg_ggg.tpl:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;thething&amp;quot; class=&amp;quot;thething&amp;quot;&amp;gt;&lt;br /&gt;
            ... everything else you declare ...&lt;br /&gt;
   &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ggg.js:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    onZoomPlus: function() {&lt;br /&gt;
       this.setZoom(this.zoom + 0.1);&lt;br /&gt;
    },&lt;br /&gt;
    onZoomMinus: function() {&lt;br /&gt;
       this.setZoom(this.zoom - 0.1);&lt;br /&gt;
    },&lt;br /&gt;
&lt;br /&gt;
    setZoom: function (zoom) {&lt;br /&gt;
      zoom = parseInt(zoom) || 0;&lt;br /&gt;
      if (zoom === 0 || zoom &amp;lt; 0.1 || zoom &amp;gt; 10) {&lt;br /&gt;
        zoom = 1;&lt;br /&gt;
      }&lt;br /&gt;
      this.zoom = zoom;&lt;br /&gt;
      var inner = document.getElementById(&amp;quot;thething&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
      if (zoom == 1) {&lt;br /&gt;
        inner.style.removeProperty(&amp;quot;transform&amp;quot;);&lt;br /&gt;
        inner.style.removeProperty(&amp;quot;width&amp;quot;);&lt;br /&gt;
      } else {&lt;br /&gt;
        inner.style.transform = &amp;quot;scale(&amp;quot; + zoom + &amp;quot;)&amp;quot;;&lt;br /&gt;
        inner.style.transformOrigin = &amp;quot;0 0&amp;quot;;&lt;br /&gt;
        inner.style.width = 100 / zoom + &amp;quot;%&amp;quot;;&lt;br /&gt;
      }&lt;br /&gt;
      localStorage.setItem(`${this.game_name}_zoom`, &amp;quot;&amp;quot; + this.zoom);&lt;br /&gt;
      this.onScreenWidthChange();&lt;br /&gt;
    },&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Dynamic tooltips===&lt;br /&gt;
&lt;br /&gt;
If you really need a dynamic tooltip you can use this technique. (Only use it if the static tooltips provided by the BGA framework are not sufficient.)&lt;br /&gt;
&lt;br /&gt;
            new dijit.Tooltip({&lt;br /&gt;
                connectId: [&amp;quot;divItemId&amp;quot;],&lt;br /&gt;
                getContent: function(matchedNode){&lt;br /&gt;
                    return &amp;quot;... calculated ...&amp;quot;; &lt;br /&gt;
                }&lt;br /&gt;
            });&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is an out-of-the-box djit.Tooltip. It has a &#039;&#039;getContent&#039;&#039; method which is called dynamically.&lt;br /&gt;
&lt;br /&gt;
The string returned by getContent() becomes the innerHTML of the tooltip, so it can be anything. In this example matchedNode is a dojo node representing dom object with id of &amp;quot;divItemId&amp;quot; but there are more parameters which I am not posting here which allows more sophisticated subnode queries (i.e. you can attach tooltip to all nodes with class or whatever).&lt;br /&gt;
&lt;br /&gt;
[https://dojotoolkit.org/reference-guide/1.10/dijit/Tooltip.html dijit.Tooltip]&lt;br /&gt;
&lt;br /&gt;
It&#039;s not part of the BGA API so use at your own risk.&lt;br /&gt;
&lt;br /&gt;
===Rendering text with players color and proper background===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Ingredients:&#039;&#039;&#039; ggg.js&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
        /* Implementation of proper colored You with background in case of white or light colors  */&lt;br /&gt;
 &lt;br /&gt;
        divYou: function() {&lt;br /&gt;
            var color = this.gamedatas.players[this.player_id].color;&lt;br /&gt;
            var color_bg = &amp;quot;&amp;quot;;&lt;br /&gt;
            if (this.gamedatas.players[this.player_id] &amp;amp;&amp;amp; this.gamedatas.players[this.player_id].color_back) {&lt;br /&gt;
                color_bg = &amp;quot;background-color:#&amp;quot; + this.gamedatas.players[this.player_id].color_back + &amp;quot;;&amp;quot;;&lt;br /&gt;
            }&lt;br /&gt;
            var you = &amp;quot;&amp;lt;span style=\&amp;quot;font-weight:bold;color:#&amp;quot; + color + &amp;quot;;&amp;quot; + color_bg + &amp;quot;\&amp;quot;&amp;gt;&amp;quot; + __(&amp;quot;lang_mainsite&amp;quot;, &amp;quot;You&amp;quot;) + &amp;quot;&amp;lt;/span&amp;gt;&amp;quot;;&lt;br /&gt;
            return you;&lt;br /&gt;
        },&lt;br /&gt;
&lt;br /&gt;
        /* Implementation of proper colored player name with background in case of white or light colors  */&lt;br /&gt;
&lt;br /&gt;
        divColoredPlayer: function(player_id) {&lt;br /&gt;
            var color = this.gamedatas.players[player_id].color;&lt;br /&gt;
            var color_bg = &amp;quot;&amp;quot;;&lt;br /&gt;
            if (this.gamedatas.players[player_id] &amp;amp;&amp;amp; this.gamedatas.players[player_id].color_back) {&lt;br /&gt;
                color_bg = &amp;quot;background-color:#&amp;quot; + this.gamedatas.players[player_id].color_back + &amp;quot;;&amp;quot;;&lt;br /&gt;
            }&lt;br /&gt;
            var div = &amp;quot;&amp;lt;span style=\&amp;quot;color:#&amp;quot; + color + &amp;quot;;&amp;quot; + color_bg + &amp;quot;\&amp;quot;&amp;gt;&amp;quot; + this.gamedatas.players[player_id].name + &amp;quot;&amp;lt;/span&amp;gt;&amp;quot;;&lt;br /&gt;
            return div;&lt;br /&gt;
        },&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Cool realistic shadow effect with CSS===&lt;br /&gt;
&lt;br /&gt;
====Rectangles and circles====&lt;br /&gt;
&lt;br /&gt;
It is often nice to have a drop shadow around tiles and tokens, to separate them from the table visually. It is very easy to add a shadow to rectangular elements, just add this to your css:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
.xxx-tile {&lt;br /&gt;
    box-shadow: 3px 3px 3px #000000a0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
box-shadow obeys &#039;&#039;&#039;border-radius&#039;&#039;&#039; of the element, so it will look good for rounded rectangles, and hence also circles (if border-radius is set appropriately).&lt;br /&gt;
&lt;br /&gt;
box-shadow also supports various other parameters and can be used to achieve effects such as glowing, borders, inner shadows etc. If you need to animate a box-shadow, you may be able to get better performance (avoiding redraws) if you attach the shadow to another element (possibly an ::after pseudo-element) and change only the &#039;&#039;&#039;opacity&#039;&#039;&#039; of that element.&lt;br /&gt;
&lt;br /&gt;
==== Irregular Shapes ====&lt;br /&gt;
&lt;br /&gt;
If you wish to make a shadow effect for game pieces that are not a rectangle, but your game pieces are drawn from rectangles in a PNG image, you can apply the shadow to the piece using any art package and save it inside the image. This usually will yield the best performance. Remember to account for the size of the shadow when you lay out images in the sprite sheet.&lt;br /&gt;
&lt;br /&gt;
However that sometimes will not be an option, for example if the image needs to be rotated while the shadow remains offset in the same direction. In this case, one option is to not use box-shadow but use filter, which is supported by recent major browsers.  This way, you can use the alpha channel of your element to drop a shadow.  This even work for transparent backgrounds, so that if you are using the &amp;quot;CSS-sprite&amp;quot; method, it will work!&lt;br /&gt;
&lt;br /&gt;
For instance:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
.xxx-token {&lt;br /&gt;
    filter: drop-shadow(0px 0px 1px #000000);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Beware that some browsers still do not always draw drop-shadow correctly. In particular, Safari frequently leaves bits of shadow behind when objects move around the screen. In Chrome, shadows sometimes flicker badly if another element is animating close by. Some of these correctness issues can be solved by adding &#039;&#039;&#039;isolation: isolate; will-change: filter;&#039;&#039;&#039; to affected elements, but this significantly affects redraw performance.&lt;br /&gt;
&lt;br /&gt;
Beware of performance issues - particularly on Safari (MacOS, iPhone and iPad). Keep in mind that drop-shadow are very GPU intensive. This becomes noticeable once you have about 40 components with drop-shadow filter. If that is your case, you can quite easily implement a user preference to disable shadows for users on slower machines:&lt;br /&gt;
&lt;br /&gt;
gameoptions.inc.php&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
100 =&amp;gt; array(&lt;br /&gt;
			&#039;name&#039; =&amp;gt; totranslate(&#039;Shadows&#039;),&lt;br /&gt;
			&#039;needReload&#039; =&amp;gt; true, // after user changes this preference game interface would auto-reload&lt;br /&gt;
			&#039;values&#039; =&amp;gt; array(&lt;br /&gt;
					1 =&amp;gt; array( &#039;name&#039; =&amp;gt; totranslate( &#039;Enabled&#039; ), &#039;cssPref&#039; =&amp;gt; &#039;&#039; ),&lt;br /&gt;
					2 =&amp;gt; array( &#039;name&#039; =&amp;gt; totranslate( &#039;Disabled&#039; ), &#039;cssPref&#039; =&amp;gt; &#039;no-shadow&#039; )&lt;br /&gt;
			)&lt;br /&gt;
	),&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[game].css&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
.no-shadow * {&lt;br /&gt;
	filter: none !important; &lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/pre&amp;gt;For Safari, it is usually better to simply disable drop-shadow completely: [[Game interface stylesheet: yourgamename.css#Warning: using drop-shadow]].&lt;br /&gt;
&lt;br /&gt;
====Shadows with clip-path====&lt;br /&gt;
&lt;br /&gt;
For some reason, a shadow will not work together with clip-path on one element. To use both clip-path (when for example using .svg to cut out cardboard components from your .jpg spritesheet) and drop-shadow, you need to wrap the element into another one, and apply drop-shadow to the outer one, and clip-path to the inner one.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;div class=&#039;my-token-wrap&#039;&amp;gt;&lt;br /&gt;
  &amp;lt;div class=&#039;my-token&#039;&amp;gt;&lt;br /&gt;
  &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
.my-token-wrap {&lt;br /&gt;
    filter: drop-shadow(0px 0px 1px #000000);&lt;br /&gt;
}&lt;br /&gt;
.my-token-wrap .my-token {&lt;br /&gt;
    clip-path: url(#my-token-path);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Using the CSS classes from the state machine ===&lt;br /&gt;
&lt;br /&gt;
If you need to hide or show stuff depending on the state of your game, you can of course use javascript, but CSS is hand enough for that.  The #overall-content element does change class depending on the game state.  For instance, if you are in state &#039;&#039;playerTurn&#039;&#039;, it will have the class &#039;&#039;gamestate_playerTurn&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
So now, if you want to show the discard pile only during player turns, you may use:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#discard_pile { display: none }&lt;br /&gt;
.gamestate_playerTurn #discard_pile { display: block }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This can be used if you want to change sizing of elements, position, layout or visual appearance.&lt;br /&gt;
&lt;br /&gt;
==Game Model and Database design ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Database for The euro game ===&lt;br /&gt;
Lets say we have a game with workers, dice, tokens, board, resources, money and vp. Workers and dice can be placed in various zones on the board, and you can get resources, money, tokens and vp in your home zone. Also tokens can be flipped or not flipped.&lt;br /&gt;
&lt;br /&gt;
[[File:Madeira board.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now lets try to map it, we have&lt;br /&gt;
*(meeple,zone)&lt;br /&gt;
*(die, zone, sideup)&lt;br /&gt;
*(resource cube/money token/vp token,player home zone)&lt;br /&gt;
*(token, player home zone, flip state)&lt;br /&gt;
We can notice that resource and money are uncountable, and don&#039;t need to be track individually so we can replace our mapping to&lt;br /&gt;
*(resource type/money,player home zone, count)&lt;br /&gt;
And vp stored already for us in player table, so we can remove it from that list.&lt;br /&gt;
&lt;br /&gt;
Now when we get to encode it we can see that everything can be encoded as (object,zone,state) form, where object and zone is string and state is integer. The resource mapping is slightly different semantically so you can go with two table, or counting using same table with state been used as count for resources.&lt;br /&gt;
&lt;br /&gt;
So the piece mapping for non-grid based games can be in most case represented by (string: token_key, string: token_location, int: token_state), example of such database schema can be found here: [https://github.com/elaskavaia/bga-sharedcode/blob/master/dbmodel.sql dbmodel.sql] and class implementing access to it here [https://github.com/elaskavaia/bga-sharedcode/blob/master/modules/tokens.php table.game.php].&lt;br /&gt;
&lt;br /&gt;
Variant 1: Minimalistic&lt;br /&gt;
&lt;br /&gt;
 CREATE TABLE IF NOT EXISTS `token` (&lt;br /&gt;
  `token_key` varchar(32) NOT NULL,&lt;br /&gt;
  `token_location` varchar(32) NOT NULL,&lt;br /&gt;
  `token_state` int(10),&lt;br /&gt;
  PRIMARY KEY (`token_key`)&lt;br /&gt;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+token&lt;br /&gt;
!token_key&lt;br /&gt;
!token_location&lt;br /&gt;
!token_state&lt;br /&gt;
|-&lt;br /&gt;
|meeple_red_1&lt;br /&gt;
|home_red&lt;br /&gt;
|0&lt;br /&gt;
|-&lt;br /&gt;
|dice_black_2&lt;br /&gt;
|board_guard&lt;br /&gt;
|1&lt;br /&gt;
|-&lt;br /&gt;
|dice_green_1&lt;br /&gt;
|board_action_mayor&lt;br /&gt;
|3&lt;br /&gt;
|-&lt;br /&gt;
|bread&lt;br /&gt;
|home_red &lt;br /&gt;
| 5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Now how we represent resource counters such as bread?&lt;br /&gt;
Using same table from we simply add special counter token for bread and use state to indicate the count. Note to keep first column unique we have to add player identification for that counter, i.e. ff0000 is red player.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+token&lt;br /&gt;
!token_key&lt;br /&gt;
!token_location&lt;br /&gt;
!token_state&lt;br /&gt;
|-&lt;br /&gt;
|bread_ff0000&lt;br /&gt;
|tableau_ff0000&lt;br /&gt;
|5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
See php module for this table here https://github.com/elaskavaia/bga-sharedcode/blob/master/modules/tokens.php&lt;br /&gt;
&lt;br /&gt;
Variant 2: Additional resource table, resource count for each player id&lt;br /&gt;
&lt;br /&gt;
 CREATE TABLE IF NOT EXISTS `resource` (&lt;br /&gt;
  `player_id` int(10) unsigned NOT NULL,&lt;br /&gt;
  `resource_key` varchar(32) NOT NULL,&lt;br /&gt;
  `resource_count` int(10) signed NOT NULL,&lt;br /&gt;
  PRIMARY KEY (`player_id`,`resource_key`)&lt;br /&gt;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;&lt;br /&gt;
&lt;br /&gt;
 ALTER TABLE resource ADD CONSTRAINT fk_player_id FOREIGN KEY (player_id) REFERENCES player(player_id);&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+resource&lt;br /&gt;
!player_id&lt;br /&gt;
!resource_key&lt;br /&gt;
!resource_count&lt;br /&gt;
|-&lt;br /&gt;
| 123456&lt;br /&gt;
|bread&lt;br /&gt;
|5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Variant 3: More normalised&lt;br /&gt;
&lt;br /&gt;
This version is similar to &amp;quot;card&amp;quot; table from hearts tutorial, you can also use exact cards database schema and Deck implementation for most purposes (even you not dealing with cards). &lt;br /&gt;
&lt;br /&gt;
 CREATE TABLE IF NOT EXISTS `token` (&lt;br /&gt;
  `token_id` int(10) unsigned NOT NULL AUTO_INCREMENT,&lt;br /&gt;
  `token_type` varchar(16) NOT NULL,&lt;br /&gt;
  `token_arg` int(11) NOT NULL,&lt;br /&gt;
  `token_location` varchar(32) NOT NULL,&lt;br /&gt;
  `token_state` int(10),&lt;br /&gt;
  PRIMARY KEY (`token_id`)&lt;br /&gt;
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+token&lt;br /&gt;
!token_id&lt;br /&gt;
!token_type&lt;br /&gt;
!token_arg&lt;br /&gt;
!token_location&lt;br /&gt;
!token_state&lt;br /&gt;
|-&lt;br /&gt;
|22&lt;br /&gt;
|meeple&lt;br /&gt;
|123456&lt;br /&gt;
|home_123456&lt;br /&gt;
|0&lt;br /&gt;
|-&lt;br /&gt;
|23&lt;br /&gt;
|dice&lt;br /&gt;
|2&lt;br /&gt;
|board_guard&lt;br /&gt;
|1&lt;br /&gt;
|-&lt;br /&gt;
|26 &lt;br /&gt;
|dice&lt;br /&gt;
|1&lt;br /&gt;
|board_action_mayor&lt;br /&gt;
|3&lt;br /&gt;
|-&lt;br /&gt;
|49&lt;br /&gt;
|bread&lt;br /&gt;
|0&lt;br /&gt;
|home_123456&lt;br /&gt;
|5&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Advantages of this would be is a bit more straightforward to do some queries in db, disadvantage its hard to read (as you can compare with previous example, you&lt;br /&gt;
cannot just look at say, ah I know what it means). Another questionable advantage is it allows you to do id randomisation, so it hard to do crafted queries to &lt;br /&gt;
cheat, the down side of that you cannot understand it either, and handcraft db states for debugging or testing.&lt;br /&gt;
&lt;br /&gt;
=== Database for The card game===&lt;br /&gt;
&lt;br /&gt;
Lets say you have a standard card game, player have hidden cards in hand, you can draw card from draw deck, play card on tableau and discard to discard pile.&lt;br /&gt;
We have to design database for such game.&lt;br /&gt;
&lt;br /&gt;
In real word to &amp;quot;save&amp;quot; the game we take a picture a play area, save cards from it, then put away draw deck, discard and hand of each player separately and mark it, also we will record current scoring (if any) and who&#039;s turn was it.&lt;br /&gt;
&lt;br /&gt;
*Framework handles state machine transition, so you don&#039;t have to worry about database design for that (i.e. who&#039;s turn it is, what phase of the game we are at, you still have to design it but part of state machine step)&lt;br /&gt;
*Also framework supports basic player information, color, order around the table, basic scoring, etc, so you don&#039;t have to worry about it either&lt;br /&gt;
*The only thing you need in our database is state of the &amp;quot;board&amp;quot;, which is &amp;quot;where each pieces is, and in what state&amp;quot;, or (position,rotation) pair.&lt;br /&gt;
&lt;br /&gt;
Lets see what we have for that: &lt;br /&gt;
*The card state is very simple, its usually &amp;quot;face up/face down&amp;quot;, &amp;quot;tapped/untapped&amp;quot;, &amp;quot;right side up/up side down&amp;quot;&lt;br /&gt;
*As position go we never need real coordinates x,y,z. We need to know what &amp;quot;zone&amp;quot; card was, and depending on the zone it may sometimes need an extra &amp;quot;z&amp;quot; or &amp;quot;x&amp;quot; as card order. The zone position usually static or irrelevant.&lt;br /&gt;
*So our model is: we have cards, which have some attributes, at any given point in time they belong to a &amp;quot;zone&amp;quot;, and can also have order and state&lt;br /&gt;
* Now for mapping we should consider what information changes and what information is static, later is always candidate for material file&lt;br /&gt;
*For dynamic information we should try to reduce amount of fields we need&lt;br /&gt;
**we need at least a field for card, so its one&lt;br /&gt;
**we need to know what zone cards belong to, its 2&lt;br /&gt;
**and we have possibly few other fields, if you look closely at you game you may find out that most of the zone only need one attribute at a time, i.e. draw pile always have cards face down, hand always face up, also for hand and discard order does not matter at all (but for draw it does matter). So in majority of cases we can get away with one single extra integer field representing state or order&lt;br /&gt;
*In real database both card and zone will be integers as primary keys referring to additional tables, but in our case its total overkill, so they can be strings as easily&lt;br /&gt;
&lt;br /&gt;
Variant 1: Minimalistic&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CREATE TABLE IF NOT EXISTS `card` (&lt;br /&gt;
  `card_key` varchar(32) unsigned NOT NULL,&lt;br /&gt;
  `card_location` varchar(32) NOT NULL,&lt;br /&gt;
  `card_state` int(11) NOT NULL,&lt;br /&gt;
  PRIMARY KEY (`card_id`)&lt;br /&gt;
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Variant 2: More normalised&lt;br /&gt;
&lt;br /&gt;
This version supported by Deck php class, so unless you want to rewrite db access layer go with this one&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CREATE TABLE IF NOT EXISTS `card` (&lt;br /&gt;
  `card_id` int(10) unsigned NOT NULL AUTO_INCREMENT,&lt;br /&gt;
  `card_type` varchar(16) NOT NULL,&lt;br /&gt;
  `card_type_arg` int(11) NOT NULL,&lt;br /&gt;
  `card_location` varchar(16) NOT NULL,&lt;br /&gt;
  `card_location_arg` int(11) NOT NULL,&lt;br /&gt;
  PRIMARY KEY (`card_id`)&lt;br /&gt;
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: if you using this schema, some zones/locations have special semantic. The &#039;hand&#039; location is actually multiple locations - one per player, but player id is encoded as card_location_arg. If &#039;hand&#039; in your game is ordered, visible or can have some other card states, you cannot use hand location (replacement is hand_&amp;lt;player_id&amp;gt; or hand_&amp;lt;color_id&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
==Game Elements==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Resource===&lt;br /&gt;
&lt;br /&gt;
A game resource, such as &amp;quot;wood,&amp;quot; is usually infinite and represented by a count allocated to a specific player or supply.&lt;br /&gt;
&lt;br /&gt;
If a resource can be placed on location, use the &amp;quot;Meeple&amp;quot; model described below.&lt;br /&gt;
&lt;br /&gt;
For a working example, you can check out: [https://codepen.io/VictoriaLa/pen/emYgLzR CodePen Example] (ui only).&lt;br /&gt;
&lt;br /&gt;
====Representation in Database====&lt;br /&gt;
In a minimalistic &amp;quot;tokens&amp;quot; database, it would look like this (e.g., the red player has 3 wood):&lt;br /&gt;
  &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+token&lt;br /&gt;
!token_key&lt;br /&gt;
!token_location&lt;br /&gt;
! token_state&lt;br /&gt;
|-&lt;br /&gt;
|wood_ff0000&lt;br /&gt;
|&lt;br /&gt;
|3&lt;br /&gt;
|-&lt;br /&gt;
|wood_supply&lt;br /&gt;
|&lt;br /&gt;
|40&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The second row you need to store the resource in the supply (if it&#039;s counted).&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t like this solution can use bga_globals table for this or create your own resource table.&lt;br /&gt;
&lt;br /&gt;
Its not recommened to extend player table to store this information.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Representation in Material File (material.inc.php)====&lt;br /&gt;
In the material file, you can define some information about resources. For instance, you can specify that it&#039;s of type &amp;quot;resource&amp;quot; and call it &amp;quot;Wood&amp;quot; in English, along with a tooltip:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$this-&amp;gt;token_types = [&lt;br /&gt;
  ...&lt;br /&gt;
  &#039;wood&#039; =&amp;gt; [&lt;br /&gt;
     &#039;name&#039; =&amp;gt; clienttranslate(&#039;Wood&#039;),&lt;br /&gt;
     &#039;tooltip&#039; =&amp;gt; clienttranslate(&#039;Game resource used for building houses&#039;),&lt;br /&gt;
     &#039;type&#039; =&amp;gt; &#039;resource&#039;,&lt;br /&gt;
     &#039;max&#039; =&amp;gt; 40&lt;br /&gt;
  ]&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====HTML Representation====&lt;br /&gt;
In HTML, this would look something like this within the player panel. Using the data attribute instead of a CDATA value is much more flexible:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;div id=&amp;quot;wood_ff0000&amp;quot; class=&amp;quot;resource wood&amp;quot; data-value=&amp;quot;3&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== JavaScript Handling ====&lt;br /&gt;
When you get the object from the server, one of the tokens will be sent in the array like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
token = {&lt;br /&gt;
  key: &#039;wood_ff0000&#039;,&lt;br /&gt;
  location: &#039;-&#039;,&lt;br /&gt;
  state: &#039;3&#039;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can create a corresponding `&amp;lt;div&amp;gt;` in the `setup()` method of `game.js` as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
const playerColor = token.key.split(&#039;_&#039;)[1];&lt;br /&gt;
const resType = token.key.split(&#039;_&#039;)[0];&lt;br /&gt;
const tokenInfo = this.gamedatas.token_types[resType]; // token_types is the structure from the material file sent to the client&lt;br /&gt;
const div = `&amp;lt;div id=&amp;quot;${token.key}&amp;quot; class=&amp;quot;${resType} ${tokenInfo.type} ${token.key}&amp;quot; data-value=&amp;quot;${token.state}&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;`;&lt;br /&gt;
&lt;br /&gt;
if (playerColor != &#039;supply&#039;) {&lt;br /&gt;
    document.querySelector(`#player_board_${this.getPlayerIdByColor(playerColor)} &amp;gt; .player-board-game-specific-content`).insertAdjacentHTML(&#039;beforeend&#039;,div);&lt;br /&gt;
    this.addTooltip(token.key, _(tokenInfo.name) + &amp;quot; &amp;quot; + _(tokenInfo.tooltip), &amp;quot;&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When you receive an update notification (assuming you get the same &amp;quot;token&amp;quot; object), you can simply update the `data-value`:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
document.querySelector(`#${token.key}`).dataset.value = token.state;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To display the resource in the game log, you can format it like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Player gains &amp;lt;div class=&amp;quot;resource wood&amp;quot; data-value=&amp;quot;1&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
For more on injecting icon images in the log, see: [[BGA_Studio_Cookbook#Inject_icon_images_in_the_log]]&lt;br /&gt;
&lt;br /&gt;
====Graphic Representation (.css)====&lt;br /&gt;
To properly display the resource image, it is preferable to use an image sprite that includes all resources, &lt;br /&gt;
usually it will be .png as these objects have shape. &lt;br /&gt;
This how will .css look like with horizontal sprite image:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
.resource {&lt;br /&gt;
  background-image: url(https://en.doc.boardgamearena.com/images/d/d3/Cubes.png);&lt;br /&gt;
  background-repeat: no-repeat;&lt;br /&gt;
  background-size: cover; /* auto-scale */&lt;br /&gt;
  aspect-ratio: 1/1; /* that will keep heigh in sync */&lt;br /&gt;
  width: 32px; /* default size, specific location should override */&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.wood {&lt;br /&gt;
  /* Since the sprite is a horizontal row of 11 cubes and 9 is the brown cube position */&lt;br /&gt;
  background-position: calc(100% / (11 - 1) * 9) 0%;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To show a text overlay with the resource value, you can use the following CSS:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
.resource[data-value]:after {&lt;br /&gt;
  content: attr(data-value);&lt;br /&gt;
  width: 100%;&lt;br /&gt;
  height: 100%;&lt;br /&gt;
  position: absolute;&lt;br /&gt;
  font-size: xx-large;&lt;br /&gt;
  text-align: center;&lt;br /&gt;
  text-shadow: 2px 0 2px #fff, 0 -2px 2px #fff, 0 2px 2px #fff, -2px 0 2px #fff;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This solution is fully scalable — you only need to specify the size where you want it displayed. &lt;br /&gt;
For example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
.player_board_content &amp;gt; .resource {&lt;br /&gt;
  width: 40px;&lt;br /&gt;
  position: relative;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: if you have that board that tracks the resource on resource tracker - you can show this IN ADDITION of showing resource on player panel.&lt;br /&gt;
&lt;br /&gt;
====Selection and Actions====&lt;br /&gt;
It is best to put buttons with resource images on the status bar, rather than having the player click on the player panel.&lt;br /&gt;
&lt;br /&gt;
For animation:&lt;br /&gt;
*Can use move animation to animate resourced gained or played from the board location to the player panel&lt;br /&gt;
*Can use &amp;quot;vapor&amp;quot; animation to show resource gained from the board&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Meeple===&lt;br /&gt;
&lt;br /&gt;
A meeple is a game piece, typically representing a &amp;quot;worker,&amp;quot; depicted as a human-shaped figure in a specific color assigned to a player.&lt;br /&gt;
&lt;br /&gt;
The key distinction between meeples and traditional resources is that meeples are placed on locations and can exist &lt;br /&gt;
in at least two states — standing or lying down. &lt;br /&gt;
&lt;br /&gt;
This concept also applies to similar pieces like &amp;quot;houses,&amp;quot; &amp;quot;animeeples,&amp;quot; &amp;quot;ships,&amp;quot; and others.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Representation in Database====&lt;br /&gt;
In a simplified &amp;quot;tokens&amp;quot; database, it might be represented like this &lt;br /&gt;
(e.g., the red player&#039;s first meeple is on action spot 1, while the white meeple remains in supply):&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+token&lt;br /&gt;
!token_key&lt;br /&gt;
!token_location&lt;br /&gt;
! token_state&lt;br /&gt;
|-&lt;br /&gt;
|meeple_ff0000_1&lt;br /&gt;
|actionspot_1&lt;br /&gt;
|1&lt;br /&gt;
|-&lt;br /&gt;
|meeple_ffffff_1&lt;br /&gt;
| supply&lt;br /&gt;
|0&lt;br /&gt;
|}  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Representation in Material File (material.inc.php)====&lt;br /&gt;
&lt;br /&gt;
Here we define some properties, for example name can be used in notification and as tooltip, type can be used to create the div by &lt;br /&gt;
javascript, &#039;create&#039; - can be used by server to create 8 meeples of this type in database and set location to &#039;supply_ff0000&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$this-&amp;gt;token_types = [&lt;br /&gt;
  ...&lt;br /&gt;
  &#039;meeple_ff0000&#039; =&amp;gt; [&lt;br /&gt;
     &#039;name&#039; =&amp;gt; clienttranslate(&#039;Red Worker&#039;),&lt;br /&gt;
     &#039;type&#039; =&amp;gt; &#039;meeple meeple_ff0000&#039;,&lt;br /&gt;
     &#039;create&#039; =&amp;gt; 8,&lt;br /&gt;
     &#039;location&#039; =&amp;gt; &#039;supply_ff0000&#039;&lt;br /&gt;
  ]&lt;br /&gt;
];&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====HTML Representation ====&lt;br /&gt;
In HTML, this would look something like this. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;div id=&amp;quot;meeple_ff0000_1&amp;quot; class=&amp;quot;meeple meeple_ff0000&amp;quot; data-state=&amp;quot;1&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====JavaScript Handling ====&lt;br /&gt;
When you get the object from the server, each meeple object will be similar to this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
meeple = {&lt;br /&gt;
  key: &#039;meeple_ff0000_1&#039;,&lt;br /&gt;
  location: &#039;actionslot_1&#039;,&lt;br /&gt;
  state: &#039;1&#039;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can create a corresponding `&amp;lt;div&amp;gt;` in the `setup()` method of `game.js` as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
const playerColor = token.key.split(&#039;_&#039;)[1];&lt;br /&gt;
const resType = token.key.split(&#039;_&#039;)[0];&lt;br /&gt;
const tokenInfo = this.gamedatas.token_types[resType]; // token_types is the structure from the material file sent to the client&lt;br /&gt;
const div = `&amp;lt;div id=&amp;quot;${token.key}&amp;quot; class=&amp;quot;${tokenInfo.type} ${token.key}&amp;quot; data-state=&amp;quot;${token.state}&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;`;&lt;br /&gt;
&lt;br /&gt;
$(token.location).insertAdjacentHTML(&#039;beforeend&#039;,div);&lt;br /&gt;
this.addTooltip(token.key, _(tokenInfo.name) + &amp;quot; &amp;quot; + _(tokenInfo.tooltip), &amp;quot;&amp;quot;);&lt;br /&gt;
$(token.key).addEventListener(&#039;onclick&#039;,(ev)=&amp;gt;this.onMeepleClick(ev));&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When you receive an update notification (assuming you get the same &amp;quot;token&amp;quot; object), you either create it if not exists or animate:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if ($(token.key)) {&lt;br /&gt;
  // exists&lt;br /&gt;
  $(token.key).dataset.state = token.state; // update state&lt;br /&gt;
  this.moveToken(token.key, token.location); // animate to new location (custom functon), see [[BGA_Studio_Cookbook#Animation]]&lt;br /&gt;
  } else {&lt;br /&gt;
  // crate meeple using code in previous section&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Graphic Representation (.css)====&lt;br /&gt;
&lt;br /&gt;
Use same sprite technique from Resource section above.&lt;br /&gt;
&lt;br /&gt;
When placed on the board it will look good with shadow, but its not recommended on mobile&lt;br /&gt;
&lt;br /&gt;
  filter: drop-shadow(black 5px 5px 5px);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To represent &amp;quot;laying down&amp;quot; meeple, you have to use a different sprite image, which you will apply based on data attribute&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
.meeple[data-state=&amp;quot;1&amp;quot;] {&lt;br /&gt;
   background-image: url(...);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also rotate you div, but it will look lame.&lt;br /&gt;
Other options include changing its shading, adding overlay (i.e. sad face) and so on. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Selection and Actions====&lt;br /&gt;
To show user that meeple is active it best to use drop-shadow as image as non-square, however this may be very slow.&lt;br /&gt;
For simplier case use box shadow.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
.active_slot {&lt;br /&gt;
  filter: drop-shadow(0px 0px 10px blue);&lt;br /&gt;
  cursor: pointer;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* draw a circle around game element for selection */&lt;br /&gt;
.active_slot_simple:after {&lt;br /&gt;
  content: &amp;quot; &amp;quot;;&lt;br /&gt;
  width: 110%;&lt;br /&gt;
  top: -5%;&lt;br /&gt;
  left: -5%;&lt;br /&gt;
  aspect-ratio: 1/1;&lt;br /&gt;
  position: absolute;&lt;br /&gt;
  border-radius: 50%;&lt;br /&gt;
  box-shadow: 0px 0px 4px 3px #64b4ff;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See code example at https://codepen.io/VictoriaLa/pen/emYgLzR&lt;br /&gt;
&lt;br /&gt;
When a meeple is gained from the supply, you can display a meeple icon on the status bar button &lt;br /&gt;
instead of showing the supply on the board.&lt;br /&gt;
&lt;br /&gt;
===Dice ===&lt;br /&gt;
The 2D dice can use similar handing as meeple but it has 6 states instead of 2.&lt;br /&gt;
&lt;br /&gt;
IMPORTANT: Never roll dice using javascript. All dice rolling must be done using bga_rand() function in php.&lt;br /&gt;
&lt;br /&gt;
====Representation in Database====&lt;br /&gt;
In a simplified &amp;quot;tokens&amp;quot; database, it might be represented like this &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+token&lt;br /&gt;
!token_key&lt;br /&gt;
!token_location&lt;br /&gt;
!token_state&lt;br /&gt;
|-&lt;br /&gt;
|die_black&lt;br /&gt;
|actionspot_1&lt;br /&gt;
|1&lt;br /&gt;
|-&lt;br /&gt;
|die_red&lt;br /&gt;
|supply &lt;br /&gt;
|6&lt;br /&gt;
|}&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
====Representation in Material File (material.inc.php)====&lt;br /&gt;
&lt;br /&gt;
Similar to resource and meeple above&lt;br /&gt;
&lt;br /&gt;
====HTML Representation====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;div id=&amp;quot;die_black&amp;quot; class=&amp;quot;die&amp;quot; data-state=&amp;quot;1&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====JavaScript Handling (.js)====&lt;br /&gt;
See meeple section&lt;br /&gt;
&lt;br /&gt;
====Graphic Representation (.css)====&lt;br /&gt;
For dice we would usually use N x 6 sprite, and since the sides are square - the .jpg format is better (it is smaller then png)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
.die {  &lt;br /&gt;
  background-image: url(https://en.doc.boardgamearena.com/images/c/c5/64_64_dice.jpg);&lt;br /&gt;
  background-size: 600%;&lt;br /&gt;
  background-repeat: no-repeat;&lt;br /&gt;
  aspect-ratio: 1/1;&lt;br /&gt;
  width: 64px;&lt;br /&gt;
  border-radius: 5%; /* looks better with rounded corders */&lt;br /&gt;
}&lt;br /&gt;
.die[data-state=&amp;quot;3&amp;quot;] {&lt;br /&gt;
  background-position: calc(100% / 5 * 2) 0%;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The 3D dice a bit tricker to create but its feasible, see https://codepen.io/VictoriaLa/pen/QWBBbwz for an example.&lt;br /&gt;
&lt;br /&gt;
Also multiple examples on N-sided dice can be found on [[BGA_Code_Sharing]]&lt;br /&gt;
&lt;br /&gt;
====Selection and Actions====&lt;br /&gt;
Since it is a square its a lot easier to make a square selection highlight&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
.die.active_slot  {&lt;br /&gt;
  box-shadow: 0px 0px 4px 4px blue;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Card===&lt;br /&gt;
&lt;br /&gt;
Cards are the most complex game resource, they can be located in various zones, stacked, tapped, put face down and can have arbitrary complete abilities.&lt;br /&gt;
If you have square tiles - it can be treated the same as cards.&lt;br /&gt;
&lt;br /&gt;
====Representation in Database====&lt;br /&gt;
&lt;br /&gt;
In a simplified &amp;quot;tokens&amp;quot; database, it might be represented like this &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+token&lt;br /&gt;
!token_key&lt;br /&gt;
!token_location&lt;br /&gt;
!token_state&lt;br /&gt;
|-&lt;br /&gt;
|card_project_123&lt;br /&gt;
|tableau_ff0000&lt;br /&gt;
|1&lt;br /&gt;
|-&lt;br /&gt;
|card_corp_p1&lt;br /&gt;
| deck_corp&lt;br /&gt;
|6&lt;br /&gt;
|}&lt;br /&gt;
  &lt;br /&gt;
Means project card is player red tableau and state 1 means it has been used for example,&lt;br /&gt;
and second card of corproration file in in deck at position 6 from the top.&lt;br /&gt;
&lt;br /&gt;
When duplcates are in play you need to add extra unique disambigator in the key.&lt;br /&gt;
&lt;br /&gt;
Usually cards will have numeric id associated with type, but it this number is per expansition, so leave the space for expansion identifier in there also.&lt;br /&gt;
&lt;br /&gt;
Another option use [[Deck]] component.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Representation in Material====&lt;br /&gt;
&lt;br /&gt;
All the card properties which do not change during the game can be put in material file (or its alternative)&lt;br /&gt;
&lt;br /&gt;
This is example from terraforming mars&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 &#039;card_main_81&#039; =&amp;gt; [  //&lt;br /&gt;
  &#039;location&#039; =&amp;gt; &#039;deck_main&#039;,&lt;br /&gt;
  &#039;create&#039; =&amp;gt; &#039;single&#039;,&lt;br /&gt;
  &#039;num&#039; =&amp;gt; 81,&lt;br /&gt;
  &#039;name&#039; =&amp;gt; clienttranslate(&#039;Ganymede Colony&#039;),&lt;br /&gt;
  &#039;t&#039; =&amp;gt; 1,&lt;br /&gt;
  &#039;r&#039; =&amp;gt; &amp;quot;city(&#039;Ganymede Colony&#039;)&amp;quot;,&lt;br /&gt;
  &#039;cost&#039; =&amp;gt; 20,&lt;br /&gt;
  &#039;tags&#039; =&amp;gt; &#039;Space City Jovian&#039;,&lt;br /&gt;
  &#039;vp&#039; =&amp;gt; &#039;tagJovian&#039;,&lt;br /&gt;
  &#039;deck&#039; =&amp;gt; &#039;Basic&#039;,&lt;br /&gt;
  &#039;text&#039; =&amp;gt; clienttranslate(&#039;Place a city tile ON THE RESERVED AREA [for Ganymede Colony].&#039;),&lt;br /&gt;
  &#039;text_vp&#039; =&amp;gt; clienttranslate(&#039;1 VP per Jovian tag you have.&#039;),&lt;br /&gt;
],&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====HTML Representation====&lt;br /&gt;
&lt;br /&gt;
There is 2 main options:&lt;br /&gt;
* Use exact cards images in english&lt;br /&gt;
*Use cards images WITHOUT text&lt;br /&gt;
&lt;br /&gt;
The 3d option is completely redo the graphic layout that game designed did already, but I won&#039;t go there&lt;br /&gt;
&lt;br /&gt;
The first option is very simple and similar to other resources and meeple&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;div id=&amp;quot;card_project_123&amp;quot; class=&amp;quot;card card_project card_project_123&amp;quot; data-state=&amp;quot;1&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The second option means you can add translated text instead&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;div id=&amp;quot;card_project_123&amp;quot; class=&amp;quot;card card_project card_project_123&amp;quot; data-state=&amp;quot;1&amp;quot; data-cost=&amp;quot;22&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;div class=&amp;quot;card_name&amp;quot;&amp;gt;Ganymede Colony&amp;lt;/div&amp;gt;&lt;br /&gt;
   &amp;lt;div class=&amp;quot;card_text&amp;quot;&amp;gt;Place a city tile ON THE RESERVED AREA [for Ganymede Colony].&amp;lt;/div&amp;gt;&lt;br /&gt;
   &amp;lt;div class=&amp;quot;card_cost&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the example above card_cost is also rendered as this can change during the game (even printed value is the same),&lt;br /&gt;
it would be rendered using data-cost attribute.&lt;br /&gt;
&lt;br /&gt;
Instead of using class you can also use state even if it is static&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;div id=&amp;quot;card_H_10&amp;quot; class=&amp;quot;card&amp;quot; data-suit=&amp;quot;H&amp;quot; data-rank=&amp;quot;10&amp;quot;&amp;gt; &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: to make flip animation you effectively need to make a &amp;quot;3d&amp;quot; card and provide both faces with separate graphics,&lt;br /&gt;
which makes more complex div. See examples at [[BgaCards]].&lt;br /&gt;
&lt;br /&gt;
Note: you can also use [[Stock]] component that handles html, js, css, layout and selection at the same time. If do that skip sections below.&lt;br /&gt;
&lt;br /&gt;
====JavaScript Handling (.js)====&lt;br /&gt;
You will get the server data which looks like this&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
card = {&lt;br /&gt;
  key: &#039;card_project_123&#039;,&lt;br /&gt;
  location: &#039;tableau_ff0000&#039;,&lt;br /&gt;
  state: &#039;1&#039;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  createCard(token: Token) {&lt;br /&gt;
    // token_types is the structure from the material file sent to the client&lt;br /&gt;
    const tokenInfo = this.gamedatas.token_types[token.key]; &lt;br /&gt;
    const div = `&lt;br /&gt;
    &amp;lt;div id=&amp;quot;${token.key}&amp;quot; class=&amp;quot;${tokenInfo.type} ${token.key}&amp;quot; data-state=&amp;quot;${token.state}&amp;quot;&amp;gt;&lt;br /&gt;
       &amp;lt;div class=&amp;quot;card_name&amp;quot;&amp;gt;${_(tokenInfo.name)}&amp;lt;/div&amp;gt;&lt;br /&gt;
       &amp;lt;div class=&amp;quot;card_text&amp;quot;&amp;gt;${_(tokenInfo.text)}&amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;/div&amp;gt;`;&lt;br /&gt;
&lt;br /&gt;
    $(token.location).insertAdjacentHTML(&#039;beforeend&#039;,div);&lt;br /&gt;
    this.addTooltipHtml(token.key, this.getTooptipHtmlForToken(token));&lt;br /&gt;
    $(token.key).addEventListener(&amp;quot;onclick&amp;quot;, (ev) =&amp;gt; this.onCardClick(ev));&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you receive an update notification (assuming you get the same &amp;quot;token&amp;quot; object), you either create it if not exists or animate:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if ($(token.key)) {&lt;br /&gt;
  // exists&lt;br /&gt;
  $(token.key).dataset.state = token.state; // update state&lt;br /&gt;
  $(token.key).dataset.cost = token.cost; // update cost (discounted cost)&lt;br /&gt;
  this.moveCard(token.key, token.location); // animate to new location (custom functon), see [[BGA_Studio_Cookbook#Animation]]&lt;br /&gt;
} else {&lt;br /&gt;
  this.createCard(token);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Graphic Representation (.css)====&lt;br /&gt;
&lt;br /&gt;
For this html&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;div id=&amp;quot;game&amp;quot; class=&amp;quot;classic_deck&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;div id=&amp;quot;hand&amp;quot; class=&amp;quot;hand&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;div id=&amp;quot;card_H_10&amp;quot; class=&amp;quot;card&amp;quot; data-suit=&#039;H&#039; data-rank=&amp;quot;10&amp;quot;&amp;gt; &amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;div id=&amp;quot;card_C_K&amp;quot; class=&amp;quot;card&amp;quot; data-suit=&#039;C&#039; data-rank=&amp;quot;K&amp;quot;&amp;gt; &amp;lt;/div&amp;gt;&lt;br /&gt;
  &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is example css using sprite image of playing cards&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
.card {&lt;br /&gt;
   background-image: url(&#039;https://x.boardgamearena.net/data/others/cards/FULLREZ_CARDS_ORIGINAL_NORMAL.jpg&#039;);   /* don&#039;t do full url in your game, copy this file inside img folder */&lt;br /&gt;
  &lt;br /&gt;
   background-size: 1500% auto;  /* this mean size of background is 15 times bigger than size of card, because its sprite */&lt;br /&gt;
   border-radius: 5%;&lt;br /&gt;
   width: 10em;&lt;br /&gt;
   height: 13.5em;&lt;br /&gt;
   box-shadow: 0.1em 0.1em 0.2em 0.1em #555;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
.card[data-rank=&amp;quot;10&amp;quot;] { /* 10 is column number 10 - 2 because we start from 0 and first card is sprite is 2. The multiplier is (15 - 1) is because we have 15 columns. -1 is because % in CSS is weird like that. */&lt;br /&gt;
   background-position-x: calc(100% / (15 - 1) * (10 - 2));&lt;br /&gt;
}&lt;br /&gt;
.card[data-rank=&amp;quot;K&amp;quot;] { /* King will be number 13 in rank */&lt;br /&gt;
   background-position-x: calc(100% / (15 - 1) * (13 - 2));&lt;br /&gt;
}&lt;br /&gt;
.card[data-suit=&amp;quot;H&amp;quot;] { /* Hears row position is 1 (because we count from 0). Multiplier (4 - 1) is because we have 4 rows and -1 is because % in CSS is weird like that. */&lt;br /&gt;
   background-position-y: calc(100% / (4 - 1) * (1));&lt;br /&gt;
}&lt;br /&gt;
.card[data-suit=&amp;quot;C&amp;quot;] { /* Clubs row position is 2 */&lt;br /&gt;
   background-position-y: calc(100% / (4 - 1) * (2));&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
See code at https://codepen.io/VictoriaLa/pen/mdMzRxa&lt;br /&gt;
&lt;br /&gt;
====Selection and Actions====&lt;br /&gt;
&lt;br /&gt;
Since it is a square its a lot easier to make a square selection highlight&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
.card.active_slot  {&lt;br /&gt;
  box-shadow: 0px 0px 4px 4px blue;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Card Layouts====&lt;br /&gt;
There are two options - you use [[Stock]] component or don&#039;t, see [[Anti-Stock]] for details on how to do your own layouts.&lt;br /&gt;
&lt;br /&gt;
This is comprehensive example of various card layouts and animations&lt;br /&gt;
https://thoun.github.io/bga-cards/demo/index.html&lt;br /&gt;
&lt;br /&gt;
===Hex Tiles===&lt;br /&gt;
From data perspective hex tiles exactly the same as cards.&lt;br /&gt;
From visualization there is a small trick.&lt;br /&gt;
&lt;br /&gt;
CSS:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
.hex {&lt;br /&gt;
  width: var(--hex-width);&lt;br /&gt;
  aspect-ratio: 1 / 1.1193;&lt;br /&gt;
  border-radius: 30%;&lt;br /&gt;
  background-color: yellow; /* this is just for demo, use proper .png file for this */&lt;br /&gt;
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.hex.active_slot_simple {&lt;br /&gt;
  background-color: rgba(86, 207, 110, 0.4);&lt;br /&gt;
}&lt;br /&gt;
.hex.active_slot {&lt;br /&gt;
  filter: drop-shadow(0px 0px 10px blue);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Tetris Tiles===&lt;br /&gt;
You can use clip-path for actual shape and svg path for outline&lt;br /&gt;
See example at https://codepen.io/VictoriaLa/pen/OJmoZGw&lt;br /&gt;
&lt;br /&gt;
===Track===&lt;br /&gt;
&lt;br /&gt;
Tracker can be represented as &amp;quot;resource&amp;quot; in database - in this case its just number, or similar to &amp;quot;meeple&amp;quot; in which case&lt;br /&gt;
the location will have the &amp;quot;number&amp;quot; associated with position on track&lt;br /&gt;
&lt;br /&gt;
In a simplified &amp;quot;tokens&amp;quot; database, it might be represented like this &lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+token&lt;br /&gt;
!token_key&lt;br /&gt;
!token_location&lt;br /&gt;
!token_state&lt;br /&gt;
|-&lt;br /&gt;
|tracker_o&lt;br /&gt;
| scale_o_1&lt;br /&gt;
|0&lt;br /&gt;
|-&lt;br /&gt;
|tracker_t &lt;br /&gt;
| scale_t_10 &lt;br /&gt;
|0&lt;br /&gt;
|}&lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
The tracker location in this case may have some properties in material file, for example to trigger game effect when we land on this spot&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  &#039;scale_t&#039; =&amp;gt; [&lt;br /&gt;
    &#039;index_start&#039; =&amp;gt; 0,&lt;br /&gt;
    &#039;max&#039; =&amp;gt; 20,&lt;br /&gt;
    &#039;value_start&#039; =&amp;gt; -30,&lt;br /&gt;
    &#039;value_step&#039; =&amp;gt; 2,&lt;br /&gt;
    &#039;slot_type&#039; =&amp;gt; &#039;slot slot_t&#039;&lt;br /&gt;
  ],&lt;br /&gt;
  &#039;scale_t_10&#039; =&amp;gt; [&lt;br /&gt;
    &#039;r&#039; =&amp;gt; &#039;ocean&#039;,&lt;br /&gt;
    &#039;param&#039; =&amp;gt; &#039;t&#039;,&lt;br /&gt;
    &#039;tooltp&#039; =&amp;gt; clienttranslate(&#039;Place an ocean&#039;),&lt;br /&gt;
    &#039;value&#039; =&amp;gt; 0&lt;br /&gt;
  ],&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The track in this case can be generated as series of slots (create in js)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    for(let i=trackInfo.index_start,value = trackInfo.value_start;i&amp;lt;trackInfo.index_start+trackInfo.max;i++,value+=trackInfo.value_step) {&lt;br /&gt;
      $(trackInfo.key).insertAdjacentHTML(&#039;beforeend&#039;,`&amp;lt;div id=&amp;quot;${trackInfo.key}_${i}&amp;quot; class=&amp;quot;${trackInfo.slot_type} data-value=${value}&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;`);&lt;br /&gt;
      this.addTooltip(`${trackInfo.key}_${i}`, _(tokenInfo.tooltip), &amp;quot;&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then use regular move animation to move tracker into position on track.&lt;br /&gt;
&lt;br /&gt;
==Code Organization==&lt;br /&gt;
&lt;br /&gt;
===Including your own JavaScript module===&lt;br /&gt;
&#039;&#039;&#039;Ingredients:&#039;&#039;&#039; ggg.js, modules/ggg_other.js&lt;br /&gt;
&lt;br /&gt;
*Create ggg_other.js in modules/ folder and sync&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
define([&lt;br /&gt;
    &amp;quot;dojo&amp;quot;, &amp;quot;dojo/_base/declare&amp;quot;&lt;br /&gt;
], function( dojo, declare )&lt;br /&gt;
{&lt;br /&gt;
return declare(&amp;quot;bgagame.other&amp;quot;, null, { // null here if we don&#039;t want to inherit from anything&lt;br /&gt;
        constructor: function(){},&lt;br /&gt;
        mystuff: function(){},&lt;br /&gt;
    });&lt;br /&gt;
        &lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
*Modify ggg.js to include it&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  define([ &amp;quot;dojo&amp;quot;, &amp;quot;dojo/_base/declare&amp;quot;, &amp;quot;ebg/core/gamegui&amp;quot;, &amp;quot;ebg/counter&amp;quot;,&lt;br /&gt;
    g_gamethemeurl + &amp;quot;modules/ggg_other.js&amp;quot;     // load my own module!!!&lt;br /&gt;
  ], function(dojo,&lt;br /&gt;
        declare) {&lt;br /&gt;
     &lt;br /&gt;
&lt;br /&gt;
use it&lt;br /&gt;
&lt;br /&gt;
  foo = new bgagame.other();&lt;br /&gt;
&lt;br /&gt;
===Including your own JavaScript module (II) ===&lt;br /&gt;
&lt;br /&gt;
*Create ggg_other.js in modules/ folder and sync&lt;br /&gt;
&lt;br /&gt;
  define([], function () {&lt;br /&gt;
    return &amp;quot;value&amp;quot;;&lt;br /&gt;
  }); &lt;br /&gt;
&lt;br /&gt;
* Modify ggg.js to include it&lt;br /&gt;
&lt;br /&gt;
  define([ &lt;br /&gt;
    &amp;quot;dojo&amp;quot;, &lt;br /&gt;
    &amp;quot;dojo/_base/declare&amp;quot;, &lt;br /&gt;
    &amp;quot;bgagame/modules/ggg_other&amp;quot;, &lt;br /&gt;
    &amp;quot;ebg/core/gamegui&amp;quot;, &lt;br /&gt;
    &amp;quot;ebg/counter&amp;quot;&lt;br /&gt;
  ], function(dojo, declare, other) {&lt;br /&gt;
  &lt;br /&gt;
  });&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
This is maybe a little bit more the idea of the AMD Loader than the first option, although the first option should work as well.&lt;br /&gt;
&lt;br /&gt;
A little explanation to this:&lt;br /&gt;
The define function loads all the modules listed in the array and calls the following function with these loaded modules as parameters.&lt;br /&gt;
By putting your module at the third position in the array it is passed as the third parameter to the function. Be aware that the modules are resolved by position only, not by name. So you can load the module &#039;&#039;&#039;ggg_other&#039;&#039;&#039; and pass it as a parameter with the name &#039;&#039;&#039;other&#039;&#039;&#039;. &#039;&#039;&#039;gamegui&#039;&#039;&#039; and &#039;&#039;&#039;counter&#039;&#039;&#039; are passed in as well, but when the parameters are not defined they are just skipped. Because these modules put their content into the global scope it does not matter and you can use them from there.&lt;br /&gt;
&lt;br /&gt;
In the example above the string &amp;quot;value&amp;quot; is passed for the parameter &#039;&#039;&#039;other&#039;&#039;&#039;, but the function in your module can return whatever you want. It can be an object, an array, something you declared with dojo.declare, you can return even functions. &lt;br /&gt;
Your module can load other modules. Just put them in the array at the beginning and pass them as parameters to your function.&lt;br /&gt;
The advantage of passing the values as parameter is that you do not need to put these values in the global scope, so they can&#039;t be collisions with values defined in other scripts or the BGA Framework.&lt;br /&gt;
&lt;br /&gt;
The dojo toolkit provides good documentation to all of its components, the complete documentation for the AMD-Loader is here:&lt;br /&gt;
https://dojotoolkit.org/documentation/tutorials/1.10/modules/index.html It should be still correct, even as it seems to be only for version 1.10&lt;br /&gt;
&lt;br /&gt;
===Including your own PHP module===&lt;br /&gt;
&#039;&#039;&#039;Ingredients:&#039;&#039;&#039; ggg.game.php, modules/ggg_other.php&lt;br /&gt;
&lt;br /&gt;
*Create ggg_other.php in modules/ folder and sync&lt;br /&gt;
*Modify ggg.game.php to include it&lt;br /&gt;
&lt;br /&gt;
 require_once (&#039;modules/ggg_other.php&#039;);&lt;br /&gt;
&lt;br /&gt;
===Creating a test class to run PHP locally ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Ingredients:&#039;&#039;&#039; ggg.game.php, stubs&lt;br /&gt;
For this you need stubs of other method you can use this for example&lt;br /&gt;
https://github.com/elaskavaia/bga-sharedcode/raw/master/misc/module/table/table.game.php&lt;br /&gt;
&lt;br /&gt;
Create another php files, i.e ggg_test.php&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
define(&amp;quot;APP_GAMEMODULE_PATH&amp;quot;, &amp;quot;misc/&amp;quot;); // include path to stubs, which defines &amp;quot;table.game.php&amp;quot; and other classes&lt;br /&gt;
require_once (&#039;eminentdomaine.game.php&#039;);&lt;br /&gt;
&lt;br /&gt;
class MyGameTest1 extends MyGame { // this is your game class defined in ggg.game.php&lt;br /&gt;
    function __construct() {&lt;br /&gt;
        parent::__construct();&lt;br /&gt;
        include &#039;../material.inc.php&#039;;// this is how this normally included, from constructor&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // override/stub methods here that access db and stuff&lt;br /&gt;
    function getGameStateValue($var) {&lt;br /&gt;
        if ($var == &#039;round&#039;)&lt;br /&gt;
            return 3;&lt;br /&gt;
        return 0;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
$x = new MyGameTest1(); // instantiate your class&lt;br /&gt;
$p = $x-&amp;gt;getGameProgression(); // call one of the methods to test&lt;br /&gt;
if ($p != 50)&lt;br /&gt;
    echo &amp;quot;Test1: FAILED&amp;quot;;&lt;br /&gt;
else&lt;br /&gt;
    echo &amp;quot;Test1: PASSED&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Run from command line like&lt;br /&gt;
 php8.2 ggg_test.php&lt;br /&gt;
&lt;br /&gt;
If you do it this way - you can also use local php debugger (i.e. integrated with IDE or command line).&lt;br /&gt;
&lt;br /&gt;
===Avoiding code in dojo declare style===&lt;br /&gt;
Dojo class declarations are rather bizzare and do not work with most IDEs.&lt;br /&gt;
If you want to write in plain JS with classes, you can stub all the dojo define/declare stuff&lt;br /&gt;
and hook your class into that, so the classes are outside of this mess.&lt;br /&gt;
&lt;br /&gt;
NOTE: this technique is for experienced developers, do not try it if you do not understand&lt;br /&gt;
the consequences.&lt;br /&gt;
&lt;br /&gt;
This is complete example of game .js class&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  // Testla is game name is has to be changed&lt;br /&gt;
class Testla {&lt;br /&gt;
	constructor(game) {&lt;br /&gt;
		console.log(&#039;game constructor&#039;);&lt;br /&gt;
		this.game = game;&lt;br /&gt;
		this.varfoo = new MyFoo(); // this example of class from custom module&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	setup(gamedatas) {&lt;br /&gt;
		console.log(&amp;quot;Starting game setup&amp;quot;, this.varfoo);&lt;br /&gt;
		this.gamedatas = gamedatas;&lt;br /&gt;
		this.dojo.create(&amp;quot;div&amp;quot;, { class: &#039;whiteblock&#039;, innerHTML: _(&amp;quot;hello&amp;quot;) }, &#039;thething&#039;);&lt;br /&gt;
		console.log(&amp;quot;Ending game setup&amp;quot;);&lt;br /&gt;
	};&lt;br /&gt;
	onEnteringState(stateName, args) {&lt;br /&gt;
		console.log(&#039;onEnteringState : &#039; + stateName, args);&lt;br /&gt;
		this.game.addActionButton(&#039;b1&#039;,_(&#039;Click Me&#039;), (e)=&amp;gt;this.onButtonClick(e));&lt;br /&gt;
	};&lt;br /&gt;
	onLeavingState(stateName) {&lt;br /&gt;
		console.log(&#039;onLeavingState : &#039; + stateName, args);&lt;br /&gt;
	};&lt;br /&gt;
	onUpdateActionButtons(stateName, args) {&lt;br /&gt;
		console.log(&#039;onUpdateActionButtons : &#039; + stateName, args);&lt;br /&gt;
	};&lt;br /&gt;
	onButtonClick(event) {&lt;br /&gt;
		console.log(&#039;onButtonClick&#039;,event);&lt;br /&gt;
	};&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
define([&lt;br /&gt;
	&amp;quot;dojo&amp;quot;, &amp;quot;dojo/_base/declare&amp;quot;,&lt;br /&gt;
	&amp;quot;ebg/core/gamegui&amp;quot;,&lt;br /&gt;
	&amp;quot;ebg/counter&amp;quot;,&lt;br /&gt;
	g_gamethemeurl + &#039;/modules/foo.js&#039; // custom module if needed&lt;br /&gt;
],&lt;br /&gt;
	function(dojo, declare) {&lt;br /&gt;
                // testla is game name is has to be changed&lt;br /&gt;
		return declare(&amp;quot;bgagame.testla&amp;quot;, ebg.core.gamegui, {&lt;br /&gt;
			constructor: function() {&lt;br /&gt;
				this.xapp = new Testla(this);&lt;br /&gt;
				this.xapp.dojo = dojo;&lt;br /&gt;
			},&lt;br /&gt;
			setup: function(gamedatas) {&lt;br /&gt;
				this.xapp.setup(gamedatas);&lt;br /&gt;
			},&lt;br /&gt;
			onEnteringState: function(stateName, args) {&lt;br /&gt;
				this.xapp.onEnteringState(stateName, args?.args);&lt;br /&gt;
			},&lt;br /&gt;
			onLeavingState: function(stateName) {&lt;br /&gt;
				this.xapp.onLeavingState(stateName, args);&lt;br /&gt;
			},&lt;br /&gt;
			onUpdateActionButtons: function(stateName, args) {&lt;br /&gt;
				this.xapp.onUpdateActionButtons(stateName, args);&lt;br /&gt;
			},&lt;br /&gt;
		});&lt;br /&gt;
	});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===More readable JS: onEnteringState===&lt;br /&gt;
&lt;br /&gt;
If you have a lot of states in onEnteringState or onUpdateActionButtons and friends - it becomes rather wild, you can do this trick to call some methods dynamically.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
     onEnteringState: function(stateName, args) {&lt;br /&gt;
       console.log(&#039;Entering state: &#039; + stateName, args);&lt;br /&gt;
&lt;br /&gt;
       // Call appropriate method&lt;br /&gt;
       var methodName = &amp;quot;onEnteringState_&amp;quot; + stateName;&lt;br /&gt;
       if (this[methodName] !== undefined) {             &lt;br /&gt;
          console.log(&#039;Calling &#039; + methodName, args.args);&lt;br /&gt;
          this[methodName](args.args);&lt;br /&gt;
       }&lt;br /&gt;
     },&lt;br /&gt;
&lt;br /&gt;
     onEnteringState_playerTurn: function(args) { // this is args directly, not args.args &lt;br /&gt;
         // process&lt;br /&gt;
     },&lt;br /&gt;
&lt;br /&gt;
     onEnteringState_playerSomethingElse: function(args) { &lt;br /&gt;
         // process&lt;br /&gt;
     },&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: since its ignores the undefined functions you don&#039;t have define function for each state, but on the other hand you cannot make typos.&lt;br /&gt;
Same applies to onUpdateActionButtons except you pass &#039;args&#039; to method, not args.args, and for onLeavingState where you don&#039;t pass anything.&lt;br /&gt;
&lt;br /&gt;
=== Frameworks and Preprocessors=== &lt;br /&gt;
&lt;br /&gt;
*[[BGA Type Safe Template]] - Setting up a fully typed project using typescript and more!&lt;br /&gt;
*[[Using Vue]] - work-in-progress guide on using the modern framework Vue.js to create a game&lt;br /&gt;
* [[Using Typescript and Scss]] - How to auto-build Typescript and SCSS files to make your code cleaner&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===PHP Migration===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Ingredients:&#039;&#039;&#039; */php, modules/*.php&lt;br /&gt;
&lt;br /&gt;
BGA recently migrated to from 7.4 to 8.2.&lt;br /&gt;
New php has new rules and deprecations.&lt;br /&gt;
&lt;br /&gt;
There is a tool that can help you do the migration automation, which is php module called rector https://getrector.com/.&lt;br /&gt;
Below is the recipe that converts variables in strings like ${var} (which is deprecated) to {$var}.&lt;br /&gt;
&lt;br /&gt;
1. Install the module&lt;br /&gt;
 composer global require --dev rector/rector&lt;br /&gt;
2. Go to your project directory, commit your code first before this!&lt;br /&gt;
&lt;br /&gt;
3. Create a rector.php file on top level with the following content:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
use Rector\Config\RectorConfig;&lt;br /&gt;
use Rector\Php82\Rector\Encapsed\VariableInStringInterpolationFixerRector;&lt;br /&gt;
&lt;br /&gt;
return RectorConfig::configure()&lt;br /&gt;
    -&amp;gt;withPaths([&lt;br /&gt;
        __DIR__ &lt;br /&gt;
    ])&lt;br /&gt;
    // A. whole set&lt;br /&gt;
    //-&amp;gt;withPreparedSets(typeDeclarations: true)&lt;br /&gt;
    // B. or few rules&lt;br /&gt;
    -&amp;gt;withRules([&lt;br /&gt;
        VariableInStringInterpolationFixerRector::class&lt;br /&gt;
    ]);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
4. Dry run (mine is on linux, not sure where global install on windows)&lt;br /&gt;
  ~/.config/composer/vendor/bin/rector process --dry-run&lt;br /&gt;
&lt;br /&gt;
5. If happy re-run without --dry-run&lt;br /&gt;
&lt;br /&gt;
6. Can remove rector.php now (or can do different rules)&lt;br /&gt;
&lt;br /&gt;
==Backend==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Assigning Player Order===&lt;br /&gt;
Normally when game starts there is &amp;quot;natural&amp;quot; player order assigned randomly.&lt;br /&gt;
&lt;br /&gt;
If you want to deliberatly assign player order at the start of the game (for example, in a game with teams options), you can do so by retrieving the initialization-only player attribute &#039;&#039;&#039;player_table_order&#039;&#039;&#039; and using it to assign values to &#039;&#039;&#039;player_no&#039;&#039;&#039; (which is normally assigned at the start of a game in the order in which players come to the table). (See [https://en.doc.boardgamearena.com/Game_database_model:_dbmodel.sql#The_player_table Game database model] for more details.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;padding: 1em; background: #FFCDD2; color: #B71C1C&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;WARNING:&amp;lt;/b&amp;gt; To prevent unfair advantage (e.g. collusion), the random order must be the default option and &amp;lt;b&amp;gt;non-random options should be limited to friendly mode.&amp;lt;/b&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
                // Retrieve inital player order ([0=&amp;gt;playerId1, 1=&amp;gt;playerId2, ...])&lt;br /&gt;
		$playerInitialOrder = [];&lt;br /&gt;
		foreach ($players as $playerId =&amp;gt; $player) {&lt;br /&gt;
			$playerInitialOrder[$player[&#039;player_table_order&#039;]] = $playerId;&lt;br /&gt;
		}&lt;br /&gt;
		ksort($playerInitialOrder);&lt;br /&gt;
		$playerInitialOrder = array_flip(array_values($playerInitialOrder));&lt;br /&gt;
&lt;br /&gt;
		// Player order based on &#039;playerTeams&#039; option&lt;br /&gt;
		$playerOrder = [0, 1, 2, 3];&lt;br /&gt;
		switch ($this-&amp;gt;getGameStateValue(&#039;playerTeams&#039;)) {&lt;br /&gt;
			case $this-&amp;gt;TEAM_1_2:&lt;br /&gt;
				$playerOrder = [0, 2, 1, 3];&lt;br /&gt;
				break;&lt;br /&gt;
			case $this-&amp;gt;TEAM_1_4:&lt;br /&gt;
				$playerOrder = [0, 1, 3, 2];&lt;br /&gt;
				break;&lt;br /&gt;
			case $this-&amp;gt;TEAM_RANDOM:&lt;br /&gt;
				shuffle($playerOrder);&lt;br /&gt;
				break;&lt;br /&gt;
			default:&lt;br /&gt;
			case $this-&amp;gt;TEAM_1_3:&lt;br /&gt;
				// Default order&lt;br /&gt;
				break;&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
                // Create players&lt;br /&gt;
		// Note: if you added some extra field on &amp;quot;player&amp;quot; table in the database (dbmodel.sql), you can initialize it there.&lt;br /&gt;
		$sql =&lt;br /&gt;
			&#039;INSERT INTO player (player_id, player_color, player_canal, player_name, player_avatar, player_no) VALUES &#039;;&lt;br /&gt;
		$values = [];&lt;br /&gt;
&lt;br /&gt;
		foreach ($players as $playerId =&amp;gt; $player) {&lt;br /&gt;
			$color = array_shift($default_colors);&lt;br /&gt;
			$values[] =&lt;br /&gt;
				&amp;quot;(&#039;&amp;quot; .&lt;br /&gt;
				$playerId .&lt;br /&gt;
				&amp;quot;&#039;,&#039;$color&#039;,&#039;&amp;quot; .&lt;br /&gt;
				$player[&#039;player_canal&#039;] .&lt;br /&gt;
				&amp;quot;&#039;,&#039;&amp;quot; .&lt;br /&gt;
				addslashes($player[&#039;player_name&#039;]) .&lt;br /&gt;
				&amp;quot;&#039;,&#039;&amp;quot; .&lt;br /&gt;
				addslashes($player[&#039;player_avatar&#039;]) .&lt;br /&gt;
				&amp;quot;&#039;,&#039;&amp;quot; .&lt;br /&gt;
				$playerOrder[$playerInitialOrder[$playerId]] .&lt;br /&gt;
				&amp;quot;&#039;)&amp;quot;;&lt;br /&gt;
		}&lt;br /&gt;
		$sql .= implode(&#039;,&#039;, $values);&lt;br /&gt;
		$this-&amp;gt;DbQuery($sql);&lt;br /&gt;
		$this-&amp;gt;reattributeColorsBasedOnPreferences(&lt;br /&gt;
			$players,&lt;br /&gt;
			$gameinfos[&#039;player_colors&#039;]&lt;br /&gt;
		);&lt;br /&gt;
		$this-&amp;gt;reloadPlayersBasicInfos();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Send different notifications to active player vs everybody else===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Ingredients:&#039;&#039;&#039; ggg.js&lt;br /&gt;
&lt;br /&gt;
Hack alert. This is a hack. We were hoping for proper solution by bga framework.&lt;br /&gt;
&lt;br /&gt;
This will allow you to send notification with two message one for specific player and one for everybody else including spectators.&lt;br /&gt;
Note that this does not split the data - all data must be shared.&lt;br /&gt;
&lt;br /&gt;
Add this to .js file&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
bgaFormatText: function(log, args) {&lt;br /&gt;
   if (typeof args.log_others != &#039;undefined&#039; &amp;amp;&amp;amp; typeof args.player_id != &#039;undefined&#039; &amp;amp;&amp;amp; this.player_id != args.player_id) {&lt;br /&gt;
      log = args.log_others;&lt;br /&gt;
   }&lt;br /&gt;
   return { log, args }; // you must return this so the framework can handle the default formatting&lt;br /&gt;
},&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example of usage (from eminentdomain)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    $this-&amp;gt;notify-&amp;gt;all(&#039;tokenMoved&#039;, &lt;br /&gt;
             clienttranslate(&#039;${player_name} adds +2 Colonies to ${place_name}&#039;), // notification with show for player with player_id&lt;br /&gt;
             [&#039;player_id&#039;=&amp;gt;$player_id, // this is mandatory&lt;br /&gt;
             &#039;log_others&#039;=&amp;gt;clienttranslate(&#039;${player_name} adds +2 Colonies to an unknown planet&#039;), // notification will show for others&lt;br /&gt;
              ...&lt;br /&gt;
             ]);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Send transient notifications without incrementing move ID===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Ingredients:&#039;&#039;&#039; ggg.php&lt;br /&gt;
&lt;br /&gt;
Hack alert. This is a hack.&lt;br /&gt;
&lt;br /&gt;
Use this if you need to send some transient notification that should not create a new move ID. The notification should be idempotent -- it should have no practical effect on the game state and would be &#039;&#039;&#039;safe to drop&#039;&#039;&#039; (e.g., it would not matter if a player never received this notification). For example, in a co-op game you want all players to see a real-time preview of some action, before the active player commits their turn.&lt;br /&gt;
&lt;br /&gt;
Doing this mainly affects the instant replay &amp;amp; archive modes. During replay, the BGA framework automatically inserts a 1.5-second pause between each &amp;quot;move&amp;quot;. With this hack, your transient notifications are not considered to be a &amp;quot;move&amp;quot;, so no pause gets added.&lt;br /&gt;
&lt;br /&gt;
;In ggg.php&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$this-&amp;gt;not_a_move_notification = true; // note: do not increase the move counter&lt;br /&gt;
$this-&amp;gt;notify-&amp;gt;all(&#039;cardsPreview&#039;, &#039;&#039;, $args);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: you cannot have code that send notification or even changes state after this, and you cannot reset this variable back either because it only takes effect when you exit action handling function&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Assorted Stuff==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Out-of-turn actions: Un-pass===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Ingredients:&#039;&#039;&#039; ggg.js, ggg.game.php, ggg.action.php, states.inc.php&lt;br /&gt;
&lt;br /&gt;
In multiplayer game sometimes players passes but than they think more and want to un-Pass and redo their choice. &lt;br /&gt;
To re-active a player who passes some trickery required.&lt;br /&gt;
&lt;br /&gt;
Define a special action that does that and hook it up.&lt;br /&gt;
&lt;br /&gt;
In states.inc.php add an action to MULTIPLE_ACTIVE_PLAYER state to &amp;quot;unpass&amp;quot;, lets call it &amp;quot;actionCancel&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In ggg.action.php add action hook&lt;br /&gt;
    public function actionCancel() {&lt;br /&gt;
        $this-&amp;gt;setAjaxMode();&lt;br /&gt;
        $this-&amp;gt;game-&amp;gt;actionCancel();&lt;br /&gt;
        $this-&amp;gt;ajaxResponse();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
In ggg.game.php add action handler&lt;br /&gt;
    function actionCancel() {&lt;br /&gt;
        $this-&amp;gt;gamestate-&amp;gt;checkPossibleAction(&#039;actionCancel&#039;);&lt;br /&gt;
        $this-&amp;gt;gamestate-&amp;gt;setPlayersMultiactive(array ($this-&amp;gt;getCurrentPlayerId() ), &#039;error&#039;, false);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
Finally to call this in client ggg.js you would do something like:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 onUpdateActionButtons:  function(stateName, args) {&lt;br /&gt;
   if (this.isCurrentPlayerActive()) { &lt;br /&gt;
     // ...&lt;br /&gt;
   } else if (!this.isSpectator) { // player is NOT active but not spectator&lt;br /&gt;
       switch (stateName) {&lt;br /&gt;
          case &#039;playerTurnMultiPlayerState&#039;:&lt;br /&gt;
		this.addActionButton(&#039;button_unpass&#039;, _(&#039;Oh no!&#039;), &#039;onUnpass&#039;);&lt;br /&gt;
		break;&lt;br /&gt;
	}&lt;br /&gt;
   }&lt;br /&gt;
 }&lt;br /&gt;
				&lt;br /&gt;
 onUnpass: function(e) {&lt;br /&gt;
    this.bgaPerformAction(&amp;quot;actionCancel&amp;quot;, null, { checkAction: false }); // no checkAction!&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Although be careful that if the turn comes back to the player while he is about to click cancel, the action buttons will be updated and the player will misclick which can be quite frustrating. To avoid this, move the cancel button to another position, like to the left of pagemaintitletext:&lt;br /&gt;
  dojo.place(&#039;button_unpass&#039;, &#039;pagemaintitletext&#039;, &#039;before&#039;);&lt;br /&gt;
Being out of the generalactions div, it won&#039;t be automatically destroyed like normal buttons, so you&#039;ll have to handle that yourself in onLeavingState. You might also want to change the button color to red (blue buttons for active player only, red buttons also for inactive players?)&lt;br /&gt;
&lt;br /&gt;
Note: same technique can be used to do other out-of-turn actions, such as re-arranging cards in hand, exchanging resources, etc (i.e. if permitted by rules, such as &amp;quot;at any time player can...&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
===Multi Step Interactions: Select Worker/Place Worker - Using Selection ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Ingredients:&#039;&#039;&#039; ggg.js&lt;br /&gt;
&lt;br /&gt;
Simple way to implement something like that without extra states is to use &amp;quot;selection&amp;quot; mechanism. When user click on worker add some sort of class into that element i.e. &#039;selected&#039; (which also have to have some indication by css i.e. outline).&lt;br /&gt;
&lt;br /&gt;
Than user can click on placement zone, you can use dojo.query for &amp;quot;selected&amp;quot; element and use it along with zone id to send data to server. If proper worker is not selected yet can give a error message using this.showMessage(...) function.&lt;br /&gt;
&lt;br /&gt;
Extra code required to properly cleanup selection between states.&lt;br /&gt;
Also when you do that sometimes you want to change the state prompt, see below &#039;Change state prompt&#039;&lt;br /&gt;
&lt;br /&gt;
===Multi Step Interactions: Select Worker/Place Worker - Using Client States ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Ingredients:&#039;&#039;&#039; ggg.js&lt;br /&gt;
&lt;br /&gt;
I don&#039;t think its documented feature but there is a way to do client-only states, which is absolutely wonderful for few reasons&lt;br /&gt;
*When player interaction is two step process, such as select worker, place worker, or place worker, pick one of two resources of your choice&lt;br /&gt;
* When multi-step process can result of impossible situation and has to be undone (by rules)&lt;br /&gt;
*When multi-step process is triggered from multiple states (such as you can do same thing as activated card action, pass action or main action)&lt;br /&gt;
&lt;br /&gt;
So lets do Select Worker/Place Worker&lt;br /&gt;
&lt;br /&gt;
Define your server state as usual, i.e. playerMainTurn -&amp;gt; &amp;quot;You must pick up a worker&amp;quot;.&lt;br /&gt;
Now define a client state, we only need &amp;quot;name&amp;quot; and &amp;quot;descriptionmyturn&amp;quot;, lets say &amp;quot;client_playerPicksLocation&amp;quot;. Always prefix names of client state with &amp;quot;client_&amp;quot; to avoid confusion. Now we have to do the following:&lt;br /&gt;
*Have a handler for onUpdateActionButtons for playerMainTurn to activate all possible workers he can pick&lt;br /&gt;
*When player clicks workers, remember the worker in one of the members of the main class, I usually use one called this.clientStateArgs.&lt;br /&gt;
*Transition to new client state&lt;br /&gt;
  onWorker: function(e) {&lt;br /&gt;
      var id = event.currentTarget.id;&lt;br /&gt;
      dojo.stopEvent(event);&lt;br /&gt;
      ... // do validity checks&lt;br /&gt;
      this.clientStateArgs.worker_id = id;&lt;br /&gt;
      this.setClientState(&amp;quot;client_playerPicksLocation&amp;quot;, {&lt;br /&gt;
                                descriptionmyturn : _(&amp;quot;${you} must select location&amp;quot;),&lt;br /&gt;
                            });&lt;br /&gt;
   }&lt;br /&gt;
* Have a handler for onUpdateActionButtons for client_playerPicksLocation to activate all possible locations this worker can go AND add Cancel button (see below)&lt;br /&gt;
*Have a location handler which will eventually send a server request, using stored this.clientStateArgs.worker_id as worker id&lt;br /&gt;
*The cancel button should call a method to restore server state, also if you doing it for more than one state you can add this universally using this.on_client_state check&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
        if (this.isCurrentPlayerActive()) {&lt;br /&gt;
          if (this.on_client_state &amp;amp;&amp;amp; !$(&#039;button_cancel&#039;)) {&lt;br /&gt;
               this.addActionButton(&#039;button_cancel&#039;, _(&#039;Cancel&#039;), dojo.hitch(this, function() {&lt;br /&gt;
                                             this.restoreServerGameState();&lt;br /&gt;
               }));&lt;br /&gt;
          }&lt;br /&gt;
        } &lt;br /&gt;
Note: usually I call my own function call this.cancelLocalStateEffects() which will do more stuff first then call restoreServerGameState(), same function is usually needs to be called when server request has failed (i.e. invalid move)&lt;br /&gt;
&lt;br /&gt;
Note: If you need more than 2 steps, you may have to do client side animation to reflect the new state, which gets trickier because you have to undo that also on cancellation.&lt;br /&gt;
&lt;br /&gt;
Code is available here [https://github.com/elaskavaia/bga-sharedcode/blob/master/sharedcode.js sharedcode.js] (its using playerTurnPlayCubes and client_selectCubeLocation).&lt;br /&gt;
&lt;br /&gt;
===Action Stack - Using Client States===&lt;br /&gt;
&lt;br /&gt;
Action stack required where game is very complex and use triggered effects that can &amp;quot;stack&amp;quot;. It not always actual stack, it can be queue or random access.&lt;br /&gt;
&lt;br /&gt;
Examples:&lt;br /&gt;
*Magic the Gathering - classic card game where effects go on Stack, that allows to counter spell and counter spell of counter spell (not on bga - it just example of mechanics)&lt;br /&gt;
*Ultimate Railroads - action taking game where effects can be executed in any order&lt;br /&gt;
*Lewis and Clark - card game where actions executed as queue&lt;br /&gt;
&lt;br /&gt;
There is two ways of implementing it - on the server or the client.&lt;br /&gt;
For the server see article below.&lt;br /&gt;
The requirement for client side stack implementation is - all action can be undone, which means&lt;br /&gt;
* No dice rolls&lt;br /&gt;
* No card drawn&lt;br /&gt;
* No other players interaction&lt;br /&gt;
&lt;br /&gt;
No snippets are here, as this will be too complex but basically flow is:&lt;br /&gt;
*You have a action/effect stack (queue/list) as js object attached to &amp;quot;this&amp;quot;, i.e. this.unprocessed_actions&lt;br /&gt;
*When player plays a card, worker, etc, you read the effect of that card from the material file (client copy), and place into stack&lt;br /&gt;
*Then we call dispatch method which pulls the next action from the stack and change client state accordinly, i.e. this.setClientState(&amp;quot;client_playerGainsCubes&amp;quot;)&lt;br /&gt;
* When players acts on it - the action is removed from the stack and added to &amp;quot;server action arguments&amp;quot; list, this is another object which be used to send ajax call, i.e. this.clientStateArgs&lt;br /&gt;
*If nothing left in stack we can submit the ajax call assembling parameters from collected arguments (that can include action name)&lt;br /&gt;
*This method allows cheap undo - by restoring server state you will wipe out all user actions (but if you need intermediate aninmation you have to handle it yourself)&lt;br /&gt;
&lt;br /&gt;
Code can be found in Ultimate Railroads game (but it is random access list - so it a bit complex) and Lewis and Clark (complexity - user can always deny part of any effect)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Action Stack - Using Server States===&lt;br /&gt;
&lt;br /&gt;
See definition of Action Stack above.&lt;br /&gt;
&lt;br /&gt;
To implement you usually need another db table that has the following fields: index of effect - which is used for sorted access, type - which is essense of the effect (i.e. collect resource), some extra arguments (i.e. resource type and resource count), and usually owner of the effect (i.e. player id)&lt;br /&gt;
The flow is:&lt;br /&gt;
* There is some initial player state, where player can play card for example&lt;br /&gt;
*Player main action - pushes the card effect on stack, which also can cause triggered effects which also go on stack&lt;br /&gt;
*After action processing is finished switch to game state which is &amp;quot;dispatcher&amp;quot;&lt;br /&gt;
*Dispatcher pulls the top effect (whatever definition of the top is), changes the active player and changes the state to appropriate player state to collect response. The &amp;quot;top&amp;quot; can be choice of multiple actions, in this case player has to chose one before resolving the effect.&lt;br /&gt;
*Player state knows about the stack and pulls arguments (argX) from the effect arguments of the db&lt;br /&gt;
*Player action should clear up the top effect, and can possibly add more effects, then switch to &amp;quot;dispatcher&amp;quot; state again&lt;br /&gt;
*If stack is empty, dispatcher can either pick next player itself or use another game state which responsible for picking next player&lt;br /&gt;
&lt;br /&gt;
Code can be found in Tapestry and Terraforming Mars.&lt;br /&gt;
===Custom error/exception handling in JavaScript === &lt;br /&gt;
&lt;br /&gt;
;In ggg.php&lt;br /&gt;
Throw \BgaUserException with some easy-to-identify prefix such as &amp;quot;!!!&amp;quot; and a custom error code. DO NOT TRANSLATE this message text. The exception will rollback database transaction and cancel all changes (including any notifications).&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    function foo(bool $didConfirm = false): void&lt;br /&gt;
    {&lt;br /&gt;
        // do processing for the user&#039;s move&lt;br /&gt;
        // afterwards, you determine this move will end the game&lt;br /&gt;
        // so you want to rollback the transaction and require the user to confirm the move first&lt;br /&gt;
&lt;br /&gt;
        if ($gameIsEnding &amp;amp;&amp;amp; !$didConfirm) {&lt;br /&gt;
            throw new \BgaUserException(&#039;!!!endGameConfirm&#039;, 9001);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;In ggg.js&lt;br /&gt;
Override framework function showMessage to suppress the red banner message and gamelog message when you detect the &amp;quot;!!!&amp;quot; prefix&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    /* @Override */&lt;br /&gt;
    showMessage: function (msg, type) {&lt;br /&gt;
      if (type == &amp;quot;error&amp;quot; &amp;amp;&amp;amp; msg &amp;amp;&amp;amp; msg.startsWith(&amp;quot;!!!&amp;quot;)) {&lt;br /&gt;
        return; // suppress red banner and gamelog message&lt;br /&gt;
      }&lt;br /&gt;
      this.inherited(arguments);&lt;br /&gt;
    },&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Deal with the error in your callback:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    fooAction: function (didConfirm) {&lt;br /&gt;
      var data = {&lt;br /&gt;
        foo: &amp;quot;bar&amp;quot;,&lt;br /&gt;
        didConfirm: !!didConfirm,&lt;br /&gt;
      };&lt;br /&gt;
      this.bgaPerformAction(&amp;quot;fooAction&amp;quot;, data).catch((error, errorMsg) =&amp;gt; {&lt;br /&gt;
        if (error &amp;amp;&amp;amp; errorMsg == &amp;quot;!!!endGameConfirm&amp;quot;) {&lt;br /&gt;
          // your custom error handling goes here&lt;br /&gt;
          // for example, show a confirmation dialog and repeat the action with additional param&lt;br /&gt;
          this.confirmationDialog(&lt;br /&gt;
            _(&amp;quot;Doing the foo action now will end the game&amp;quot;),&lt;br /&gt;
            () =&amp;gt; this.fooAction(true)&lt;br /&gt;
          );&lt;br /&gt;
        }&lt;br /&gt;
      });&lt;br /&gt;
    },&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For custom global error handling, you could modify ajaxcallwrapper:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  ajaxcallwrapper: function (action, args, handler) {&lt;br /&gt;
    if (!args) args = {};&lt;br /&gt;
    args.lock = true;&lt;br /&gt;
    args.version = this.gamedatas.version;&lt;br /&gt;
    if (this.checkAction(action)) {&lt;br /&gt;
      this.bgaPerformAction(&lt;br /&gt;
        action,&lt;br /&gt;
        args&lt;br /&gt;
      ).catch((error, errorMsg, errorCode) =&amp;gt; {&lt;br /&gt;
          if (error &amp;amp;&amp;amp; errorMsg == &amp;quot;!!!checkVersion&amp;quot;) {&lt;br /&gt;
            this.infoDialog(&lt;br /&gt;
              _(&amp;quot;A new version of this game is now available&amp;quot;),&lt;br /&gt;
              _(&amp;quot;Reload Required&amp;quot;),&lt;br /&gt;
              () =&amp;gt; {&lt;br /&gt;
                window.location.reload();&lt;br /&gt;
              },&lt;br /&gt;
              true&lt;br /&gt;
            );&lt;br /&gt;
          } else {&lt;br /&gt;
            if (handler) handler(error, errorMsg, errorCode);&lt;br /&gt;
          }&lt;br /&gt;
        }&lt;br /&gt;
      );&lt;br /&gt;
    }&lt;br /&gt;
  },&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Force players to refresh after new deploy===&lt;br /&gt;
&lt;br /&gt;
When you deploy a new version of your game, the PHP backend code is immediately updated but the JavaScript/HTML/CSS frontend code *does not update* for active players until they manually refresh the page (F5) in their browser. Obviously this is not ideal. In the best case, real-time tables don&#039;t see your shiny new enhancements. In the worst case, your old JS code isn&#039;t compatible with your new PHP code and the game breaks in strange ways (any bug reports filed will be false positives and unable to reproduce). To avoid any problems, you should force all players to immediately reload the page following a new deploy.&lt;br /&gt;
&lt;br /&gt;
By throwing a &amp;quot;visible&amp;quot; exception (simplest solution), you&#039;ll get something like this which instructs the user to reload:&lt;br /&gt;
&lt;br /&gt;
[[File:Force-refresh.png|950x950px]]&lt;br /&gt;
&lt;br /&gt;
Or, if you combine this technique with the above custom error handling technique, you could do something a bit nicer. You could show a dialog box and automatically refresh the page when the user clicks &amp;quot;OK&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
[[File:Reload-required.png|500x500px]]&lt;br /&gt;
; In ggg.php&lt;br /&gt;
Transmit the server version number in &amp;lt;code&amp;gt;getAllDatas()&amp;lt;/code&amp;gt;.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    protected function getAllDatas(): array&lt;br /&gt;
    {&lt;br /&gt;
        $players = $this-&amp;gt;getCollectionFromDb(&amp;quot;SELECT player_id id, player_score score FROM player&amp;quot;);&lt;br /&gt;
        return [&lt;br /&gt;
            &#039;players&#039; =&amp;gt; $players,&lt;br /&gt;
            &#039;version&#039; =&amp;gt; intval($this-&amp;gt;gamestate-&amp;gt;table_globals[300]), // &amp;lt;-- ADD HERE&lt;br /&gt;
            ...&lt;br /&gt;
        ];&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create a helper function to fail if the client and server versions mismatch. Note the version check uses &amp;lt;code&amp;gt;!=&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;&amp;amp;lt;&amp;lt;/code&amp;gt; so it can support rollback to a previous deploy as well. ;-)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    public function checkVersion(int $clientVersion): void&lt;br /&gt;
    {&lt;br /&gt;
        if ($clientVersion != intval($this-&amp;gt;gamestate-&amp;gt;table_globals[300])) {&lt;br /&gt;
            // Simplest way is to throw a &amp;quot;visible&amp;quot; exception&lt;br /&gt;
            // It&#039;s ugly but comes with a &amp;quot;click here&amp;quot; link to refresh&lt;br /&gt;
            throw new BgaVisibleSystemException($this-&amp;gt;_(&amp;quot;A new version of this game is now available. Please reload the page (F5).&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
            // For something prettier, throw a &amp;quot;user&amp;quot; exception and handle in JS&lt;br /&gt;
            // (see BGA cookbook section above on custom error handling)&lt;br /&gt;
            throw new \BgaUserException(&#039;!!!checkVersion&#039;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Every action requires a parameter &amp;lt;code&amp;gt;int $version&amp;lt;/code&amp;gt; and a call to &amp;lt;code&amp;gt;$this-&amp;gt;checkVersion()&amp;lt;/code&amp;gt; as the first line. The version check should happen before anything else, even before checking if the action is allowed (since possible actions could change between versions). If you are using auto-wired &amp;quot;act&amp;quot; action functions, modify each to start like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    #[CheckAction(false)]&lt;br /&gt;
    public function actXxx(int $version, ...) {&lt;br /&gt;
        $this-&amp;gt;checkVersion($version);&lt;br /&gt;
        $this-&amp;gt;checkAction(&#039;actXxx&#039;); // or $this-&amp;gt;gamestate-&amp;gt;checkPossibleAction(&#039;actXxx&#039;);&lt;br /&gt;
        ...&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;In ggg.js&lt;br /&gt;
Transmit the version (from gamedatas) as a parameter with every ajax call. For example, if you&#039;re already using a wrapper function for every ajax call, add it like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  ajaxcallwrapper: function (action, args) {&lt;br /&gt;
    if (!args) args = {};&lt;br /&gt;
    args.version = this.gamedatas.version; // &amp;lt;-- ADD HERE&lt;br /&gt;
    this.bgaPerformAction(action, args);&lt;br /&gt;
  },&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Disable / lock table creation for new deploy===&lt;br /&gt;
&lt;br /&gt;
If you are deploying a major new game version, especially if it involves upgrading production game databases, you may have a lot of angry players if you break their tables.  Depending on your changes, you may be able to restore the previous version and fix the tables easily.&lt;br /&gt;
&lt;br /&gt;
However, if a new deploy turns out bad and players created turn-based tables while it was live, it may be quite difficult to fix those tables, since they were created from a bad deploy.&lt;br /&gt;
&lt;br /&gt;
The solution?  You can announce in your game group that you are locking table creation, and then in your new version, add an impossible startcondition to an existing option.  &lt;br /&gt;
Note: This only makes sense if you have a few games running in real time mode in the time of deployment, otherwise it won&#039;t achieve much, unless you wait at least a day for other turn based games to break (or not)&lt;br /&gt;
&lt;br /&gt;
Here is an example of an option with only 2 values (if you don&#039;t have options at all you have to create a fake option to use this method, if you have more values - you have to list them all): &lt;br /&gt;
&lt;br /&gt;
;In gameoptions.json&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
        &amp;quot;startcondition&amp;quot;: {&lt;br /&gt;
            &amp;quot;0&amp;quot;: [ { &amp;quot;type&amp;quot;: &amp;quot;minplayers&amp;quot;, &amp;quot;value&amp;quot;: 32, &amp;quot;message&amp;quot;: &amp;quot;Maintenance in progress.  Table creation is disabled.&amp;quot; } ],&lt;br /&gt;
            &amp;quot;1&amp;quot;: [ { &amp;quot;type&amp;quot;: &amp;quot;minplayers&amp;quot;, &amp;quot;value&amp;quot;: 32, &amp;quot;message&amp;quot;: &amp;quot;Maintenance in progress.  Table creation is disabled.&amp;quot; } ]&lt;br /&gt;
        },&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
;In gameoptions.inc.php (older method if you have it in php)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// TODO NEXT remove after testing deploy to upgrade, here 0 and 1 - replace with values of your option!&lt;br /&gt;
&#039;startcondition&#039; =&amp;gt; [&lt;br /&gt;
   0 =&amp;gt; [ [ &#039;type&#039; =&amp;gt; &#039;minplayers&#039;, &#039;value&#039; =&amp;gt; 32, &#039;message&#039; =&amp;gt; totranslate(&#039;Maintenance in progress.  Table creation is disabled.&#039;) ] ],&lt;br /&gt;
   1 =&amp;gt; [ [ &#039;type&#039; =&amp;gt; &#039;minplayers&#039;, &#039;value&#039; =&amp;gt; 32, &#039;message&#039; =&amp;gt; totranslate(&#039;Maintenance in progress.  Table creation is disabled.&#039;) ] ],&lt;br /&gt;
],&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Be sure to click &amp;quot;Reload game options configuration&amp;quot; after making this change, then test in studio (test that you cannot create any table)&lt;br /&gt;
* Deploy to production&lt;br /&gt;
*Now, when a player attempts to create a new table, they will see a red error bar with your &amp;quot;Maintenance in progress&amp;quot; message.&lt;br /&gt;
*Wait for screaming (if you have real times games in progress waiting 15 min probably ok, if you have only turn based games, probably a day)&lt;br /&gt;
*Once you confirm the new deploy looks good, you can revert the change in gameoptions.inc.php and do another deploy.&lt;br /&gt;
&lt;br /&gt;
===Local Storage===&lt;br /&gt;
&lt;br /&gt;
There is not much you can store in localStorage (https://developer.mozilla.org/docs/Web/API/Window/localStorage), since most stuff should be stored either in game db or in user prefrences,&lt;br /&gt;
but some stuff makes sense to store there, for example &amp;quot;zoom&amp;quot; level (if you use custom zooming). This setting really affect this specific host and specific browser, setting it localStorage makes most sense.&lt;br /&gt;
&lt;br /&gt;
game.js&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   setup: function (gamedatas) {&lt;br /&gt;
        let zoom = localStorage.getItem(`${this.game_name}_zoom`);&lt;br /&gt;
        this.setZoom(zoom);&lt;br /&gt;
...&lt;br /&gt;
   },&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In this case setZoom is custom function to actually set it.&lt;br /&gt;
When zoom changed, for example when some buttons pressed, store current value (but sanitize it so it never so bad that game cannot be viewed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    setZoom: function (zoom) {&lt;br /&gt;
      zoom = parseInt(zoom) || 0;&lt;br /&gt;
      if (zoom === 0 || zoom &amp;lt; 0.1 || zoom &amp;gt; 10) {&lt;br /&gt;
        zoom = 1;&lt;br /&gt;
      }&lt;br /&gt;
      this.zoom = zoom;&lt;br /&gt;
      localStorage.setItem(`${this.game_name}_zoom`, &amp;quot;&amp;quot; + this.zoom);&lt;br /&gt;
... do actual zooming stuff&lt;br /&gt;
    },&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Capture client JavaScript errors in the &amp;quot;unexpected error&amp;quot; log===&lt;br /&gt;
&lt;br /&gt;
PHP (backend) errors are recorded in the &amp;quot;unexpected error&amp;quot; log, but JavaScript (frontend) errors are only available in the browser itself. This means you have no visibility about things that go wrong in the client... unless you make clients report their errors to the server.&lt;br /&gt;
&lt;br /&gt;
;In actions.php:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  public function jsError()&lt;br /&gt;
  {&lt;br /&gt;
    $this-&amp;gt;setAjaxMode(false);&lt;br /&gt;
    $this-&amp;gt;game-&amp;gt;jsError($_POST[&#039;userAgent&#039;], $_POST[&#039;msg&#039;]);&lt;br /&gt;
    $this-&amp;gt;ajaxResponse();&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
; In game.php:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    public function jsError($userAgent, $msg): void&lt;br /&gt;
    {&lt;br /&gt;
        $this-&amp;gt;error(&amp;quot;JavaScript error from User-Agent: $userAgent\n$msg // &amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;In game.js:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
define([&amp;quot;dojo&amp;quot;, &amp;quot;dojo/_base/declare&amp;quot;, &amp;quot;ebg/core/gamegui&amp;quot;, &amp;quot;ebg/counter&amp;quot;], function (dojo, declare) {&lt;br /&gt;
  const uniqJsError = {};&lt;br /&gt;
  ...&lt;br /&gt;
&lt;br /&gt;
  return declare(&amp;quot;bgagame.nowboarding&amp;quot;, ebg.core.gamegui, {&lt;br /&gt;
    ...&lt;br /&gt;
    /* @Override */&lt;br /&gt;
    onScriptError(msg) {&lt;br /&gt;
      if (!uniqJsError[msg]) {&lt;br /&gt;
        uniqJsError[msg] = true;&lt;br /&gt;
        console.error(&amp;quot;⛔ Reporting JavaScript error&amp;quot;, msg);&lt;br /&gt;
        this.ajaxcall(&lt;br /&gt;
          &amp;quot;/&amp;quot; + this.game_name + &amp;quot;/&amp;quot; + this.game_name + &amp;quot;/jsError.html&amp;quot;,&lt;br /&gt;
          {&lt;br /&gt;
            msg,&lt;br /&gt;
            userAgent: navigator.userAgent,&lt;br /&gt;
          },&lt;br /&gt;
          this,&lt;br /&gt;
          () =&amp;gt; {},&lt;br /&gt;
          () =&amp;gt; {},&lt;br /&gt;
          &amp;quot;post&amp;quot;&lt;br /&gt;
        );&lt;br /&gt;
      }&lt;br /&gt;
      this.inherited(arguments);&lt;br /&gt;
    },&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Algorithms ==&lt;br /&gt;
&lt;br /&gt;
===Generate permutations in lexicographic order===&lt;br /&gt;
&lt;br /&gt;
Use this when you have an array like [1, 2, 3, 4] and need to loop over some/all 24 permutations of possible ordering. This type of [https://www.php.net/manual/en/language.generators.syntax.php generator function] computes each possibility one at a time, making it vastly more efficient than either a normal iteration or recursive function that produce all possibilities up front.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
function generatePermutations(array $array): Generator&lt;br /&gt;
{&lt;br /&gt;
    // https://en.wikipedia.org/wiki/Permutation#Generation_in_lexicographic_order&lt;br /&gt;
    // Sort the array and this is the first permutation&lt;br /&gt;
    sort($array);&lt;br /&gt;
    yield $array;&lt;br /&gt;
&lt;br /&gt;
    $count = count($array);&lt;br /&gt;
    do {&lt;br /&gt;
        // Find the largest index k where a[k] &amp;lt; a[k + 1]&lt;br /&gt;
        // End when no such index exists&lt;br /&gt;
        $found = false;&lt;br /&gt;
        for ($k = $count - 2; $k &amp;gt;= 0; $k--) {&lt;br /&gt;
            $kvalue = $array[$k];&lt;br /&gt;
            $knext = $array[$k + 1];&lt;br /&gt;
            if ($kvalue &amp;lt; $knext) {&lt;br /&gt;
                // Find the largest index l greater than k where a[k] &amp;lt; a[l]&lt;br /&gt;
                for ($l = $count - 1; $l &amp;gt; $k; $l--) {&lt;br /&gt;
                    $lvalue = $array[$l];&lt;br /&gt;
                    if ($kvalue &amp;lt; $lvalue) {&lt;br /&gt;
                        // Swap a[k] and a[l]&lt;br /&gt;
                        [$array[$k], $array[$l]] = [$array[$l], $array[$k]];&lt;br /&gt;
&lt;br /&gt;
                        // Reverse the sequence from a[k + 1] up to and including the final element&lt;br /&gt;
                        $reverse = array_reverse(array_slice($array, $k + 1));&lt;br /&gt;
                        array_splice($array, $k + 1, $count, $reverse);&lt;br /&gt;
                        yield $array;&lt;br /&gt;
&lt;br /&gt;
                        // Restart with the new array to find the next permutation&lt;br /&gt;
                        $found = true;&lt;br /&gt;
                        break 2;&lt;br /&gt;
                    }&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    } while ($found);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$cash = [4, 1, 2, 3, 4];&lt;br /&gt;
foreach ($this-&amp;gt;generatePermutations($cash) as $p) {&lt;br /&gt;
    // your code here to evaluate permutation $p&lt;br /&gt;
    // first iteration: $p = [1, 2, 3, 4, 4]&lt;br /&gt;
    // last (60th) iteration: $p = [4, 4, 3, 2, 1]&lt;br /&gt;
    // break from loop once you achieve your goal&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Studio]]&lt;/div&gt;</summary>
		<author><name>Fenadoruk</name></author>
	</entry>
	<entry>
		<id>https://en.doc.boardgamearena.com/index.php?title=Gamehelpauctionland&amp;diff=25971</id>
		<title>Gamehelpauctionland</title>
		<link rel="alternate" type="text/html" href="https://en.doc.boardgamearena.com/index.php?title=Gamehelpauctionland&amp;diff=25971"/>
		<updated>2025-07-31T09:58:45Z</updated>

		<summary type="html">&lt;p&gt;Fenadoruk: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
Build and auction tiles to create the most impressive paradise island!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Setup:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Each player grabs a screen and some money. The player who last visited a new island starts the game and takes the gavel! Starting money is distributed as follows:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|1st player&lt;br /&gt;
|2nd player&lt;br /&gt;
|3rd player&lt;br /&gt;
|4th player&lt;br /&gt;
|5th player&lt;br /&gt;
|6th player&lt;br /&gt;
|-&lt;br /&gt;
|$7&lt;br /&gt;
|$8&lt;br /&gt;
|$9&lt;br /&gt;
|$10&lt;br /&gt;
|$11&lt;br /&gt;
|$12&lt;br /&gt;
|} For a 2-player game: &lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|1st player&lt;br /&gt;
|2nd player&lt;br /&gt;
|-&lt;br /&gt;
|$10&lt;br /&gt;
|$12&lt;br /&gt;
|}&lt;br /&gt;
Place money behind your screen.&lt;br /&gt;
&lt;br /&gt;
Create 3 rows of 5 tiles (6 tiles in a 5-6 player game) into the middle to form the market. Sort them by the number of icons (Peace, Love &amp;amp; Music), with more icons closer to the stack of tiles.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Turn summary:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
1. &#039;&#039;&#039;Build Tile&#039;&#039;&#039;: Select a tile from the market to add to your island.&lt;br /&gt;
&lt;br /&gt;
2. &#039;&#039;&#039;Auction Tile&#039;&#039;&#039;: After building, select another tile and auction it off.&lt;br /&gt;
&lt;br /&gt;
3. &#039;&#039;&#039;End turn&#039;&#039;&#039;: Pass the gavel to the player on your left. It’s now their turn. Refresh the market back to 8 tiles (or the market size set in game settings) but don&#039;t sort them.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The Market:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Whenever you take a tile from the market (for building, auctioning, or Bonus), place $1 on each skipped tile starting from the free tile. Earn the money on the selected tile and place it behind your screen.&lt;br /&gt;
&lt;br /&gt;
If you already took a tile from a Market Row, you may not take another one from that same row again until the end of your turn. This restriction applies per player: it does not affect other players. For example, if you took a tile from a row, the auction winner can still take a tile from that same row (see Bonus).&lt;br /&gt;
&lt;br /&gt;
If a player needs to take a tile from the market, and any row has only 1 tile left, immediately draw new tiles and refresh the rows back to the tile limit (5 tiles with 2-4 players, 6 tiles with 5-6 players). Do not arrange the tiles by their icon count.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Building Tiles:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
New tiles placed after your first must share an edge with an existing tile on your island. You can expand your island in any direction as long as it doesn’t go beyond 4x4.&lt;br /&gt;
&lt;br /&gt;
Placing the 4th tile in a row or column earns you a Bonus tile (see Bonus Tiles).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Auctioning Tiles:&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
After building your tile, select a new tile following &#039;&#039;&#039;the market&#039;&#039;&#039; rules and put it on auction! It’s an open auction carried out simultaneously. Players can increase bids -even their own- any time as long as you have enough money to pay for it. The auction phase is over once all but one player has passed.&lt;br /&gt;
&lt;br /&gt;
In a 2-player game, the bidding player makes only 1 bid which concludes the auction phase.&lt;br /&gt;
&lt;br /&gt;
In the rare case that no one bids, the auctioneer takes the tile for free.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Buy back:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Once the auction phase is over, the auctioneer can either:&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Sell&#039;&#039;&#039; the auctioned tile to the highest bidder.&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Buy back&#039;&#039;&#039; the tile by paying the winning bid plus $1 to the highest bidder. i.e. Alex won the auction phase with a bid of $3, the auctioneer can pay $4 to Alex and build the tile.&lt;br /&gt;
&lt;br /&gt;
The auctioneer can still buy back even if their island is full. In that case, the auctioned tile is returned to the game box.&lt;br /&gt;
&lt;br /&gt;
Make sure you are not bidding so little that the auctioneer buys it back from you. Or maybe you want them to! After all, you&#039;re being paid without losing anything!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Bonus Tiles:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
After adding a tile to your island in &#039;&#039;&#039;any&#039;&#039;&#039; phase or for &#039;&#039;&#039;any&#039;&#039;&#039; reason, check whether it was the 4th tile of a row or column. If so, you immediately earn a Bonus tile!&lt;br /&gt;
&lt;br /&gt;
Draw a new tile following &#039;&#039;&#039;the market rules&#039;&#039;&#039; and build it by following the &#039;&#039;&#039;building tiles&#039;&#039;&#039; rules. Each player can earn only 1 Bonus tile per turn. In other words, a Bonus tile cannot trigger another Bonus, but more than 1 player can draw a Bonus tile on a single turn.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Game End:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Once a player has filled their 4x4 island, the game will be over at the end of that turn. This means you still proceed to the &#039;&#039;&#039;auction phase&#039;&#039;&#039; if you haven’t already done so.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;SCORING&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Beaches:&#039;&#039;&#039; Imagine the table is the ocean! Count tiles with a beach zone touching the edge of your island. Score points based on the scoring table found in the game’s tooltips. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If a beach is not on the edge but still adjacent to a gap (because your 4x4 island wasn’t filled up) it still scores. The table is the ocean and it’s a wonderful beach by the water!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Theme Parks:&#039;&#039;&#039; Count tiles in your largest contiguous theme park area (diagonal connections don’t count). Score points based on the scoring table found in the game’s tooltips. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Gardens &amp;amp; Houses:&#039;&#039;&#039; Multiply the number of garden areas by the number of house areas. Adjacent zones of the same type count as one area; so keep gardens separate from other gardens and likewise for the houses. &#039;&#039;&#039;It’s fine if a garden is touching a house.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Icons:&#039;&#039;&#039; The positions of the icons don’t matter. Each icon type scores separately. The player with the highest number of an icon type scores 20 points, 2nd player scores 10 and 3rd player scores 5. Ties are friendly; all tying players score the same amount of points but you skip the next number for each tying player.&lt;br /&gt;
&lt;br /&gt;
You must have at least 1 icon of the type to score points from it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039; Alex has 2 ☮️, 2 ❤️, 3 🎵. Bonnie has 3 ☮️, 2 ❤️, 3 🎵. Charlie has 3 ☮️and 3 🎵. Doruk has only 1 🎵.&lt;br /&gt;
&lt;br /&gt;
☮️ (A: 2, B: 3, C: 3, D: 0): Alex scores 5 points. Bonnie and Charlie score 20 each.&lt;br /&gt;
&lt;br /&gt;
❤️ (A: 2, B: 2, C: 0, D: 0): Alex and Bonnie score 20 points. Other players score 0 as they don’t have any ❤️ icons. If they had only 1 ❤️, it’d be 5 points for them!&lt;br /&gt;
&lt;br /&gt;
🎵 (A: 3, B: 3, C: 3, D: 1): Alex, Bonnie and Charlie score 20 points. Doruk doesn’t score.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Most points win. Money breaks ties.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Tropical Treats expansion:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
For this expansion, please refer to the rulebook: https://drive.google.com/file/d/1DD24YzVmEZxE2K8FaAdEeuF6AFvsRLld/view&lt;/div&gt;</summary>
		<author><name>Fenadoruk</name></author>
	</entry>
	<entry>
		<id>https://en.doc.boardgamearena.com/index.php?title=BGA_Code_Sharing&amp;diff=23362</id>
		<title>BGA Code Sharing</title>
		<link rel="alternate" type="text/html" href="https://en.doc.boardgamearena.com/index.php?title=BGA_Code_Sharing&amp;diff=23362"/>
		<updated>2024-11-30T13:40:10Z</updated>

		<summary type="html">&lt;p&gt;Fenadoruk: /* Projects */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Studio_Framework_Navigation}}&lt;br /&gt;
&lt;br /&gt;
This page is for listing of externally hosted bga projects, tools and resources, as well as internal project&lt;br /&gt;
intended for sharing&lt;br /&gt;
&lt;br /&gt;
== Community shared components, pens, etc ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! NAME&lt;br /&gt;
! CODE LINK&lt;br /&gt;
! DESCRIPTION&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; | Dice models and animation&lt;br /&gt;
|-&lt;br /&gt;
| Die: 4 sided &lt;br /&gt;
| https://codepen.io/mrkiffie/pen/doVZgW  ; https://codepen.io/VictoriaLa/pen/JjZNezr&lt;br /&gt;
| code pen&lt;br /&gt;
|-&lt;br /&gt;
| Die: 6 sided &lt;br /&gt;
| https://github.com/elaskavaia/bga-sharedcode ; https://codepen.io/VictoriaLa/pen/QWBBbwz&lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
| Die: 8 sided &lt;br /&gt;
| https://codepen.io/VictoriaLa/pen/YzMPeGq&lt;br /&gt;
| code pen&lt;br /&gt;
|-&lt;br /&gt;
| Die: 12 sided (dodecahedron) &lt;br /&gt;
| https://codepen.io/VictoriaLa/pen/xxLLxOP &amp;lt;nowiki/&amp;gt;  https://codepen.io/hoursgoby/pen/GRwQzxo&lt;br /&gt;
| Code pen&lt;br /&gt;
|- &lt;br /&gt;
| Die: 20 sided &lt;br /&gt;
| https://codepen.io/vicentemundim/details/cenIh&lt;br /&gt;
| Code pen&lt;br /&gt;
|-&lt;br /&gt;
|Dice&lt;br /&gt;
|[https://github.com/thoun/bga-dice/ Repo]&amp;lt;nowiki&amp;gt; | &amp;lt;/nowiki&amp;gt;[https://thoun.github.io/bga-dice/demo/index.html Demo] (not used yet)&lt;br /&gt;
|Handle dice display and animation &#039;&#039;&#039;WORK IN PROGRESS&#039;&#039;&#039; Only d6 is started&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; | Moving object using CSS animation (mostly)&lt;br /&gt;
|-&lt;br /&gt;
| Phantom object move on oversurface &lt;br /&gt;
| https://codepen.io/VictoriaLa/pen/gORvdJo&lt;br /&gt;
| This technique creates clone of the object it moves it on another surface. It works well when parents that css transform applies such as scale and rotate&lt;br /&gt;
|-&lt;br /&gt;
| Move object directly using positioning &lt;br /&gt;
| https://codepen.io/VictoriaLa/pen/dyzgKVX&lt;br /&gt;
| This technique is modification of BGA framework method to allow mobile object not to have absolute position before or after the move (and uses css animation not dojo). Methods slideToObjectRelative, attachToNewObjectNoDestroy&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; | Responsive layout, zoom and navigation for game boards&lt;br /&gt;
|-&lt;br /&gt;
|Flex Layout&lt;br /&gt;
|https://codepen.io/VictoriaLa/pen/XWjJJgG&lt;br /&gt;
|Example on how to create flexible layout just by using css&lt;br /&gt;
|-&lt;br /&gt;
|Zoom&lt;br /&gt;
|[https://github.com/thoun/bga-zoom/ Repo]&amp;lt;nowiki&amp;gt; | &amp;lt;/nowiki&amp;gt;[https://thoun.github.io/bga-zoom/demo/index.html Demo] (visible on Knarr, Azul, Abyss, ...)&lt;br /&gt;
|Allow the user to zoom on the game board. Include the controls to zoom, and handle the scale applied to the HTML element.&lt;br /&gt;
|-&lt;br /&gt;
|Jump to&lt;br /&gt;
|[https://github.com/thoun/bga-jump-to/ Repo]&amp;lt;nowiki&amp;gt; | &amp;lt;/nowiki&amp;gt;[https://thoun.github.io/bga-jump-to/demo/index.html Demo] (visible on Knarr, Elawa)&lt;br /&gt;
|Add floating controls to quickly jump to a player&#039;s table&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; | Algorithms&lt;br /&gt;
|-&lt;br /&gt;
|Hex grid&lt;br /&gt;
|tapestry,Tumbleweed,gaia project,Gold West&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Shortest path on hex grid&lt;br /&gt;
|memoir 44&lt;br /&gt;
| Dijkstra&lt;br /&gt;
|-&lt;br /&gt;
|Largest area on hex grid&lt;br /&gt;
|tapestry, ...&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Largest area on square grid&lt;br /&gt;
|king domino, ...&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Tetris pieces&lt;br /&gt;
|patchwork, ...&lt;br /&gt;
|Matrix manupations to rotate, flip and fit tetris pieces&lt;br /&gt;
|-&lt;br /&gt;
|Line of sights on hex grid&lt;br /&gt;
|memoir 44&lt;br /&gt;
|Find intersecting hexes on a line between two cells&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; | Alternative implementations of BGA modules&lt;br /&gt;
|-&lt;br /&gt;
|Scrollmap with zoom&lt;br /&gt;
|https://github.com/yansnow78/bga_scrollmap&lt;br /&gt;
|you can find it in cacao, ginkgopilis, sagani, bigmonster,dominoes, Carcassonne hunters and gatherers and many others. &amp;lt;nowiki&amp;gt;#&amp;lt;/nowiki&amp;gt; improvements compare to scrollmap:&lt;br /&gt;
- add zoom capabilities &lt;br /&gt;
&lt;br /&gt;
- add possibility to adjust pan delta to tile size when clicking on arrows&lt;br /&gt;
&lt;br /&gt;
- allow zoom with scroll wheel. only allow zoom with wheel if alt or ctrl or shift are pressed by default.  add possibility to select which key need to be pressed when zooming with wheel&lt;br /&gt;
&lt;br /&gt;
- allow pan/scroll and pinch zoom on smartphone. only allow 2 fingers to start scrolling by default, one finger is for page scrolling&lt;br /&gt;
&lt;br /&gt;
- make clickable area of buttons a bit bigger on smartphone&lt;br /&gt;
&lt;br /&gt;
- improve animation between game board and player bards thanks to an animation_div&lt;br /&gt;
&lt;br /&gt;
- add support to long click on buttons (continuous scroll or zoom or enlarge/reduce until button released)&lt;br /&gt;
|-&lt;br /&gt;
|Scrollmap Plus &lt;br /&gt;
|patchwork&lt;br /&gt;
|Implementation with some bugs fixed, improved drag support and ability to use only one direction (i.e. only horizontal like carousel). Found in modules/extscrollmap.js&lt;br /&gt;
|-&lt;br /&gt;
|Cards&lt;br /&gt;
|[https://github.com/thoun/bga-cards/ Repo]&amp;lt;nowiki&amp;gt; | &amp;lt;/nowiki&amp;gt;[https://thoun.github.io/bga-cards/demo/index.html Demo] (visible on Knarr, King of Tokyo, Abyss, ...)&lt;br /&gt;
|Alternative to BGA Stock component, using CSS transitions instead of dojo animations.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; | Assorted stuff&lt;br /&gt;
|-&lt;br /&gt;
|Help&lt;br /&gt;
|[https://github.com/thoun/bga-help/ Repo]&amp;lt;nowiki&amp;gt; | &amp;lt;/nowiki&amp;gt;[https://thoun.github.io/bga-help/demo/index.html Demo] (visible on Knarr)&lt;br /&gt;
|Add floating help buttons at the bottom left corner of the screen&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Projects ==&lt;br /&gt;
&lt;br /&gt;
Add the game name, a link to repository and nickname of the developer on bga (same as used for dev forum), and short description. See [[Tools_and_tips_of_BGA_Studio#Version_Control]] for some suggestions on how and where to publish your code externally. Also see the [https://github.com/topics/boardgamearena boardgamearena] topic on github.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Important notice about artwork on BGA Open Source projects: original hi-resolution images from publishers must not be published on the repositories. In addition, it is better to specify that the images derivated from publishers artwork are copyrighted and cannot be licensed under a free license like Creative Commons.&lt;br /&gt;
&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! NON-GAME PROJECTS&lt;br /&gt;
! CODE LINK&lt;br /&gt;
! DEVELOPER&lt;br /&gt;
! COMMENT&lt;br /&gt;
|-&lt;br /&gt;
| Shared Code (not a game)&lt;br /&gt;
| https://github.com/elaskavaia/bga-sharedcode&lt;br /&gt;
| Victoria_La&lt;br /&gt;
| Examples of various game components and PHP stubs of framework code to make IDE happy&lt;br /&gt;
|-&lt;br /&gt;
| Vanilla Typescipt template (not a game)&lt;br /&gt;
| https://github.com/elaskavaia/bga-dojoless&lt;br /&gt;
| Victoria_La&lt;br /&gt;
| Project template for typescript and using minimal dojo, good for vscode - type checking, auto-complete, navigation&lt;br /&gt;
|-&lt;br /&gt;
| BoardGameArena Workbench (not a game)&lt;br /&gt;
| https://github.com/danielholmes/bga-workbench&lt;br /&gt;
| Daniel Holmes (dhau)&lt;br /&gt;
|-&lt;br /&gt;
|BGA-boilerplate&lt;br /&gt;
|https://github.com/bga-devs/tisaac-boilerplate/&lt;br /&gt;
|Tisaac (and Vincentt ?)&lt;br /&gt;
|Main boilerplate with extended &amp;quot;basic&amp;quot; function and code structure&lt;br /&gt;
|-&lt;br /&gt;
|BGA Type Safe Template&lt;br /&gt;
|https://github.com/NevinAF/bga-ts-template&lt;br /&gt;
|NevinAF&lt;br /&gt;
|Full typing of all BGA Framework components.&lt;br /&gt;
|-&lt;br /&gt;
! GAME&lt;br /&gt;
! CODE LINK&lt;br /&gt;
! DEVELOPER&lt;br /&gt;
! COMMENT&lt;br /&gt;
|-&lt;br /&gt;
| 99 (Trick-taking Card Game)&lt;br /&gt;
| https://github.com/ekelly/bga-ninetynine&lt;br /&gt;
| QuasarDukeDev&lt;br /&gt;
|-&lt;br /&gt;
| Abandon All Artichokes&lt;br /&gt;
| https://github.com/0-wiz-0/bga-abandonallartichokes&lt;br /&gt;
| __wiz__, rojomojo&lt;br /&gt;
|-&lt;br /&gt;
| Assyria &lt;br /&gt;
| https://github.com/sebastien-prudhomme/bga-assyria&lt;br /&gt;
| daikinee &lt;br /&gt;
|-&lt;br /&gt;
| Aura&lt;br /&gt;
| https://github.com/micahstairs/bga-aura&lt;br /&gt;
| Micah Stairs (micahstairs)&lt;br /&gt;
|-&lt;br /&gt;
| Bandido &lt;br /&gt;
| https://github.com/opheliehb/BandidoBGA&lt;br /&gt;
| ophelopede &amp;amp; Harkle &lt;br /&gt;
|-&lt;br /&gt;
| The Battle for Hill 218&lt;br /&gt;
| https://github.com/danielholmes/battle-for-hill-218&lt;br /&gt;
| Daniel Holmes (dhau)&lt;br /&gt;
|-&lt;br /&gt;
| Bonbons&lt;br /&gt;
| https://github.com/AntonioSoler/bga-bonbons&lt;br /&gt;
| Morgalad &lt;br /&gt;
|-&lt;br /&gt;
|Big Monster&lt;br /&gt;
|https://github.com/nmatton/bigmonster&lt;br /&gt;
|nicotacotac&lt;br /&gt;
|-&lt;br /&gt;
| Bonsai&lt;br /&gt;
| https://github.com/PhilipDavis/BGA-Bonsai&lt;br /&gt;
| Philip Davis (pdw3)&lt;br /&gt;
| Action stack for client-side undo system; generator functions to model complex turn workflows; infinite hex grid with auto resizing; all data in a single JSON blob; animated scorepad&lt;br /&gt;
|-&lt;br /&gt;
| Canosa&lt;br /&gt;
| https://codeberg.org/halibut/Canosa&lt;br /&gt;
| junibegood&lt;br /&gt;
|-&lt;br /&gt;
| Coinche&lt;br /&gt;
| https://github.com/drasill/bga-coinche&lt;br /&gt;
| Draasill&lt;br /&gt;
|-&lt;br /&gt;
|Copenhagen&lt;br /&gt;
|https://github.com/JoeProgram/bga-copenhagen&lt;br /&gt;
|JoeProgram&lt;br /&gt;
|-&lt;br /&gt;
| Coup: City State&lt;br /&gt;
| https://github.com/quietmint/bga-coupcitystate&lt;br /&gt;
| quietmint&lt;br /&gt;
|-&lt;br /&gt;
| Dice Summoners&lt;br /&gt;
| https://github.com/eoincos/bga-dicesummoners&lt;br /&gt;
| eoincos&lt;br /&gt;
|-&lt;br /&gt;
| Dungeon Roll&lt;br /&gt;
| https://github.com/MartinGoulet/bga-dungeonroll&lt;br /&gt;
| MGoulet&lt;br /&gt;
|-&lt;br /&gt;
| Egyptian Ratscrew&lt;br /&gt;
| https://github.com/0BuRner/bga-egyptianratscrew&lt;br /&gt;
| 0BuRner&lt;br /&gt;
|-&lt;br /&gt;
| Eruption&lt;br /&gt;
| https://github.com/AndyKerrison/bga-eruption&lt;br /&gt;
| Andy_K&lt;br /&gt;
|-&lt;br /&gt;
| A Fistful Of Gold&lt;br /&gt;
| https://bitbucket.org/Joel_L/fistfulofgold&lt;br /&gt;
| Brainchild&lt;br /&gt;
|-&lt;br /&gt;
| Fled&lt;br /&gt;
| https://github.com/PhilipDavis/BGA-Fled&lt;br /&gt;
| Philip Davis (pdw3)&lt;br /&gt;
| All data in a single JSON blob&lt;br /&gt;
|-&lt;br /&gt;
|Flip Freighters&lt;br /&gt;
|https://github.com/joesimpson/bga-flipfreighters&lt;br /&gt;
|joesimpson&lt;br /&gt;
|-&lt;br /&gt;
| Florenza: The Card Game&lt;br /&gt;
| https://github.com/alberto-bottarini/bga-florenza&lt;br /&gt;
| tarini &lt;br /&gt;
|-&lt;br /&gt;
| For-Ex&lt;br /&gt;
| https://github.com/Fnordistan/forex&lt;br /&gt;
| AmadanNaBriona&lt;br /&gt;
|-&lt;br /&gt;
| Get the MacGuffin&lt;br /&gt;
| https://github.com/mizutismask/bga-get-the-MacGuffin&lt;br /&gt;
| mizutismask&lt;br /&gt;
|-&lt;br /&gt;
| Hardback&lt;br /&gt;
| https://github.com/quietmint/bga-hardback&lt;br /&gt;
| quietmint&lt;br /&gt;
|-&lt;br /&gt;
| Hearts &#039;&#039;&#039;(Tutorial)&#039;&#039;&#039;&lt;br /&gt;
| https://github.com/elaskavaia/bga-heartsla&lt;br /&gt;
| Victoria_La&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| Homesteaders&lt;br /&gt;
| https://github.com/npatron/bga-homesteaders&lt;br /&gt;
| TheBoot&lt;br /&gt;
|-&lt;br /&gt;
| Incan Gold&lt;br /&gt;
| https://github.com/AntonioSoler/bga-incangold&lt;br /&gt;
| Morgalad &lt;br /&gt;
|-&lt;br /&gt;
| In the Year of the Dragon (10th Anniversary Edition)&lt;br /&gt;
| https://github.com/Fnordistan/ityotd&lt;br /&gt;
| AmadanNaBriona&lt;br /&gt;
|-&lt;br /&gt;
| Just Desserts&lt;br /&gt;
| https://github.com/mizutismask/bga-just-desserts&lt;br /&gt;
| mizutismask&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| The King&#039;s Guild&lt;br /&gt;
| https://github.com/AdamNovotny/BGG-KingsGuild&lt;br /&gt;
| A-dam&lt;br /&gt;
|-&lt;br /&gt;
| The Lady and the Tiger (Doors)&lt;br /&gt;
| https://github.com/Fnordistan/ladyandthetiger&lt;br /&gt;
| AmadanNaBriona&lt;br /&gt;
|-&lt;br /&gt;
|Linkage&lt;br /&gt;
|https://github.com/ShaPhi7/linkage&lt;br /&gt;
|ShaPhi7&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Love Letter&lt;br /&gt;
|https://github.com/ShaPhi7/loveletter&lt;br /&gt;
|ShaPhi7&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| Mapmaker: The Gerrymandering Game&lt;br /&gt;
| https://github.com/gzhang01/bga-mapmaker&lt;br /&gt;
| gkz&lt;br /&gt;
|-&lt;br /&gt;
| Marco Polo&lt;br /&gt;
| https://github.com/rcitaliano/MarcoPolo&lt;br /&gt;
| rcitaliano&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| Nile&lt;br /&gt;
| https://github.com/AndyKerrison/bga-nile&lt;br /&gt;
| Andy_K&lt;br /&gt;
|-&lt;br /&gt;
|Ninjan&lt;br /&gt;
|https://github.com/dorukkicikoglu/bga-ninjan&lt;br /&gt;
|fenadoruk&lt;br /&gt;
|-&lt;br /&gt;
| Noir: Killer vs Inspector&lt;br /&gt;
| https://bitbucket.org/chhuang76/bga_noirkvi&lt;br /&gt;
| ch huang&lt;br /&gt;
|-&lt;br /&gt;
|Now Boarding&lt;br /&gt;
|https://github.com/quietmint/bga-nowboarding&lt;br /&gt;
|quietmint&lt;br /&gt;
|-&lt;br /&gt;
|Odin&lt;br /&gt;
|https://github.com/dorukkicikoglu/bga-odin&lt;br /&gt;
|fenadoruk&lt;br /&gt;
|-&lt;br /&gt;
| Penny Press&lt;br /&gt;
| https://github.com/AdamNovotny/bga-blooms&lt;br /&gt;
| A-dam&lt;br /&gt;
|-&lt;br /&gt;
| Perikles&lt;br /&gt;
| https://github.com/Fnordistan/perikles&lt;br /&gt;
| AmadanNaBriona&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| P.I.&lt;br /&gt;
| https://gitlab.com/fa81/bga-pi, https://github.com/hellp/bga-pi (mirror)&lt;br /&gt;
| Fabian Neumann (fa81)&lt;br /&gt;
|-&lt;br /&gt;
| President&lt;br /&gt;
| https://github.com/quaresma95/president&lt;br /&gt;
| quaresma95&lt;br /&gt;
|-&lt;br /&gt;
| Santorini&lt;br /&gt;
| https://github.com/AntonioSoler/bga-santorini&lt;br /&gt;
| Morgalad, quietmint, Tisaac&lt;br /&gt;
|-&lt;br /&gt;
| Tablut&lt;br /&gt;
| https://github.com/Lucas-C/tablut&lt;br /&gt;
| Lucas-C &amp;amp; ntaffore&lt;br /&gt;
|-&lt;br /&gt;
| Takara Island&lt;br /&gt;
| https://github.com/AntonioSoler/bga-takaraisland&lt;br /&gt;
| Morgalad&lt;br /&gt;
|-&lt;br /&gt;
| Taluva&lt;br /&gt;
| https://github.com/quietmint/bga-taluva&lt;br /&gt;
| Morgalad &amp;amp; quietmint&lt;br /&gt;
|-&lt;br /&gt;
| Teotihuacan: City of Gods&lt;br /&gt;
| https://github.com/Trompetenhut/bga-teotihuacan&lt;br /&gt;
| Trompetenhut&lt;br /&gt;
|-&lt;br /&gt;
| Texas 42 (domino game, still under development)&lt;br /&gt;
| https://github.com/ishermandom/bga-42&lt;br /&gt;
| Stardust Spikes, Jason Turner-Maier, Ilya Sherman&lt;br /&gt;
|-&lt;br /&gt;
| Tic Tac Match&lt;br /&gt;
| https://github.com/leocaseiro/bga-tictacmatch&lt;br /&gt;
| Leo Caseiro&lt;br /&gt;
|-&lt;br /&gt;
| Trick of the Rails&lt;br /&gt;
| https://github.com/Fnordistan/trickoftherails&lt;br /&gt;
| AmadanNaBriona&lt;br /&gt;
|-&lt;br /&gt;
| Uptown&lt;br /&gt;
| https://github.com/elliotkendall/bga-uptown&lt;br /&gt;
| SpottedShroom&lt;br /&gt;
|-&lt;br /&gt;
| Via Magica&lt;br /&gt;
| https://github.com/christopherburke/bga_viamagica&lt;br /&gt;
| CuriousTerran&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Projects on studio ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Any developer can add themselves to a project as read-only from https://studio.boardgamearena.com/#!projects page (almost any project).&lt;br /&gt;
&lt;br /&gt;
If it is not visible: a) it has no bgg id b) it is already published (use radio button to switch) c) it is an old game not developed on studio.&lt;br /&gt;
&lt;br /&gt;
== Other useful resources ==&lt;br /&gt;
&lt;br /&gt;
Moved to [[Tools_and_tips_of_BGA_Studio]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Studio]]&lt;/div&gt;</summary>
		<author><name>Fenadoruk</name></author>
	</entry>
	<entry>
		<id>https://en.doc.boardgamearena.com/index.php?title=BGA_Code_Sharing&amp;diff=23361</id>
		<title>BGA Code Sharing</title>
		<link rel="alternate" type="text/html" href="https://en.doc.boardgamearena.com/index.php?title=BGA_Code_Sharing&amp;diff=23361"/>
		<updated>2024-11-30T13:08:44Z</updated>

		<summary type="html">&lt;p&gt;Fenadoruk: /* Projects */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Studio_Framework_Navigation}}&lt;br /&gt;
&lt;br /&gt;
This page is for listing of externally hosted bga projects, tools and resources, as well as internal project&lt;br /&gt;
intended for sharing&lt;br /&gt;
&lt;br /&gt;
== Community shared components, pens, etc ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! NAME&lt;br /&gt;
! CODE LINK&lt;br /&gt;
! DESCRIPTION&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; | Dice models and animation&lt;br /&gt;
|-&lt;br /&gt;
| Die: 4 sided &lt;br /&gt;
| https://codepen.io/mrkiffie/pen/doVZgW  ; https://codepen.io/VictoriaLa/pen/JjZNezr&lt;br /&gt;
| code pen&lt;br /&gt;
|-&lt;br /&gt;
| Die: 6 sided &lt;br /&gt;
| https://github.com/elaskavaia/bga-sharedcode ; https://codepen.io/VictoriaLa/pen/QWBBbwz&lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
| Die: 8 sided &lt;br /&gt;
| https://codepen.io/VictoriaLa/pen/YzMPeGq&lt;br /&gt;
| code pen&lt;br /&gt;
|-&lt;br /&gt;
| Die: 12 sided (dodecahedron) &lt;br /&gt;
| https://codepen.io/VictoriaLa/pen/xxLLxOP &amp;lt;nowiki/&amp;gt;  https://codepen.io/hoursgoby/pen/GRwQzxo&lt;br /&gt;
| Code pen&lt;br /&gt;
|- &lt;br /&gt;
| Die: 20 sided &lt;br /&gt;
| https://codepen.io/vicentemundim/details/cenIh&lt;br /&gt;
| Code pen&lt;br /&gt;
|-&lt;br /&gt;
|Dice&lt;br /&gt;
|[https://github.com/thoun/bga-dice/ Repo]&amp;lt;nowiki&amp;gt; | &amp;lt;/nowiki&amp;gt;[https://thoun.github.io/bga-dice/demo/index.html Demo] (not used yet)&lt;br /&gt;
|Handle dice display and animation &#039;&#039;&#039;WORK IN PROGRESS&#039;&#039;&#039; Only d6 is started&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; | Moving object using CSS animation (mostly)&lt;br /&gt;
|-&lt;br /&gt;
| Phantom object move on oversurface &lt;br /&gt;
| https://codepen.io/VictoriaLa/pen/gORvdJo&lt;br /&gt;
| This technique creates clone of the object it moves it on another surface. It works well when parents that css transform applies such as scale and rotate&lt;br /&gt;
|-&lt;br /&gt;
| Move object directly using positioning &lt;br /&gt;
| https://codepen.io/VictoriaLa/pen/dyzgKVX&lt;br /&gt;
| This technique is modification of BGA framework method to allow mobile object not to have absolute position before or after the move (and uses css animation not dojo). Methods slideToObjectRelative, attachToNewObjectNoDestroy&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; | Responsive layout, zoom and navigation for game boards&lt;br /&gt;
|-&lt;br /&gt;
|Flex Layout&lt;br /&gt;
|https://codepen.io/VictoriaLa/pen/XWjJJgG&lt;br /&gt;
|Example on how to create flexible layout just by using css&lt;br /&gt;
|-&lt;br /&gt;
|Zoom&lt;br /&gt;
|[https://github.com/thoun/bga-zoom/ Repo]&amp;lt;nowiki&amp;gt; | &amp;lt;/nowiki&amp;gt;[https://thoun.github.io/bga-zoom/demo/index.html Demo] (visible on Knarr, Azul, Abyss, ...)&lt;br /&gt;
|Allow the user to zoom on the game board. Include the controls to zoom, and handle the scale applied to the HTML element.&lt;br /&gt;
|-&lt;br /&gt;
|Jump to&lt;br /&gt;
|[https://github.com/thoun/bga-jump-to/ Repo]&amp;lt;nowiki&amp;gt; | &amp;lt;/nowiki&amp;gt;[https://thoun.github.io/bga-jump-to/demo/index.html Demo] (visible on Knarr, Elawa)&lt;br /&gt;
|Add floating controls to quickly jump to a player&#039;s table&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; | Algorithms&lt;br /&gt;
|-&lt;br /&gt;
|Hex grid&lt;br /&gt;
|tapestry,Tumbleweed,gaia project,Gold West&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Shortest path on hex grid&lt;br /&gt;
|memoir 44&lt;br /&gt;
| Dijkstra&lt;br /&gt;
|-&lt;br /&gt;
|Largest area on hex grid&lt;br /&gt;
|tapestry, ...&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Largest area on square grid&lt;br /&gt;
|king domino, ...&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Tetris pieces&lt;br /&gt;
|patchwork, ...&lt;br /&gt;
|Matrix manupations to rotate, flip and fit tetris pieces&lt;br /&gt;
|-&lt;br /&gt;
|Line of sights on hex grid&lt;br /&gt;
|memoir 44&lt;br /&gt;
|Find intersecting hexes on a line between two cells&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; | Alternative implementations of BGA modules&lt;br /&gt;
|-&lt;br /&gt;
|Scrollmap with zoom&lt;br /&gt;
|https://github.com/yansnow78/bga_scrollmap&lt;br /&gt;
|you can find it in cacao, ginkgopilis, sagani, bigmonster,dominoes, Carcassonne hunters and gatherers and many others. &amp;lt;nowiki&amp;gt;#&amp;lt;/nowiki&amp;gt; improvements compare to scrollmap:&lt;br /&gt;
- add zoom capabilities &lt;br /&gt;
&lt;br /&gt;
- add possibility to adjust pan delta to tile size when clicking on arrows&lt;br /&gt;
&lt;br /&gt;
- allow zoom with scroll wheel. only allow zoom with wheel if alt or ctrl or shift are pressed by default.  add possibility to select which key need to be pressed when zooming with wheel&lt;br /&gt;
&lt;br /&gt;
- allow pan/scroll and pinch zoom on smartphone. only allow 2 fingers to start scrolling by default, one finger is for page scrolling&lt;br /&gt;
&lt;br /&gt;
- make clickable area of buttons a bit bigger on smartphone&lt;br /&gt;
&lt;br /&gt;
- improve animation between game board and player bards thanks to an animation_div&lt;br /&gt;
&lt;br /&gt;
- add support to long click on buttons (continuous scroll or zoom or enlarge/reduce until button released)&lt;br /&gt;
|-&lt;br /&gt;
|Scrollmap Plus &lt;br /&gt;
|patchwork&lt;br /&gt;
|Implementation with some bugs fixed, improved drag support and ability to use only one direction (i.e. only horizontal like carousel). Found in modules/extscrollmap.js&lt;br /&gt;
|-&lt;br /&gt;
|Cards&lt;br /&gt;
|[https://github.com/thoun/bga-cards/ Repo]&amp;lt;nowiki&amp;gt; | &amp;lt;/nowiki&amp;gt;[https://thoun.github.io/bga-cards/demo/index.html Demo] (visible on Knarr, King of Tokyo, Abyss, ...)&lt;br /&gt;
|Alternative to BGA Stock component, using CSS transitions instead of dojo animations.&lt;br /&gt;
|-&lt;br /&gt;
! colspan=&amp;quot;3&amp;quot; | Assorted stuff&lt;br /&gt;
|-&lt;br /&gt;
|Help&lt;br /&gt;
|[https://github.com/thoun/bga-help/ Repo]&amp;lt;nowiki&amp;gt; | &amp;lt;/nowiki&amp;gt;[https://thoun.github.io/bga-help/demo/index.html Demo] (visible on Knarr)&lt;br /&gt;
|Add floating help buttons at the bottom left corner of the screen&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Projects ==&lt;br /&gt;
&lt;br /&gt;
Add the game name, a link to repository and nickname of the developer on bga (same as used for dev forum), and short description. See [[Tools_and_tips_of_BGA_Studio#Version_Control]] for some suggestions on how and where to publish your code externally. Also see the [https://github.com/topics/boardgamearena boardgamearena] topic on github.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Important notice about artwork on BGA Open Source projects: original hi-resolution images from publishers must not be published on the repositories. In addition, it is better to specify that the images derivated from publishers artwork are copyrighted and cannot be licensed under a free license like Creative Commons.&lt;br /&gt;
&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! NON-GAME PROJECTS&lt;br /&gt;
! CODE LINK&lt;br /&gt;
! DEVELOPER&lt;br /&gt;
! COMMENT&lt;br /&gt;
|-&lt;br /&gt;
| Shared Code (not a game)&lt;br /&gt;
| https://github.com/elaskavaia/bga-sharedcode&lt;br /&gt;
| Victoria_La&lt;br /&gt;
| Examples of various game components and PHP stubs of framework code to make IDE happy&lt;br /&gt;
|-&lt;br /&gt;
| Vanilla Typescipt template (not a game)&lt;br /&gt;
| https://github.com/elaskavaia/bga-dojoless&lt;br /&gt;
| Victoria_La&lt;br /&gt;
| Project template for typescript and using minimal dojo, good for vscode - type checking, auto-complete, navigation&lt;br /&gt;
|-&lt;br /&gt;
| BoardGameArena Workbench (not a game)&lt;br /&gt;
| https://github.com/danielholmes/bga-workbench&lt;br /&gt;
| Daniel Holmes (dhau)&lt;br /&gt;
|-&lt;br /&gt;
|BGA-boilerplate&lt;br /&gt;
|https://github.com/bga-devs/tisaac-boilerplate/&lt;br /&gt;
|Tisaac (and Vincentt ?)&lt;br /&gt;
|Main boilerplate with extended &amp;quot;basic&amp;quot; function and code structure&lt;br /&gt;
|-&lt;br /&gt;
|BGA Type Safe Template&lt;br /&gt;
|https://github.com/NevinAF/bga-ts-template&lt;br /&gt;
|NevinAF&lt;br /&gt;
|Full typing of all BGA Framework components.&lt;br /&gt;
|-&lt;br /&gt;
! GAME&lt;br /&gt;
! CODE LINK&lt;br /&gt;
! DEVELOPER&lt;br /&gt;
! COMMENT&lt;br /&gt;
|-&lt;br /&gt;
| 99 (Trick-taking Card Game)&lt;br /&gt;
| https://github.com/ekelly/bga-ninetynine&lt;br /&gt;
| QuasarDukeDev&lt;br /&gt;
|-&lt;br /&gt;
| Abandon All Artichokes&lt;br /&gt;
| https://github.com/0-wiz-0/bga-abandonallartichokes&lt;br /&gt;
| __wiz__, rojomojo&lt;br /&gt;
|-&lt;br /&gt;
| Assyria &lt;br /&gt;
| https://github.com/sebastien-prudhomme/bga-assyria&lt;br /&gt;
| daikinee &lt;br /&gt;
|-&lt;br /&gt;
| Aura&lt;br /&gt;
| https://github.com/micahstairs/bga-aura&lt;br /&gt;
| Micah Stairs (micahstairs)&lt;br /&gt;
|-&lt;br /&gt;
| Bandido &lt;br /&gt;
| https://github.com/opheliehb/BandidoBGA&lt;br /&gt;
| ophelopede &amp;amp; Harkle &lt;br /&gt;
|-&lt;br /&gt;
| The Battle for Hill 218&lt;br /&gt;
| https://github.com/danielholmes/battle-for-hill-218&lt;br /&gt;
| Daniel Holmes (dhau)&lt;br /&gt;
|-&lt;br /&gt;
| Bonbons&lt;br /&gt;
| https://github.com/AntonioSoler/bga-bonbons&lt;br /&gt;
| Morgalad &lt;br /&gt;
|-&lt;br /&gt;
|Big Monster&lt;br /&gt;
|https://github.com/nmatton/bigmonster&lt;br /&gt;
|nicotacotac&lt;br /&gt;
|-&lt;br /&gt;
| Bonsai&lt;br /&gt;
| https://github.com/PhilipDavis/BGA-Bonsai&lt;br /&gt;
| Philip Davis (pdw3)&lt;br /&gt;
| Action stack for client-side undo system; generator functions to model complex turn workflows; infinite hex grid with auto resizing; all data in a single JSON blob; animated scorepad&lt;br /&gt;
|-&lt;br /&gt;
| Canosa&lt;br /&gt;
| https://codeberg.org/halibut/Canosa&lt;br /&gt;
| junibegood&lt;br /&gt;
|-&lt;br /&gt;
| Coinche&lt;br /&gt;
| https://github.com/drasill/bga-coinche&lt;br /&gt;
| Draasill&lt;br /&gt;
|-&lt;br /&gt;
|Copenhagen&lt;br /&gt;
|https://github.com/JoeProgram/bga-copenhagen&lt;br /&gt;
|JoeProgram&lt;br /&gt;
|-&lt;br /&gt;
| Coup: City State&lt;br /&gt;
| https://github.com/quietmint/bga-coupcitystate&lt;br /&gt;
| quietmint&lt;br /&gt;
|-&lt;br /&gt;
| Dice Summoners&lt;br /&gt;
| https://github.com/eoincos/bga-dicesummoners&lt;br /&gt;
| eoincos&lt;br /&gt;
|-&lt;br /&gt;
| Dungeon Roll&lt;br /&gt;
| https://github.com/MartinGoulet/bga-dungeonroll&lt;br /&gt;
| MGoulet&lt;br /&gt;
|-&lt;br /&gt;
| Egyptian Ratscrew&lt;br /&gt;
| https://github.com/0BuRner/bga-egyptianratscrew&lt;br /&gt;
| 0BuRner&lt;br /&gt;
|-&lt;br /&gt;
| Eruption&lt;br /&gt;
| https://github.com/AndyKerrison/bga-eruption&lt;br /&gt;
| Andy_K&lt;br /&gt;
|-&lt;br /&gt;
| A Fistful Of Gold&lt;br /&gt;
| https://bitbucket.org/Joel_L/fistfulofgold&lt;br /&gt;
| Brainchild&lt;br /&gt;
|-&lt;br /&gt;
| Fled&lt;br /&gt;
| https://github.com/PhilipDavis/BGA-Fled&lt;br /&gt;
| Philip Davis (pdw3)&lt;br /&gt;
| All data in a single JSON blob&lt;br /&gt;
|-&lt;br /&gt;
|Flip Freighters&lt;br /&gt;
|https://github.com/joesimpson/bga-flipfreighters&lt;br /&gt;
|joesimpson&lt;br /&gt;
|-&lt;br /&gt;
| Florenza: The Card Game&lt;br /&gt;
| https://github.com/alberto-bottarini/bga-florenza&lt;br /&gt;
| tarini &lt;br /&gt;
|-&lt;br /&gt;
| For-Ex&lt;br /&gt;
| https://github.com/Fnordistan/forex&lt;br /&gt;
| AmadanNaBriona&lt;br /&gt;
|-&lt;br /&gt;
| Get the MacGuffin&lt;br /&gt;
| https://github.com/mizutismask/bga-get-the-MacGuffin&lt;br /&gt;
| mizutismask&lt;br /&gt;
|-&lt;br /&gt;
| Hardback&lt;br /&gt;
| https://github.com/quietmint/bga-hardback&lt;br /&gt;
| quietmint&lt;br /&gt;
|-&lt;br /&gt;
| Hearts &#039;&#039;&#039;(Tutorial)&#039;&#039;&#039;&lt;br /&gt;
| https://github.com/elaskavaia/bga-heartsla&lt;br /&gt;
| Victoria_La&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| Homesteaders&lt;br /&gt;
| https://github.com/npatron/bga-homesteaders&lt;br /&gt;
| TheBoot&lt;br /&gt;
|-&lt;br /&gt;
| Incan Gold&lt;br /&gt;
| https://github.com/AntonioSoler/bga-incangold&lt;br /&gt;
| Morgalad &lt;br /&gt;
|-&lt;br /&gt;
| In the Year of the Dragon (10th Anniversary Edition)&lt;br /&gt;
| https://github.com/Fnordistan/ityotd&lt;br /&gt;
| AmadanNaBriona&lt;br /&gt;
|-&lt;br /&gt;
| Just Desserts&lt;br /&gt;
| https://github.com/mizutismask/bga-just-desserts&lt;br /&gt;
| mizutismask&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| The King&#039;s Guild&lt;br /&gt;
| https://github.com/AdamNovotny/BGG-KingsGuild&lt;br /&gt;
| A-dam&lt;br /&gt;
|-&lt;br /&gt;
| The Lady and the Tiger (Doors)&lt;br /&gt;
| https://github.com/Fnordistan/ladyandthetiger&lt;br /&gt;
| AmadanNaBriona&lt;br /&gt;
|-&lt;br /&gt;
|Linkage&lt;br /&gt;
|https://github.com/ShaPhi7/linkage&lt;br /&gt;
|ShaPhi7&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Love Letter&lt;br /&gt;
|https://github.com/ShaPhi7/loveletter&lt;br /&gt;
|ShaPhi7&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| Mapmaker: The Gerrymandering Game&lt;br /&gt;
| https://github.com/gzhang01/bga-mapmaker&lt;br /&gt;
| gkz&lt;br /&gt;
|-&lt;br /&gt;
| Marco Polo&lt;br /&gt;
| https://github.com/rcitaliano/MarcoPolo&lt;br /&gt;
| rcitaliano&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| Nile&lt;br /&gt;
| https://github.com/AndyKerrison/bga-nile&lt;br /&gt;
| Andy_K&lt;br /&gt;
|-&lt;br /&gt;
| Noir: Killer vs Inspector&lt;br /&gt;
| https://bitbucket.org/chhuang76/bga_noirkvi&lt;br /&gt;
| ch huang&lt;br /&gt;
|-&lt;br /&gt;
|Now Boarding&lt;br /&gt;
|https://github.com/quietmint/bga-nowboarding&lt;br /&gt;
|quietmint&lt;br /&gt;
|-&lt;br /&gt;
|Odin&lt;br /&gt;
|https://github.com/dorukkicikoglu/bga-odin&lt;br /&gt;
|fenadoruk&lt;br /&gt;
|-&lt;br /&gt;
| Penny Press&lt;br /&gt;
| https://github.com/AdamNovotny/bga-blooms&lt;br /&gt;
| A-dam&lt;br /&gt;
|-&lt;br /&gt;
| Perikles&lt;br /&gt;
| https://github.com/Fnordistan/perikles&lt;br /&gt;
| AmadanNaBriona&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| P.I.&lt;br /&gt;
| https://gitlab.com/fa81/bga-pi, https://github.com/hellp/bga-pi (mirror)&lt;br /&gt;
| Fabian Neumann (fa81)&lt;br /&gt;
|-&lt;br /&gt;
| President&lt;br /&gt;
| https://github.com/quaresma95/president&lt;br /&gt;
| quaresma95&lt;br /&gt;
|-&lt;br /&gt;
| Santorini&lt;br /&gt;
| https://github.com/AntonioSoler/bga-santorini&lt;br /&gt;
| Morgalad, quietmint, Tisaac&lt;br /&gt;
|-&lt;br /&gt;
| Tablut&lt;br /&gt;
| https://github.com/Lucas-C/tablut&lt;br /&gt;
| Lucas-C &amp;amp; ntaffore&lt;br /&gt;
|-&lt;br /&gt;
| Takara Island&lt;br /&gt;
| https://github.com/AntonioSoler/bga-takaraisland&lt;br /&gt;
| Morgalad&lt;br /&gt;
|-&lt;br /&gt;
| Taluva&lt;br /&gt;
| https://github.com/quietmint/bga-taluva&lt;br /&gt;
| Morgalad &amp;amp; quietmint&lt;br /&gt;
|-&lt;br /&gt;
| Teotihuacan: City of Gods&lt;br /&gt;
| https://github.com/Trompetenhut/bga-teotihuacan&lt;br /&gt;
| Trompetenhut&lt;br /&gt;
|-&lt;br /&gt;
| Texas 42 (domino game, still under development)&lt;br /&gt;
| https://github.com/ishermandom/bga-42&lt;br /&gt;
| Stardust Spikes, Jason Turner-Maier, Ilya Sherman&lt;br /&gt;
|-&lt;br /&gt;
| Tic Tac Match&lt;br /&gt;
| https://github.com/leocaseiro/bga-tictacmatch&lt;br /&gt;
| Leo Caseiro&lt;br /&gt;
|-&lt;br /&gt;
| Trick of the Rails&lt;br /&gt;
| https://github.com/Fnordistan/trickoftherails&lt;br /&gt;
| AmadanNaBriona&lt;br /&gt;
|-&lt;br /&gt;
| Uptown&lt;br /&gt;
| https://github.com/elliotkendall/bga-uptown&lt;br /&gt;
| SpottedShroom&lt;br /&gt;
|-&lt;br /&gt;
| Via Magica&lt;br /&gt;
| https://github.com/christopherburke/bga_viamagica&lt;br /&gt;
| CuriousTerran&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Projects on studio ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Any developer can add themselves to a project as read-only from https://studio.boardgamearena.com/#!projects page (almost any project).&lt;br /&gt;
&lt;br /&gt;
If it is not visible: a) it has no bgg id b) it is already published (use radio button to switch) c) it is an old game not developed on studio.&lt;br /&gt;
&lt;br /&gt;
== Other useful resources ==&lt;br /&gt;
&lt;br /&gt;
Moved to [[Tools_and_tips_of_BGA_Studio]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Studio]]&lt;/div&gt;</summary>
		<author><name>Fenadoruk</name></author>
	</entry>
	<entry>
		<id>https://en.doc.boardgamearena.com/index.php?title=Gamehelpninjan&amp;diff=23260</id>
		<title>Gamehelpninjan</title>
		<link rel="alternate" type="text/html" href="https://en.doc.boardgamearena.com/index.php?title=Gamehelpninjan&amp;diff=23260"/>
		<updated>2024-11-18T19:27:23Z</updated>

		<summary type="html">&lt;p&gt;Fenadoruk: Created page with &amp;quot;Ninjas bring rocks, scissors, and paper to a fight in Ninjan to help you recruit the strongest ninjas possible.  Each player starts with a hand of nine cards, with cards belonging to one of three suits — rock/paper/scissor — and being valued from -6 to 10. Place three random cards face up on the table in separate piles; these are your first targets.  Each turn, each player chooses a card from their hand, then reveals them simultaneously. Going from high value to low,...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Ninjas bring rocks, scissors, and paper to a fight in Ninjan to help you recruit the strongest ninjas possible.&lt;br /&gt;
&lt;br /&gt;
Each player starts with a hand of nine cards, with cards belonging to one of three suits — rock/paper/scissor — and being valued from -6 to 10. Place three random cards face up on the table in separate piles; these are your first targets.&lt;br /&gt;
&lt;br /&gt;
Each turn, each player chooses a card from their hand, then reveals them simultaneously. Going from high value to low, breaking ties according to the RPS rule, players see whether they will claim one of the piles in the center of the table. If you play 8 rock, for example, you must claim one of the piles with a scissor card on top, placing these claimed cards face up in front of you, then starting a new pile with your 8 rock. If you cannot claim a card, place your played card on a pile, leaving all numbers in the pile visible.&lt;br /&gt;
&lt;br /&gt;
After nine rounds, sum the values of the cards you&#039;ve claimed. Whoever has the highest score wins.&lt;/div&gt;</summary>
		<author><name>Fenadoruk</name></author>
	</entry>
	<entry>
		<id>https://en.doc.boardgamearena.com/index.php?title=Gamehelpodin&amp;diff=22554</id>
		<title>Gamehelpodin</title>
		<link rel="alternate" type="text/html" href="https://en.doc.boardgamearena.com/index.php?title=Gamehelpodin&amp;diff=22554"/>
		<updated>2024-09-13T13:00:12Z</updated>

		<summary type="html">&lt;p&gt;Fenadoruk: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Overview===&lt;br /&gt;
&lt;br /&gt;
Combine cards to make whole numbers e.g. 5-2-8 is 852, and play the highest value combos in order to empty your hand the fastest&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Turn===&lt;br /&gt;
&lt;br /&gt;
The first player plays 1 card&lt;br /&gt;
&lt;br /&gt;
Following players can play 1 or more cards&lt;br /&gt;
&lt;br /&gt;
The value of the card(s) played must be greater than what is already on the table&lt;br /&gt;
&lt;br /&gt;
Values of multiple cards are combined in such a way to form a whole number of the highest value possible e.g. two cards will form a value in the 10s e.g. 3 and 4 make 43, three cards will form a value in the 100s e.g. 5-2-8 will form 852, and so on&lt;br /&gt;
&lt;br /&gt;
You can play the same quantity of cards as previously played, or exactly 1 more than it, i.e. if there are three cards out, you can play 3 or 4 cards with a higher combined value, but not 5 cards&lt;br /&gt;
&lt;br /&gt;
If you play more than one card, they must all be of the same numeral or same suit e.g. 888 or 5-3-1 of all blue&lt;br /&gt;
&lt;br /&gt;
Once you have played a valid card(s), take one of the cards from the play you just defeated into your hand and discard the rest of the old cards&lt;br /&gt;
&lt;br /&gt;
If you cannot or do not wish to play, you can pass, but you still get a turn when it next comes round to you&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Round End===&lt;br /&gt;
&lt;br /&gt;
If you were the last to change the game state and it comes round to you to play again, you just won the round&lt;br /&gt;
&lt;br /&gt;
The play area is cleared and you may start again with a new single card as first player&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Hand End===&lt;br /&gt;
&lt;br /&gt;
If you start the round, and all cards in your hand are the same suit or value, you can play your whole hand instead of just one card and end the hand&lt;br /&gt;
&lt;br /&gt;
Otherwise, when a player empties their hand the Hand is over&lt;br /&gt;
&lt;br /&gt;
Everyone gains 1 point per card still in their hand when this is triggered - Be mindful that on the BGA adaptation, you lose points instead of gaining them&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Game End===&lt;br /&gt;
&lt;br /&gt;
Depending on the length of the game, the game ends when a player reaches or exceeds 10/15/20 points&lt;br /&gt;
&lt;br /&gt;
The player with the fewest points, wins!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Summarised by https://boardgamearena.com/player?id=90078516&lt;/div&gt;</summary>
		<author><name>Fenadoruk</name></author>
	</entry>
	<entry>
		<id>https://en.doc.boardgamearena.com/index.php?title=Gamehelpauctionland&amp;diff=21624</id>
		<title>Gamehelpauctionland</title>
		<link rel="alternate" type="text/html" href="https://en.doc.boardgamearena.com/index.php?title=Gamehelpauctionland&amp;diff=21624"/>
		<updated>2024-06-22T22:12:50Z</updated>

		<summary type="html">&lt;p&gt;Fenadoruk: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
Build and auction tiles to create the most impressive paradise island!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Setup:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Each player grabs a screen and some money. The player who last visited a new island starts the game and takes the gavel! Starting money is distributed as follows:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|1st player&lt;br /&gt;
|2nd player&lt;br /&gt;
|3rd player&lt;br /&gt;
|4th player&lt;br /&gt;
|5th player&lt;br /&gt;
|6th player&lt;br /&gt;
|-&lt;br /&gt;
|$10&lt;br /&gt;
|$12&lt;br /&gt;
|$14&lt;br /&gt;
|$16&lt;br /&gt;
|$18&lt;br /&gt;
|$20&lt;br /&gt;
|}&lt;br /&gt;
Place money behind your screen. You can enable &#039;&#039;&#039;visible money&#039;&#039;&#039; in the game settings.&lt;br /&gt;
&lt;br /&gt;
Create a stack of tiles and deal 8 tiles (or the market size set in game settings) into the middle to form the market. Sort them by the number of icons (Peace, Love &amp;amp; Music), with more icons closer to the stack.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Turn summary:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
1. &#039;&#039;&#039;Build Tile&#039;&#039;&#039;: Select a tile from the market to add to your island.&lt;br /&gt;
&lt;br /&gt;
2. &#039;&#039;&#039;Auction Tile&#039;&#039;&#039;: After building, select another tile and auction it off.&lt;br /&gt;
&lt;br /&gt;
3. &#039;&#039;&#039;End turn&#039;&#039;&#039;: Pass the gavel to the player on your left. It’s now their turn. Refresh the market back to 8 tiles (or the market size set in game settings) but don&#039;t sort them.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The Market:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Whenever you take a tile from the market (for building, auctioning, or Bonus), place $1 on each skipped tile starting from the free tile. Earn the money on the selected tile and place it behind your screen.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Building Tiles:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
New tiles placed after your first must share an edge with an existing tile on your island. You can expand your island in any direction as long as it doesn’t go beyond 4x4.&lt;br /&gt;
&lt;br /&gt;
Placing the 4th tile in a row or column earns you a Bonus tile (see Bonus Tiles).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Auctioning Tiles:&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
After building your tile, select a new tile following &#039;&#039;&#039;the market&#039;&#039;&#039; rules and put it on auction! It’s an open auction carried out simultaneously. Players can increase bids -even their own- any time as long as you have enough money to pay for it. The auction phase is over once all but one player has passed.&lt;br /&gt;
&lt;br /&gt;
In a 2-player game, the bidding player makes only 1 bid which concludes the auction phase.&lt;br /&gt;
&lt;br /&gt;
In the rare case that no one bids, the auctioneer takes the tile for free.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Buy back:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Once the auction phase is over, the auctioneer can either:&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Sell&#039;&#039;&#039; the auctioned tile to the highest bidder.&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Buy back&#039;&#039;&#039; the tile by paying the winning bid plus $1 to the highest bidder. i.e. Alex won the auction phase with a bid of $3, the auctioneer can pay $4 to Alex and build the tile.&lt;br /&gt;
&lt;br /&gt;
The auctioneer can still buy back even if their island is full. In that case, the auctioned tile is returned to the game box.&lt;br /&gt;
&lt;br /&gt;
Make sure you are not bidding so little that the auctioneer buys it back from you. Or maybe you want them to! After all, you&#039;re being paid without losing anything!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Bonus Tiles:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
After adding a tile to your island in &#039;&#039;&#039;any&#039;&#039;&#039; phase or for &#039;&#039;&#039;any&#039;&#039;&#039; reason, check whether it was the 4th tile of a row or column. If so, you immediately earn a Bonus tile!&lt;br /&gt;
&lt;br /&gt;
Draw a new tile following &#039;&#039;&#039;the market rules&#039;&#039;&#039; and build it by following the &#039;&#039;&#039;building tiles&#039;&#039;&#039; rules. Each player can earn only 1 Bonus tile per turn. In other words, a Bonus tile cannot trigger another Bonus, but more than 1 player can draw a Bonus tile on a single turn.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Game End:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Once a player has filled their 4x4 island, the game will be over at the end of that turn. This means you still proceed to the &#039;&#039;&#039;auction phase&#039;&#039;&#039; if you haven’t already done so.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;SCORING&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Beaches:&#039;&#039;&#039; Imagine the table is the ocean! Count tiles with a beach zone touching the edge of your island. Score points based on the scoring table found in the game’s tooltips. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If a beach is not on the edge but still adjacent to a gap (because your 4x4 island wasn’t filled up) it still scores. The table is the ocean and it’s a wonderful beach by the water!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Theme Parks:&#039;&#039;&#039; Count tiles in your largest contiguous theme park area (diagonal connections don’t count). Score points based on the scoring table found in the game’s tooltips. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Gardens &amp;amp; Houses:&#039;&#039;&#039; Multiply the number of garden areas by the number of house areas. Adjacent zones of the same type count as one area; so keep gardens separate from other gardens and likewise for the houses. &#039;&#039;&#039;It’s fine if a garden is touching a house.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Icons:&#039;&#039;&#039; The positions of the icons don’t matter. Each icon type scores separately. The player with the highest number of an icon type scores 20 points, 2nd player scores 10 and 3rd player scores 5. Ties are friendly; all tying players score the same amount of points but you skip the next number for each tying player.&lt;br /&gt;
&lt;br /&gt;
You must have at least 1 icon of the type to score points from it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039; Alex has 2 ☮️, 2 ❤️, 3 🎵. Bonnie has 3 ☮️, 2 ❤️, 3 🎵. Charlie has 3 ☮️and 3 🎵. Doruk has only 1 🎵.&lt;br /&gt;
&lt;br /&gt;
☮️ (A: 2, B: 3, C: 3, D: 0): Alex scores 5 points. Bonnie and Charlie score 20 each.&lt;br /&gt;
&lt;br /&gt;
❤️ (A: 2, B: 2, C: 0, D: 0): Alex and Bonnie score 20 points. Other players score 0 as they don’t have any ❤️ icons. If they had only 1 ❤️, it’d be 5 points for them!&lt;br /&gt;
&lt;br /&gt;
🎵 (A: 3, B: 3, C: 3, D: 1): Alex, Bonnie and Charlie score 20 points. Doruk doesn’t score.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Most points win. Money breaks ties.&lt;/div&gt;</summary>
		<author><name>Fenadoruk</name></author>
	</entry>
	<entry>
		<id>https://en.doc.boardgamearena.com/index.php?title=Gamehelpauctionland&amp;diff=21622</id>
		<title>Gamehelpauctionland</title>
		<link rel="alternate" type="text/html" href="https://en.doc.boardgamearena.com/index.php?title=Gamehelpauctionland&amp;diff=21622"/>
		<updated>2024-06-22T21:49:10Z</updated>

		<summary type="html">&lt;p&gt;Fenadoruk: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
Build and auction tiles to create the most impressive paradise island!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Setup&#039;&#039;&#039; [BGA handles this for you, feel free to skip this part]:&lt;br /&gt;
&lt;br /&gt;
Each player grabs a screen and some money. The player who last visited a new island starts the game and takes the gavel! Starting money is distributed as follows:&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|1st player&lt;br /&gt;
|2nd player&lt;br /&gt;
|3rd player&lt;br /&gt;
|4th player&lt;br /&gt;
|5th player&lt;br /&gt;
|6th player&lt;br /&gt;
|-&lt;br /&gt;
|$10&lt;br /&gt;
|$12&lt;br /&gt;
|$14&lt;br /&gt;
|$16&lt;br /&gt;
|$18&lt;br /&gt;
|$20&lt;br /&gt;
|}&lt;br /&gt;
Place money behind your screen. You can enable &#039;&#039;&#039;visible money&#039;&#039;&#039; in the game settings.&lt;br /&gt;
&lt;br /&gt;
Create a stack of tiles and deal 8 tiles (or the market size set in game settings) into the middle to form the market. Sort them by the number of icons (Peace, Love &amp;amp; Music), with more icons closer to the stack.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Turn summary:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
1. &#039;&#039;&#039;Build Tile&#039;&#039;&#039;: Select a tile from the market to add to your island.&lt;br /&gt;
&lt;br /&gt;
2. &#039;&#039;&#039;Auction Tile&#039;&#039;&#039;: After building, select another tile and auction it off.&lt;br /&gt;
&lt;br /&gt;
3. &#039;&#039;&#039;End turn&#039;&#039;&#039;: Pass the gavel to the player on your left. It’s now their turn. Refresh the market back to 8 tiles (or the market size set in game settings) but don&#039;t sort them.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The Market:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Whenever you take a tile from the market (for building, auctioning, or Bonus), place $1 on each skipped tile starting from the free tile. Earn the money on the selected tile and place it behind your screen.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Building Tiles:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
New tiles placed after your first must share an edge with an existing tile on your island. You can expand your island in any direction as long as it doesn’t go beyond 4x4.&lt;br /&gt;
&lt;br /&gt;
Placing the 4th tile in a row or column earns you a Bonus tile (see Bonus Tiles).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Auctioning Tiles:&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
After building your tile, select a new tile following &#039;&#039;&#039;the market&#039;&#039;&#039; rules and put it on auction! It’s an open auction carried out simultaneously. Players can increase bids -even their own- any time as long as you have enough money to pay for it. The auction phase is over once all but one player has passed.&lt;br /&gt;
&lt;br /&gt;
In a 2-player game, the bidding player makes only 1 bid which concludes the auction phase.&lt;br /&gt;
&lt;br /&gt;
In the rare case that no one bids, the auctioneer takes the tile for free.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Buy back:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Once the auction phase is over, the auctioneer can either:&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Sell&#039;&#039;&#039; the auctioned tile to the highest bidder.&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Buy back&#039;&#039;&#039; the tile by paying the winning bid plus $1 to the highest bidder. i.e. Alex won the auction phase with a bid of $3, the auctioneer can pay $4 to Alex and build the tile.&lt;br /&gt;
&lt;br /&gt;
The auctioneer can still buy back even if their island is full. In that case, the auctioned tile is returned to the game box.&lt;br /&gt;
&lt;br /&gt;
Make sure you are not bidding so little that the auctioneer buys it back from you. Or maybe you want them to! After all, you&#039;re being paid without losing anything!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Bonus Tiles:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
After adding a tile to your island in &#039;&#039;&#039;any&#039;&#039;&#039; phase or for &#039;&#039;&#039;any&#039;&#039;&#039; reason, check whether it was the 4th tile of a row or column. If so, you immediately earn a Bonus tile!&lt;br /&gt;
&lt;br /&gt;
Draw a new tile following &#039;&#039;&#039;the market rules&#039;&#039;&#039; and build it by following the &#039;&#039;&#039;building tiles&#039;&#039;&#039; rules. Each player can earn only 1 Bonus tile per turn. In other words, a Bonus tile cannot trigger another Bonus, but more than 1 player can draw a Bonus tile on a single turn.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Game End:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Once a player has filled their 4x4 island, the game will be over at the end of that turn. This means you still proceed to the &#039;&#039;&#039;auction phase&#039;&#039;&#039; if you haven’t already done so.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;SCORING&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Beaches:&#039;&#039;&#039; Imagine the table is the ocean! Count tiles with a beach terrain touching the edge of your island. Score points based on the scoring table found in the game’s tooltips. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If a beach is not on the edge but still adjacent to a gap (because your 4x4 island wasn’t filled up) it still scores. The table is the ocean and it’s a wonderful beach by the water!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Theme Parks:&#039;&#039;&#039; Count tiles in your largest contiguous theme park area (contiguous terrains of the same type count as one area, diagonal connections don’t count). Score points based on the scoring table found in the game’s tooltips. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Gardens &amp;amp; Houses:&#039;&#039;&#039; Multiply the number of garden areas by the number of house areas; so try to keep gardens separate from other gardens and likewise for the houses. &#039;&#039;&#039;It’s fine if a garden is touching a house.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Icons:&#039;&#039;&#039; The positions of the icons don’t matter. Each icon type scores separately. The player with the highest number of an icon type scores 20 points, 2nd player scores 10 and 3rd player scores 5. Ties are friendly; all tying players score the same amount of points but you skip the next number for each tying player.&lt;br /&gt;
&lt;br /&gt;
You must have at least 1 icon of the type to score points from it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039; Alex has 2 ☮️, 2 ❤️, 3 🎵. Bonnie has 3 ☮️, 2 ❤️, 3 🎵. Charlie has 3 ☮️and 3 🎵. Doruk has only 1 🎵.&lt;br /&gt;
&lt;br /&gt;
☮️ (A: 2, B: 3, C: 3, D: 0): Alex scores 5 points. Bonnie and Charlie score 20 each.&lt;br /&gt;
&lt;br /&gt;
❤️ (A: 2, B: 2, C: 0, D: 0): Alex and Bonnie score 20 points. Other players score 0 as they don’t have any ❤️ icons. If they had only 1 ❤️, it’d be 5 points for them!&lt;br /&gt;
&lt;br /&gt;
🎵 (A: 3, B: 3, C: 3, D: 1): Alex, Bonnie and Charlie score 20 points. Doruk doesn’t score.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Most points win. Money breaks ties.&lt;/div&gt;</summary>
		<author><name>Fenadoruk</name></author>
	</entry>
	<entry>
		<id>https://en.doc.boardgamearena.com/index.php?title=Gamehelpauctionland&amp;diff=21573</id>
		<title>Gamehelpauctionland</title>
		<link rel="alternate" type="text/html" href="https://en.doc.boardgamearena.com/index.php?title=Gamehelpauctionland&amp;diff=21573"/>
		<updated>2024-06-20T11:26:40Z</updated>

		<summary type="html">&lt;p&gt;Fenadoruk: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
Build and auction tiles to create the most impressive paradise island!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Setup&#039;&#039;&#039; [BGA handles this for you, feel free to skip this part]:&lt;br /&gt;
&lt;br /&gt;
Each player grabs a screen and some money. The player who last visited a new island starts the game and takes the gavel! Starting money is distributed as follows:&lt;br /&gt;
&lt;br /&gt;
- 1st player: $10&lt;br /&gt;
&lt;br /&gt;
- 2nd player: $12&lt;br /&gt;
&lt;br /&gt;
- 3rd player: $14&lt;br /&gt;
&lt;br /&gt;
- 4th player: $16&lt;br /&gt;
&lt;br /&gt;
- 5th player: $18&lt;br /&gt;
&lt;br /&gt;
- 6th player: $20&lt;br /&gt;
&lt;br /&gt;
Place money behind your screen. You can enable &#039;&#039;&#039;visible money&#039;&#039;&#039; in the game settings.&lt;br /&gt;
&lt;br /&gt;
Create a stack of tiles and deal 8 tiles (or the market size set in game settings) into the middle to form the market. Sort them by the number of icons (Peace, Love &amp;amp; Music), with more icons closer to the stack.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Turn summary:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
1. &#039;&#039;&#039;Build Tile&#039;&#039;&#039;: Select a tile from the market to add to your island.&lt;br /&gt;
&lt;br /&gt;
2. &#039;&#039;&#039;Auction Tile&#039;&#039;&#039;: After building, select another tile and auction it off.&lt;br /&gt;
&lt;br /&gt;
3. &#039;&#039;&#039;End turn&#039;&#039;&#039;: Pass the gavel to the player on your left. It’s now their turn. Refresh the market back to 8 tiles (or the market size set in game settings) but don&#039;t sort them.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The Market:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Whenever you take a tile from the market (for building, auctioning, or Bonus), place $1 on each skipped tile starting from the free tile. Earn the money on the selected tile and place it behind your screen.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Building Tiles:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
New tiles placed after your first must share an edge with an existing tile on your island. You can expand your island in any direction as long as it doesn’t go beyond 4x4.&lt;br /&gt;
&lt;br /&gt;
Placing the 4th tile in a row or column earns you a Bonus tile (see Bonus Tiles).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Auctioning Tiles:&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
After building your tile, select a new tile following &#039;&#039;&#039;the market&#039;&#039;&#039; rules and put it on auction! It’s an open auction carried out simultaneously. Players can increase bids -even their own- any time as long as you have enough money to pay for it. The auction phase is over once all but one player has passed.&lt;br /&gt;
&lt;br /&gt;
In a 2-player game, the bidding player makes only 1 bid which concludes the auction phase.&lt;br /&gt;
&lt;br /&gt;
In the rare case that no one bids, the auctioneer takes the tile for free.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Buy back:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Once the auction phase is over, the auctioneer can either:&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Sell&#039;&#039;&#039; the auctioned tile to the highest bidder.&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Buy back&#039;&#039;&#039; the tile by paying the winning bid plus $1 to the highest bidder. i.e. Alex won the auction phase with a bid of $3, the auctioneer can pay $4 to Alex and build the tile.&lt;br /&gt;
&lt;br /&gt;
The auctioneer can still buy back even if their island is full. In that case, the auctioned tile is returned to the game box.&lt;br /&gt;
&lt;br /&gt;
Make sure you are not bidding so little that the auctioneer buys it back from you. Or maybe you want them to! After all, you&#039;re being paid without losing anything!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Bonus Tiles:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
After adding a tile to your island in &#039;&#039;&#039;any&#039;&#039;&#039; phase or for &#039;&#039;&#039;any&#039;&#039;&#039; reason, check whether it was the 4th tile of a row or column. If so, you immediately earn a Bonus tile!&lt;br /&gt;
&lt;br /&gt;
Draw a new tile following &#039;&#039;&#039;the market rules&#039;&#039;&#039; and build it by following the &#039;&#039;&#039;building tiles&#039;&#039;&#039; rules. Each player can earn only 1 Bonus tile per turn. In other words, a Bonus tile cannot trigger another Bonus, but more than 1 player can draw a Bonus tile on a single turn.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Game End:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Once a player has filled their 4x4 island, the game will be over at the end of that turn. This means you still proceed to the &#039;&#039;&#039;auction phase&#039;&#039;&#039; if you haven’t already done so.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;SCORING&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Beaches:&#039;&#039;&#039; Imagine the table is the ocean! Count tiles with a beach terrain touching the edge of your island. Score points based on the scoring table found in the game’s tooltips. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If a beach is not on the edge but still adjacent to a gap (because your 4x4 island wasn’t filled up) it still scores. The table is the ocean and it’s a wonderful beach by the water!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Theme Parks:&#039;&#039;&#039; Count tiles in your largest contiguous theme park area (contiguous terrains of the same type count as one area, diagonal connections don’t count). Score points based on the scoring table found in the game’s tooltips. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Gardens &amp;amp; Houses:&#039;&#039;&#039; Multiply the number of garden areas by the number of house areas; so try to keep gardens separate from other gardens and likewise for the houses. &#039;&#039;&#039;It’s fine if a garden is touching a house.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Icons:&#039;&#039;&#039; The positions of the icons don’t matter. Each icon type scores separately. The player with the highest number of an icon type scores 20 points, 2nd player scores 10 and 3rd player scores 5. Ties are friendly; all tying players score the same amount of points but you skip the next number for each tying player.&lt;br /&gt;
&lt;br /&gt;
You must have at least 1 icon of the type to score points from it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039; Alex has 2 ☮️, 2 ❤️, 3 🎵. Bonnie has 3 ☮️, 2 ❤️, 3 🎵. Charlie has 3 ☮️and 3 🎵. Doruk has only 1 🎵.&lt;br /&gt;
&lt;br /&gt;
☮️ (A: 2, B: 3, C: 3, D: 0): Alex scores 5 points. Bonnie and Charlie score 20 each.&lt;br /&gt;
&lt;br /&gt;
❤️ (A: 2, B: 2, C: 0, D: 0): Alex and Bonnie score 20 points. Other players score 0 as they don’t have any ❤️ icons. If they had only 1 ❤️, it’d be 5 points for them!&lt;br /&gt;
&lt;br /&gt;
🎵 (A: 3, B: 3, C: 3, D: 1): Alex, Bonnie and Charlie score 20 points. Doruk doesn’t score.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Most points win. Money breaks ties.&lt;/div&gt;</summary>
		<author><name>Fenadoruk</name></author>
	</entry>
	<entry>
		<id>https://en.doc.boardgamearena.com/index.php?title=Game_art:_img_directory&amp;diff=21507</id>
		<title>Game art: img directory</title>
		<link rel="alternate" type="text/html" href="https://en.doc.boardgamearena.com/index.php?title=Game_art:_img_directory&amp;diff=21507"/>
		<updated>2024-06-12T19:27:28Z</updated>

		<summary type="html">&lt;p&gt;Fenadoruk: /* Use CSS Sprites */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Studio_Framework_Navigation}}&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Metadata images ==&lt;br /&gt;
&lt;br /&gt;
Game metadata images are images of game box, banner, title, etc. These images are no longer stored in project directory.&lt;br /&gt;
&lt;br /&gt;
Metadata images are managed through the [[Game_metadata_manager|Game Metadata Manager]]. After you go there select the link to the game you want to upload images for.&lt;br /&gt;
&lt;br /&gt;
== Game art ==&lt;br /&gt;
&lt;br /&gt;
You must upload in img directory all images of your game interface.&lt;br /&gt;
&lt;br /&gt;
=== Images naming constraints ===&lt;br /&gt;
&lt;br /&gt;
To be correctly deployed your images file names should not contain spaces or parentheses.&lt;br /&gt;
&lt;br /&gt;
=== Images loading ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Be careful&#039;&#039;&#039;: by default, ALL images of your img directory are loaded on a player&#039;s browser when he loads the game. For this reason, don&#039;t let in your img directory images that are not useful, otherwise it&#039;s going to slowdown the game load.&lt;br /&gt;
&lt;br /&gt;
Note that you can tune the way images are loaded with Javascript method &amp;quot;dontPreloadImage&amp;quot; (see [[Game_interface_logic:_yourgamename.js|Game Interface Logic]]).&lt;br /&gt;
&lt;br /&gt;
General recommendation it to have no more than dozen of image files, 2Mb max each. However if there is heavy game resources specific to a player (i.e. player board of specific color or set of cards) it is better to separate them and &amp;quot;don&#039;t pre-load&amp;quot; since in any given game only some of them will be used.&lt;br /&gt;
&lt;br /&gt;
=== Images format ===&lt;br /&gt;
&lt;br /&gt;
You can use these image formats while building your game interface:&lt;br /&gt;
;jpg images&lt;br /&gt;
&lt;br /&gt;
should be used for non-transparent images. Jpg are usually lighter than pngs, so please choose Jpg for big pictures (ex: game board, cards) when you don&#039;t need transparency to accelerate game load. You don&#039;t need transparency for rounded card corners, it can be done using css.&lt;br /&gt;
&lt;br /&gt;
;png images&lt;br /&gt;
&lt;br /&gt;
should be used for images with transparency, such as non-square tokens, meeples, etc (combined into sprite).&lt;br /&gt;
&lt;br /&gt;
;gif images&lt;br /&gt;
&lt;br /&gt;
can be used for animated images. This is not recommended to use gif animated images as they can upset players, but for some specific interface element this could be useful.&lt;br /&gt;
&lt;br /&gt;
;svg images&lt;br /&gt;
&lt;br /&gt;
svg images can be really efficient for icons or abstract images. Note: consider also using font awesome for icons instead of separate asset file.&lt;br /&gt;
&lt;br /&gt;
=== Webp ===&lt;br /&gt;
png and jpg images are automatically converted to webp during deployment. Webp&#039;s are lighter weight.&lt;br /&gt;
&lt;br /&gt;
When requesting a png/jpg file, many modern browsers will specify a preference for webp in their Accept header, and our CDN will comply with this request serving the converted webp image instead of the original png you uploaded. You can confirm which format your browser requests by checking request and response headers for the image in the network tab of your browser&#039;s developer tools.&lt;br /&gt;
&lt;br /&gt;
In rare cases, this can cause a problem because the conversion is lossy.&lt;br /&gt;
&lt;br /&gt;
If and only if this does cause a problem, then you can capitalise the first letter of your image&#039;s extension, &amp;lt;code&amp;gt;.Png&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;.Jpg&amp;lt;/code&amp;gt;, and reference &amp;lt;code&amp;gt;image.Png&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;image.png&amp;lt;/code&amp;gt; in the CSS. This will bypass the webp conversion and ensure you use the original image. This should not be done unless it is required.&lt;br /&gt;
&lt;br /&gt;
=== Use background-size ===&lt;br /&gt;
&lt;br /&gt;
In order to allow for players to use the browser zoom without your images becoming pixelated, it&#039;s recommended to use higher resolution images than needed for the normal display of your interface, and to use the css property &#039;&#039;&#039;background-size&#039;&#039;&#039; to fit the image to the size you need for your interface.&lt;br /&gt;
&lt;br /&gt;
=== Use CSS Sprites ===&lt;br /&gt;
&lt;br /&gt;
To limit the number of images load and make the game load faster, you must use CSS sprites, i.e. you must gather several images in a single one. However, there are limitations. Do not make any CSS image sprite with dimensions that exceed 4096x4096 pixels or it will not work on mobile devices (Android max texture size is 4096 pixels, test your own browser at [http://webglreport.com/ WebGL Report]).&lt;br /&gt;
&lt;br /&gt;
To learn more on CSS Sprites:&lt;br /&gt;
* [http://www.w3schools.com/css/css_image_sprites.asp CSS sprites (W3C documentation)].&lt;br /&gt;
* [[Game interface stylesheet: yourgamename.css]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Important:&#039;&#039;&#039; the maximum image size should be 4096x4096 (otherwise, some devices may not display parts of the image, see https://stackoverflow.com/questions/34682482/what-is-the-maximum-sprite-sheet-size-i-can-use-for-android-devices)&lt;br /&gt;
&lt;br /&gt;
Tools:&lt;br /&gt;
* Sprite Generator https://www.toptal.com/developers/css/sprite-generator/&lt;br /&gt;
* Another Sprite Generator https://www.finalparsec.com/tools/sprite_sheet_maker&lt;br /&gt;
&lt;br /&gt;
=== Shrink images ===&lt;br /&gt;
&lt;br /&gt;
If you get high resolution images from publisher you need to shrink them since web display requires much lower resolution than printing.&lt;br /&gt;
&lt;br /&gt;
* Shrink images size without visible loss of quality &lt;br /&gt;
** Offline tool for PNG: https://pngquant.org/ &lt;br /&gt;
** Online tools for PNG/JPG: https://tinypng.com/ or http://www.iloveimg.com/ or https://squoosh.app/&lt;br /&gt;
** Online tool for SVG: https://jakearchibald.github.io/svgomg/&lt;br /&gt;
&lt;br /&gt;
== Image Manipulation Tools ==&lt;br /&gt;
&lt;br /&gt;
You have no choice but to use one of the image manipulating tools to create a successful game adaptation, you would have to&lt;br /&gt;
deal with&lt;br /&gt;
* Converting to supported formats&lt;br /&gt;
* Adding transparency &lt;br /&gt;
* Stitching&lt;br /&gt;
* Shrinking with no quality loss&lt;br /&gt;
* Resizing&lt;br /&gt;
&lt;br /&gt;
For that you need a good tools, recommended tools (if you know more add them here)&lt;br /&gt;
* Gimp (all platforms) - general GUI image editor&lt;br /&gt;
* Paint.net (Windows) - general GUI image editor&lt;br /&gt;
* ImageMagic (All platforms) - https://www.imagemagick.org/script/download.php - command line image editor, great for mass manipulations and scripting&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Examples ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
PDF to png convertion (linux)&lt;br /&gt;
 gs -sDEVICE=pngalpha   -o output.png -r600 -dDownScaleFactor=3 input.pdf &lt;br /&gt;
&lt;br /&gt;
PDF to jpg using image magic and cropping page&lt;br /&gt;
 montage -colorspace sRGB -density 300 -geometry 452x+0+0 -tile 5 -crop 82x87%+130+126 input.pdf  output.jpg&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
PSD Extraction (image magic - CMYK to sRBG - one layer per file)&lt;br /&gt;
 for i in *.psd; do  convert  $i -profile /usr/share/color/icc/colord/sRGB.icc   `basename $i .psd`.png; done;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Tiling - The order of the images will match the &#039;ls&#039; order. If needed change the filenames if you need a specific order.&lt;br /&gt;
&lt;br /&gt;
 montage -colorspace sRGB -density 300 *.png -tile 6 -background transparent ../tokens.png&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
PDF scrabber (linux) - extract all graphics file from pdf&lt;br /&gt;
 pdfimages my.pdf prefix-&lt;br /&gt;
&lt;br /&gt;
=== Online tools ===&lt;br /&gt;
&lt;br /&gt;
PSD extraction (adobe file format)&lt;br /&gt;
&lt;br /&gt;
 https://www.photopea.com/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Seamless background (for tiled background wallpaper)&lt;br /&gt;
&lt;br /&gt;
 https://www.imgonline.com.ua/eng/make-seamless-texture.php&lt;br /&gt;
&lt;br /&gt;
Download game assets from tabletop simulator&lt;br /&gt;
&lt;br /&gt;
 https://www.npmjs.com/package/ttsbackup&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Studio]]&lt;/div&gt;</summary>
		<author><name>Fenadoruk</name></author>
	</entry>
	<entry>
		<id>https://en.doc.boardgamearena.com/index.php?title=Gamehelpauctionland&amp;diff=21499</id>
		<title>Gamehelpauctionland</title>
		<link rel="alternate" type="text/html" href="https://en.doc.boardgamearena.com/index.php?title=Gamehelpauctionland&amp;diff=21499"/>
		<updated>2024-06-11T10:21:19Z</updated>

		<summary type="html">&lt;p&gt;Fenadoruk: minor corrections&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
Build and auction tiles to create the most impressive paradise island!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Setup&#039;&#039;&#039; [BGA handles this for you, feel free to skip this part]:&lt;br /&gt;
&lt;br /&gt;
Each player grabs a screen and some money. The player who last visited a new island starts the game and takes the gavel! Starting money is distributed as follows:&lt;br /&gt;
&lt;br /&gt;
- 1st player: $10&lt;br /&gt;
&lt;br /&gt;
- 2nd player: $12&lt;br /&gt;
&lt;br /&gt;
- 3rd player: $14&lt;br /&gt;
&lt;br /&gt;
- 4th player: $16&lt;br /&gt;
&lt;br /&gt;
- 5th player: $18&lt;br /&gt;
&lt;br /&gt;
- 6th player: $20&lt;br /&gt;
&lt;br /&gt;
Place money behind your screen. You can enable &#039;&#039;&#039;visible money&#039;&#039;&#039; in the game settings.&lt;br /&gt;
&lt;br /&gt;
Create a stack of tiles and deal 8 tiles (or the market size set in game settings) into the middle to form the market. Sort them by the number of icons (Peace, Love &amp;amp; Music), with more icons closer to the stack.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Turn summary:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
1. &#039;&#039;&#039;Build Tile&#039;&#039;&#039;: Select a tile from the market to add to your island.&lt;br /&gt;
&lt;br /&gt;
2. &#039;&#039;&#039;Auction Tile&#039;&#039;&#039;: After building, select another tile and auction it off.&lt;br /&gt;
&lt;br /&gt;
3. &#039;&#039;&#039;End turn&#039;&#039;&#039;: Pass the gavel to the player on your left. It’s now their turn. Refresh the market back to 8 tiles (or the market size set in game settings) but don&#039;t sort them.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The Market:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Whenever you take a tile from the market (for building, auctioning, or Bonus), place $1 on each skipped tile starting from the free tile. Earn the money on the selected tile and place it behind your screen.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Building Tiles:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
New tiles placed after your first must share an edge with an existing tile on your island. You can expand your island in any direction as long as it doesn’t go beyond 4x4.&lt;br /&gt;
&lt;br /&gt;
Placing the 4th tile in a row or column earns you a Bonus tile (see Bonus Tiles).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Auctioning Tiles:&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
After building your tile, select a new tile following &#039;&#039;&#039;the market&#039;&#039;&#039; rules and put it on auction! It’s an open auction carried out simultaneously. Players can increase bids -even their own- any time as long as you have enough money to pay for it. The auction phase is over once all but one player has passed.&lt;br /&gt;
&lt;br /&gt;
In a 2-player game, the bidding player makes only 1 bid which concludes the auction phase.&lt;br /&gt;
&lt;br /&gt;
In the rare case that no one bids, the auctioneer takes the tile for free.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Buy back:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Once the auction phase is over, the auctioneer can either:&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Sell&#039;&#039;&#039; the auctioned tile to the highest bidder.&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Buy back&#039;&#039;&#039; the tile by paying the winning bid plus $1 to the highest bidder. i.e. Alex won the auction phase with a bid of $3, the auctioneer can pay $4 to Alex and build the tile.&lt;br /&gt;
&lt;br /&gt;
The auctioneer can still buy back even if their island is full. In that case, the auctioned tile is returned to the game box.&lt;br /&gt;
&lt;br /&gt;
Make sure you are not bidding so little that the auctioneer buys it back from you. Or maybe you want them to! After all, you&#039;re being paid without losing anything!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Bonus Tiles:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
After adding a tile to your island in &#039;&#039;&#039;any&#039;&#039;&#039; phase or for &#039;&#039;&#039;any&#039;&#039;&#039; reason, check whether it was the 4th tile of a row or column. If so, you immediately earn a Bonus tile!&lt;br /&gt;
&lt;br /&gt;
Draw a new tile following &#039;&#039;&#039;the market rules&#039;&#039;&#039; and build it by following the &#039;&#039;&#039;building tiles&#039;&#039;&#039; rules. Each player can earn only 1 Bonus tile per turn. In other words, a Bonus tile cannot trigger another Bonus, but more than 1 player can draw a Bonus tile on a single turn.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Game End:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Once a player has filled their 4x4 island, the game will be over at the end of that turn. This means you still proceed to the &#039;&#039;&#039;auction phase&#039;&#039;&#039; if you haven’t already done so.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;SCORING&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Beaches:&#039;&#039;&#039; Imagine the table is the ocean! Count tiles with a beach terrain touching the edge of your island. Score points based on the scoring table found in the game’s tooltips. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If a beach is not on the edge but still adjacent to a gap (because your 4x4 island wasn’t filled up) it still scores. The table is the ocean and it’s a wonderful beach by the water!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Theme Parks:&#039;&#039;&#039; Count tiles in your largest contiguous theme park area (diagonal connections don’t count). Score points based on the scoring table found in the game’s tooltips. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Gardens &amp;amp; Houses:&#039;&#039;&#039; Multiply the number of garden areas by the number of house areas. Adjacent terrains of the same type count as one area; so keep gardens separate from other gardens and likewise for the houses. &#039;&#039;&#039;It’s fine if a garden is touching a house.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Icons:&#039;&#039;&#039; The positions of the icons don’t matter. Each icon type scores separately. The player with the highest number of an icon type scores 20 points, 2nd player scores 10 and 3rd player scores 5. Ties are friendly; all tying players score the same amount of points but you skip the next number for each tying player.&lt;br /&gt;
&lt;br /&gt;
You must have at least 1 icon of the type to score points from it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039; Alex has 2 ☮️, 2 ❤️, 3 🎵. Bonnie has 3 ☮️, 2 ❤️, 3 🎵. Charlie has 3 ☮️and 3 🎵. Doruk has only 1 🎵.&lt;br /&gt;
&lt;br /&gt;
☮️ (A: 2, B: 3, C: 3, D: 0): Alex scores 5 points. Bonnie and Charlie score 20 each.&lt;br /&gt;
&lt;br /&gt;
❤️ (A: 2, B: 2, C: 0, D: 0): Alex and Bonnie score 20 points. Other players score 0 as they don’t have any ❤️ icons. If they had only 1 ❤️, it’d be 5 points for them!&lt;br /&gt;
&lt;br /&gt;
🎵 (A: 3, B: 3, C: 3, D: 1): Alex, Bonnie and Charlie score 20 points. Doruk doesn’t score.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Most points win. Money breaks ties.&lt;/div&gt;</summary>
		<author><name>Fenadoruk</name></author>
	</entry>
	<entry>
		<id>https://en.doc.boardgamearena.com/index.php?title=Gamehelpauctionland&amp;diff=21493</id>
		<title>Gamehelpauctionland</title>
		<link rel="alternate" type="text/html" href="https://en.doc.boardgamearena.com/index.php?title=Gamehelpauctionland&amp;diff=21493"/>
		<updated>2024-06-10T09:33:28Z</updated>

		<summary type="html">&lt;p&gt;Fenadoruk: minor edits. BGA interface is not updating :( why?&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
Build and auction tiles to create the most impressive paradise island!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Setup&#039;&#039;&#039; [BGA handles this for you, feel free to skip this part]:&lt;br /&gt;
&lt;br /&gt;
Each player grabs a screen and some money. The player who last visited a new island starts the game and takes the gavel! Starting money is distributed as follows:&lt;br /&gt;
&lt;br /&gt;
- 1st player: $10&lt;br /&gt;
&lt;br /&gt;
- 2nd player: $12&lt;br /&gt;
&lt;br /&gt;
- 3rd player: $14&lt;br /&gt;
&lt;br /&gt;
- 4th player: $16&lt;br /&gt;
&lt;br /&gt;
- 5th player: $18&lt;br /&gt;
&lt;br /&gt;
- 6th player: $20&lt;br /&gt;
&lt;br /&gt;
Place money behind your screen. You can enable &#039;&#039;&#039;visible money&#039;&#039;&#039; in the game settings.&lt;br /&gt;
&lt;br /&gt;
Create a stack of tiles and deal 8 tiles (or the market size set in game settings) into the middle to form the market. Sort them by the number of icons (Peace, Love &amp;amp; Music), with more icons closer to the stack.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Turn summary:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
1. &#039;&#039;&#039;Build Tile&#039;&#039;&#039;: Select a tile from the market to add to your island.&lt;br /&gt;
&lt;br /&gt;
2. &#039;&#039;&#039;Auction Tile&#039;&#039;&#039;: After building, select another tile and auction it off.&lt;br /&gt;
&lt;br /&gt;
3. &#039;&#039;&#039;End turn&#039;&#039;&#039;: Pass the gavel to the player on your left. It’s now their turn. Refresh the market back to 8 tiles (or the market size set in game settings) but don&#039;t sort them.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The Market:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Whenever you take a tile from the market (for building, auctioning, or Bonus), place $1 on each skipped tile starting from the free tile. Earn the money on the selected tile and place it behind your screen.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Building Tiles:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
New tiles placed after your first must share an edge with an existing tile on your island. You can expand your island in any direction as long as it doesn’t go beyond 4x4.&lt;br /&gt;
&lt;br /&gt;
Placing the 4th tile in a row or column earns you a Bonus tile (see Bonus Tiles).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Auctioning Tiles:&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
After building your tile, select a new tile following &#039;&#039;&#039;the market&#039;&#039;&#039; rules and put it on auction! It’s an open auction carried out simultaneously. Players can increase bids -even their own- any time as long as you have enough money to pay for it. The auction phase is over once all but one player has passed.&lt;br /&gt;
&lt;br /&gt;
In a 2-player game, the bidding player makes only 1 bid which concludes the auction phase.&lt;br /&gt;
&lt;br /&gt;
In the rare case that no one bids, the auctioneer takes the tile for free.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Buy back:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Once the auction phase is over, the auctioneer can either:&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Sell&#039;&#039;&#039; the auctioned tile to the highest bidder.&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Buy back&#039;&#039;&#039; the tile by paying the winning bid plus $1 to the highest bidder. i.e. Alex won the auction phase with a bid of $3, the auctioneer can pay $4 to Alex and build the tile.&lt;br /&gt;
&lt;br /&gt;
The auctioneer can still buy back even if their island is full. In that case, the auctioned tile is returned to the game box.&lt;br /&gt;
&lt;br /&gt;
Make sure you are not bidding so little that the auctioneer buys it back from you. Or maybe you want them to! After all, you&#039;re being paid without losing anything!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Bonus Tiles:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
After adding a tile to your island in &#039;&#039;&#039;any&#039;&#039;&#039; phase or for &#039;&#039;&#039;any&#039;&#039;&#039; reason, check whether it was the 4th tile of a row or column. If so, you immediately earn a Bonus tile!&lt;br /&gt;
&lt;br /&gt;
Draw a new tile following &#039;&#039;&#039;the market rules&#039;&#039;&#039; and build it by following the &#039;&#039;&#039;building tiles&#039;&#039;&#039; rules. Each player can earn only 1 Bonus tile per turn. In other words, a Bonus tile cannot trigger another Bonus, but more than 1 player can draw a Bonus tile on a single turn.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Game End:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Once a player has filled their 4x4 island, the game will be over at the end of that turn. This means you still proceed to the &#039;&#039;&#039;auction phase&#039;&#039;&#039; if you haven’t already done so.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;SCORING&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Beaches:&#039;&#039;&#039; Imagine the table is the ocean! Count tiles with a beach zone touching the edge of your island. Score points based on the scoring table found in the game’s tooltips. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If a beach is not on the edge but still adjacent to a gap (because your 4x4 island wasn’t filled up) it still scores. The table is the ocean and it’s a wonderful beach by the water!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Theme Parks:&#039;&#039;&#039; Count tiles in your largest contiguous theme park area (diagonal connections don’t count). Score points based on the scoring table found in the game’s tooltips. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Gardens &amp;amp; Houses:&#039;&#039;&#039; Multiply the number of garden areas by the number of house areas. Adjacent zones of the same type count as one area; so keep gardens separate from other gardens and likewise for the houses. &#039;&#039;&#039;It’s fine if a garden is touching a house.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Icons:&#039;&#039;&#039; The positions of the icons don’t matter. Each icon type scores separately. The player with the highest number of an icon type scores 20 points, 2nd player scores 10 and 3rd player scores 5. Ties are friendly; all tying players score the same amount of points but you skip the next number for each tying player.&lt;br /&gt;
&lt;br /&gt;
You must have at least 1 icon of the type to score points from it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039; Alex has 2 ☮️, 2 ❤️, 3 🎵. Bonnie has 3 ☮️, 2 ❤️, 3 🎵. Charlie has 3 ☮️and 3 🎵. Doruk has only 1 🎵.&lt;br /&gt;
&lt;br /&gt;
☮️ (A: 2, B: 3, C: 3, D: 0): Alex scores 5 points. Bonnie and Charlie score 20 each.&lt;br /&gt;
&lt;br /&gt;
❤️ (A: 2, B: 2, C: 0, D: 0): Alex and Bonnie score 20 points. Other players score 0 as they don’t have any love icons. If they had only 1 Love icon, it’d be 5 points for them!&lt;br /&gt;
&lt;br /&gt;
🎵 (A: 3, B: 3, C: 3, D: 1): Alex, Bonnie and Charlie score 20 points. Doruk doesn’t score.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Most points win. Money breaks ties.&lt;/div&gt;</summary>
		<author><name>Fenadoruk</name></author>
	</entry>
	<entry>
		<id>https://en.doc.boardgamearena.com/index.php?title=Gamehelpauctionland&amp;diff=21492</id>
		<title>Gamehelpauctionland</title>
		<link rel="alternate" type="text/html" href="https://en.doc.boardgamearena.com/index.php?title=Gamehelpauctionland&amp;diff=21492"/>
		<updated>2024-06-10T09:13:38Z</updated>

		<summary type="html">&lt;p&gt;Fenadoruk: rules updated&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
Build and auction tiles to create the most impressive paradise island!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Setup&#039;&#039;&#039; [BGA handles this for you, feel free to skip this part]:&lt;br /&gt;
&lt;br /&gt;
Each player grabs a screen and some money. The player who last visited a new island starts the game and takes the gavel! Starting money is distributed as follows:&lt;br /&gt;
&lt;br /&gt;
- 1st player: $10&lt;br /&gt;
&lt;br /&gt;
- 2nd player: $12&lt;br /&gt;
&lt;br /&gt;
- 3rd player: $14&lt;br /&gt;
&lt;br /&gt;
- 4th player: $16&lt;br /&gt;
&lt;br /&gt;
- 5th player: $18&lt;br /&gt;
&lt;br /&gt;
- 6th player: $20&lt;br /&gt;
&lt;br /&gt;
Place money behind your screen. You can enable &#039;&#039;&#039;visible money&#039;&#039;&#039; in the game settings.&lt;br /&gt;
&lt;br /&gt;
Create a stack of tiles and deal 8 tiles (or the market size set in game settings) into the middle to form the market. Sort them by the number of icons (Peace, Love &amp;amp; Music), with more icons closer to the stack.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Turn summary:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Build Tile&#039;&#039;&#039;: Select a tile from the market to add to your island. &lt;br /&gt;
# &#039;&#039;&#039;Auction Tile&#039;&#039;&#039;: After building, select another tile and auction it off.&lt;br /&gt;
# &#039;&#039;&#039;End turn&#039;&#039;&#039;: Pass the gavel to the player on your left. It’s now their turn. Refresh the market back to 8 tiles (or the market size set in game settings) but don&#039;t sort them.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The Market:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Whenever you take a tile from the market (for building, auctioning, or Bonus), place $1 on each skipped tile starting from the free tile. Earn the money on the selected tile and place it behind your screen.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Building Tiles:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
New tiles placed after your first must share an edge with an existing tile on your island. You can expand your island in any direction as long as it doesn’t go beyond 4x4.&lt;br /&gt;
&lt;br /&gt;
Placing the 4th tile in a row or column earns you a Bonus tile (see Bonus Tiles).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Auctioning Tiles:&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
After building your tile, select a new tile following &#039;&#039;&#039;the market&#039;&#039;&#039; rules and put it on auction! It’s an open auction carried out simultaneously. Players can increase bids -even their own- any time as long as you have enough money to pay for it. The auction phase is over once all but one player has passed.&lt;br /&gt;
&lt;br /&gt;
In a 2-player game, the bidding player makes only 1 bid which concludes the auction phase.&lt;br /&gt;
&lt;br /&gt;
In the rare case that no one bids, the auctioneer takes the tile for free.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Buy back:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Once the auction phase is over, the auctioneer can either:&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Sell&#039;&#039;&#039; the auctioned tile to the highest bidder.&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Buy back&#039;&#039;&#039; the tile by paying the winning bid plus $1 to the highest bidder. i.e. Alex won the auction phase with a bid of $3, the auctioneer can pay $4 to Alex and build the tile.&lt;br /&gt;
&lt;br /&gt;
The auctioneer can still buy back even if their island is full. In that case, the auctioned tile is returned to the game box.&lt;br /&gt;
&lt;br /&gt;
Make sure you are not bidding so little that the auctioneer buys it back from you. Or maybe you want them to! After all, you&#039;re being paid without losing anything!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Bonus Tiles:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
After adding a tile to your island in &#039;&#039;&#039;any&#039;&#039;&#039; phase or for &#039;&#039;&#039;any&#039;&#039;&#039; reason, check whether it was the 4th tile of a row or column. If so, you immediately earn a Bonus tile!&lt;br /&gt;
&lt;br /&gt;
Draw a new tile following &#039;&#039;&#039;the market rules&#039;&#039;&#039; and build it by following the &#039;&#039;&#039;building tiles&#039;&#039;&#039; rules. Each player can earn only 1 Bonus tile per turn. In other words, a Bonus tile cannot trigger another Bonus, but more than 1 player can draw a Bonus tile on a single turn.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Game End:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Once a player has filled their 4x4 island, the game will be over at the end of that turn. This means you still proceed to the &#039;&#039;&#039;auction phase&#039;&#039;&#039; if you haven’t already done so.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;SCORING&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Beaches:&#039;&#039;&#039; Imagine the table is the ocean! Count tiles with a beach zone touching the edge of your island. Score points based on the scoring table found in the game’s tooltips. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If a beach is not on the edge but still adjacent to a gap (because your 4x4 island wasn’t filled up) it still scores. The table is the ocean and it’s a wonderful beach by the water!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Theme Parks:&#039;&#039;&#039; Count tiles in your largest contiguous theme park area (diagonal connections don’t count). Score points based on the scoring table found in the game’s tooltips. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Gardens &amp;amp; Houses:&#039;&#039;&#039; Multiply the number of garden areas by the number of house areas. Adjacent zones of the same type count as one area; so keep gardens separate from other gardens and likewise for the houses. &#039;&#039;&#039;It’s fine if a garden is touching a house.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Icons:&#039;&#039;&#039; The positions of the icons don’t matter. Each icon type scores separately. The player with the highest number of an icon type scores 20 points, 2nd player scores 10 and 3rd player scores 5. Ties are friendly; all tying players score the same amount of points but you skip the next number for each tying player.&lt;br /&gt;
&lt;br /&gt;
You must have at least 1 icon of the type to score points from it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039; Alex has 2 ☮️, 2 ❤️, 3 🎵. Bonnie has 3 ☮️, 2 ❤️, 3 🎵. Charlie has 3 ☮️and 3 🎵. Doruk has only 1 🎵.&lt;br /&gt;
&lt;br /&gt;
☮️ (A: 2, B: 3, C: 3, D: 0): Alex scores 5 points. Bonnie and Charlie score 20 each.&lt;br /&gt;
&lt;br /&gt;
❤️ (A: 2, B: 2, C: 0, D: 0): Alex and Bonnie score 20 points. Other players score 0 as they don’t have any love icons. If they had only 1 Love icon, it’d be 5 points for them!&lt;br /&gt;
&lt;br /&gt;
🎵 (A: 3, B: 3, C: 3, D: 1): Alex, Bonnie and Charlie score 20 points. Doruk doesn’t score.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Most points win. Money breaks ties.&lt;/div&gt;</summary>
		<author><name>Fenadoruk</name></author>
	</entry>
	<entry>
		<id>https://en.doc.boardgamearena.com/index.php?title=Gamehelpauctionland&amp;diff=21491</id>
		<title>Gamehelpauctionland</title>
		<link rel="alternate" type="text/html" href="https://en.doc.boardgamearena.com/index.php?title=Gamehelpauctionland&amp;diff=21491"/>
		<updated>2024-06-10T09:07:15Z</updated>

		<summary type="html">&lt;p&gt;Fenadoruk: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
Build and auction tiles to create the most impressive paradise island!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Setup&#039;&#039;&#039; [BGA handles this for you, feel free to skip this part]:&lt;br /&gt;
&lt;br /&gt;
Each player grabs a screen and some money. The player who last visited a new island starts the game and takes the gavel! Starting money is distributed as follows:&lt;br /&gt;
&lt;br /&gt;
- 1st player: $10&lt;br /&gt;
&lt;br /&gt;
- 2nd player: $12&lt;br /&gt;
&lt;br /&gt;
- 3rd player: $14&lt;br /&gt;
&lt;br /&gt;
- 4th player: $16&lt;br /&gt;
&lt;br /&gt;
- 5th player: $18&lt;br /&gt;
&lt;br /&gt;
- 6th player: $20&lt;br /&gt;
&lt;br /&gt;
Place money behind your screen. You can enable &#039;&#039;&#039;visible money&#039;&#039;&#039; in the game settings.&lt;br /&gt;
&lt;br /&gt;
Create a stack of tiles and deal 8 tiles (or the market size set in game settings) into the middle to form the market. Sort them by the number of icons (Peace, Love &amp;amp; Music), with more icons closer to the stack.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Turn summary:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Build Tile&#039;&#039;&#039;: Select a tile from the market to add to your island. &lt;br /&gt;
# &#039;&#039;&#039;Auction Tile&#039;&#039;&#039;: After building, select another tile and auction it off.&lt;br /&gt;
# &#039;&#039;&#039;End turn&#039;&#039;&#039;: Pass the gavel to the player on your left. It’s now their turn. Refresh the market back to 8 tiles (or the market size set in game settings) but don&#039;t sort them.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The Market:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Whenever you take a tile from the market (for building, auctioning, or Bonus), place $1 on each skipped tile starting from the free tile. Earn the money on the selected tile and place it behind your screen.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Building Tiles:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
New tiles placed after your first must share an edge with an existing tile on your island. You can expand your island in any direction as long as it doesn’t go beyond 4x4.&lt;br /&gt;
&lt;br /&gt;
Placing the 4th tile in a row or column earns you a Bonus tile (see Bonus Tiles).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Auctioning Tiles:&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
After building your tile, select a new tile following &#039;&#039;&#039;the market&#039;&#039;&#039; rules and put it on auction! It’s an open auction carried out simultaneously. Players can increase bids -even their own- any time as long as you have enough money to pay for it. The auction phase is over once all but one player has passed.&lt;br /&gt;
&lt;br /&gt;
In a 2-player game, the bidding player makes only 1 bid which concludes the auction phase.&lt;br /&gt;
&lt;br /&gt;
In the rare case that no one bids, the auctioneer takes the tile for free.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Buy back:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Once the auction phase is over, the auctioneer can either:&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Sell&#039;&#039;&#039; the auctioned tile to the highest bidder.&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Buy back&#039;&#039;&#039; the tile by paying the winning bid plus $1 to the highest bidder. i.e. Alex won the auction phase with a bid of $3, the auctioneer can pay $4 to Alex and build the tile.&lt;br /&gt;
&lt;br /&gt;
The auctioneer can still buy back even if their island is full. In that case, the auctioned tile is returned to the game box.&lt;br /&gt;
&lt;br /&gt;
Make sure you are not bidding so little that the auctioneer buys it back from you. Or maybe you want them to! After all, you&#039;re being paid without losing anything!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Bonus Tiles:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
After adding a tile to your island in &#039;&#039;&#039;any&#039;&#039;&#039; phase or for &#039;&#039;&#039;any&#039;&#039;&#039; reason, check whether it was the 4th tile of a row or column. If so, you immediately earn a Bonus tile!&lt;br /&gt;
&lt;br /&gt;
Draw a new tile following &#039;&#039;&#039;the market rules&#039;&#039;&#039; and build it by following the &#039;&#039;&#039;building tiles&#039;&#039;&#039; rules. Each player can earn only 1 Bonus tile per turn. In other words, a Bonus tile cannot trigger another Bonus, but more than 1 player can draw a Bonus tile on a single turn.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Game End:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Once a player has filled their 4x4 island, the game will be over at the end of that turn. This means you still proceed to the &#039;&#039;&#039;auction phase&#039;&#039;&#039; if you haven’t already done so.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;SCORING&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Beaches:&#039;&#039;&#039; Imagine the table is the ocean! Count tiles with a beach zone touching the edge of your island. Score points based on the scoring table found in the game’s tooltips. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If a beach is not on the edge but still adjacent to a gap (because your 4x4 island wasn’t filled up) it still scores. The table is the ocean and it’s a wonderful facing the water!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Theme Parks:&#039;&#039;&#039; Count tiles in your largest contiguous theme park area (diagonal connections don’t count). Score points based on the scoring table found in the game’s tooltips. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Gardens &amp;amp; Houses:&#039;&#039;&#039; Multiply the number of garden areas by the number of house areas. Adjacent zones of the same type count as one area; so keep gardens separate from other gardens and likewise for the houses. &#039;&#039;&#039;It’s fine if a garden is touching a house.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Icons:&#039;&#039;&#039; The positions of the icons don’t matter. Each icon type scores separately. The player with the highest number of an icon type scores 20 points, 2nd player scores 10 and 3rd player scores 5. Ties are friendly; all tying players score the same amount of points but you skip the next number for each tying player.&lt;br /&gt;
&lt;br /&gt;
You must have at least 1 icon of the type to score points from it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039; Alex has 2 ☮️, 2 ❤️, 3 🎵. Bonnie has 3 ☮️, 2 ❤️, 3 🎵. Charlie has 3 ☮️and 3 🎵. Doruk has only 1 🎵.&lt;br /&gt;
&lt;br /&gt;
☮️ (A: 2, B: 3, C: 3, D: 0): Alex scores 5 points. Bonnie and Charlie score 20 each.&lt;br /&gt;
&lt;br /&gt;
❤️ (A: 2, B: 2, C: 0, D: 0): Alex and Bonnie score 20 points. Other players score 0 as they don’t have any love icons. If they had only 1 Love icon, it’d be 5 points for them!&lt;br /&gt;
&lt;br /&gt;
🎵 (A: 3, B: 3, C: 3, D: 1): Alex, Bonnie and Charlie score 20 points. Doruk doesn’t score.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Most points win. Money breaks ties.&lt;/div&gt;</summary>
		<author><name>Fenadoruk</name></author>
	</entry>
	<entry>
		<id>https://en.doc.boardgamearena.com/index.php?title=Gamehelpauctionland&amp;diff=21490</id>
		<title>Gamehelpauctionland</title>
		<link rel="alternate" type="text/html" href="https://en.doc.boardgamearena.com/index.php?title=Gamehelpauctionland&amp;diff=21490"/>
		<updated>2024-06-10T09:04:42Z</updated>

		<summary type="html">&lt;p&gt;Fenadoruk: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
Build and auction tiles to create the most impressive paradise island!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Setup&#039;&#039;&#039; [BGA handles this for you, feel free to skip this part]:&lt;br /&gt;
&lt;br /&gt;
Each player grabs a screen and some money. The player who last visited a new island starts the game and takes the gavel! Starting money is distributed as follows:&lt;br /&gt;
&lt;br /&gt;
- 1st player: $10&lt;br /&gt;
&lt;br /&gt;
- 2nd player: $12&lt;br /&gt;
&lt;br /&gt;
- 3rd player: $14&lt;br /&gt;
&lt;br /&gt;
- 4th player: $16&lt;br /&gt;
&lt;br /&gt;
- 5th player: $18&lt;br /&gt;
&lt;br /&gt;
- 6th player: $20&lt;br /&gt;
&lt;br /&gt;
Place money behind your screen. You can enable &#039;&#039;&#039;visible money&#039;&#039;&#039; in the game settings.&lt;br /&gt;
&lt;br /&gt;
Create a stack of tiles and deal 8 tiles (or the market size set in game settings) into the middle to form the market. Sort them by the number of icons (Peace, Love &amp;amp; Music), with more icons closer to the stack.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Turn summary:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Build Tile&#039;&#039;&#039;: Select a tile from the market to add to your island. &lt;br /&gt;
# &#039;&#039;&#039;Auction Tile&#039;&#039;&#039;: After building, select another tile and auction it off.&lt;br /&gt;
# &#039;&#039;&#039;End turn&#039;&#039;&#039;: Pass the gavel to the player on your left. It’s now their turn. Refresh the market back to 8 tiles (or the market size set in game settings) but don&#039;t sort them.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The Market:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Whenever you take a tile from the market (for building, auctioning, or Bonus), place $1 on each skipped tile starting from the free tile. Earn the money on the selected tile and place it behind your screen.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Building Tiles:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
New tiles placed after your first must share an edge with an existing tile on your island. You can expand your island in any direction as long as it doesn’t go beyond 4x4.&lt;br /&gt;
&lt;br /&gt;
Placing the 4th tile in a row or column earns you a Bonus tile (see Bonus Tiles).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Auctioning Tiles:&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
After building your tile, select a new tile following &#039;&#039;&#039;the market&#039;&#039;&#039; rules and put it on auction! It’s an open auction carried out simultaneously. Players can increase bids -even their own- any time as long as you have enough money to pay for it. The auction phase is over once all but one player has passed.&lt;br /&gt;
&lt;br /&gt;
In a 2-player game, the bidding player makes only 1 bid which concludes the auction phase.&lt;br /&gt;
&lt;br /&gt;
In the rare case that no one bids, the auctioneer takes the tile for free.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Buy back:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Once the auction phase is over, the auctioneer can either:&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Sell&#039;&#039;&#039; the auctioned tile to the highest bidder.&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Buy back&#039;&#039;&#039; the tile by paying the winning bid plus $1 to the highest bidder. i.e. Alex won the auction phase with a bid of $3, the auctioneer can pay $4 to Alex and build the tile.&lt;br /&gt;
&lt;br /&gt;
The auctioneer can still buy back even if their island is full. In that case, the auctioned tile is returned to the game box.&lt;br /&gt;
&lt;br /&gt;
Make sure you are not bidding so little that the auctioneer buys it back from you. Or maybe you want them to! After all, you&#039;re being paid without losing anything!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Bonus Tiles:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
After adding a tile to your island in &#039;&#039;&#039;any&#039;&#039;&#039; phase or for &#039;&#039;&#039;any&#039;&#039;&#039; reason, check whether it was the 4th tile of a row or column. If so, you immediately earn a Bonus tile!&lt;br /&gt;
&lt;br /&gt;
Draw a new tile following &#039;&#039;&#039;the market rules&#039;&#039;&#039; and build it by following the &#039;&#039;&#039;building tiles&#039;&#039;&#039; rules. Each player can earn only 1 Bonus tile per turn. In other words, a Bonus tile cannot trigger another Bonus, but more than 1 player can draw a Bonus tile on a single turn.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Game End:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Once a player has filled their 4x4 island, the game will be over at the end of that turn. This means you still proceed to the &#039;&#039;&#039;auction phase&#039;&#039;&#039; if you haven’t already done so.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;SCORING&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Beaches:&#039;&#039;&#039; Imagine the table is the ocean! Count tiles with a beach zone touching the edge of your island. Score points based on the scoring table found in the game’s tooltips. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If a beach is not on the edge but still adjacent to a gap (because your 4x4 island wasn’t filled up) it still scores. The table is the ocean and it’s a wonderful facing the water!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Theme Parks:&#039;&#039;&#039; Count tiles in your largest contiguous theme park area (diagonal connections don’t count). Score points based on the scoring table found in the game’s tooltips. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Gardens &amp;amp; Houses:&#039;&#039;&#039; Multiply the number of garden areas by the number of house areas. Adjacent zones of the same type count as one area; so keep gardens separate from other gardens and likewise for the houses. &#039;&#039;&#039;It’s fine if a garden is touching a house.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Icons:&#039;&#039;&#039; The positions of the icons don’t matter. Each icon type scores separately. The player with the highest number of an icon type scores 20 points, 2nd player scores 10 and 3rd player scores 5. Ties are friendly; all tying players score the same amount of points but you skip the next number for each tying player.&lt;br /&gt;
&lt;br /&gt;
You must have at least 1 icon of the type to score points from it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039; Alex has 2 ☮️, 2 ❤️, 3 🎵. Bonnie has 3 ☮️, 2 ❤️, 3 🎵. Charlie has 3 ☮️and 3 🎵. Doruk has only 1 🎵.&lt;br /&gt;
&lt;br /&gt;
☮️ (A: 2, B: 3, C: 3, D: 0): Alex scores 5 points. Bonnie and Charlie score 20 each.&lt;br /&gt;
&lt;br /&gt;
❤️ (A: 2, B: 2, C: 0, D: 0): Alex and Bonnie score 20 points. Charlie scores 0 as they don’t have any love icons. If they had only 1 Love icon, it’d be 5 points for them!&lt;br /&gt;
&lt;br /&gt;
🎵 (A: 3, B: 3, C: 3, D: 1): Alex, Bonnie and Charlie score 20 points. Doruk doesn’t score.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Most points win. Money breaks ties.&lt;/div&gt;</summary>
		<author><name>Fenadoruk</name></author>
	</entry>
	<entry>
		<id>https://en.doc.boardgamearena.com/index.php?title=Gamehelpauctionland&amp;diff=21489</id>
		<title>Gamehelpauctionland</title>
		<link rel="alternate" type="text/html" href="https://en.doc.boardgamearena.com/index.php?title=Gamehelpauctionland&amp;diff=21489"/>
		<updated>2024-06-10T09:02:08Z</updated>

		<summary type="html">&lt;p&gt;Fenadoruk: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
Build and auction tiles to create the most impressive paradise island!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Setup&#039;&#039;&#039; [BGA handles this for you, feel free to skip this part]:&lt;br /&gt;
&lt;br /&gt;
Each player grabs a screen and some money. The player who last visited a new island starts the game and takes the gavel! Starting money is distributed as follows:&lt;br /&gt;
&lt;br /&gt;
- 1st player: $10&lt;br /&gt;
&lt;br /&gt;
- 2nd player: $12&lt;br /&gt;
&lt;br /&gt;
- 3rd player: $14&lt;br /&gt;
&lt;br /&gt;
- 4th player: $16&lt;br /&gt;
&lt;br /&gt;
- 5th player: $18&lt;br /&gt;
&lt;br /&gt;
- 6th player: $20&lt;br /&gt;
&lt;br /&gt;
Place money behind your screen. You can enable &#039;&#039;&#039;visible money&#039;&#039;&#039; in the game settings.&lt;br /&gt;
&lt;br /&gt;
Create a stack of tiles and deal 8 tiles (or the market size set in game settings) into the middle to form the market. Sort them by the number of icons (Peace, Love &amp;amp; Music), with more icons closer to the stack.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Turn summary:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Build Tile&#039;&#039;&#039;: Select a tile from the market to add to your island. &lt;br /&gt;
# &#039;&#039;&#039;Auction Tile&#039;&#039;&#039;: After building, select another tile and auction it off.&lt;br /&gt;
# &#039;&#039;&#039;End turn&#039;&#039;&#039;: Pass the gavel to the player on your left. It’s now their turn. Refresh the market back to 8 tiles (or the market size set in game settings), don&#039;t sort them by icons.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The Market:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Whenever you take a tile from the market (for building, auctioning, or Bonus), place $1 on each skipped tile starting from the free tile. Earn the money on the selected tile and place it behind your screen.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Building Tiles:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
New tiles placed after your first must share an edge with an existing tile on your island. You can expand your island in any direction as long as it doesn’t go beyond 4x4.&lt;br /&gt;
&lt;br /&gt;
Placing the 4th tile in a row or column earns you a Bonus tile (see Bonus Tiles).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Auctioning Tiles:&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
After building your tile, select a new tile following &#039;&#039;&#039;the market&#039;&#039;&#039; rules and put it on auction! It’s an open auction carried out simultaneously. Players can increase bids -even their own- any time as long as you have enough money to pay for it. The auction phase is over once all but one player has passed.&lt;br /&gt;
&lt;br /&gt;
In a 2-player game, the bidding player makes only 1 bid which concludes the auction phase.&lt;br /&gt;
&lt;br /&gt;
In the rare case that no one bids, the auctioneer takes the tile for free.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Buy back:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Once the auction phase is over, the auctioneer can either:&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Sell&#039;&#039;&#039; the auctioned tile to the highest bidder.&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Buy back&#039;&#039;&#039; the tile by paying the winning bid plus $1 to the highest bidder. i.e. Alex won the auction phase with a bid of $3, the auctioneer can pay $4 to Alex and build the tile.&lt;br /&gt;
&lt;br /&gt;
The auctioneer can still buy back even if their island is full. In that case, the auctioned tile is returned to the game box.&lt;br /&gt;
&lt;br /&gt;
Make sure you are not bidding so little that the auctioneer buys it back from you. Or maybe you want them to! After all, you&#039;re being paid without losing anything!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Bonus Tiles:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
After adding a tile to your island in &#039;&#039;&#039;any&#039;&#039;&#039; phase or for &#039;&#039;&#039;any&#039;&#039;&#039; reason, check whether it was the 4th tile of a row or column. If so, you immediately earn a Bonus tile!&lt;br /&gt;
&lt;br /&gt;
Draw a new tile following &#039;&#039;&#039;the market rules&#039;&#039;&#039; and build it by following the &#039;&#039;&#039;building tiles&#039;&#039;&#039; rules. Each player can earn only 1 Bonus tile per turn. In other words, a Bonus tile cannot trigger another Bonus, but more than 1 player can draw a Bonus tile on a single turn.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Game End:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Once a player has filled their 4x4 island, the game will be over at the end of that turn. This means you still proceed to the &#039;&#039;&#039;auction phase&#039;&#039;&#039; if you haven’t already done so.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;SCORING&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Beaches:&#039;&#039;&#039; Imagine the table is the ocean! Count tiles with a beach zone touching the edge of your island. Score points based on the scoring table found in the game’s tooltips. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If a beach is not on the edge but still adjacent to a gap (because your 4x4 island wasn’t filled up) it still scores. The table is the ocean and it’s a wonderful beach by the water!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Theme Parks:&#039;&#039;&#039; Count tiles in your largest contiguous theme park area (diagonal connections don’t count). Score points based on the scoring table found in the game’s tooltips. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Gardens &amp;amp; Houses:&#039;&#039;&#039; Multiply the number of garden areas by the number of house areas. Adjacent zones of the same type count as one area; so keep gardens separate from other gardens and likewise for the houses. &#039;&#039;&#039;It’s fine if a garden is touching a house.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Icons:&#039;&#039;&#039; The positions of the icons don’t matter. Each icon type scores separately. The player with the highest number of an icon type scores 20 points, 2nd player scores 10 and 3rd player scores 5. Ties are friendly; all tying players score the same amount of points but you skip the next number for each tying player.&lt;br /&gt;
&lt;br /&gt;
You must have at least 1 icon of the type to score points from it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039; Alex has 2 ☮️, 2 ❤️, 3 🎵. Bonnie has 3 ☮️, 2 ❤️, 3 🎵. Charlie has 3 ☮️and 3 🎵. Doruk has only 1 🎵.&lt;br /&gt;
&lt;br /&gt;
☮️ (A: 2, B: 3, C: 3, D: 0): Alex scores 5 points. Bonnie and Charlie score 20 each.&lt;br /&gt;
&lt;br /&gt;
❤️ (A: 2, B: 2, C: 0, D: 0): Alex and Bonnie score 20 points. Charlie scores 0 as they don’t have any love icons. If they had only 1 Love icon, it’d be 5 points for them!&lt;br /&gt;
&lt;br /&gt;
🎵 (A: 3, B: 3, C: 3, D: 1): Alex, Bonnie and Charlie score 20 points. Doruk doesn’t score.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Most points win. Money breaks ties.&lt;/div&gt;</summary>
		<author><name>Fenadoruk</name></author>
	</entry>
	<entry>
		<id>https://en.doc.boardgamearena.com/index.php?title=Gamehelpauctionland&amp;diff=21488</id>
		<title>Gamehelpauctionland</title>
		<link rel="alternate" type="text/html" href="https://en.doc.boardgamearena.com/index.php?title=Gamehelpauctionland&amp;diff=21488"/>
		<updated>2024-06-10T08:58:20Z</updated>

		<summary type="html">&lt;p&gt;Fenadoruk: Minor updates to the rules&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
Build and auction tiles to create the most impressive paradise island!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Setup&#039;&#039;&#039; [BGA handles this for you, feel free to skip this part]:&lt;br /&gt;
&lt;br /&gt;
Each player grabs a screen and some money. The player who last visited a new island starts the game and takes the gavel! Starting money is distributed as follows:&lt;br /&gt;
&lt;br /&gt;
- 1st player: $10&lt;br /&gt;
&lt;br /&gt;
- 2nd player: $12&lt;br /&gt;
&lt;br /&gt;
- 3rd player: $14&lt;br /&gt;
&lt;br /&gt;
- 4th player: $16&lt;br /&gt;
&lt;br /&gt;
- 5th player: $18&lt;br /&gt;
&lt;br /&gt;
- 6th player: $20&lt;br /&gt;
&lt;br /&gt;
Place money behind your screen. You can enable &#039;&#039;&#039;visible money&#039;&#039;&#039; in the game settings.&lt;br /&gt;
&lt;br /&gt;
Create a stack of tiles and deal 8 tiles (or the number set in game settings) into the middle to form the market. Sort them by the number of icons (Peace, Love &amp;amp; Music), with more icons closer to the stack.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Turn summary:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Build Tile&#039;&#039;&#039;: Select a tile from the market to add to your island. &lt;br /&gt;
# &#039;&#039;&#039;Auction Tile&#039;&#039;&#039;: After building, select another tile and auction it off.&lt;br /&gt;
# &#039;&#039;&#039;End turn&#039;&#039;&#039;: Pass the gavel to the player on your left. It’s now their turn.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The Market:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Whenever you take a tile from the market (for building, auctioning, or Bonus), place $1 on each skipped tile starting from the free tile. Earn the money on the selected tile and place it behind your screen.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Building Tiles:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
New tiles placed after your first must share an edge with an existing tile on your island. You can expand your island in any direction as long as it doesn’t go beyond 4x4.&lt;br /&gt;
&lt;br /&gt;
Placing the 4th tile in a row or column earns you a Bonus tile (see Bonus Tiles).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Auctioning Tiles:&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
After building your tile, select a new tile following &#039;&#039;&#039;the market&#039;&#039;&#039; rules and put it on auction! It’s an open auction carried out simultaneously. Players can increase bids -even their own- any time as long as you have enough money to pay for it. The auction phase is over once all but one player has passed.&lt;br /&gt;
&lt;br /&gt;
In a 2-player game, the bidding player makes only 1 bid which concludes the auction phase.&lt;br /&gt;
&lt;br /&gt;
In the rare case that no one bids, the auctioneer takes the tile for free.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Buy back:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Once the auction phase is over, the auctioneer can either:&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Sell&#039;&#039;&#039; the auctioned tile to the highest bidder.&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Buy back&#039;&#039;&#039; the tile by paying the winning bid plus $1 to the bidder. i.e. Alex won the auction phase with a bid of $3, the auctioneer can pay $4 to Alex and build the tile.&lt;br /&gt;
&lt;br /&gt;
The auctioneer can still buy back even if their island is full. In that case, the auctioned tile is returned to the game box.&lt;br /&gt;
&lt;br /&gt;
Make sure you are not bidding so little that the auctioneer buys it back from you. Or maybe you want them to! After all, you&#039;re being paid without losing anything!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Bonus Tiles:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
After adding a tile to your island in &#039;&#039;&#039;any&#039;&#039;&#039; phase or for &#039;&#039;&#039;any&#039;&#039;&#039; reason, check whether it was the 4th tile of a row or column. If so, you immediately earn a Bonus tile!&lt;br /&gt;
&lt;br /&gt;
Draw a new tile following &#039;&#039;&#039;the market rules&#039;&#039;&#039; and build it by following the &#039;&#039;&#039;building tiles&#039;&#039;&#039; rules. Each player can earn only 1 Bonus tile per turn. In other words, a Bonus tile cannot trigger another Bonus, but more than 1 player can draw a Bonus tile on a single turn.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Game End:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Once a player has filled their 4x4 island, the game will be over at the end of that turn. This means you still proceed to the &#039;&#039;&#039;auction phase&#039;&#039;&#039; if you haven’t already done so.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;SCORING&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Beaches:&#039;&#039;&#039; Imagine the table is the ocean! Count tiles with a beach zone touching the edge of your island. Score points based on the scoring table found in the game’s tooltips. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If a beach is not on the edge but still adjacent to a gap (because your 4x4 island wasn’t filled up) it still scores. The table is the ocean and it’s a wonderful beach by the water!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Theme Parks:&#039;&#039;&#039; Count tiles in your largest contiguous theme park area (diagonal connections don’t count). Score points based on the scoring table found in the game’s tooltips. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Gardens &amp;amp; Houses:&#039;&#039;&#039; Multiply the number of garden areas by the number of house areas. Adjacent zones of the same type count as one area; so keep gardens separate from other gardens and likewise for the houses. &#039;&#039;&#039;It’s fine if a garden is touching a house.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
• &#039;&#039;&#039;Icons:&#039;&#039;&#039; The positions of the icons don’t matter. Each icon type scores separately. The player with the highest number of an icon type scores 20 points, 2nd player scores 10 and 3rd player scores 5. Ties are friendly; all tying players score the same amount of points but you skip the next number for each tying player.&lt;br /&gt;
&lt;br /&gt;
You must have at least 1 icon of the type to score points from it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example:&#039;&#039;&#039; Alex has 2 ☮️, 2 ❤️, 3 🎵. Bonnie has 3 ☮️, 2 ❤️, 3 🎵. Charlie has 3 ☮️and 3 🎵. Doruk has only 1 🎵.&lt;br /&gt;
&lt;br /&gt;
☮️ (A: 2, B: 3, C: 3, D: 0): Alex scores 5 points. Bonnie and Charlie score 20 each.&lt;br /&gt;
&lt;br /&gt;
❤️ (A: 2, B: 2, C: 0, D: 0): Alex and Bonnie score 20 points. Charlie scores 0 as they don’t have any love icons. If they had only 1 Love icon, it’d be 5 points for them!&lt;br /&gt;
&lt;br /&gt;
🎵 (A: 3, B: 3, C: 3, D: 1): Alex, Bonnie and Charlie score 20 points. Doruk doesn’t score.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Most points win. Money breaks ties.&lt;/div&gt;</summary>
		<author><name>Fenadoruk</name></author>
	</entry>
	<entry>
		<id>https://en.doc.boardgamearena.com/index.php?title=Gamehelpauctionland&amp;diff=21487</id>
		<title>Gamehelpauctionland</title>
		<link rel="alternate" type="text/html" href="https://en.doc.boardgamearena.com/index.php?title=Gamehelpauctionland&amp;diff=21487"/>
		<updated>2024-06-10T08:47:25Z</updated>

		<summary type="html">&lt;p&gt;Fenadoruk: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
Build and auction tiles to create the most impressive paradise island!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Setup&#039;&#039;&#039; [BGA handles this for you, feel free to skip this part]:&lt;br /&gt;
&lt;br /&gt;
Each player grabs a screen and some money. The player who last visited a new island starts the game and takes the gavel! Starting money is distributed as follows:&lt;br /&gt;
&lt;br /&gt;
- 1st player: $10&lt;br /&gt;
&lt;br /&gt;
- 2nd player: $12&lt;br /&gt;
&lt;br /&gt;
- 3rd player: $14&lt;br /&gt;
&lt;br /&gt;
- 4th player: $16&lt;br /&gt;
&lt;br /&gt;
- 5th player: $18&lt;br /&gt;
&lt;br /&gt;
- 6th player: $20&lt;br /&gt;
&lt;br /&gt;
Place money behind your screen. You can enable &#039;&#039;&#039;visible money&#039;&#039;&#039; in the game settings.&lt;br /&gt;
&lt;br /&gt;
Create a stack of tiles and deal 8 tiles (or the number set in game settings) into the middle to form the market. Sort them by the number of icons (Peace, Love &amp;amp; Music), with more icons closer to the stack.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Turn summary:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Build Tile&#039;&#039;&#039;: Select a tile from the market to add to your island. &lt;br /&gt;
# &#039;&#039;&#039;Auction Tile&#039;&#039;&#039;: After building, select another tile and auction it off.&lt;br /&gt;
# &#039;&#039;&#039;End turn&#039;&#039;&#039;: Pass the gavel to the player on your left. It’s now their turn.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The Market:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Whenever you take a tile from the market (for building, auctioning, or Bonus), place $1 on each skipped tile starting from the free tile. Earn the money on the selected tile and place it behind your screen.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Building Tiles:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
New tiles placed after your first must share an edge with an existing tile on your island. You can expand your island in any direction as long as it doesn’t go beyond 4x4.&lt;br /&gt;
&lt;br /&gt;
Placing the 4th tile in a row or column earns you a Bonus tile (see Bonus Tiles).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Auctioning Tiles:&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
After building your tile, select a new tile following &#039;&#039;&#039;the market&#039;&#039;&#039; rules and put it on auction! It’s an open auction carried out simultaneously. Players can increase bids -even their own- any time as long as you have enough money to pay for it. The auction phase is over once all but one player has passed.&lt;br /&gt;
&lt;br /&gt;
In a 2-player game, the bidding player makes only 1 bid which concludes the auction phase.&lt;br /&gt;
&lt;br /&gt;
In the rare case that no one bids, the auctioneer takes the tile for free.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Buy back:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Once the auction phase is over, the auctioneer can either:&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Sell&#039;&#039;&#039; the auctioned tile to the highest bidder.&lt;br /&gt;
# &#039;&#039;&#039;Buy back&#039;&#039;&#039; the tile by paying the winning bid plus $1 to the bidder. i.e. Alex won the auction phase with a bid of $3, the auctioneer can pay $4 to Alex and build the tile.&lt;br /&gt;
&lt;br /&gt;
The auctioneer can still buy back even if their island is full. In that case, the auctioned tile is returned to the game box.&lt;br /&gt;
&lt;br /&gt;
Make sure you are not bidding so little that the auctioneer buys it back from you. Or maybe you want them to! After all, you&#039;re being paid without losing anything!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Bonus Tiles:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
After adding a tile to your island in &#039;&#039;&#039;any&#039;&#039;&#039; phase or for &#039;&#039;&#039;any&#039;&#039;&#039; reason, check whether it was the 4th tile of a row or column. If so, you immediately earn a Bonus tile!&lt;br /&gt;
&lt;br /&gt;
Draw a new tile following &#039;&#039;&#039;the market rules&#039;&#039;&#039; and build it by following the &#039;&#039;&#039;building tiles&#039;&#039;&#039; rules. Each player can earn only 1 Bonus tile per turn. In other words, a Bonus tile cannot trigger another Bonus, but more than 1 player can draw a Bonus tile on a single turn.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Game End:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Once a player has filled their 4x4 island, the game will be over at the end of that turn. This means you still proceed to the &#039;&#039;&#039;auction phase&#039;&#039;&#039; if you haven’t already done so.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;SCORING&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Beaches:&#039;&#039;&#039; Imagine the table is the ocean! Count tiles with a beach zone touching the edge of your island. Score points based on the scoring table found in the game’s tooltips. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If a beach is not on the edge but still adjacent to a gap (because your 4x4 island wasn’t filled up) it still scores. The table is the ocean and it’s a wonderful beach by the water!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Theme Parks:&#039;&#039;&#039; Count tiles in your largest contiguous theme park area (diagonal connections don’t count). Score points based on the scoring table found in the game’s tooltips. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Gardens &amp;amp; Houses:&#039;&#039;&#039; Multiply the number of garden areas by the number of house areas. Adjacent zones of the same type count as one area; so keep gardens separate from other gardens and likewise for the houses. &#039;&#039;&#039;It’s fine if a garden is touching a house.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Icons:&#039;&#039;&#039; The positions of the icons don’t matter. Each icon type scores separately. The player with the highest number of an icon type scores 20 points, 2nd player scores 10 and 3rd player scores 5. Ties are friendly; all tying players score the same amount of points but you skip the next number for each tying player.&lt;br /&gt;
&lt;br /&gt;
You must have at least 1 icon of the type to score points from it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example: Alex has 2 ☮️, 2 ❤️, 3 🎵. Bonnie has 3 ☮️, 2 ❤️, 3 🎵. Charlie has 3 ☮️and 3 🎵. Doruk has only 1 🎵.&lt;br /&gt;
&lt;br /&gt;
☮️ (A: 2, B: 3, C: 3, D: 0): Alex scores 5 points. Bonnie and Charlie score 20 each.&lt;br /&gt;
&lt;br /&gt;
❤️ (A: 2, B: 2, C: 0, D: 0): Alex and Bonnie score 20 points. Charlie scores 0 as they don’t have any love icons. If they had only 1 Love icon, it’d be 5 points for them!&lt;br /&gt;
&lt;br /&gt;
🎵 (A: 3, B: 3, C: 3, D: 1): Alex, Bonnie and Charlie score 20 points. Doruk doesn’t score.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Most points win. Money breaks ties.&lt;/div&gt;</summary>
		<author><name>Fenadoruk</name></author>
	</entry>
	<entry>
		<id>https://en.doc.boardgamearena.com/index.php?title=Gamehelpauctionland&amp;diff=21482</id>
		<title>Gamehelpauctionland</title>
		<link rel="alternate" type="text/html" href="https://en.doc.boardgamearena.com/index.php?title=Gamehelpauctionland&amp;diff=21482"/>
		<updated>2024-06-09T20:59:18Z</updated>

		<summary type="html">&lt;p&gt;Fenadoruk: Rules updated by Doruk Kicikoglu (game designer and BGA developer)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
Build and auction tiles to create the most impressive paradise island!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Setup&#039;&#039;&#039; [BGA handles this for you, feel free to skip this part]:&lt;br /&gt;
&lt;br /&gt;
Each player grabs a screen and some money. The player who last visited a new island starts the game and takes the gavel! Starting money is distributed as follows:&lt;br /&gt;
&lt;br /&gt;
- 1st player: $10&lt;br /&gt;
&lt;br /&gt;
- 2nd player: $12&lt;br /&gt;
&lt;br /&gt;
- 3rd player: $14&lt;br /&gt;
&lt;br /&gt;
- 4th player: $16&lt;br /&gt;
&lt;br /&gt;
- 5th player: $18&lt;br /&gt;
&lt;br /&gt;
- 6th player: $20&lt;br /&gt;
&lt;br /&gt;
Place money behind your screen. You can enable &#039;&#039;&#039;visible money&#039;&#039;&#039; in the game settings.&lt;br /&gt;
&lt;br /&gt;
Create a stack of tiles and deal 8 tiles (or the number set in game settings) into the middle to form the market. Sort them by the number of icons (Peace, Love &amp;amp; Music), with more icons closer to the stack.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Turn summary:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Build Tile&#039;&#039;&#039;: Select a tile from the market to add to your island. &lt;br /&gt;
# &#039;&#039;&#039;Auction Tile&#039;&#039;&#039;: After building, select another tile and auction it off.&lt;br /&gt;
# &#039;&#039;&#039;End turn&#039;&#039;&#039;: Pass the gavel to the player on your left. It’s now their turn.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The Market:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Whenever you take a tile from the market (for building, auctioning, or Bonus), place $1 on each skipped tile starting from the free tile. Earn the money on the selected tile and place it behind your screen.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Building Tiles:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
New tiles placed after your first must share an edge with an existing tile on your island. You can expand your island in any direction as long as it doesn’t go beyond 4x4.&lt;br /&gt;
&lt;br /&gt;
Placing the 4th tile in a row or column earns you a Bonus tile (see Bonus Tiles).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Auctioning Tiles:&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
After building your tile, select a new tile following &#039;&#039;&#039;the market&#039;&#039;&#039; rules and put it on auction! It’s an open auction carried out simultaneously. Players can increase bids -even their own- any time as long as you have enough money to pay for it. The auction phase is over once all but one player has passed.&lt;br /&gt;
&lt;br /&gt;
In a 2-player game, the bidding player makes only 1 bid which concludes the auction phase.&lt;br /&gt;
&lt;br /&gt;
In the rare case that no one bids, the auctioneer takes the tile for free.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Buy back:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Once the auction phase is over, the auctioneer can either:&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Sell&#039;&#039;&#039; the auctioned tile to the highest bidder.&lt;br /&gt;
# &#039;&#039;&#039;Buy back&#039;&#039;&#039; the tile by paying the winning bid plus $1 to the bidder. i.e. Alex won the auction phase with a bid of $3, the auctioneer can pay $4 to Alex and build the tile.&lt;br /&gt;
&lt;br /&gt;
The auctioneer can still buy back even if their island is full. In that case, the auctioned tile is returned to the game box.&lt;br /&gt;
&lt;br /&gt;
Make sure you are not bidding so little that the auctioneer buys it back from you. Or maybe you want them to! After all, you&#039;re being paid without losing anything!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Bonus Tiles:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
After adding a tile to your island in &#039;&#039;&#039;any&#039;&#039;&#039; phase or for &#039;&#039;&#039;any&#039;&#039;&#039; reason, check whether it was the 4th tile of a row or column. If so, you immediately earn a Bonus tile!&lt;br /&gt;
&lt;br /&gt;
Draw a new tile following &#039;&#039;&#039;the market rules&#039;&#039;&#039; and build it by following the &#039;&#039;&#039;building tiles&#039;&#039;&#039; rules. Each player can earn only 1 Bonus tile per turn. In other words, a Bonus tile cannot trigger another Bonus, but more than 1 player can draw a Bonus tile on a single turn.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Game End:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Once a player has filled their 4x4 island, the game will be over at the end of that turn. This means you still proceed to the &#039;&#039;&#039;auction phase&#039;&#039;&#039; if you haven’t already done so.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;SCORING&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Beaches:&#039;&#039;&#039; Imagine the table is the ocean! Count tiles with a beach zone touching the edge of your island. Score points based on the scoring table found in the game’s tooltips. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If a beach is not on the edge but still adjacent to a gap (because your 4x4 island wasn’t filled up) it still scores. The table is the ocean and it’s a wonderful beach by the water!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Theme Parks:&#039;&#039;&#039; Count tiles in your largest contiguous theme park area (diagonal connections don’t count). Score points based on the scoring table found in the game’s tooltips. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Gardens &amp;amp; Houses:&#039;&#039;&#039; Multiply the number of garden areas by the number of house areas. Adjacent zones of the same type count as one area; so keep gardens separate from other gardens and likewise for the houses. &#039;&#039;&#039;It’s fine if a garden is touching a house.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Icons:&#039;&#039;&#039; The positions of the icons don’t matter. Each icon type scores separately. The player with the highest number of an icon type scores 20 points, 2nd player scores 10 and 3rd player scores 5. Ties are friendly; all tying players score the same amount of points but you skip the next number for each tying player.&lt;br /&gt;
&lt;br /&gt;
You must have at least 1 icon of the type to score points from it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example: Alex has 2 ☮️, 2 ❤️, 3 🎵. Bonnie-Beth has 3 ☮️, 2 ❤️, 3 🎵. Charlie has 3 ☮️and 3 🎵. Doruk has only 1 🎵.&lt;br /&gt;
&lt;br /&gt;
☮️ (A: 2, B: 3, C: 3, D: 0): Alex scores 5 points. Bonnie-Beth and Charlie score 20 each.&lt;br /&gt;
&lt;br /&gt;
❤️ (A: 2, B: 2, C: 0, D: 0): Alex and Bonnie-Beth score 20 points. Charlie scores 0 as they don’t have any love icons. If they had only 1 Love icon, it’d be 5 points for them!&lt;br /&gt;
&lt;br /&gt;
🎵 (A: 3, B: 3, C: 3, D: 1): Alex, Bonnie-beth and Charlie score 20 points. Doruk doesn’t score.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Most points win. Money breaks ties.&lt;/div&gt;</summary>
		<author><name>Fenadoruk</name></author>
	</entry>
	<entry>
		<id>https://en.doc.boardgamearena.com/index.php?title=Main_game_logic:_Game.php&amp;diff=20054</id>
		<title>Main game logic: Game.php</title>
		<link rel="alternate" type="text/html" href="https://en.doc.boardgamearena.com/index.php?title=Main_game_logic:_Game.php&amp;diff=20054"/>
		<updated>2024-02-16T12:29:07Z</updated>

		<summary type="html">&lt;p&gt;Fenadoruk: /* Multiple activate player handling */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Studio_Framework_Navigation}}&lt;br /&gt;
&lt;br /&gt;
This is the main file for your game logic. Here you initialize the game, persist data, implement the rules and notify the client interface of changes.&lt;br /&gt;
&lt;br /&gt;
This is the main  class that implements the &amp;quot;server&amp;quot; callbacks. As it is a server it cannot initiate any data communicate with the game client (running in browser) and only can respond to client using notifications.&lt;br /&gt;
&lt;br /&gt;
Your php class instance won&#039;t be in memory between two callbacks, every time client send a request a new class will be created, constructor will be called and eventually your callback function.&lt;br /&gt;
&lt;br /&gt;
== File Structure ==&lt;br /&gt;
&lt;br /&gt;
The details of how the file is structured are described directly with comments in the code skeleton provided to you.&lt;br /&gt;
 &lt;br /&gt;
Here is the basic structure:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;__construct&#039;&#039;&#039;: the game constructor, where you define global variables and initiaze class members.&lt;br /&gt;
* &#039;&#039;&#039;setupNewGame&#039;&#039;&#039;: initial setup of the game. Takes an array of players, indexed by player_id. Structure of each player includes player_name, player_canal, player_avatar, and flags indicating admin/ai/premium/order/language/beginner.&lt;br /&gt;
* &#039;&#039;&#039;getAllDatas&#039;&#039;&#039;: where you retrieve all game data during a complete reload of the game. Return value must be associative array. Value of &#039;players&#039; is reserved for returning players data from players table, if you set it it must follow certain rules &lt;br /&gt;
        $result [&#039;players&#039;] = self::getCollectionFromDb(&amp;quot;SELECT player_id id, player_score score, player_no no, player_color color FROM player&amp;quot;);&lt;br /&gt;
        // Returned value must include [&#039;players&#039;][$player_id]][&#039;score&#039;] for scores to populate when F5 is pressed.&lt;br /&gt;
* &#039;&#039;&#039;getGameProgression&#039;&#039;&#039;: where you compute the game progression indicator. Returns a number indicating percent of progression (0-100). Used to calculate ELO changes of remaining players when a player quits, or as a conceding requirement (in non-tournament 2 player games, a player may concede if the progression is at least 50%).&lt;br /&gt;
* Utility functions: your utility functions.&lt;br /&gt;
* Player actions: the entry points for players actions ([https://en.doc.boardgamearena.com/Players_actions:_yourgamename.action.php more info here]). &lt;br /&gt;
* Game state arguments: methods to return additional data on specific game states ([http://en.doc.boardgamearena.com/Your_game_state_machine:_states.inc.php#args more info here]).&lt;br /&gt;
* Game state actions: the logic to run when entering a new game state ([http://en.doc.boardgamearena.com/Your_game_state_machine:_states.inc.php#action more info here]).&lt;br /&gt;
* &#039;&#039;&#039;initTable&#039;&#039;&#039;: (not part of template) - this function is called for every php callback by the framework and it can be implement by the game (empty by default). You can use it in rare cases where you need to read database and manipulate some data before any ANY php entry functions are called (such as getAllDatas,action*,st*, etc). Note: it is not called before arg* methods &lt;br /&gt;
* &#039;&#039;&#039;zombieTurn&#039;&#039;&#039;: what to do it&#039;s the turn of a zombie player.&lt;br /&gt;
* &#039;&#039;&#039;upgradeTableDb&#039;&#039;&#039;: function to migrate database if you change it after release on production.&lt;br /&gt;
* &#039;&#039;&#039;getGameName&#039;&#039;&#039;: returns the game name. This will be setup when you create the project. If you are copying files in from another project, make sure you keep this function intact. It must return the right game name, or lots of things will be broken.&lt;br /&gt;
&lt;br /&gt;
== Accessing player information ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Important&#039;&#039;&#039;: In the following methods, be mindful of the difference between the &amp;quot;active&amp;quot; player and the &amp;quot;current&amp;quot; player. The &#039;&#039;&#039;active&#039;&#039;&#039; player is the player whose turn it is - not necessarily the player who sent a request! The &#039;&#039;&#039;current&#039;&#039;&#039; player is the player who sent the request and will see the results returned by your methods: not necessarily the player whose turn it is!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; getPlayersNumber()&lt;br /&gt;
: Returns the number of players playing at the table&lt;br /&gt;
: Note: doesn&#039;t work in the beggining of setupNewGame (use count($players) instead). It will work after initialization of player table.&lt;br /&gt;
&lt;br /&gt;
; getActivePlayerId()&lt;br /&gt;
: Get the &amp;quot;active_player&amp;quot;, whatever what is the current state type.&lt;br /&gt;
: Note: it does NOT mean that this player is active right now, because state type could be &amp;quot;game&amp;quot; or &amp;quot;multiplayer&amp;quot;&lt;br /&gt;
: Note: avoid using this method in a &amp;quot;multiplayer&amp;quot; state because it does not mean anything.&lt;br /&gt;
&lt;br /&gt;
; getActivePlayerName()&lt;br /&gt;
: Get the &amp;quot;active_player&amp;quot; name&lt;br /&gt;
: Note: avoid using this method in a &amp;quot;multiplayer&amp;quot; state because it does not mean anything.&lt;br /&gt;
&lt;br /&gt;
; getPlayerNameById($player_id)&lt;br /&gt;
: Get the name by id&lt;br /&gt;
&lt;br /&gt;
; getPlayerColorById($player_id)&lt;br /&gt;
: Get the color by id&lt;br /&gt;
&lt;br /&gt;
; getPlayerNoById($player_id)&lt;br /&gt;
: Get &#039;player_no&#039; (number) by id&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; loadPlayersBasicInfos()&lt;br /&gt;
: Get an associative array with generic data about players (ie: not game specific data).&lt;br /&gt;
: The key of the associative array is the player id. The returned table is cached, so ok to call multiple times without performance concerns.&lt;br /&gt;
: The content of each value is:&lt;br /&gt;
: * player_name - the name of the player&lt;br /&gt;
: * player_color (ex: ff0000) - the color code of the player (as string)&lt;br /&gt;
: * player_no - the position of the player at the start of the game in natural table order, i.e. 1,2,3&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
                $players = $this-&amp;gt;loadPlayersBasicInfos();&lt;br /&gt;
                foreach ($players as $player_id =&amp;gt; $info) {&lt;br /&gt;
                    $player_color = $info[&#039;player_color&#039;];&lt;br /&gt;
                    ...&lt;br /&gt;
                }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Note: if you want array of player ids only you can do this:&lt;br /&gt;
    $player_ids =  array_keys($this-&amp;gt;loadPlayersBasicInfos());  &lt;br /&gt;
&lt;br /&gt;
; getCurrentPlayerId(bool $bReturnNullIfNotLogged = false) int&lt;br /&gt;
: Get the &amp;quot;current_player&amp;quot;. The current player is the one from which the action originated (the one who sent the request).&lt;br /&gt;
: &#039;&#039;&#039;Be careful&#039;&#039;&#039;: This is not necessarily the active player!&lt;br /&gt;
: In general, you shouldn&#039;t use this method, unless you are in &amp;quot;multiplayer&amp;quot; state.&lt;br /&gt;
: &#039;&#039;&#039;Very important&#039;&#039;&#039;: in your setupNewGame and zombieTurn function, you must never use getCurrentPlayerId() or getCurrentPlayerName(), &lt;br /&gt;
: otherwise it will fail with a &amp;quot;Not logged&amp;quot; error message (these actions are triggered from the main site and propagated to the gameserver from a server, not from a browser. As a consequence, there is no current player associated to these actions).&lt;br /&gt;
&lt;br /&gt;
; getCurrentPlayerName(bool $bReturnEmptyIfNotLogged = false) string&lt;br /&gt;
: Get the &amp;quot;current_player&amp;quot; name. &lt;br /&gt;
: Note: this will throw an exception if current player is not at the table, i.e. spectator&lt;br /&gt;
: Be careful using this method (see above).&lt;br /&gt;
&lt;br /&gt;
; getCurrentPlayerColor()&lt;br /&gt;
: Get the &amp;quot;current_player&amp;quot; color. &lt;br /&gt;
: Note: this will throw an exception if current player is not at the table, i.e. spectator&lt;br /&gt;
: Be careful using this method (see above).&lt;br /&gt;
&lt;br /&gt;
; isCurrentPlayerZombie()&lt;br /&gt;
: Check the &amp;quot;current_player&amp;quot; zombie status. If true, player is zombie, i.e. left or was kicked out of the game.&lt;br /&gt;
: Note: this will throw an exception if current player is not at the table, i.e. spectator&lt;br /&gt;
&lt;br /&gt;
; isSpectator()&lt;br /&gt;
: Check the &amp;quot;current_player&amp;quot; spectator status. If true, the user accessing the game is a spectator (not part of the game). For this user, the interface should display all public information, and no private information (like a friend sitting at the same table as players and just spectating the game).&lt;br /&gt;
&lt;br /&gt;
; getActivePlayerColor()&lt;br /&gt;
: This function does not seems to exist in API, if you need it here is implementation&lt;br /&gt;
      function getActivePlayerColor() {&lt;br /&gt;
        $player_id = self::getActivePlayerId();&lt;br /&gt;
        $players = self::loadPlayersBasicInfos();&lt;br /&gt;
        if (isset($players[$player_id]))&lt;br /&gt;
            return $players[$player_id][&#039;player_color&#039;];&lt;br /&gt;
        else&lt;br /&gt;
            return null;&lt;br /&gt;
    }&lt;br /&gt;
; isPlayerZombie($player_id)&lt;br /&gt;
: This method does not exists, but if you need it it looks like this&lt;br /&gt;
    protected function isPlayerZombie($player_id) {&lt;br /&gt;
        $players = self::loadPlayersBasicInfos();&lt;br /&gt;
        if (! isset($players[$player_id]))&lt;br /&gt;
            throw new BgaSystemException(&amp;quot;Player $player_id is not playing here&amp;quot;);&lt;br /&gt;
        &lt;br /&gt;
        return ($players[$player_id][&#039;player_zombie&#039;] == 1);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
== Accessing the database ==&lt;br /&gt;
&lt;br /&gt;
The main game logic should be the only point from which you should access the game database. You access your database using SQL queries with the methods below.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
BGA uses [http://dev.mysql.com/doc/refman/5.0/en/sql-syntax-transactions.html database transactions]. This means that your database changes WON&#039;T BE APPLIED to the database until your request ends normally (web request, not database request). Using transactions is in fact very useful for you; at any time, if your game logic detects that something is wrong (example: a disallowed move), you just have to throw an exception and all changes to the game situation will be removed. This also means that you need not (and in fact cannot) use your own transactions for multiple related database operations.&lt;br /&gt;
&lt;br /&gt;
However there are sets of database operation that will do implicit commit (most common mistake is to use &amp;quot;TRUNCATE&amp;quot;), you cannot use these operations during the game, it breaks the unrolling of transactions and will lead to nasty issues&lt;br /&gt;
(https://mariadb.com/kb/en/sql-statements-that-cause-an-implicit-commit).&lt;br /&gt;
&lt;br /&gt;
All methods below are part of game class (and view class) and can be accessed using $this-&amp;gt; or self::&lt;br /&gt;
&lt;br /&gt;
; DbQuery( string $sql )&lt;br /&gt;
: This is the generic method to access the database.&lt;br /&gt;
: It can execute any type of SELECT/UPDATE/DELETE/REPLACE/INSERT query on the database. Returns result of the query.&lt;br /&gt;
: For SELECT queries, the specialized methods below are much better.&lt;br /&gt;
: Do not use method for TUNCATE, DROP and other table altering operations. See disclamer above about implicit commits. If you really need TRUNCATE use DELETE FROM xxx instead.&lt;br /&gt;
&lt;br /&gt;
; getUniqueValueFromDB( string $sql )&lt;br /&gt;
: Returns a unique value from DB or null if no value is found.&lt;br /&gt;
: $sql must be a SELECT query.&lt;br /&gt;
: Raise an exception if more than 1 row is returned.&lt;br /&gt;
&lt;br /&gt;
; getCollectionFromDB( string $sql, bool $bSingleValue=false ) array&lt;br /&gt;
: Returns an associative array of rows for a sql SELECT query.&lt;br /&gt;
: The key of the resulting associative array is the first field specified in the SELECT query.&lt;br /&gt;
: The value of the resulting associative array is an associative array with all the field specified in the SELECT query and associated values.&lt;br /&gt;
: First column must be a primary or alternate key (semantically, it does not actually have to declared in sql as such).&lt;br /&gt;
: The resulting collection can be empty (it won&#039;t be null).&lt;br /&gt;
: If you specified $bSingleValue=true and if your SQL query requests 2 fields A and B, the method returns an associative array &amp;quot;A=&amp;gt;B&amp;quot;, otherwise its A=&amp;gt;[A,B]&lt;br /&gt;
: Note: The name a bit misleading, it really return associative array, i.e. map and NOT a collection. You cannot use it to get list of values which may have duplicates (hence primary key requirement on first column). If you need simple array use getObjectListFromDB() method.&lt;br /&gt;
&lt;br /&gt;
Example 1:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$result = self::getCollectionFromDB( &amp;quot;SELECT player_id id, player_name name, player_score score FROM player&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
Result:&lt;br /&gt;
[&lt;br /&gt;
 1234 =&amp;gt; [ &#039;id&#039;=&amp;gt;1234, &#039;name&#039;=&amp;gt;&#039;myuser0&#039;, &#039;score&#039;=&amp;gt;1 ],&lt;br /&gt;
 1235 =&amp;gt; [ &#039;id&#039;=&amp;gt;1235, &#039;name&#039;=&amp;gt;&#039;myuser1&#039;, &#039;score&#039;=&amp;gt;0 ]&lt;br /&gt;
]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example 2:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$result = self::getCollectionFromDB( &amp;quot;SELECT player_id id, player_name name FROM player&amp;quot;, true );&lt;br /&gt;
&lt;br /&gt;
Result:&lt;br /&gt;
[&lt;br /&gt;
 1234 =&amp;gt; &#039;myuser0&#039;,&lt;br /&gt;
 1235 =&amp;gt; &#039;myuser1&#039;&lt;br /&gt;
]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; getNonEmptyCollectionFromDB(string $sql) array&lt;br /&gt;
: Same as getCollectionFromDB($sdl), but raise an exception if the collection is empty. Note: this function does NOT have 2nd argument as previous one does.&lt;br /&gt;
&lt;br /&gt;
; getObjectFromDB(string $sql) array&lt;br /&gt;
: Returns one row for the sql SELECT query as an associative array or null if there is no result (where fields are keys mapped to values)&lt;br /&gt;
: Raise an exception if the query return more than one row (you can use LIMIT 1 in the query to avoid the exception)&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$result = self::getObjectFromDB( &amp;quot;SELECT player_id id, player_name name, player_score score FROM player WHERE player_id=&#039;$player_id&#039;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
Result:&lt;br /&gt;
array(&lt;br /&gt;
  &#039;id&#039;=&amp;gt;1234, &#039;name&#039;=&amp;gt;&#039;myuser0&#039;, &#039;score&#039;=&amp;gt;1 &lt;br /&gt;
)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; getNonEmptyObjectFromDB(string $sql) array&lt;br /&gt;
: Similar to previous one, but raise an exception if no row is found&lt;br /&gt;
&lt;br /&gt;
; getObjectListFromDB(string $sql, bool $bUniqueValue=false) array&lt;br /&gt;
: Return an array of rows for a sql SELECT query.&lt;br /&gt;
: The result is the same as &amp;quot;getCollectionFromDB&amp;quot; except that the result is a simple array (and not an associative array).&lt;br /&gt;
: The result can be empty.&lt;br /&gt;
: If you specified $bUniqueValue=true and if your SQL query request 1 field, the method returns directly an array of values.&lt;br /&gt;
&lt;br /&gt;
Example 1:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$result = self::getObjectListFromDB( &amp;quot;SELECT player_id id, player_name name, player_score score FROM player&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
Result:&lt;br /&gt;
[&lt;br /&gt;
 [ &#039;id&#039;=&amp;gt;1234, &#039;name&#039;=&amp;gt;&#039;myuser0&#039;, &#039;score&#039;=&amp;gt;1 ],&lt;br /&gt;
 [ &#039;id&#039;=&amp;gt;1235, &#039;name&#039;=&amp;gt;&#039;myuser1&#039;, &#039;score&#039;=&amp;gt;0 ]&lt;br /&gt;
]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example 2:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$result = self::getObjectListFromDB( &amp;quot;SELECT player_name name FROM player&amp;quot;, true );&lt;br /&gt;
&lt;br /&gt;
Result:&lt;br /&gt;
[&lt;br /&gt;
 &#039;myuser0&#039;,&lt;br /&gt;
 &#039;myuser1&#039;&lt;br /&gt;
]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; getDoubleKeyCollectionFromDB(string $sql, bool $bSingleValue=false) array&lt;br /&gt;
: Return an associative array of associative array, from a SQL SELECT query.&lt;br /&gt;
: First array level correspond to first column specified in SQL query.&lt;br /&gt;
: Second array level correspond to second column specified in SQL query.&lt;br /&gt;
: If $bSingleValue = true, keep only third column on result&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; DbGetLastId()&lt;br /&gt;
: Return the PRIMARY key of the last inserted row (see PHP mysql_insert_id function).&lt;br /&gt;
&lt;br /&gt;
; DbAffectedRow() int&lt;br /&gt;
: Return the number of row affected by the last operation&lt;br /&gt;
&lt;br /&gt;
; escapeStringForDB(string $string) string&lt;br /&gt;
: You must use this function on every string type data in your database that contains unsafe data.&lt;br /&gt;
: (unsafe = can be modified by a player).&lt;br /&gt;
: This method makes sure that no SQL injection will be done through the string used.&lt;br /&gt;
: Note: if you using standard types in ajax actions, like AT_alphanum it is sanitized before arrival,&lt;br /&gt;
: this is only needed if you manage to get unchecked string, like in the games where user has to enter text as a response.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: see Editing [[Game database model: dbmodel.sql]] to know how to define your database model.&lt;br /&gt;
&lt;br /&gt;
== Use globals ==&lt;br /&gt;
&lt;br /&gt;
Sometimes, you want a single global integer value for your game, and you don&#039;t want to create a DB table specifically for it.&lt;br /&gt;
&lt;br /&gt;
You can do this with the BGA framework &amp;quot;global&amp;quot;. Your value will be stored in the &amp;quot;global&amp;quot; table in the database, and you can access it with simple methods.&lt;br /&gt;
&lt;br /&gt;
All methods below are memeber of game class and should be accessed $this-&amp;gt; or self::&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;initGameStateLabels(array $labelsMap): void&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This method should be located at the beginning of constructor of &#039;&#039;yourgamename.game.php&#039;&#039;. This is where you define the globals used in your game logic, by assigning them IDs.&lt;br /&gt;
&lt;br /&gt;
You can define up to 80 globals, with IDs from 10 to 89 (inclusive, there can be gaps). &lt;br /&gt;
Also you must use this method to access value of game options [[Game_options_and_preferences:_gameoptions.inc.php]], in that case, IDs need to be between 100 and 199.&lt;br /&gt;
You must &#039;&#039;&#039;not&#039;&#039;&#039; use globals outside the range defined above, as those values are used by other components of the framework.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   function __construct() {&lt;br /&gt;
        parent::__construct();&lt;br /&gt;
        $this-&amp;gt;initGameStateLabels([ &lt;br /&gt;
                &amp;quot;my_first_global_variable&amp;quot; =&amp;gt; 10,&lt;br /&gt;
                &amp;quot;my_second_global_variable&amp;quot; =&amp;gt; 11,&lt;br /&gt;
                &amp;quot;my_game_variant&amp;quot; =&amp;gt; 100&lt;br /&gt;
        ]);&lt;br /&gt;
         // other code ...&lt;br /&gt;
   }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
NOTE: The methods below WILL throw an exception if label is not defined using the call above.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;setGameStateInitialValue( string $label, int $value ): void&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Initialize global value. This is not required if you ok with default value if 0. This should be called from setupNewGame function.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;getGameStateValue( string $label, int $default = 0): int&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Retrieve the value of a global. Returns $default if global is not been initialized (by setGameStateInitialValue).&lt;br /&gt;
&lt;br /&gt;
NOTE: this method use globals &amp;quot;cache&amp;quot; if you directly manipulated globals table OR call this function after undoRestorePoint() - it won&#039;t work as expected.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  $value = $this-&amp;gt;getGameStateValue(&#039;my_first_global_variable&#039;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For debugging purposes, you can have labels and value pairs send to client side by inserting that code in your &amp;quot;getAllDatas&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$labels = array_keys($this-&amp;gt;mygamestatelabels);&lt;br /&gt;
$result[&#039;myglobals&#039;] = array_combine($labels, array_map([$this,&#039;getGameStateValue&#039;],$labels));&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That assumes you stored your label mapping in $this-&amp;gt;mygamestatelabels in constructor&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  $this-&amp;gt;mygamestatelabels=[&amp;quot;my_first_global_variable&amp;quot; =&amp;gt; 10, ...];&lt;br /&gt;
  $this-&amp;gt;initGameStateLabels($this-&amp;gt;mygamestatelabels);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;setGameStateValue( string $label, int $value ): void&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Set the current value of a global. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  $this-&amp;gt;setGameStateValue(&#039;my_first_global_variable&#039;, 42);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;incGameStateValue( string $label, int $increment ): int&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Increment the current value of a global. If increment is negative, decrement the value of the global.&lt;br /&gt;
&lt;br /&gt;
Return the final value of the global. If global was not initialized it will initialize it as 0.&lt;br /&gt;
&lt;br /&gt;
NOTE: this method use globals &amp;quot;cache&amp;quot; if you directly manipulated globals table OR call this function after undoRestorePoint() - it won&#039;t work as expected.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  $value = $this-&amp;gt;incGameStateValue(&#039;my_first_global_variable&#039;, 1);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== BGA predefined globals ===&lt;br /&gt;
&lt;br /&gt;
BGA already defines some globals in the &#039;&#039;global&#039;&#039; database table. You should not change them directly but it can be useful to know what they mean when debugging:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! global_id !! label !! Meaning&lt;br /&gt;
|-&lt;br /&gt;
| 1 || || Current state &lt;br /&gt;
|-&lt;br /&gt;
| 2 || || Active player id&lt;br /&gt;
|-&lt;br /&gt;
| 3 || next_move_id || Next move number&lt;br /&gt;
|-&lt;br /&gt;
| 4 ||  || Game id&lt;br /&gt;
|-&lt;br /&gt;
| 5 ||  || Table creator id&lt;br /&gt;
|-&lt;br /&gt;
| 6 || playerturn_nbr || Player turn number&lt;br /&gt;
|-&lt;br /&gt;
| 7 || gameprogression || Game progression&lt;br /&gt;
|-&lt;br /&gt;
| 8 || initial_reflexion_time || Initial reflection time&lt;br /&gt;
|-&lt;br /&gt;
| 9 || additional_reflexion_time || Additional reflection time&lt;br /&gt;
|-&lt;br /&gt;
| 200 || reflexion_time_profile || Reflexion time profile&lt;br /&gt;
|-&lt;br /&gt;
| 201 || bgaranking_mode ||  BGA ranking mode&lt;br /&gt;
|-&lt;br /&gt;
| 207 || game_language ||GAMESTATE_GAME_LANG&lt;br /&gt;
|-&lt;br /&gt;
| 300 || game_db_version ||GAMESTATE_GAMEVERSION: Current version of the game (when in production)&lt;br /&gt;
|-&lt;br /&gt;
| 301 || game_result_neutralized ||GAMESTATE_GAME_RESULT_NEUTRALIZED&lt;br /&gt;
|-&lt;br /&gt;
| 302 || neutralized_player_id ||GAMESTATE_NEUTRALIZED_PLAYER_ID&lt;br /&gt;
|-&lt;br /&gt;
| 304 || undo_moves_stored ||GAMESTATE_UNDO_MOVES_STORED&lt;br /&gt;
|-&lt;br /&gt;
| 305 || undo_moves_player ||GAMESTATE_UNDO_MOVES_PLAYER&lt;br /&gt;
|-&lt;br /&gt;
| 306 || lock_screen_timestamp ||GAMESTATE_LOCK_TIMESTAMP&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Game states and active players ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Activate player handling ===&lt;br /&gt;
&lt;br /&gt;
; $this-&amp;gt;activeNextPlayer()&lt;br /&gt;
: Make the next player active in the natural player order.&lt;br /&gt;
: Note: you CANNOT use this method in a &amp;quot;activeplayer&amp;quot; or &amp;quot;multipleactiveplayer&amp;quot; state. You must use a &amp;quot;game&amp;quot; type game state for this.&lt;br /&gt;
&lt;br /&gt;
; $this-&amp;gt;activePrevPlayer()&lt;br /&gt;
: Make the previous player active (in the natural player order).&lt;br /&gt;
: Note: you CANNOT use this method in a &amp;quot;activeplayer&amp;quot; or &amp;quot;multipleactiveplayer&amp;quot; state. You must use a &amp;quot;game&amp;quot; type game state for this.&lt;br /&gt;
&lt;br /&gt;
; $this-&amp;gt;gamestate-&amp;gt;changeActivePlayer( $player_id )&lt;br /&gt;
: You can call this method to make any player active.&lt;br /&gt;
: Note: you CANNOT use this method in a &amp;quot;activeplayer&amp;quot; or &amp;quot;multipleactiveplayer&amp;quot; state. You must use a &amp;quot;game&amp;quot; type game state for this.&lt;br /&gt;
&lt;br /&gt;
; $this-&amp;gt;getActivePlayerId()&lt;br /&gt;
: Return the &amp;quot;active_player&amp;quot; id&lt;br /&gt;
: Note: it does NOT mean that this player is active right now, because state type could be &amp;quot;game&amp;quot; or &amp;quot;multipleactiveplayer&amp;quot;&lt;br /&gt;
: Note: avoid using this method in a &amp;quot;multipleactiveplayer&amp;quot; state because it does not mean anything.&lt;br /&gt;
&lt;br /&gt;
=== Multiple activate player handling ===&lt;br /&gt;
&lt;br /&gt;
; $this-&amp;gt;gamestate-&amp;gt;setAllPlayersMultiactive()&lt;br /&gt;
: All playing players are made active. Update notification is sent to all players (this will trigger &#039;&#039;&#039;onUpdateActionButtons&#039;&#039;&#039;).&lt;br /&gt;
: Usually, you use this method at the beginning of a game state (e.g., &amp;quot;stGameState&amp;quot;) which transitions to a &#039;&#039;multipleactiveplayer&#039;&#039; state in which multiple players have to perform some action. Do not use this method if you going to make some more changes in the active player list. (I.e., if you want to take away multipleactiveplayer status immediately afterwards, use setPlayersMultiactive instead.)&lt;br /&gt;
&lt;br /&gt;
Example of usage:&lt;br /&gt;
    &amp;lt;pre&amp;gt;&lt;br /&gt;
    function st_MultiPlayerInit() {&lt;br /&gt;
        $this-&amp;gt;gamestate-&amp;gt;setAllPlayersMultiactive();&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; $this-&amp;gt;stMakeEveryoneActive()&lt;br /&gt;
:this method can be used in state machine to make everybody active as &amp;quot;st&amp;quot; method of multiplayeractive state, it just calls $this-&amp;gt;gamestate-&amp;gt;setAllPlayersMultiactive()&lt;br /&gt;
&lt;br /&gt;
This is to be used in state declaration:&lt;br /&gt;
    &amp;lt;pre&amp;gt;&lt;br /&gt;
    2 =&amp;gt; array(&lt;br /&gt;
    		&amp;quot;name&amp;quot; =&amp;gt; &amp;quot;playerTurnPlace&amp;quot;,&lt;br /&gt;
    		&amp;quot;description&amp;quot; =&amp;gt; clienttranslate(&#039;Other player must place ships&#039;),&lt;br /&gt;
    		&amp;quot;descriptionmyturn&amp;quot; =&amp;gt; clienttranslate(&#039;${you} must place ships (click on YOUR SHIPS board to place)&#039;),&lt;br /&gt;
    		&amp;quot;type&amp;quot; =&amp;gt; &amp;quot;multipleactiveplayer&amp;quot;,&lt;br /&gt;
                &#039;action&#039; =&amp;gt; &#039;stMakeEveryoneActive&#039;,&lt;br /&gt;
                &#039;args&#039; =&amp;gt; &#039;arg_playerTurnPlace&#039;,&lt;br /&gt;
    	     	&amp;quot;possibleactions&amp;quot; =&amp;gt; array( &amp;quot;actionBla&amp;quot; ),&lt;br /&gt;
                &amp;quot;transitions&amp;quot; =&amp;gt; array( &amp;quot;next&amp;quot; =&amp;gt; 4, &amp;quot;last&amp;quot; =&amp;gt; 99)&lt;br /&gt;
    ),&lt;br /&gt;
    &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; $this-&amp;gt;gamestate-&amp;gt;setAllPlayersNonMultiactive( $next_state )&lt;br /&gt;
: All playing players are made inactive. Transition to next state&lt;br /&gt;
&lt;br /&gt;
; $this-&amp;gt;gamestate-&amp;gt;setPlayersMultiactive( $players, $next_state, $bExclusive = false )&lt;br /&gt;
: Make a specific list of players active during a multiactive gamestate. Update notification is sent to all players whose state changed.&lt;br /&gt;
: &amp;quot;players&amp;quot; is the array of player id that should be made active. If &amp;quot;players&amp;quot; is not empty the value of &amp;quot;next_state&amp;quot; will be ignored (you can put whatever you want)&lt;br /&gt;
: If &amp;quot;bExclusive&amp;quot; parameter is not set or false it doesn&#039;t deactivate other previously active players. If its set to true, the players who will be multiactive at the end are only these in &amp;quot;$players&amp;quot; array&lt;br /&gt;
&lt;br /&gt;
: In case &amp;quot;players&amp;quot; is empty, the method trigger the &amp;quot;next_state&amp;quot; transition to go to the next game state.&lt;br /&gt;
: returns true if state transition happened, false otherwise&lt;br /&gt;
&lt;br /&gt;
; $this-&amp;gt;gamestate-&amp;gt;setPlayerNonMultiactive( $player_id, $next_state )&lt;br /&gt;
: During a multiactive game state, make the specified player inactive.&lt;br /&gt;
: Usually, you call this method during a multiactive game state after a player did his action. It is also possible to call it directly from multiplayer action handler.&lt;br /&gt;
: If this player was the last active player, the method trigger the &amp;quot;next_state&amp;quot; transition to go to the next game state.&lt;br /&gt;
: returns true if state transition happened, false otherwise&lt;br /&gt;
Example of usage (see state declaration of playerTurnPlace above):&lt;br /&gt;
    &amp;lt;pre&amp;gt;&lt;br /&gt;
    function actionBla($args) {&lt;br /&gt;
        self::checkAction(&#039;actionBla&#039;);&lt;br /&gt;
        // handle the action using $this-&amp;gt;getCurrentPlayerId()&lt;br /&gt;
        $this-&amp;gt;gamestate-&amp;gt;setPlayerNonMultiactive( $this-&amp;gt;getCurrentPlayerId(), &#039;next&#039;);&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; $this-&amp;gt;gamestate-&amp;gt;getActivePlayerList()&lt;br /&gt;
: With this method you can retrieve the list of the active player at any time.&lt;br /&gt;
: During a &amp;quot;game&amp;quot; type gamestate, it will return a void array.&lt;br /&gt;
: During a &amp;quot;activeplayer&amp;quot; type gamestate, it will return an array with one value (the active player id).&lt;br /&gt;
: During a &amp;quot;multipleactiveplayer&amp;quot; type gamestate, it will return an array of the active players id.&lt;br /&gt;
: Note: you should only use this method in the latter case.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;  $this-&amp;gt;gamestate-&amp;gt;updateMultiactiveOrNextState( $next_state_if_none )&lt;br /&gt;
: Sends update notification about multiplayer changes. All multiactive set* functions above do that, however if you want to change state manually using db queries for complex calculations, you have to call this yourself after. Do not call this if you calling one of the other setters above.&lt;br /&gt;
Example: you have player teams and you want to activate all players in one team&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
        $sql = &amp;quot;UPDATE player SET player_is_multiactive=&#039;0&#039;&amp;quot;;&lt;br /&gt;
        self::DbQuery( $sql );&lt;br /&gt;
        $sql = &amp;quot;UPDATE player SET player_is_multiactive=&#039;1&#039; WHERE player_id=&#039;$player_id&#039; AND player_team=&#039;$team_no&#039;&amp;quot;;&lt;br /&gt;
        self::DbQuery( $sql );&lt;br /&gt;
        &lt;br /&gt;
        $this-&amp;gt;gamestate-&amp;gt;updateMultiactiveOrNextState( &#039;error&#039; );&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; updating database manually&lt;br /&gt;
: Use this helper function to change multiactive state without sending notification&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    /**&lt;br /&gt;
     * Changes values of multiactivity in db, does not sent notifications.&lt;br /&gt;
     * To send notifications after use updateMultiactiveOrNextState&lt;br /&gt;
     * @param number $player_id, player id &amp;lt;=0 or null - means ALL&lt;br /&gt;
     * @param number $value - 1 multiactive, 0 non multiactive&lt;br /&gt;
     */&lt;br /&gt;
    function dbSetPlayerMultiactive($player_id = -1, $value = 1) {&lt;br /&gt;
        if (! $value)&lt;br /&gt;
            $value = 0;&lt;br /&gt;
        else&lt;br /&gt;
            $value = 1;&lt;br /&gt;
        $sql = &amp;quot;UPDATE player SET player_is_multiactive = &#039;$value&#039; WHERE player_zombie = 0 and player_eliminated = 0&amp;quot;;&lt;br /&gt;
        if ($player_id &amp;gt; 0) {&lt;br /&gt;
            $sql .= &amp;quot; AND player_id = $player_id&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
        self::DbQuery($sql);&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
;$this-&amp;gt;gamestate-&amp;gt;isPlayerActive($player_id)&lt;br /&gt;
:Return true if specified player is active right now.&lt;br /&gt;
:This method take into account game state type, ie nobody is active if game state is &amp;quot;game&amp;quot; and several players can be active if game state is &amp;quot;multiplayer&amp;quot;&lt;br /&gt;
&lt;br /&gt;
;$this-&amp;gt;bIndependantMultiactiveTable&lt;br /&gt;
:This flag can be set to true in constructor of game.php to force creation of second table to handle multiplayer states (normally these are in player table), this is very advanced feature.&lt;br /&gt;
:ONLY use it after you deploy you game to production if you receive unusual amount of bug report with dead lock symptoms DURING multiactiveplayer states&lt;br /&gt;
    function __construct() {&lt;br /&gt;
      ...&lt;br /&gt;
      $this-&amp;gt;bIndependantMultiactiveTable=true;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
=== States functions ===&lt;br /&gt;
; $this-&amp;gt;gamestate-&amp;gt;nextState( $transition )&lt;br /&gt;
: Change current state to a new state. Important: the $transition parameter is the name of the transition, and NOT the name of the target game state, see [[Your game state machine: states.inc.php]] for more information about states.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;$this-&amp;gt;gamestate-&amp;gt;jumpToState($stateNum)&#039;&#039;&#039;&lt;br /&gt;
: Change current state to a new state. Important: the $stateNum parameter is the key of the state. See [[Your game state machine: states.inc.php]] for more information about states.&lt;br /&gt;
: Note: this is very advanced method, it should not be used in normal cases. Specific advanced cases include - jumping to specific state from &amp;quot;do_anytime&amp;quot; actions, jumping to dispatcher state or jumping to recovery state from zombie player function&lt;br /&gt;
&lt;br /&gt;
; $this-&amp;gt;checkAction( $actionName, $bThrowException=true )&lt;br /&gt;
: Check if the current player can perform a specific action in the current game state, and optionally throw an exception if they can&#039;t.&lt;br /&gt;
: The action is valid if it is listed in the &amp;quot;possibleactions&amp;quot; array for the current game state (see game state description).&lt;br /&gt;
: This method MUST be the first one called in ALL your PHP methods that handle player actions, in order to make sure a player doesn&#039;t perform an action not allowed by the rules at the point in the game.  It should not be called from methods where the current player is not necessarily the active player, otherwise it may fail with an &amp;quot;It is not your turn&amp;quot; exception.&lt;br /&gt;
: If &amp;quot;bThrowException&amp;quot; is set to &amp;quot;false&amp;quot;, the function returns &#039;&#039;&#039;false&#039;&#039;&#039; in case of failure instead of throwing an exception. This is useful when several actions are possible, in order to test each of them without throwing exceptions.&lt;br /&gt;
&lt;br /&gt;
; $this-&amp;gt;gamestate-&amp;gt;checkPossibleAction( $action )&lt;br /&gt;
: (rarely used)&lt;br /&gt;
: This works exactly like &amp;quot;checkAction&amp;quot; (above), except that it does NOT check if the current player is active.&lt;br /&gt;
: &#039;&#039;&#039;Note: This does NOT check either spectator or eliminated status, so those checks must be done manually.&#039;&#039;&#039;&lt;br /&gt;
: This is used specifically in certain game states when you want to authorize additional actions for players that are not active at the moment.&lt;br /&gt;
: Example: in &#039;&#039;Libertalia&#039;&#039;, you want to authorize players to change their mind about the card played. They are of course not active at the time they change their mind, so you cannot use &amp;quot;checkAction&amp;quot;; use &amp;quot;checkPossibleAction&amp;quot; instead.&lt;br /&gt;
&lt;br /&gt;
This is how PHP action looks that returns player to active state (only for multiplayeractive states). To be able to execute this on client do not call checkAction on js side for this specific action.&lt;br /&gt;
&lt;br /&gt;
   function actionUnpass() {&lt;br /&gt;
        $this-&amp;gt;gamestate-&amp;gt;checkPossibleAction(&#039;actionUnpass&#039;); // player changed mind about passing while others were thinking&lt;br /&gt;
        $this-&amp;gt;gamestate-&amp;gt;setPlayersMultiactive(array ($this-&amp;gt;getCurrentPlayerId() ), &#039;error&#039;, false);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
; $this-&amp;gt;gamestate-&amp;gt;state()&lt;br /&gt;
: Get an associative array of current game state attributes, see [[Your game state machine: states.inc.php]] for state attributes.&lt;br /&gt;
&lt;br /&gt;
  $state=$this-&amp;gt;gamestate-&amp;gt;state(); if( $state[&#039;name&#039;] == &#039;myGameState&#039; ) {...}&lt;br /&gt;
&lt;br /&gt;
I suggest to define and use this function in your php class to access state name:&lt;br /&gt;
&lt;br /&gt;
    public function getStateName() {&lt;br /&gt;
        $state = $this-&amp;gt;gamestate-&amp;gt;state();&lt;br /&gt;
        return $state[&#039;name&#039;];&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
; $this-&amp;gt;gamestate-&amp;gt;state_id()&lt;br /&gt;
: Get the id of the current game state (rarely useful, its best to use name, unless you use constants for state ids)&lt;br /&gt;
&lt;br /&gt;
; $this-&amp;gt;gamestate-&amp;gt;isMutiactiveState()&lt;br /&gt;
: Return true if we are in multipleactiveplayer state, false otherwise&lt;br /&gt;
&lt;br /&gt;
=== Private parallel states ===&lt;br /&gt;
&lt;br /&gt;
See the overview of private parallel states [[Your_game_state_machine:_states.inc.php#Private_parallel_states|here]].&lt;br /&gt;
&lt;br /&gt;
; $this-&amp;gt;gamestate-&amp;gt;initializePrivateStateForAllActivePlayers()&lt;br /&gt;
: All active players in a multiactive state are entering a first private state defined in the master state&#039;s initialprivate parameter.&lt;br /&gt;
: Every time you need to start a private parallel states you need to call this or similar methods below.&lt;br /&gt;
: Note: at least one player needs to be active (see [[#Multiple_activate_player_handling|above]]) and current game state must be a multiactive state with initialprivate parameter defined&lt;br /&gt;
: Note: initialprivate parameter of master state should be set to the id of the first private state. This private state needs to be defined in states.php with the type set to &#039;private&#039;.&lt;br /&gt;
: Note: this method is usually preceded with activating some or all players&lt;br /&gt;
: Note: initializing private state can run action or args methods of the initial private state&lt;br /&gt;
&lt;br /&gt;
Example of usage:&lt;br /&gt;
    &amp;lt;pre&amp;gt;&lt;br /&gt;
    function stStartPlayerTurn() {&lt;br /&gt;
        // This is usually done in master state action method&lt;br /&gt;
        &lt;br /&gt;
        $this-&amp;gt;gamestate-&amp;gt;setAllPlayersMultiactive();&lt;br /&gt;
        $this-&amp;gt;gamestate-&amp;gt;initializePrivateStateForAllActivePlayers();&lt;br /&gt;
&lt;br /&gt;
        // in some cases you can move immediately some or all players to different private states&lt;br /&gt;
        if ($someCondition) {&lt;br /&gt;
            //move all players to different state &lt;br /&gt;
            $this-&amp;gt;gamestate-&amp;gt;nextPrivateStateForAllActivePlayers(&amp;quot;some_transition&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        if ($other condition) {&lt;br /&gt;
            //move single player to different state&lt;br /&gt;
            $this-&amp;gt;gamestate-&amp;gt;nextPrivateState($specificPlayerId, &amp;quot;some_transition&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; $this-&amp;gt;gamestate-&amp;gt;initializePrivateStateForPlayers($playerIds)&lt;br /&gt;
: Players with specified ids are entering a first private state defined in the master state initialprivate parameter.&lt;br /&gt;
: Same considerations apply as for the method above.&lt;br /&gt;
&lt;br /&gt;
; $this-&amp;gt;gamestate-&amp;gt;initializePrivateState($playerId)&lt;br /&gt;
: Player with the specified id is entering a first private state defined in the master state initialprivate parameter.&lt;br /&gt;
: Everytime you need to start a private parallel states you need to call this or similar methods above&lt;br /&gt;
: Note: player needs to be active (see [[#Multiple_activate_player_handling|above]]) and current game state must be a multiactive state with initialprivate parameter defined&lt;br /&gt;
: Note: initialprivate parameter of master state should be set to the id of the first private state. This private state needs to be defined in states.php with the type set to &#039;private&#039;.&lt;br /&gt;
: Note: this method is usually preceded with activating that player&lt;br /&gt;
: Note: initializing private state can run action or args methods of the initial private state&lt;br /&gt;
&lt;br /&gt;
Example of usage:&lt;br /&gt;
    &amp;lt;pre&amp;gt;&lt;br /&gt;
    function st_ChangeMind() {&lt;br /&gt;
        // This player finished his move before, but now decides change something while other players are still active&lt;br /&gt;
        // We activate the player and initialize his private state&lt;br /&gt;
        $this-&amp;gt;gamestate-&amp;gt;setPlayersMultiactive([$this-&amp;gt;getCurrentPlayerId()], &amp;quot;&amp;quot;);&lt;br /&gt;
        $this-&amp;gt;gamestate-&amp;gt;initializePrivateState(this-&amp;gt;getCurrentPlayerId());&lt;br /&gt;
&lt;br /&gt;
        // It is also possible to move the player to some other specific state immediately&lt;br /&gt;
        $this-&amp;gt;gamestate-&amp;gt;nextPrivateState($this-&amp;gt;getCurrentPlayerId(), &amp;quot;some_transition&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; $this-&amp;gt;gamestate-&amp;gt;nextPrivateStateForAllActivePlayers($transition)&lt;br /&gt;
: All active players will transition to next private state by specified transition&lt;br /&gt;
: Note: game needs to be in a master state which allows private parallel states&lt;br /&gt;
: Note: transition should lead to another private state (i.e. a state with type defined as &#039;private&#039;&lt;br /&gt;
: Note: transition should be defined in private state in which the players currently are. &lt;br /&gt;
: Note: this method can run action or args methods of the target state&lt;br /&gt;
: Note: this is usually used after initializing the private state to move players to specific private state according to the game logic&lt;br /&gt;
&lt;br /&gt;
Example of usage:&lt;br /&gt;
    &amp;lt;pre&amp;gt;&lt;br /&gt;
    function stStartPlayerTurn() {&lt;br /&gt;
        // This is usually done in master state action method&lt;br /&gt;
        $this-&amp;gt;gamestate-&amp;gt;setAllPlayersMultiactive();&lt;br /&gt;
        $this-&amp;gt;gamestate-&amp;gt;initializePrivateStateForAllActivePlayers();&lt;br /&gt;
&lt;br /&gt;
        if ($specificOption) {&lt;br /&gt;
            //move all players to different state &lt;br /&gt;
            $this-&amp;gt;gamestate-&amp;gt;nextPrivateStateForAllActivePlayers(&amp;quot;some_transition&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; $this-&amp;gt;gamestate-&amp;gt;nextPrivateStateForPlayers($playerIds, $transition)&lt;br /&gt;
: Players with specified ids will transition to next private state specified by provided transition.&lt;br /&gt;
: Same considerations apply as for the method above.&lt;br /&gt;
&lt;br /&gt;
; $this-&amp;gt;gamestate-&amp;gt;nextPrivateState($playerId, $transition)&lt;br /&gt;
: Player with specified id will transition to next private state specified by provided transition&lt;br /&gt;
: Note: game needs to be in a master state which allows private parallel states&lt;br /&gt;
: Note: transition should lead to another private state (i.e. a state with type defined as &#039;private&#039;&lt;br /&gt;
: Note: transition should be defined in private state in which the players currently are. &lt;br /&gt;
: Note: this method can run action or args methods of the target state for specified player&lt;br /&gt;
: Note: this is usually used after some player actions to move to next private state&lt;br /&gt;
&lt;br /&gt;
Example of usage:&lt;br /&gt;
    &amp;lt;pre&amp;gt;&lt;br /&gt;
    function someAction() {&lt;br /&gt;
        $this-&amp;gt;checkAction(&amp;quot;someAction&amp;quot;); //needs to be defined in the current state&lt;br /&gt;
        $this-&amp;gt;gamestate-&amp;gt;nextPrivateState($this-&amp;gt;getCurrentPlayerId(), &amp;quot;some_transition&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; $this-&amp;gt;gamestate-&amp;gt;unsetPrivateStateForAllPlayers()&lt;br /&gt;
: All players private state will be reset to null, which means they will get out of private parallel states and be in a master state like the private states are not used &lt;br /&gt;
: Note: game needs to be in a master state which allows private parallel states&lt;br /&gt;
: Note: this is usually used to clean up after leaving a master state in which private states were used, but can be used in other cases when we want to exit private parallel states and use a regular multiactive state for all players&lt;br /&gt;
: Note: After unseting private state only actions on master state are possible&lt;br /&gt;
: Note: Usually it is not necessary to unset private states as they will be initialized to first private state when private states are needed again. Nevertheless it is generally better to clean private state after exiting private parallel states to avoid bugs. &lt;br /&gt;
&lt;br /&gt;
Example of usage:&lt;br /&gt;
    &amp;lt;pre&amp;gt;&lt;br /&gt;
    function stNextRound() {&lt;br /&gt;
        $this-&amp;gt;gamestate-&amp;gt;unsetPrivateStateForAllPlayers();&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; $this-&amp;gt;gamestate-&amp;gt;unsetPrivateStateForPlayers($playerIds, $transition)&lt;br /&gt;
: For players with specified ids private state will be reset to null, which means they will get out of private parallel states and be in a master state like the private states are not used.&lt;br /&gt;
: Same considerations apply as for the method above.&lt;br /&gt;
&lt;br /&gt;
; $this-&amp;gt;gamestate-&amp;gt;unsetPrivateState($playerId)&lt;br /&gt;
: For player with specified id private state will be reset to null, which means they will get out of private parallel states and be in a master state like the private states are not used &lt;br /&gt;
: Note: game needs to be in a master state which allows private parallel states&lt;br /&gt;
: Note: this is usually used when deactivating player to clean up their parallel state&lt;br /&gt;
: Note: After unseting private state only actions on master state are possible&lt;br /&gt;
: Note: Usually it is not necessary to unset private state as it will be initialized to first private state when private states are needed again. Nevertheless it is generally better to clean private state when not needed to avoid bugs. &lt;br /&gt;
&lt;br /&gt;
Example of usage:&lt;br /&gt;
    &amp;lt;pre&amp;gt;&lt;br /&gt;
    function done() {&lt;br /&gt;
        $this-&amp;gt;gamestate-&amp;gt;setPlayerNonMultiactive( $this-&amp;gt;getCurrentPlayerId(), &amp;quot;newTurn&amp;quot; );&lt;br /&gt;
        $this-&amp;gt;gamestate-&amp;gt;unsetPrivateState($this-&amp;gt;getCurrentPlayerId());&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; $this-&amp;gt;gamestate-&amp;gt;setPrivateState($playerId, $newStateId)&lt;br /&gt;
: For player with specified id a new private state would be set&lt;br /&gt;
: Note: game needs to be in a master state which allows private parallel states&lt;br /&gt;
: Note: this should be rarely used as it doesn&#039;t check if the transition is allowed (it doesn&#039;t even specifies transition). This can be useful in very complex cases when standard state machine is not adequate (i.e. specific cards can lead to some micro action in various states where defining transitions back and forth can become very tedious.) &lt;br /&gt;
: Note: this method can run action or args methods of the target state for specified player&lt;br /&gt;
&lt;br /&gt;
Example of usage:&lt;br /&gt;
    &amp;lt;pre&amp;gt;&lt;br /&gt;
    function someAction() {&lt;br /&gt;
        $this-&amp;gt;checkAction(&amp;quot;someAction&amp;quot;); //needs to be defined in the current state&lt;br /&gt;
&lt;br /&gt;
        if ($playerHaveSpecificCard)&lt;br /&gt;
            return $this-&amp;gt;gamestate-&amp;gt;setPrivateState($this-&amp;gt;getCurrentPlayerId(), 35);&lt;br /&gt;
&lt;br /&gt;
        $this-&amp;gt;gamestate-&amp;gt;nextPrivateState($this-&amp;gt;getCurrentPlayerId(), &amp;quot;some_transition&amp;quot;);        &lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; $this-&amp;gt;gamestate-&amp;gt;getPrivateState($playerId) &lt;br /&gt;
: This return the private state or null if not initialized or not in private state&lt;br /&gt;
&lt;br /&gt;
==== State Arguments in Private parallel states ====&lt;br /&gt;
&lt;br /&gt;
The args method called for private states will have the player_id passed to it, allowing you to customise the arguments returned for that player.&lt;br /&gt;
&lt;br /&gt;
Example of usage:&lt;br /&gt;
    &amp;lt;pre&amp;gt;&lt;br /&gt;
    function argMyPrivateState($player_id) {&lt;br /&gt;
        return array(&lt;br /&gt;
          &#039;my_data&#039; =&amp;gt; $this-&amp;gt;getPlayerSpecificData($player_id)&lt;br /&gt;
        );&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Inactive Players ====&lt;br /&gt;
&lt;br /&gt;
During Private Parallel State, active players will be managed by the private state that is current assigned to them.&lt;br /&gt;
&lt;br /&gt;
Inactive players will be managed by the master multipleactiveplayer state, so your client should respond to that state in order to display any status message advising players that they are waiting for others to have their turn, or to add any buttons that allow players to potentially &amp;quot;break in&amp;quot; and become active.&lt;br /&gt;
&lt;br /&gt;
== Players turn order ==&lt;br /&gt;
&lt;br /&gt;
When table is created the &amp;quot;natural&amp;quot; player order is assigned to player at random, and stored in &amp;quot;read-only&amp;quot; field &amp;quot;player_no&amp;quot;.&lt;br /&gt;
If you need to create a custom order you should never change natural order but have a separate data structure. &lt;br /&gt;
For example you can alter the players table to add another &amp;quot;custom_order&amp;quot; field, you can use state globals or you can use your natural board database, &lt;br /&gt;
to store meeple_color/position_location pair.&lt;br /&gt;
BGA currently does not provide any API to create/store custom player order.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;getNextPlayerTable()&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Return an associative array which associate each player with the next player around the table.&lt;br /&gt;
&lt;br /&gt;
In addition, key 0 is associated to the first player to play.&lt;br /&gt;
&lt;br /&gt;
Example: if three player with ID 1000, 2000 and 3000 are around the table, in this order, the method returns:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
   array( &lt;br /&gt;
    1000 =&amp;gt; 2000, &lt;br /&gt;
    2000 =&amp;gt; 3000, &lt;br /&gt;
    3000 =&amp;gt; 1000, &lt;br /&gt;
    0 =&amp;gt; 1000 &lt;br /&gt;
   );&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;getPrevPlayerTable()&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Same as above, but the associative array associate the previous player around the table. However there no 0 index here.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;getPlayerAfter( $player_id )&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Get player playing after given player in natural playing order.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;getPlayerBefore( $player_id )&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Get player playing before given player in natural playing order.&lt;br /&gt;
&lt;br /&gt;
Note: There is no API to modify this order, if you have custom player order you have to maintain it in your database&lt;br /&gt;
and have custom function to access it.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;createNextPlayerTable( $players, $bLoop=true )&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Using $players array creates a map of current =&amp;gt; next as in example from getNextPlayerTable(), however you can use custom order here. &lt;br /&gt;
If parmeter $bLoop is set to true then last player will points to first (creaing a loop), false otherwise.&lt;br /&gt;
In any case index 0 points to first player (first element of $players array). $players is array of player ids in desired order.&lt;br /&gt;
&lt;br /&gt;
Note: This function &#039;&#039;&#039;DOES NOT&#039;&#039;&#039; change the order in database, it only creates a map using key/values as descibed.&lt;br /&gt;
&lt;br /&gt;
Example of usage:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    function getNextPlayerTableCustom() {&lt;br /&gt;
        $starting = $this-&amp;gt;getStartingPlayer(); // custom function to get starting player&lt;br /&gt;
        $player_ids = $this-&amp;gt;getPlayerIdsInOrder($starting); // custom function to create players array starting from starting player&lt;br /&gt;
        return $this-&amp;gt;createNextPlayerTable($player_ids, false); // create next player table in custom order&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$table = $this-&amp;gt;createNextPlayerTable([3000,2000,1000], false);&lt;br /&gt;
&lt;br /&gt;
will return:&lt;br /&gt;
   [ &lt;br /&gt;
    3000 =&amp;gt; 2000, &lt;br /&gt;
    2000 =&amp;gt; 1000, &lt;br /&gt;
    1000 =&amp;gt; null,&lt;br /&gt;
    0 =&amp;gt; 3000 &lt;br /&gt;
   ]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Notify players ==&lt;br /&gt;
&lt;br /&gt;
To understand notifications, please read [http://www.slideshare.net/boardgamearena/the-bga-framework-at-a-glance The BGA Framework at a glance] first.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Notifications are sent at the very end of the request, when it ends normally. It means that if you throw an exception for any reason (ex: move not allowed), no notifications will be sent to players.&lt;br /&gt;
Notifications sent between the game start (setupNewGame) and the end of the &amp;quot;action&amp;quot; method of the first active state will never reach their destination.&lt;br /&gt;
&lt;br /&gt;
=== NotifyAllPlayers ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;notifyAllPlayers(string $notification_type,string $notification_log,array $notification_args )&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Send a notification to all players of the game.&lt;br /&gt;
&lt;br /&gt;
* notification_type: A string that defines the type of your notification.&lt;br /&gt;
&lt;br /&gt;
Your game interface Javascript logic will use this to know what is the type of the received notification (and to trigger the corresponding method).&lt;br /&gt;
&lt;br /&gt;
* notification_log: A string that defines what is to be displayed in the game log.&lt;br /&gt;
&lt;br /&gt;
You can use an empty string here (&#039;&#039;). In this case, nothing is displayed in the game log.&lt;br /&gt;
&lt;br /&gt;
Unless its empty, use &amp;quot;clienttranslate&amp;quot; method to make sure string is translated.&lt;br /&gt;
&lt;br /&gt;
You can use arguments in your $notification_log string, that refers to values defines in the &amp;quot;$notification_args&amp;quot; argument (see below). &lt;br /&gt;
Note: Make sure you only use single quotes (&#039;), otherwise PHP will try to interpolate the variable and will ignore the values in the args array.&lt;br /&gt;
&lt;br /&gt;
* notification_args: The arguments of your notifications, as an associative array.&lt;br /&gt;
&lt;br /&gt;
This array will be transmitted to the game interface logic, in order the game interface can be updated.&lt;br /&gt;
&lt;br /&gt;
Complete notifyAllPlayers example (from &amp;quot;Reversi&amp;quot;):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
self::notifyAllPlayers( &amp;quot;playDisc&amp;quot;, clienttranslate( &#039;${player_name} plays a disc and turns over ${returned_nbr} disc(s)&#039; ),&lt;br /&gt;
 array(&lt;br /&gt;
        &#039;player_id&#039; =&amp;gt; $player_id,&lt;br /&gt;
        &#039;player_name&#039; =&amp;gt; self::getActivePlayerName(),&lt;br /&gt;
        &#039;returned_nbr&#039; =&amp;gt; count( $turnedOverDiscs ),&lt;br /&gt;
        &#039;x&#039; =&amp;gt; $x,&lt;br /&gt;
        &#039;y&#039; =&amp;gt; $y&lt;br /&gt;
     ) );&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can see in the example above the use of the &amp;quot;clienttranslate&amp;quot; method, and the use of 2 arguments &amp;quot;player_name&amp;quot; and &amp;quot;returned_nbr&amp;quot; in the notification log.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Important&#039;&#039;&#039;: NO private data must be sent with this method, as a cheater could see it even if it is not used explicitly by the game interface logic. If you want to send private information to a player, please use notifyPlayer below.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Important&#039;&#039;&#039;: this array is serialized to be sent to the browsers, and will be saved with the notification to be able to replay the game later. If it is too big, it can make notifications slower / less reliable, and replay archives very big (to the point of failing). So as a general rule, you should send only the minimum of information necessary to update the client interface with no overhead in order to keep the notifications as light as possible.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Important&#039;&#039;&#039;: When the game page is reloaded (i.e. F5 or when loading turn based game) all previous notifications are replayed as history notifications. These notifications do not trigger notification handlers and are used basically to build the game log. Because of that most of the notification arguments, except i18n, player_id and all arguments used in the message, are removed from these history notifications. If you need additional arguments in history notifications you can add special field &amp;lt;b&amp;gt;preserve&amp;lt;/b&amp;gt; to notification arguments, like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
self::notifyAllPlayers( &amp;quot;playDisc&amp;quot;, clienttranslate( &#039;${player_name} plays a disc and turns over ${returned_nbr} disc(s)&#039; ),&lt;br /&gt;
 array(&lt;br /&gt;
        &#039;player_id&#039; =&amp;gt; $player_id,&lt;br /&gt;
        &#039;player_name&#039; =&amp;gt; self::getActivePlayerName(),&lt;br /&gt;
        &#039;returned_nbr&#039; =&amp;gt; count( $turnedOverDiscs ),&lt;br /&gt;
        &#039;x&#039; =&amp;gt; $x,&lt;br /&gt;
        &#039;y&#039; =&amp;gt; $y,&lt;br /&gt;
        &#039;preserve&#039; =&amp;gt; [ &#039;x&#039;, &#039;y&#039; ]&lt;br /&gt;
     ) );&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In this example, fields x and y will be preserved when replaying history notification at the game load.&lt;br /&gt;
&lt;br /&gt;
NOTE: The ONLY reason &#039;preserve&#039; is useful if you have custom method to render notifications (or logs) which changes some text arguments into html (i.e. to insert the images instead of plain text). Do not use preserve &amp;quot;just in case&amp;quot; - it will only bloat the logs and make game load VERY slow.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Important&#039;&#039;&#039;: If both public and private notifications are sent to the same player in the same action (AJAX call), they will initially appear in the log in the order in which they were called, but they are placed into the game log in the following order: All private notifications first, then all public notifications. This means that when the page is refreshed, or when a player loads an asynchronous game, if you have called any public notifications &#039;&#039;before&#039;&#039; the last private notification, they will appear out of order in the log.&lt;br /&gt;
&lt;br /&gt;
==== HTML in Notifications ====&lt;br /&gt;
&lt;br /&gt;
You CAN use some HTML inside your notification log, however it not recommended for many reasons:&lt;br /&gt;
* Its bad architecture, ui elements leak into server now you have to manage ui in many places&lt;br /&gt;
* If you decided to change something in ui in a future version, old games replay and tutorials may not work, since they use stored notifications&lt;br /&gt;
* When you read log preview for old games its unreadable (this is log before you enter the game replay, useful for troubleshooting or game analysis)&lt;br /&gt;
* Its more data to transfer and store in db&lt;br /&gt;
* Its nightmare for translators, at least don&#039;t put HTML tags inside the &amp;quot;clienttranslate&amp;quot; method. You can use a notification argument instead, and provide your HTML through this argument.&lt;br /&gt;
&lt;br /&gt;
If you still want to have pretty pictures in the log check this [[BGA_Studio_Cookbook#Inject_images_and_styled_html_in_the_log]].&lt;br /&gt;
&lt;br /&gt;
==== Recursive Notifications ====&lt;br /&gt;
&lt;br /&gt;
If your notification contains some phrases that build programmatically you may need to use recursive notifications. In this case the argument can be not only the string but&lt;br /&gt;
an array itself, which contains &#039;log&#039; and &#039;args&#039;, i.e.&lt;br /&gt;
&lt;br /&gt;
  $this-&amp;gt;notifyAllPlayers(&#039;playerLog&#039;,clienttranslate(&#039;Game moves ${token_name_rec}&#039;),&lt;br /&gt;
                   [&#039;token_name_rec&#039;=&amp;gt;[&#039;log&#039;=&amp;gt;&#039;${token_name} #${token_number}&#039;,&lt;br /&gt;
                                       &#039;args&#039;=&amp;gt; [&#039;token_name&#039;=&amp;gt;clienttranslate(&#039;Boo&#039;), &#039;token_number&#039;=&amp;gt;$number, &#039;i18n&#039;=&amp;gt;[&#039;token_name&#039;] ]&lt;br /&gt;
                                      ]&lt;br /&gt;
                   ]);&lt;br /&gt;
&lt;br /&gt;
Special handling of arguments:&lt;br /&gt;
* ${player_name}  - this will be wrapped in html and text shown using color of the corresponding player, some colors also have reserved background. This will apply recursively as well.&lt;br /&gt;
* ${player_name1}, ${player_name2}, ${player_name3}, etc. - same&lt;br /&gt;
&lt;br /&gt;
==== Excluding some players ====&lt;br /&gt;
&lt;br /&gt;
Sometimes you want to notify all players of a message but not have it appear in the log of specific players (for example, have every player see &amp;quot;Player X draws a card&amp;quot; but have Player X see &amp;quot;You draw the Ace of Spades&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
To send a notification to all players but have some clients ignore it, send it as normal from the server, but implement &#039;&#039;&#039;setIgnoreNotificationCheck&#039;&#039;&#039; on the client to ignore the message under given conditions. See the [[Game_interface_logic:_yourgamename.js#Ignoring_notifications]] documentation for more details.&lt;br /&gt;
&lt;br /&gt;
=== NotifyPlayer ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;notifyPlayer( $player_id, $notification_type, $notification_log, $notification_args )&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Same as above, except that the notification is sent to one player only.&lt;br /&gt;
&lt;br /&gt;
This method must be used each time some private information must be transmitted to a player.&lt;br /&gt;
&lt;br /&gt;
Important: the variable for player name must be ${player_name} in order to be highlighted with the player color in the game log. If you want a second player name in the log, name the variable ${player_name2}, etc.&lt;br /&gt;
&lt;br /&gt;
Note that spectators cannot be notified using this method, because their player ID is not available via loadPlayersBasicInfos() or otherwise. You must use notifyAllPlayers() for any notification that spectators should get.&lt;br /&gt;
&lt;br /&gt;
== Randomization ==&lt;br /&gt;
&lt;br /&gt;
A large number of board games rely on random, most often based on dice, cards shuffling, picking some item in a bag, and so on. This is very important to ensure a high level of randomness for each of these situations.&lt;br /&gt;
&lt;br /&gt;
Here&#039;s are a list of techniques you should use in these situations, from the best to the worst.&lt;br /&gt;
&lt;br /&gt;
=== Dice and bga_rand ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;bga_rand( min, max )&#039;&#039;&#039; &lt;br /&gt;
This is a BGA framework function that provides you a random number between &amp;quot;min&amp;quot; and &amp;quot;max&amp;quot; (inclusive), using the best available random method available on the system.&lt;br /&gt;
&lt;br /&gt;
This is the preferred function you should use, because we are updating it when a better method is introduced.&lt;br /&gt;
&lt;br /&gt;
As of now, bga_rand is based on the PHP function &amp;quot;random_int&amp;quot;, which ensures a cryptographic level of randomness.&lt;br /&gt;
&lt;br /&gt;
In particular, it is &#039;&#039;&#039;mandatory&#039;&#039;&#039; to use it for all &#039;&#039;&#039;dice throw&#039;&#039;&#039; (ie: games using other methods for dice throwing will be rejected by BGA during review).&lt;br /&gt;
&lt;br /&gt;
Note: rand() and mt_rand() are deprecated on BGA and should not be used anymore, as their randomness is not as good as &amp;quot;bga_rand&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Arrays ===&lt;br /&gt;
&lt;br /&gt;
Although PHP&#039;s &amp;quot;shuffle()&amp;quot; is generally considered good enough (see below, BGA&#039;s own Deck component uses this), the following PHP code based on &amp;quot;random_int&amp;quot; provides a cryptographically-secure method to choose a random key, value, or slice of an array. (the slice preserves keys)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    private function getRandomKey(array &amp;amp;$array)&lt;br /&gt;
    {&lt;br /&gt;
        $size = count($array);&lt;br /&gt;
        if ($size == 0) {&lt;br /&gt;
            trigger_error(&amp;quot;getRandomKey(): Array is empty&amp;quot;, E_USER_WARNING);&lt;br /&gt;
            return null;&lt;br /&gt;
        }&lt;br /&gt;
        $rand = random_int(0, $size - 1);&lt;br /&gt;
        $slice = array_slice($array, $rand, 1, true);&lt;br /&gt;
        foreach ($slice as $key =&amp;gt; $value) {&lt;br /&gt;
            return $key;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    private function getRandomValue(array &amp;amp;$array)&lt;br /&gt;
    {&lt;br /&gt;
        $size = count($array);&lt;br /&gt;
        if ($size == 0) {&lt;br /&gt;
            trigger_error(&amp;quot;getRandomValue(): Array is empty&amp;quot;, E_USER_WARNING);&lt;br /&gt;
            return null;&lt;br /&gt;
        }&lt;br /&gt;
        $rand = random_int(0, $size - 1);&lt;br /&gt;
        $slice = array_slice($array, $rand, 1, true);&lt;br /&gt;
        foreach ($slice as $key =&amp;gt; $value) {&lt;br /&gt;
            return $value;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    private function getRandomSlice(array &amp;amp;$array, int $count)&lt;br /&gt;
    {&lt;br /&gt;
        $size = count($array);&lt;br /&gt;
        if ($size == 0) {&lt;br /&gt;
            trigger_error(&amp;quot;getRandomSlice(): Array is empty&amp;quot;, E_USER_WARNING);&lt;br /&gt;
            return null;&lt;br /&gt;
        }&lt;br /&gt;
        if ($count &amp;lt; 1 || $count &amp;gt; $size) {&lt;br /&gt;
            trigger_error(&amp;quot;getRandomSlice(): Invalid count $count for array with size $size&amp;quot;, E_USER_WARNING);&lt;br /&gt;
            return null;&lt;br /&gt;
        }&lt;br /&gt;
        $slice = [];&lt;br /&gt;
        $randUnique = [];&lt;br /&gt;
        while (count($randUnique) &amp;lt; $count) {&lt;br /&gt;
            $rand = random_int(0, $size - 1);&lt;br /&gt;
            if (array_key_exists($rand, $randUnique)) {&lt;br /&gt;
                continue;&lt;br /&gt;
            }&lt;br /&gt;
            $randUnique[$rand] = true;&lt;br /&gt;
            $slice += array_slice($array, $rand, 1, true);&lt;br /&gt;
        }&lt;br /&gt;
        return $slice;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== shuffle and cards shuffling ===&lt;br /&gt;
&lt;br /&gt;
To shuffle items, like a pile of cards, the best way is to use the BGA PHP [[Deck]] component and to use &amp;quot;shuffle&amp;quot; method. This ensures that the best available shuffling method is used, and that if in the future we improve it your game will be up to date.&lt;br /&gt;
&lt;br /&gt;
As of now, the Deck component shuffle method is based on PHP &amp;quot;shuffle&amp;quot; method, which has quite good randomness (even if not as good as bga_rand). In consequence, we accept other shuffling methods during reviews, as long as they are based on PHP &amp;quot;shuffle&amp;quot; function (or similar, like &amp;quot;array_rand&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
=== Other methods ===&lt;br /&gt;
&lt;br /&gt;
Mysql &amp;quot;RAND()&amp;quot; function has not enough randomness to be a valid method to get a random element on BGA. This function has been used in some existing games and has given acceptable results, but now it should be avoided and you should use other methods instead.&lt;br /&gt;
&lt;br /&gt;
== Game statistics ==&lt;br /&gt;
&lt;br /&gt;
There are 2 types of statistics:&lt;br /&gt;
* a &amp;quot;player&amp;quot; statistic is a statistic associated to a player&lt;br /&gt;
* a &amp;quot;table&amp;quot; statistic is a statistic not associated to a player (global statistic for this game).&lt;br /&gt;
&lt;br /&gt;
See [[Game statistics: stats.inc.php]] to see how you define statistics for your game.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;initStat( $table_or_player, $name, $value, $player_id = null )&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create a statistic entry with a default value.&lt;br /&gt;
&lt;br /&gt;
This method must be called for each statistic of your game, in your setupNewGame method.&lt;br /&gt;
If you neglect to call this for a statistic, and also do not update the value during the course of a certain game using setStat or incStat, the value of the stat will be undefined rather than 0. This will result in it being ignored at the end of the game, as if it didn&#039;t apply to that particular game, and excluded from cumulative statistics. As a consequence - if do not want statistic to be applied, do not init it, or call set or inc on it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;$table_or_player&#039; must be set to &amp;quot;table&amp;quot; if this is a table statistic, or &amp;quot;player&amp;quot; if this is a player statistic.&lt;br /&gt;
&lt;br /&gt;
&#039;$name&#039; is the name of your statistic, as it has been defined in your stats.inc.php file.&lt;br /&gt;
&lt;br /&gt;
&#039;$value&#039; is the initial value of the statistic. If this is a player statistic and if the player is not specified by &amp;quot;$player_id&amp;quot; argument, the value is set for ALL players.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;setStat( $value, $name, $player_id = null )&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Set a statistic $name to $value.&lt;br /&gt;
&lt;br /&gt;
If &amp;quot;$player_id&amp;quot; is not specified, setStat consider it is a TABLE statistic.&lt;br /&gt;
&lt;br /&gt;
If &amp;quot;$player_id&amp;quot; is specified, setStat consider it is a PLAYER statistic.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;incStat( $delta, $name, $player_id = null )&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Increment (or decrement) specified statistic value by $delta value. Same behavior as setStat function.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;getStat( $name, $player_id = null )&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Return the value of statistic specified by $name. Useful when creating derivative statistics such as average.&lt;br /&gt;
&lt;br /&gt;
== Translations ==&lt;br /&gt;
&lt;br /&gt;
See [[Translations]]&lt;br /&gt;
&lt;br /&gt;
== Manage player scores and Tie breaker ==&lt;br /&gt;
&lt;br /&gt;
=== Normal scoring ===&lt;br /&gt;
&lt;br /&gt;
At the end of the game, players automatically get a rank depending on their score: the player with the biggest score is #1, the player with the second biggest score is #2, and so on...&lt;br /&gt;
&lt;br /&gt;
During the game, you update player&#039;s score directly by updating &amp;quot;player_score&amp;quot; field of &amp;quot;player&amp;quot; table in database.&lt;br /&gt;
&lt;br /&gt;
Examples:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  // +2 points to active player&lt;br /&gt;
  self::DbQuery( &amp;quot;UPDATE player SET player_score=player_score+2 WHERE player_id=&#039;&amp;quot;.self::getActivePlayerId().&amp;quot;&#039;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
  // Set score of active player to 5&lt;br /&gt;
  self::DbQuery( &amp;quot;UPDATE player SET player_score=5 WHERE player_id=&#039;&amp;quot;.self::getActivePlayerId().&amp;quot;&#039;&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: don&#039;t forget to notify the client side in order the score control can be updated accordingly.&lt;br /&gt;
&lt;br /&gt;
=== Tie breaker ===&lt;br /&gt;
&lt;br /&gt;
Tie breaker is used when two players get the same score at the end of a game.&lt;br /&gt;
&lt;br /&gt;
Tie breaker is using &amp;quot;player_score_aux&amp;quot; field of &amp;quot;player&amp;quot; table. It is updated exactly like the &amp;quot;player_score&amp;quot; field.&lt;br /&gt;
&lt;br /&gt;
Tie breaker score is displayed only for players who are tied at the end of the game. Most of the time, it is not supposed to be displayed explicitly during the game.&lt;br /&gt;
&lt;br /&gt;
When you are using &amp;quot;player_score_aux&amp;quot; functionality, you must describe the formula to use in your gameinfos.inc.php file like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
         &#039;tie_breaker_description&#039; =&amp;gt; totranslate(&amp;quot;Describe here your tie breaker formula&amp;quot;),&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This description will be used as a tooltip to explain to players how this auxiliary score has been calculated.&lt;br /&gt;
&lt;br /&gt;
See also [https://en.doc.boardgamearena.com/Game_meta-information:_gameinfos.inc.php#Multiple_tie_breaker_management Multiple Tie Breaker Management].&lt;br /&gt;
&lt;br /&gt;
=== Co-operative game ===&lt;br /&gt;
&lt;br /&gt;
To make everyone win/lose together in a full-coop game:&lt;br /&gt;
&lt;br /&gt;
Add the following in gameinfos.inc.php :&lt;br /&gt;
&#039;is_coop&#039; =&amp;gt; 1, // full cooperative&lt;br /&gt;
&lt;br /&gt;
Assign a score of zero to everyone if it&#039;s a loss.&lt;br /&gt;
Assign the same score &amp;gt; 0 to everyone if it&#039;s a win.&lt;br /&gt;
&lt;br /&gt;
=== Semi-coop ===&lt;br /&gt;
&lt;br /&gt;
If the game is not full-coop, then everyone loses = everyone is tied. I.e. set score to 0 to everybody.&lt;br /&gt;
&lt;br /&gt;
=== Only &amp;quot;winners&amp;quot; and &amp;quot;losers&amp;quot; ===&lt;br /&gt;
&lt;br /&gt;
For some games, there is only a group (or a single) &amp;quot;winner&amp;quot;, and everyone else is a &amp;quot;loser&amp;quot;, with no &amp;quot;end of game rank&amp;quot; (1st, 2nd, 3rd...).&lt;br /&gt;
&lt;br /&gt;
Examples:&lt;br /&gt;
* Coup&lt;br /&gt;
* Not Alone&lt;br /&gt;
* Werewolves&lt;br /&gt;
* Quantum&lt;br /&gt;
&lt;br /&gt;
In this case:&lt;br /&gt;
* Set the scores so that the winner has the best score, and the other players have the same (lower) score.&lt;br /&gt;
* Add the following lines to gameinfos.inc.php:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// If in the game, all losers are equal (no score to rank them or explicit in the rules that losers are not ranked between them), set this to true &lt;br /&gt;
// The game end result will display &amp;quot;Winner&amp;quot; for the 1st player and &amp;quot;Loser&amp;quot; for all other players&lt;br /&gt;
&#039;losers_not_ranked&#039; =&amp;gt; true,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Werewolves and Coup are implemented like this, as you can see here:&lt;br /&gt;
* https://boardgamearena.com/#!gamepanel?game=werewolves&amp;amp;section=lastresults&lt;br /&gt;
* https://boardgamearena.com/#!gamepanel?game=coupcitystate&amp;amp;section=lastresults&lt;br /&gt;
&lt;br /&gt;
Adding this has the following effects:&lt;br /&gt;
* On game results for this game, &amp;quot;Winner&amp;quot; or &amp;quot;Loser&amp;quot; is going to appear instead of the usual &amp;quot;1st, 2nd, 3rd, ...&amp;quot;.&lt;br /&gt;
* When a game is over, the result of the game will be &amp;quot;End of game: Victory&amp;quot; or &amp;quot;End of game: Defeat&amp;quot; depending on the result of the CURRENT player (instead of the usual &amp;quot;Victory of XXX&amp;quot;).&lt;br /&gt;
* When calculating ELO points, if there is at least one &amp;quot;Loser&amp;quot;, no &amp;quot;victorious&amp;quot; player can lose ELO points, and no &amp;quot;losing&amp;quot; player can win ELO point. Usually it may happened because being tie with many players with a low rank is considered as a tie and may cost you points. If losers_not_ranked is set, we prevent this behavior and make sure you only gain/loss ELO when you get the corresponding results.&lt;br /&gt;
&lt;br /&gt;
Important: this SHOULD NOT be used for cooperative games (see is_coop parameter), or for 2 players games (it makes no sense in this case).&lt;br /&gt;
&lt;br /&gt;
=== Solo ===&lt;br /&gt;
&lt;br /&gt;
If game supports solo variant, a negative or zero score means defeat, a positive score means victory.&lt;br /&gt;
&lt;br /&gt;
=== Player elimination ===&lt;br /&gt;
&lt;br /&gt;
In some games, this is useful to eliminate a player from the game in order he/she can start another game without waiting for the current game end.&lt;br /&gt;
&lt;br /&gt;
This case should be rare. Please don&#039;t use player elimination feature if some player just has to wait the last 10% of the game for game end. This feature should be used only in games where players are eliminated all along the game (typical examples: &amp;quot;Perudo&amp;quot; or &amp;quot;The Werewolves of Miller&#039;s Hollow&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&lt;br /&gt;
* Player to eliminate should NOT be active anymore (preferably use the feature in a &amp;quot;game&amp;quot; type game state).&lt;br /&gt;
* In your PHP code:&lt;br /&gt;
  self::eliminatePlayer( &amp;lt;player_to_eliminate_id&amp;gt; );&lt;br /&gt;
* the player is informed in a dialog box that he no longer have to play and can start another game if he/she wants too (with buttons &amp;quot;stay at this table&amp;quot; &amp;quot;quit table and back to main site&amp;quot;). In any case, the player is free to start &amp;amp; join another table from now.&lt;br /&gt;
* When your game is over, all players who have been eliminated before receive a &amp;quot;notification&amp;quot; (the small &amp;quot;!&amp;quot; icon on the top right of the BGA interface) that indicate them that &amp;quot;the game has ended&amp;quot; and invite them to review the game results.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Important:&#039;&#039;&#039; this should not be used on a player who has already left the game (&amp;quot;zombie&amp;quot;) as leaving/being kicked of the game (outside of the scope of the rules) is not the same as being eliminated from the game (according to the rules), except if in the course of the game, the zombie player is eliminated according to the rules.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Important:&#039;&#039;&#039; When all surviving players are eliminated at the same time BGA framework causes the game to be abandoned automatically.&lt;br /&gt;
To circumvent this, the game should leave 1 player not eliminated but change final scores accordingly and end the game.&lt;br /&gt;
&lt;br /&gt;
=== Scoring Helper functions ===&lt;br /&gt;
&lt;br /&gt;
These functions should have been API but they are not, just add them to your php game and use for every game.&lt;br /&gt;
&lt;br /&gt;
    // get score&lt;br /&gt;
    function dbGetScore($player_id) {&lt;br /&gt;
        return $this-&amp;gt;getUniqueValueFromDB(&amp;quot;SELECT player_score FROM player WHERE player_id=&#039;$player_id&#039;&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // set score&lt;br /&gt;
    function dbSetScore($player_id, $count) {&lt;br /&gt;
        $this-&amp;gt;DbQuery(&amp;quot;UPDATE player SET player_score=&#039;$count&#039; WHERE player_id=&#039;$player_id&#039;&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // set aux score (tie breaker)&lt;br /&gt;
    function dbSetAuxScore($player_id, $score) {&lt;br /&gt;
        $this-&amp;gt;DbQuery(&amp;quot;UPDATE player SET player_score_aux=$score WHERE player_id=&#039;$player_id&#039;&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // increment score (can be negative too)&lt;br /&gt;
    function dbIncScore($player_id, $inc) {&lt;br /&gt;
        $count = $this-&amp;gt;dbGetScore($player_id);&lt;br /&gt;
        if ($inc != 0) {&lt;br /&gt;
            $count += $inc;&lt;br /&gt;
            $this-&amp;gt;dbSetScore($player_id, $count);&lt;br /&gt;
        }&lt;br /&gt;
        return $count;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
== Reflexion time ==&lt;br /&gt;
&lt;br /&gt;
; function giveExtraTime( $player_id, $specific_time=null )&lt;br /&gt;
: Give standard extra time to this player.&lt;br /&gt;
: Standard extra time depends on the speed of the game (small with &amp;quot;slow&amp;quot; game option, bigger with other options).&lt;br /&gt;
: You can also specify an exact time to add, in seconds, with the &amp;quot;specified_time&amp;quot; argument (rarely used).&lt;br /&gt;
&lt;br /&gt;
; function isAsync()&lt;br /&gt;
: Returns true if game is turn based, false if it is realtime&lt;br /&gt;
&lt;br /&gt;
== Undo moves ==&lt;br /&gt;
&lt;br /&gt;
Please read our [[BGA Undo policy]] before.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Important&#039;&#039;&#039;: Before using these methods, you must also add the following to your &amp;quot;gameinfos.inc.php&amp;quot; file, otherwise these methods are ineffective:&lt;br /&gt;
  &#039;db_undo_support&#039; =&amp;gt; true&lt;br /&gt;
&lt;br /&gt;
Note: if you deploy undo support after game is in production this will take into effect for new games only, old games will give user an error if user choses Undo action, but otherwise it should not affect them.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; function undoSavepoint( )&lt;br /&gt;
: Save the whole game situation inside an &amp;quot;Undo save point&amp;quot;.&lt;br /&gt;
: There is only ONE undo save point available (see [[BGA Undo policy]]). Cannot use in multiactivate state or in game state where next state is multiactive.&lt;br /&gt;
: Note: this function does not actually do anything when it is called, it only raises the flag to store the database AFTER transaction is over. So the actual state will be saved when you exit the function  calling it (technically before first queued notification is sent, which matters if you transition to game state not to user state after), this may affect what you end up saving.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; function undoRestorePoint()&lt;br /&gt;
: Restore the situation previously saved as an &amp;quot;Undo save point&amp;quot;.&lt;br /&gt;
: You must make sure that the active player is the same after and before the undoRestorePoint (ie: this is your responsibility to ensure that the player that is active when this method is called is exactly the same than the player that was active when the undoSavePoint method has been called).&lt;br /&gt;
&lt;br /&gt;
    function actionUndo() {&lt;br /&gt;
        self::checkAction(&#039;actionUndo&#039;);&lt;br /&gt;
        $this-&amp;gt;undoRestorePoint();&lt;br /&gt;
        $this-&amp;gt;gamestate-&amp;gt;nextState(&#039;next&#039;); // transition to single player state (i.e. beginning of player actions for this turn)&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Important note&#039;&#039;&#039;: if you are reading game state variable right after restore (without changing state first) it won&#039;t work properly as the global table cache is not automatically refreshed after undoRestorePoint(). So you should either change state immediately to refresh game state values, or use $this-&amp;gt;gamestate-&amp;gt;reloadState() to refresh the state. If you choose to do the latest, be aware that this will bring the state machine back to the state during which the save point snapshot has been taken using undoSavepoint() (which means your transition you do after has to declared in the state which was saved, not in the state which was active for your actionUndo())&lt;br /&gt;
&lt;br /&gt;
== Managing errors and exceptions ==&lt;br /&gt;
&lt;br /&gt;
Note: when you throw an exception, all database changes and all notifications are cancelled immediately. This way, the game situation that existed before the request is completely restored.&lt;br /&gt;
&lt;br /&gt;
; throw new BgaUserException ( $error_message)&lt;br /&gt;
: Base class to notify a user error&lt;br /&gt;
: You must throw this exception when a player wants to do something that they are not allowed to do.&lt;br /&gt;
: The error message will be shown to the player as a &amp;quot;red message&amp;quot;.&lt;br /&gt;
: The error message must be translated, make sure you use self::_() or $this-&amp;gt;_() here and NOT clientranslate()&lt;br /&gt;
: Throwing such an exception is NOT considered a bug, so it is not traced in BGA error logs.&lt;br /&gt;
&lt;br /&gt;
Example from Gomoku:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
     throw new BgaUserException( self::_(&amp;quot;There is already a stone on this intersection, you can&#039;t play there&amp;quot;) );&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; throw new BgaVisibleSystemException ( $error_message)&lt;br /&gt;
: You must throw this exception when you detect something that is not supposed to happened in your code.&lt;br /&gt;
: The error message is shown to the user as an &amp;quot;Unexpected error&amp;quot;, in order that he can report it in the forum.&lt;br /&gt;
: The error message is logged in BGA error logs. If it happens regularly, we will report it to you.&lt;br /&gt;
&lt;br /&gt;
; throw new BgaSystemException ( $error_message)&lt;br /&gt;
: Base class to notify a system exception. The message will be hidden from the user, but show in the logs. Use this if the message contains technical information.&lt;br /&gt;
: You shouldn&#039;t use this type of exception except if you think the information shown could be critical. Indeed: a generic error message will be shown to the user, so it&#039;s going to be difficult for you to see what happened.&lt;br /&gt;
&lt;br /&gt;
== Zombie mode ==&lt;br /&gt;
&lt;br /&gt;
When a player leaves a game for any reason (expelled, quit), he becomes a &amp;quot;zombie player&amp;quot;. In this case, the results of the game won&#039;t count for statistics, but this is cool if the other players can finish the game anyway. That&#039;s why zombie mode exists: allow the other player to finish the game, even if the situation is not ideal.&lt;br /&gt;
&lt;br /&gt;
While developing your zombie mode, keep in mind that:&lt;br /&gt;
* Do not refer to the rules, because this situation is not planned by the rules.&lt;br /&gt;
* Try to figure that you are playing with your friends and one of them has to leave: how can we finish the game without killing the spirit of the game?&lt;br /&gt;
* The idea is NOT to develop an artificial intelligence for the game.&lt;br /&gt;
* Do not try to end the game early, even in a two-player game. The zombie is there to allow the game to continue, not to end it. Trying to end the game is not supported by the framework and will likely cause unexpected errors.&lt;br /&gt;
&lt;br /&gt;
Most of the time, the best thing to do when it is zombie player turn is to jump immediately to a state where he is not active anymore. For example, if he is in a game state where he has a choice between playing A and playing B, the best thing to do is NOT to choose A or B, but to pass. So, even if there&#039;s no &amp;quot;pass&amp;quot; action in the rules, add a &amp;quot;zombiepass&amp;quot; transitition in your game state and use it.&lt;br /&gt;
&lt;br /&gt;
Each time a zombie player must play, your &amp;quot;zombieTurn&amp;quot; method is called.&lt;br /&gt;
&lt;br /&gt;
Parameters:&lt;br /&gt;
* $state: the name of the current game state.&lt;br /&gt;
* $active_player: the id of the active player.&lt;br /&gt;
&lt;br /&gt;
Most of the time, your zombieTurn method looks like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    function zombieTurn( $state, $active_player )&lt;br /&gt;
    {&lt;br /&gt;
    	$statename = $state[&#039;name&#039;];&lt;br /&gt;
&lt;br /&gt;
        if( $statename == &#039;myFirstGameState&#039;&lt;br /&gt;
             ||  $statename == &#039;my2ndGameState&#039;&lt;br /&gt;
             ||  $statename == &#039;my3rdGameState&#039;&lt;br /&gt;
               ....&lt;br /&gt;
           )&lt;br /&gt;
        {&lt;br /&gt;
            $this-&amp;gt;gamestate-&amp;gt;nextState( &amp;quot;zombiePass&amp;quot; );&lt;br /&gt;
        }&lt;br /&gt;
        else&lt;br /&gt;
            throw new BgaVisibleSystemException( &amp;quot;Zombie mode not supported at this game state: &amp;quot;.$statename );&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that in the example above, all corresponding game state should implement &amp;quot;zombiePass&amp;quot; as a transition.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Very important&#039;&#039;&#039;: your zombie code will be called when the player leaves the game. This action is triggered from the main site and propagated to the gameserver from a server, not from a browser. As a consequence, there is no current player associated to this action. In your zombieTurn function, you must &#039;&#039;&#039;never&#039;&#039;&#039; use getCurrentPlayerId() or getCurrentPlayerName(), otherwise it will fail with a &amp;quot;Not logged&amp;quot; error message.&lt;br /&gt;
&lt;br /&gt;
== Player color preferences ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
BGA premium users may choose their preferred color for playing. For example, if they are used to play green for every board game, they can select &amp;quot;green&amp;quot; in their BGA preferences page.&lt;br /&gt;
&lt;br /&gt;
Making your game compatible with colors preferences is very easy and requires only 1 line of configuration change:&lt;br /&gt;
&lt;br /&gt;
On your gameinfos.inc.php file, add the following lines :&lt;br /&gt;
&lt;br /&gt;
  // Favorite colors support: if set to &amp;quot;true&amp;quot;, support attribution of favorite colors based on player&#039;s preferences (see reattributeColorsBasedOnPreferences PHP method)&lt;br /&gt;
  // NB: this parameter is used only to flag games supporting this feature; you must use (or not use) reattributeColorsBasedOnPreferences PHP method to actually enable or disable the feature.&lt;br /&gt;
  &#039;favorite_colors_support&#039; =&amp;gt; true,&lt;br /&gt;
&lt;br /&gt;
Then, on your main &amp;lt;your_game&amp;gt;.game.php file check the code of &amp;quot;setupNewGame&amp;quot;. New template already have correct code, but if you editing very old game and it may be absent.&lt;br /&gt;
&lt;br /&gt;
        $gameinfos = $this-&amp;gt;getGameinfos();&lt;br /&gt;
        ...&lt;br /&gt;
        if ($gameinfos[&#039;favorite_colors_support&#039;])&lt;br /&gt;
            $this-&amp;gt;reattributeColorsBasedOnPreferences($players, $gameinfos[&#039;player_colors&#039;]); // this should be above reloadPlayersBasicInfos()&lt;br /&gt;
        self::reloadPlayersBasicInfos();&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;reattributeColorsBasedOnPreferences&amp;quot; method reattributes all colors, taking into account players color preferences and available colors.&lt;br /&gt;
&lt;br /&gt;
Note that you must update the colors to indicate the colors available for your game.&lt;br /&gt;
&lt;br /&gt;
Some important remarks:&lt;br /&gt;
* for some games (i.e. Chess), the color has an influence on a mechanism of the game, most of the time by giving a special advantage to a player (i.e. Starting the game). Color preference mechanism must NOT be used in such a case.&lt;br /&gt;
* your logic should NEVER consider that the first player has the color X, that the second player has the color Y, and so on. If this is the case, your game will NOT be compatible with reattributeColorsBasedOnPreferences as this method attribute colors to players based on their preferences and not based as their order at the table.&lt;br /&gt;
&lt;br /&gt;
=== Custom color assignments ===&lt;br /&gt;
Some colors don&#039;t play nicely with BGA&#039;s color difference algorithm. If you receive feedback that colors are not well chosen, you can bypass the BGA algorithm by specifying a map from user preference colors to game colors.&lt;br /&gt;
&lt;br /&gt;
For example, you may wish to assign BGA&#039;s blue to your game&#039;s baby blue: &amp;lt;code&amp;gt;&amp;quot;0000ff&amp;quot; /* Blue */ =&amp;gt; &amp;quot;89CFF0&amp;quot;,&amp;lt;/code&amp;gt; whereas otherwise, a deep purple might be chosen instead. Just be sure that the assigned colors are also present in the &amp;lt;code&amp;gt;player_colors&amp;lt;/code&amp;gt; array passed to &amp;lt;code&amp;gt;reattributeColorsBasedOnPreferences&amp;lt;/code&amp;gt;, otherwise the assignment will be ignored.&lt;br /&gt;
&lt;br /&gt;
To do this, implement this method in your &amp;lt;code&amp;gt;X.game.php&amp;lt;/code&amp;gt; class.&lt;br /&gt;
&lt;br /&gt;
Note: the user preference colors (the keys in the returned array) should not be modified, or the code may not work as expected. These are the colors players can choose between in their profile.&lt;br /&gt;
     /**&lt;br /&gt;
      * Returns an array of user preference colors to game colors.&lt;br /&gt;
      * Game colors must be among those which are passed to reattributeColorsBasedOnPreferences()&lt;br /&gt;
      * Each game color can be an array of suitable colors, or a single color:&lt;br /&gt;
      * [&lt;br /&gt;
      *    // The first available color chosen:&lt;br /&gt;
      *    &#039;ff0000&#039; =&amp;gt; [&#039;990000&#039;, &#039;aa1122&#039;],&lt;br /&gt;
      *    // This color is chosen, if available&lt;br /&gt;
      *    &#039;0000ff&#039; =&amp;gt; &#039;000099&#039;,&lt;br /&gt;
      * ]&lt;br /&gt;
      * If no color can be matched from this array, then the default implementation is used.&lt;br /&gt;
      */&lt;br /&gt;
     function getSpecificColorPairings(): array {&lt;br /&gt;
         return array(&lt;br /&gt;
             &amp;quot;ff0000&amp;quot; /* Red */         =&amp;gt; null,&lt;br /&gt;
             &amp;quot;008000&amp;quot; /* Green */       =&amp;gt; null,&lt;br /&gt;
             &amp;quot;0000ff&amp;quot; /* Blue */        =&amp;gt; null,&lt;br /&gt;
             &amp;quot;ffa500&amp;quot; /* Yellow */      =&amp;gt; null,&lt;br /&gt;
             &amp;quot;000000&amp;quot; /* Black */       =&amp;gt; null,&lt;br /&gt;
             &amp;quot;ffffff&amp;quot; /* White */       =&amp;gt; null,&lt;br /&gt;
             &amp;quot;e94190&amp;quot; /* Pink */        =&amp;gt; null,&lt;br /&gt;
             &amp;quot;982fff&amp;quot; /* Purple */      =&amp;gt; null,&lt;br /&gt;
             &amp;quot;72c3b1&amp;quot; /* Cyan */        =&amp;gt; null,&lt;br /&gt;
             &amp;quot;f07f16&amp;quot; /* Orange */      =&amp;gt; null,&lt;br /&gt;
             &amp;quot;bdd002&amp;quot; /* Khaki green */ =&amp;gt; null,&lt;br /&gt;
             &amp;quot;7b7b7b&amp;quot; /* Gray */        =&amp;gt; null,&lt;br /&gt;
         );&lt;br /&gt;
     }&lt;br /&gt;
&lt;br /&gt;
== Legacy games API ==&lt;br /&gt;
&lt;br /&gt;
For some very specific games (&amp;quot;legacy&amp;quot;, &amp;quot;campaign&amp;quot;), you need to keep some informations from a game to another.&lt;br /&gt;
&lt;br /&gt;
This should be an exceptional situation: the legacy API is costing resources on Board Game Arena databases, and is slowing down the game setup process + game end of game process. Please do not use it for things like:&lt;br /&gt;
* keeping a player preference/settings (=&amp;gt; player preferences and game options should be used instead)&lt;br /&gt;
* keeping a statistics, a score, or a ranking, while it is not planned in the physical board game, or while there is no added value compared to BGA statistics / rankings.&lt;br /&gt;
&lt;br /&gt;
You should use it for:&lt;br /&gt;
* legacy games: when some components of the game has been altered in a previous game and should be kept as it is.&lt;br /&gt;
* &amp;quot;campaign style&amp;quot; games: when a player is getting a &amp;quot;reward&amp;quot; at the end of a game, and should be able to use it in further games.&lt;br /&gt;
&lt;br /&gt;
Important: you cannot store more than 64k of data (serialized as JSON) per player per game. If you go over 64k, storeLegacyData function is going to FAIL, and there is a risk to create a major bug (= players blocked) in your game. You MUST make sure that no more than 64k of data is used for each player for your game. For example, if you are implementing a &amp;quot;campaign style&amp;quot; game and if you allow a player to start multiple campaign, you must LIMIT the number of different campaign so that the total data size to not go over the limit. We strongly recommend you to use this:&lt;br /&gt;
&lt;br /&gt;
  try &lt;br /&gt;
  {&lt;br /&gt;
  	$this-&amp;gt;storeLegacyTeamData( $my_data );&lt;br /&gt;
  }&lt;br /&gt;
  catch( feException $e ) // feException is a base class of BgaSystemException and others...&lt;br /&gt;
  {&lt;br /&gt;
  	if( $e-&amp;gt;getCode() == FEX_legacy_size_exceeded )&lt;br /&gt;
  	{&lt;br /&gt;
  		// Do something here to free some space in Legacy data (ex: by removing some variables)&lt;br /&gt;
  	}&lt;br /&gt;
  	else&lt;br /&gt;
  		throw $e;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
The keys may only contain letters and numbers, underscore seems not to be allowed.&lt;br /&gt;
&lt;br /&gt;
; function storeLegacyData( $player_id, $key, $data, $ttl = 365 )&lt;br /&gt;
: Store some data associated with $key for the given user / current game&lt;br /&gt;
: In the opposite of all other game data, this data will PERSIST after the end of this table, and can be re-used&lt;br /&gt;
: in a future table with the same game.&lt;br /&gt;
: IMPORTANT: The only possible place where you can use this method is when the game is over at your table (last game action). Otherwise, there is a risk of conflicts between ongoing games.    &lt;br /&gt;
: TTL is a time-to-live: the maximum, and default, is 365 days.&lt;br /&gt;
: In any way, the total data (= all keys) you can store for a given user+game is 64k (note: data is store serialized as JSON data)&lt;br /&gt;
: NOTICE: You can store some persistant data across all tables from your game using the specific player_id 0 which is unused. In such case, it&#039;s even more important to manage correctly the size of your data to avoid any exception or issue while storing updated data (ie. you can use this for some kind of leaderbord for solo game or contest)&lt;br /&gt;
: Note: This function cannot be called during game setup (will throw an error).&lt;br /&gt;
&lt;br /&gt;
; function retrieveLegacyData( $player_id, $key )&lt;br /&gt;
: Get data associated with $key for the current game&lt;br /&gt;
: This data is common to ALL tables from the same game for this player, and persist from one table to another.&lt;br /&gt;
: Note: calling this function has an important cost =&amp;gt; please call it few times (possibly: only ONCE) for each player for 1 game if possible&lt;br /&gt;
: Note: you can use &#039;%&#039; in $key to retrieve all keys matching the given patterns&lt;br /&gt;
&lt;br /&gt;
; function removeLegacyData( $player_id, $key )&lt;br /&gt;
: Remove some legacy data with the given key&lt;br /&gt;
: (useful to free some data to avoid going over 64k)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
; function storeLegacyTeamData( $data, $ttl = 365 )&lt;br /&gt;
: Same as storeLegacyData, except that it stores some data for the whole team within the current table and does not use a key&lt;br /&gt;
: Ie: if players A, B and C are at a table, the legacy data will be saved for future table with (exactly) A, B and C on the table.&lt;br /&gt;
: This is useful for games which are intended to be played several time by the same team.&lt;br /&gt;
: Note: the data total size is still limited, so you must implement catch the FEX_legacy_size_exceeded exception if it happens&lt;br /&gt;
&lt;br /&gt;
; function retrieveLegacyTeamData()&lt;br /&gt;
: Same as retrieveLegacyData, except that it retrieves some data for the whole team within the current table (set by storeLegacyTeamData)&lt;br /&gt;
&lt;br /&gt;
; function removeLegacyTeamData()&lt;br /&gt;
: Same as removeLegacyData, except that it retrieves some data for the whole team within the current table (set by storeLegacyTeamData)&lt;br /&gt;
&lt;br /&gt;
== Players text input and moderation ==&lt;br /&gt;
This section concerns only games where the players have to write some words to play: games based on words, like &amp;quot;Just one&amp;quot; or &amp;quot;Codenames&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Some players will use your game to write insults or profanities. As this is part of the game and not in the game chat, these words cannot be reported by players and moderated.&lt;br /&gt;
&lt;br /&gt;
If you met the following situation:&lt;br /&gt;
&lt;br /&gt;
* You are asking a player to type a text (word(s) or sentence)&lt;br /&gt;
* The player can enter any text (this is not a pre-selection or anything you can control)&lt;br /&gt;
* This text is visible by at least one other player&lt;br /&gt;
&lt;br /&gt;
Then, you must use the following method:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;function logTextForModeration( $player_id, $text )&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
player_id = player who write the text&lt;br /&gt;
&lt;br /&gt;
text = text that has been written&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This function will have no visible consequence for your game, but will allow players to report the text to moderators if something happens.&lt;br /&gt;
&lt;br /&gt;
== Language dependent games API ==&lt;br /&gt;
&lt;br /&gt;
This API is used for games that are heavily language dependent. Two most common use cases are:&lt;br /&gt;
* Games that have a language dependent component that are not necessarily translatable, typically a list of words. (Think of games like Codenames, Decrypto, Just One...)&lt;br /&gt;
* Games with massive communication where players would like to ensure that all participants speak the same language. (Think of games like Werewolf, The Resistance, maybe even dixit...)&lt;br /&gt;
&lt;br /&gt;
If this option is used, the table created will be limited only to users that have specific language in their profile. Player starting the game would be able to chose one of the languages they speak.&lt;br /&gt;
&lt;br /&gt;
There is a new property language_dependency in gameinfos.inc.php which can be set like this:&lt;br /&gt;
  &#039;language_dependency&#039; =&amp;gt; false,  //or if the property is missing, the game is not language dependent&lt;br /&gt;
  &#039;language_dependency&#039; =&amp;gt; true, //all players at the table must speak the same language&lt;br /&gt;
  &#039;language_dependency&#039; =&amp;gt; array( 1 =&amp;gt; &#039;en&#039;, 2 =&amp;gt; &#039;fr&#039;, 3 =&amp;gt; &#039;it&#039; ), //1-based list of supported languages&lt;br /&gt;
&lt;br /&gt;
In the gamename.game.php file, you can get the id of selected language with the method &#039;&#039;&#039;getGameLanguage&#039;&#039;&#039;.&lt;br /&gt;
; function getGameLanguage()&lt;br /&gt;
: Returns an index of the selected language as defined in gameinfos.inc.php.&lt;br /&gt;
&lt;br /&gt;
Languages currently available on BGA are:&lt;br /&gt;
  &#039;ar&#039; =&amp;gt; array( &#039;name&#039; =&amp;gt; &amp;quot;العربية&amp;quot;, &#039;code&#039; =&amp;gt; &#039;ar_AE&#039; ),             // Arabic&lt;br /&gt;
  &#039;be&#039; =&amp;gt; array( &#039;name&#039; =&amp;gt; &amp;quot;беларуская мова&amp;quot;, &#039;code&#039; =&amp;gt; &#039;be_BY&#039; ),     // Belarusian&lt;br /&gt;
  &#039;bn&#039; =&amp;gt; array( &#039;name&#039; =&amp;gt; &amp;quot;বাংলা&amp;quot;, &#039;code&#039; =&amp;gt; &#039;bn_BD&#039; ),                // Bengali&lt;br /&gt;
  &#039;bg&#039; =&amp;gt; array( &#039;name&#039; =&amp;gt; &amp;quot;български език&amp;quot;, &#039;code&#039; =&amp;gt; &#039;bg_BG&#039; ),      // Bulgarian&lt;br /&gt;
  &#039;ca&#039; =&amp;gt; array( &#039;name&#039; =&amp;gt; &amp;quot;català&amp;quot;, &#039;code&#039; =&amp;gt; &#039;ca_ES&#039; ),              // Catalan&lt;br /&gt;
  &#039;cs&#039; =&amp;gt; array( &#039;name&#039; =&amp;gt; &amp;quot;čeština&amp;quot;, &#039;code&#039; =&amp;gt; &#039;cs_CZ&#039; ),             // Czech&lt;br /&gt;
  &#039;da&#039; =&amp;gt; array( &#039;name&#039; =&amp;gt; &amp;quot;dansk&amp;quot;, &#039;code&#039; =&amp;gt; &#039;da_DK&#039; ),               // Danish&lt;br /&gt;
  &#039;de&#039; =&amp;gt; array( &#039;name&#039; =&amp;gt; &amp;quot;deutsch&amp;quot;, &#039;code&#039; =&amp;gt; &#039;de_DE&#039; ),             // German&lt;br /&gt;
  &#039;el&#039; =&amp;gt; array( &#039;name&#039; =&amp;gt; &amp;quot;Ελληνικά&amp;quot;, &#039;code&#039; =&amp;gt; &#039;el_GR&#039; ),            // Greek&lt;br /&gt;
  &#039;en&#039; =&amp;gt; array( &#039;name&#039; =&amp;gt; &amp;quot;English&amp;quot;, &#039;code&#039; =&amp;gt; &#039;en_US&#039; ),             // English&lt;br /&gt;
  &#039;es&#039; =&amp;gt; array( &#039;name&#039; =&amp;gt; &amp;quot;español&amp;quot;, &#039;code&#039; =&amp;gt; &#039;es_ES&#039; ),             // Spanish&lt;br /&gt;
  &#039;et&#039; =&amp;gt; array( &#039;name&#039; =&amp;gt; &amp;quot;eesti keel&amp;quot;, &#039;code&#039; =&amp;gt; &#039;et_EE&#039; ),          // Estonian       &lt;br /&gt;
  &#039;fi&#039; =&amp;gt; array( &#039;name&#039; =&amp;gt; &amp;quot;suomi&amp;quot;, &#039;code&#039; =&amp;gt; &#039;fi_FI&#039; ),               // Finnish&lt;br /&gt;
  &#039;fr&#039; =&amp;gt; array( &#039;name&#039; =&amp;gt; &amp;quot;français&amp;quot;, &#039;code&#039; =&amp;gt; &#039;fr_FR&#039; ),            // French&lt;br /&gt;
  &#039;he&#039; =&amp;gt; array( &#039;name&#039; =&amp;gt; &amp;quot;עברית&amp;quot;, &#039;code&#039; =&amp;gt; &#039;he_IL&#039; ),               // Hebrew       &lt;br /&gt;
  &#039;hi&#039; =&amp;gt; array( &#039;name&#039; =&amp;gt; &amp;quot;हिन्दी&amp;quot;, &#039;code&#039; =&amp;gt; &#039;hi_IN&#039; ),                 // Hindi&lt;br /&gt;
  &#039;hr&#039; =&amp;gt; array( &#039;name&#039; =&amp;gt; &amp;quot;Hrvatski&amp;quot;, &#039;code&#039; =&amp;gt; &#039;hr_HR&#039; ),            // Croatian&lt;br /&gt;
  &#039;hu&#039; =&amp;gt; array( &#039;name&#039; =&amp;gt; &amp;quot;magyar&amp;quot;, &#039;code&#039; =&amp;gt; &#039;hu_HU&#039; ),              // Hungarian&lt;br /&gt;
  &#039;id&#039; =&amp;gt; array( &#039;name&#039; =&amp;gt; &amp;quot;Bahasa Indonesia&amp;quot;, &#039;code&#039; =&amp;gt; &#039;id_ID&#039; ),    // Indonesian&lt;br /&gt;
  &#039;ms&#039; =&amp;gt; array( &#039;name&#039; =&amp;gt; &amp;quot;Bahasa Malaysia&amp;quot;, &#039;code&#039; =&amp;gt; &#039;ms_MY&#039; ),     // Malaysian&lt;br /&gt;
  &#039;it&#039; =&amp;gt; array( &#039;name&#039; =&amp;gt; &amp;quot;italiano&amp;quot;, &#039;code&#039; =&amp;gt; &#039;it_IT&#039; ),            // Italian&lt;br /&gt;
  &#039;ja&#039; =&amp;gt; array( &#039;name&#039; =&amp;gt; &amp;quot;日本語&amp;quot;, &#039;code&#039; =&amp;gt; &#039;ja_JP&#039; ),               // Japanese&lt;br /&gt;
  &#039;jv&#039; =&amp;gt; array( &#039;name&#039; =&amp;gt; &amp;quot;Basa Jawa&amp;quot;, &#039;code&#039; =&amp;gt; &#039;jv_JV&#039; ),           // Javanese                       &lt;br /&gt;
  &#039;ko&#039; =&amp;gt; array( &#039;name&#039; =&amp;gt; &amp;quot;한국어&amp;quot;, &#039;code&#039; =&amp;gt; &#039;ko_KR&#039; ),               // Korean&lt;br /&gt;
  &#039;lt&#039; =&amp;gt; array( &#039;name&#039; =&amp;gt; &amp;quot;lietuvių&amp;quot;, &#039;code&#039; =&amp;gt; &#039;lt_LT&#039; ),            // Lithuanian&lt;br /&gt;
  &#039;lv&#039; =&amp;gt; array( &#039;name&#039; =&amp;gt; &amp;quot;latviešu&amp;quot;, &#039;code&#039; =&amp;gt; &#039;lv_LV&#039; ),            // Latvian&lt;br /&gt;
  &#039;nl&#039; =&amp;gt; array( &#039;name&#039; =&amp;gt; &amp;quot;nederlands&amp;quot;, &#039;code&#039; =&amp;gt; &#039;nl_NL&#039; ),          // Dutch&lt;br /&gt;
  &#039;no&#039; =&amp;gt; array( &#039;name&#039; =&amp;gt; &amp;quot;norsk&amp;quot;, &#039;code&#039; =&amp;gt; &#039;nb_NO&#039; ),               // Norwegian&lt;br /&gt;
  &#039;oc&#039; =&amp;gt; array( &#039;name&#039; =&amp;gt; &amp;quot;occitan&amp;quot;, &#039;code&#039; =&amp;gt; &#039;oc_FR&#039; ),             // Occitan&lt;br /&gt;
  &#039;pl&#039; =&amp;gt; array( &#039;name&#039; =&amp;gt; &amp;quot;polski&amp;quot;, &#039;code&#039; =&amp;gt; &#039;pl_PL&#039; ),              // Polish&lt;br /&gt;
  &#039;pt&#039; =&amp;gt; array( &#039;name&#039; =&amp;gt; &amp;quot;português&amp;quot;,  &#039;code&#039; =&amp;gt; &#039;pt_PT&#039; ),          // Portuguese&lt;br /&gt;
  &#039;ro&#039; =&amp;gt; array( &#039;name&#039; =&amp;gt; &amp;quot;română&amp;quot;,  &#039;code&#039; =&amp;gt; &#039;ro_RO&#039;  ),            // Romanian&lt;br /&gt;
  &#039;ru&#039; =&amp;gt; array( &#039;name&#039; =&amp;gt; &amp;quot;Русский язык&amp;quot;, &#039;code&#039; =&amp;gt; &#039;ru_RU&#039; ),        // Russian&lt;br /&gt;
  &#039;sk&#039; =&amp;gt; array( &#039;name&#039; =&amp;gt; &amp;quot;slovenčina&amp;quot;, &#039;code&#039; =&amp;gt; &#039;sk_SK&#039; ),          // Slovak&lt;br /&gt;
  &#039;sl&#039; =&amp;gt; array( &#039;name&#039; =&amp;gt; &amp;quot;slovenščina&amp;quot;, &#039;code&#039; =&amp;gt; &#039;sl_SI&#039; ),         // Slovenian       &lt;br /&gt;
  &#039;sr&#039; =&amp;gt; array( &#039;name&#039; =&amp;gt; &amp;quot;Српски&amp;quot;, &#039;code&#039; =&amp;gt; &#039;sr_RS&#039; ),              // Serbian       &lt;br /&gt;
  &#039;sv&#039; =&amp;gt; array( &#039;name&#039; =&amp;gt; &amp;quot;svenska&amp;quot;, &#039;code&#039; =&amp;gt; &#039;sv_SE&#039; ),             // Swedish&lt;br /&gt;
  &#039;tr&#039; =&amp;gt; array( &#039;name&#039; =&amp;gt; &amp;quot;Türkçe&amp;quot;, &#039;code&#039; =&amp;gt; &#039;tr_TR&#039; ),              // Turkish       &lt;br /&gt;
  &#039;uk&#039; =&amp;gt; array( &#039;name&#039; =&amp;gt; &amp;quot;Українська мова&amp;quot;, &#039;code&#039; =&amp;gt; &#039;uk_UA&#039; ),     // Ukrainian&lt;br /&gt;
  &#039;zh&#039; =&amp;gt; array( &#039;name&#039; =&amp;gt; &amp;quot;中文 (漢)&amp;quot;,  &#039;code&#039; =&amp;gt; &#039;zh_TW&#039; ),           // Traditional Chinese (Hong Kong, Macau, Taiwan)&lt;br /&gt;
  &#039;zh-cn&#039; =&amp;gt; array( &#039;name&#039; =&amp;gt; &amp;quot;中文 (汉)&amp;quot;, &#039;code&#039; =&amp;gt; &#039;zh_CN&#039; ),         // Simplified Chinese (Mainland China, Singapore)&lt;br /&gt;
&lt;br /&gt;
== Debugging and Tracing ==&lt;br /&gt;
&lt;br /&gt;
To debug php code you can use some tracing functions available from the parent class such as debug, trace, error, warn, dump.&lt;br /&gt;
  &lt;br /&gt;
  self::debug(&amp;quot;Ahh!&amp;quot;);&lt;br /&gt;
  self::dump(&#039;my_var&#039;,$my_var);&lt;br /&gt;
&lt;br /&gt;
See [[Practical_debugging]] section for complete information about debugging interfaces and where to find logs.&lt;br /&gt;
&lt;br /&gt;
[[Category:Studio]]&lt;/div&gt;</summary>
		<author><name>Fenadoruk</name></author>
	</entry>
	<entry>
		<id>https://en.doc.boardgamearena.com/index.php?title=Studio_logs&amp;diff=19585</id>
		<title>Studio logs</title>
		<link rel="alternate" type="text/html" href="https://en.doc.boardgamearena.com/index.php?title=Studio_logs&amp;diff=19585"/>
		<updated>2024-01-17T09:21:47Z</updated>

		<summary type="html">&lt;p&gt;Fenadoruk: /* BGA request&amp;amp;SQL logs */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Studio_Framework_Navigation}}&lt;br /&gt;
&lt;br /&gt;
Logs allows you to check out what happened recently on server and to debug your game.&lt;br /&gt;
&lt;br /&gt;
BGA Studio logs are available directly from your game development interface. You can also navigate to them: https://studio.boardgamearena.com/1/mygame/mygame/logaccess.html?table=######, where you replace mygame and ###### accordingly.&lt;br /&gt;
&lt;br /&gt;
== BGA request&amp;amp;SQL logs ==&lt;br /&gt;
&lt;br /&gt;
This log is useful:&lt;br /&gt;
* When you want to check what SQL requests has been built during a request.&lt;br /&gt;
* When you want to debug your PHP code using &amp;quot;self::trace&amp;quot;&lt;br /&gt;
* When you want to know why a request takes too much time.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On this log, you can see:&lt;br /&gt;
&lt;br /&gt;
=== Your requests ===&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
  20/06 21:50:56 [info] [T403] [4/mytest0] /cinco/cinco/exchange4Cards.html?id=4&amp;amp;lock=97d1c7a1-903a-4d1f-8206-de39ce8204fc&amp;amp;table=403&amp;amp;testuser=4&amp;amp;dojo.preventCache=1371757856044&lt;br /&gt;
&lt;br /&gt;
Note that the best way to check your Ajax request is to read the [[http://en.doc.boardgamearena.com/Tools_and_tips_of_BGA_Studio#Input.2FOutput_debugging_section Input/Output section]].&lt;br /&gt;
&lt;br /&gt;
=== Request responses ===&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
  20/06 21:50:56 [notice] [T403] [4/mytest0] OK-0 169 d141 c8 e0 I9 A158 V0 T0 /cinco/cinco/exchange4Cards.html?id=4&amp;amp;lock=97d1c7a1-903a-4d1f-8206-de39ce8204fc&amp;amp;table=403&amp;amp;testuser=4&amp;amp;dojo.preventCache=1371757856044&lt;br /&gt;
&lt;br /&gt;
You can recognize a response because it contains [notice]. Usually, there is one response for each request.&lt;br /&gt;
&lt;br /&gt;
Let&#039;s details the beginning of the log:&lt;br /&gt;
* 20/06 21:50:56: the date&lt;br /&gt;
* [notice]&lt;br /&gt;
* [T403]: this is a log from table 403&lt;br /&gt;
* [4/mytest0]: this is use &amp;quot;mytest0&amp;quot;, with id 4&lt;br /&gt;
* OK-0: it means that the request ended up successfully, with no exception (expected or unexpected).&lt;br /&gt;
* 169: this is the time taken to process the request (169ms).&lt;br /&gt;
* d141: this is the total Database time used to process the request (141ms).&lt;br /&gt;
&lt;br /&gt;
=== SQL requests ===&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
  20/06 21:50:56 [info] [T403] [4/mytest0] 0.26 SELECT player_tokenColor FROM player WHERE player_id =&#039;4&#039;&lt;br /&gt;
&lt;br /&gt;
All requests to Database are traced in this log. You can see here the time take by the request (0,26ms).&lt;br /&gt;
&lt;br /&gt;
=== Custom trace ===&lt;br /&gt;
&lt;br /&gt;
You can use special PHP methods in your PHP code to left some trace in this log:&lt;br /&gt;
* self::trace( &amp;quot;your message here&amp;quot; );    // Display &amp;quot;your message here&amp;quot; in the log&lt;br /&gt;
* self::dump( &amp;quot;My variable&amp;quot;, $variable_to_dump );   // Display the content of $variable_to_dump in the log&lt;br /&gt;
&lt;br /&gt;
== BGA unexpected exceptions logs ==&lt;br /&gt;
&lt;br /&gt;
In this log you can check the last Unexpected exceptions from your game.&lt;br /&gt;
&lt;br /&gt;
Exceptions management on PHP side [[http://en.doc.boardgamearena.com/Main_game_logic:_yourgamename.game.php#Managing_errors_and_exceptions is described here]].&lt;br /&gt;
&lt;br /&gt;
The log displayed the complete stacktrace of the exception, so you can debug it.&lt;br /&gt;
&lt;br /&gt;
The SQL log is very verbose and sometimes it too hard to extract your tracing from it, in this case you can use error log for tracing temporarily.&lt;br /&gt;
You can add debug statement using self::warn() which will appear in that the log. Do not leave these tracing method calls after you done debugging unless they&lt;br /&gt;
are real warnings or errors (only the error log level will appear in production).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Studio]]&lt;/div&gt;</summary>
		<author><name>Fenadoruk</name></author>
	</entry>
	<entry>
		<id>https://en.doc.boardgamearena.com/index.php?title=Tutorial_hearts&amp;diff=19513</id>
		<title>Tutorial hearts</title>
		<link rel="alternate" type="text/html" href="https://en.doc.boardgamearena.com/index.php?title=Tutorial_hearts&amp;diff=19513"/>
		<updated>2024-01-11T08:58:37Z</updated>

		<summary type="html">&lt;p&gt;Fenadoruk: /* Full game model synchronisation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Studio_Framework_Navigation}}&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Using this tutorial, you can build a complete working game on the BGA environment: Hearts.&lt;br /&gt;
&lt;br /&gt;
Before you read this tutorial, you must:&lt;br /&gt;
* Read the overall presentations of the BGA Framework ([[Studio|see here]]).&lt;br /&gt;
* Know the rules for Hearts&lt;br /&gt;
* Some-what know the languages used on BGA: PHP, SQL, HTML, CSS, Javascript&lt;br /&gt;
* Set up your development environment [http://en.doc.boardgamearena.com/First_steps_with_BGA_Studio First Steps with BGA Studio]&lt;br /&gt;
* As part of setup you have to have access to your ftp home folder in studio, which would have the full &#039;hearts&#039; game source code. We will be using some resources of this game in this tutorial, so copy it over to local disk if you have not done so.&lt;br /&gt;
&lt;br /&gt;
If you are stuck or have question about this tutorial, post on [https://forum.boardgamearena.com/viewforum.php?f=12 BGA Developers forum]&lt;br /&gt;
&lt;br /&gt;
== Create your first game ==&lt;br /&gt;
&lt;br /&gt;
If you have not already, you have to create a project in BGA Studio. For this tutorial you can create a project heartsYOURNAME where&lt;br /&gt;
YOURNAME is your developer login name. You can also re-use the project you have created for the &amp;quot;First Steps&amp;quot; tutorial above.&lt;br /&gt;
With the initial skeleton of code provided, you can already start a game from the BGA Studio. &lt;br /&gt;
&lt;br /&gt;
1. Find and express start the game in turn-based mode with 4 players. Make sure it works. If you want to see the game as 2nd player press red arrow button on the player panel to switch to that player. More details can be found in [[First_steps_with_BGA_Studio]]&lt;br /&gt;
&lt;br /&gt;
2. Modify the text in heartsYOURNAME_heartsYOURNAME.tpl, reload the page in the browser and make sure your ftp sync works as expected.&lt;br /&gt;
Note: if you have not setup auto-sync do it now, manually copying files is a no-starter.&lt;br /&gt;
&lt;br /&gt;
3. Express stop from settings menu (the gear icon).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;Note: please do &#039;&#039;&#039;not&#039;&#039;&#039; use the hearts project code as a base. This tutorial assumes you started with a TEMPLATE project with no prior modifications. Using the hearts project as a base will be very confusing and you won&#039;t be able to follow all the steps.&lt;br /&gt;
&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Attention!!!&amp;lt;/b&amp;gt; Very important note about reloading, if you don&#039;t remember this you may spent hours debugging. Browser caches .css files and images. If you change any of these files you have to do &amp;quot;full reload&amp;quot; which is usually Ctrl+F5 (or Ctrl+reload button on browser) not just a regular reload.&lt;br /&gt;
&lt;br /&gt;
== Hook version control system ==&lt;br /&gt;
&lt;br /&gt;
For a real game, or even for this tutorial, we recommend committing the code to version control right from the start. You are going to find yourself in a situation where the game doesn&#039;t even start anymore and no way of debugging it, unless you have a way to revert. That is where version control becomes very handy. If you are not familiar with version control (e.g. [https://git-scm.com/docs/gittutorial git]) then at least back up your files after each major change. Start now.&lt;br /&gt;
&lt;br /&gt;
Code for this tutorial available is on github: https://github.com/elaskavaia/bga-heartsla&lt;br /&gt;
&lt;br /&gt;
Different revisions represent different steps along the process, starting from original template to a PARTIAL game. The full game can be found in your FTP home folder.&lt;br /&gt;
&lt;br /&gt;
== Update game infos and box graphics ==&lt;br /&gt;
&lt;br /&gt;
Even it does nothing yet, always start by making sure the game looks decent in the game selector, meaning it has nice box graphics and its information is correct. For that we need to edit [[Game_meta-information: gameinfos.inc.php|gameinfos.inc.php]].&lt;br /&gt;
&lt;br /&gt;
For a real game, you would go to [http://boardgamegeek.com BoardGameGeek], find the game, and use the information from BGG to fill in the gameinfos.&lt;br /&gt;
&lt;br /&gt;
So let&#039;s do that. Find &amp;quot;hearts&amp;quot; on BoardGameGeek. (Hint: Original release 1850 :))&lt;br /&gt;
&lt;br /&gt;
You can fill in the year of publishing and bgg id, put &#039;&#039;Public Domain&#039;&#039; under publisher (for a real game, leave an empty string so it won&#039;t be displayed), and a publisher id of 171 for public domain. And as designer and author you can just put your own name just for fun. Set number of players to 4.&lt;br /&gt;
&lt;br /&gt;
  // Players configuration that can be played (ex: 2 to 4 players)&lt;br /&gt;
  &#039;players&#039; =&amp;gt; array( 4 ),  &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Important step&#039;&#039;&#039;: you have to refresh the information in the Studio website through the control panel. So go to Control Panel -&amp;gt; Manage Games -&amp;gt; heartsYOURNAME&lt;br /&gt;
and press Reload for &#039;Reload game informations&#039;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The next step would be to replace &#039;&#039;&#039;game_box.png&#039;&#039;&#039; with nicer images. This can be done from the [[Game metadata manager]]. &lt;br /&gt;
&lt;br /&gt;
Now try to start the game again. If you somehow introduced a syntax error in the gameinfos file it may not work (the game won&#039;t start).&lt;br /&gt;
Always use the &amp;quot;Express Start&amp;quot; button to start the game. You should see a standard state prompt from the template. You should see 4 players on the right: testdude0 .. testdude3.&lt;br /&gt;
To switch between them press the red arrow button near their names, it will open another tab. This way you don&#039;t need to login and logout from multiple accounts!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;Note: if you had run the game before with less than 4 players there is a bug that will prevent you from running it with 4 only (if you did not run it before or run it with 4 players as instructed stop reading this note), to workaround revert back to original players array (i.e. 1,2,3,4), reload game options, then create a table with 4 players, exit that game table, then change gameoptions to 4 only as above, reload game options, create table again.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Code Rev [https://github.com/elaskavaia/bga-heartsla/tree/4b3a73eeb5acae961ade18473af119e8ce8d1a8f]&lt;br /&gt;
&lt;br /&gt;
== Layout and Graphics ==&lt;br /&gt;
&lt;br /&gt;
In this section we will do graphics of the game, and main layout of the game.&lt;br /&gt;
&lt;br /&gt;
First copy a sprite with cards image from [https://github.com/elaskavaia/bga-heartsla/blob/4b3a73eeb5acae961ade18473af119e8ce8d1a8f/img/cards.jpg hearts img/cards.jpg]  into img/ folder of your project. Project hearts is mounted to your home directory on bga server.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;There are better quality deck of cards image at https://en.doc.boardgamearena.com/Common_board_game_elements_image_resources&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Details about images can be found here: [[Game art: img directory]].&lt;br /&gt;
&lt;br /&gt;
Edit .tpl to add some divs to represent player table and hand area&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;div id=&amp;quot;myhand_wrap&amp;quot; class=&amp;quot;whiteblock&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;h3&amp;gt;My Hand&amp;lt;/h3&amp;gt;&lt;br /&gt;
    &amp;lt;div id=&amp;quot;myhand&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you refresh you should see now white area with My Hand title.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Heartsla-tpl2.png]]&lt;br /&gt;
&lt;br /&gt;
Now lets add a card into the hand, just so you can feel it. Edit .tpl and a playertablecard div inside a hand div&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
    &amp;lt;div id=&amp;quot;myhand&amp;quot;&amp;gt;&lt;br /&gt;
       &amp;lt;div class=&amp;quot;playertablecard&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit .css file&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
.playertablecard {&lt;br /&gt;
    display: inline-block;&lt;br /&gt;
    position: relative;&lt;br /&gt;
    margin-top: 5px;&lt;br /&gt;
    width: 72px;&lt;br /&gt;
    height: 96px;&lt;br /&gt;
    background-image: url(&#039;img/cards.jpg&#039;); /* temp hack to see it */&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you edit CSS remember that you have to FORCE-reload page, i.e. Ctrl-F5, otherwise its cached.&lt;br /&gt;
&amp;lt;i&amp;gt;Same when you change existing graphics files&amp;lt;/i&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You should see this:&lt;br /&gt;
&lt;br /&gt;
[[File:Heartsla-tpl3.png]]&lt;br /&gt;
&lt;br /&gt;
Awesome! Now lets do the rest of layout.&lt;br /&gt;
&lt;br /&gt;
There are few ways of how html could have been generated, you could have start with nothing and generate&lt;br /&gt;
all by java script. Or you could have started with complete game markup in html and make java script just hide and move pieces around. BGA framework provides also a third way which is mix of both plus template engine to generate HTML using php. So lets do that.&lt;br /&gt;
&lt;br /&gt;
Change .tpl file to have this inside&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;div id=&amp;quot;playertables&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;!-- BEGIN playerhandblock --&amp;gt;&lt;br /&gt;
    &amp;lt;div class=&amp;quot;playertable whiteblock playertable_{DIR}&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;div class=&amp;quot;playertablename&amp;quot; style=&amp;quot;color:#{PLAYER_COLOR}&amp;quot;&amp;gt;&lt;br /&gt;
            {PLAYER_NAME}&lt;br /&gt;
        &amp;lt;/div&amp;gt;&lt;br /&gt;
        &amp;lt;div class=&amp;quot;playertablecard&amp;quot; id=&amp;quot;playertablecard_{PLAYER_ID}&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;!-- END playerhandblock --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;myhand_wrap&amp;quot; class=&amp;quot;whiteblock&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;h3&amp;gt;{MY_HAND}&amp;lt;/h3&amp;gt;&lt;br /&gt;
    &amp;lt;div id=&amp;quot;myhand&amp;quot;&amp;gt;&lt;br /&gt;
       &amp;lt;div class=&amp;quot;playertablecard&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What we did is we added &amp;quot;block&amp;quot; playerhandblock, it is marked up using html comments. {VAR} notation is used&lt;br /&gt;
to inject variables and &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  &amp;lt;!-- BEGIN xxx --&amp;gt; &lt;br /&gt;
   inside &lt;br /&gt;
  &amp;lt;!-- END xxx --&amp;gt; &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
effectively allows us to do template loops.&lt;br /&gt;
&lt;br /&gt;
In .view.php insert this code after &#039;Place your code below&#039; comment&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
        $template = self::getGameName() . &amp;quot;_&amp;quot; . self::getGameName();&lt;br /&gt;
        &lt;br /&gt;
        $directions = array( &#039;S&#039;, &#039;W&#039;, &#039;N&#039;, &#039;E&#039; );&lt;br /&gt;
        &lt;br /&gt;
        // this will inflate our player block with actual players data&lt;br /&gt;
        $this-&amp;gt;page-&amp;gt;begin_block($template, &amp;quot;playerhandblock&amp;quot;);&lt;br /&gt;
        foreach ( $players as $player_id =&amp;gt; $info ) {&lt;br /&gt;
            $dir = array_shift($directions);&lt;br /&gt;
            $this-&amp;gt;page-&amp;gt;insert_block(&amp;quot;playerhandblock&amp;quot;, array (&amp;quot;PLAYER_ID&amp;quot; =&amp;gt; $player_id,&lt;br /&gt;
                    &amp;quot;PLAYER_NAME&amp;quot; =&amp;gt; $players [$player_id] [&#039;player_name&#039;],&lt;br /&gt;
                    &amp;quot;PLAYER_COLOR&amp;quot; =&amp;gt; $players [$player_id] [&#039;player_color&#039;],&lt;br /&gt;
                    &amp;quot;DIR&amp;quot; =&amp;gt; $dir ));&lt;br /&gt;
        }&lt;br /&gt;
        // this will make our My Hand text translatable&lt;br /&gt;
        $this-&amp;gt;tpl[&#039;MY_HAND&#039;] = self::_(&amp;quot;My hand&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What it does is for each player we have it will replicate the html between &amp;lt;!-- BEGIN playerhandblock --&amp;gt; and &amp;lt;!-- END playerhandblock --&amp;gt; tags, substituting the variable denoted by {XXX}&lt;br /&gt;
with the values you provide. The DIR variable in this case we pulling from directions array (where array_shift will take first element and remove it from the array).&lt;br /&gt;
&lt;br /&gt;
Reload. If everything went well you should see this:&lt;br /&gt;
&lt;br /&gt;
[[File:Hearts all rows.png|alt=Display a list of all players, with a dummy card in each position]]&lt;br /&gt;
&lt;br /&gt;
These are &amp;quot;tableau&amp;quot; areas for 4 players plus My hand visible only to one player. They are not exactly how we wanted them to be because we did not edit .css yet.&lt;br /&gt;
&lt;br /&gt;
Now edit .css, add these lines after import before our previous definition&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/** Table layout **/&lt;br /&gt;
&lt;br /&gt;
#playertables {&lt;br /&gt;
    position: relative;&lt;br /&gt;
    width: 710px;&lt;br /&gt;
    height: 340px;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.playertablename {&lt;br /&gt;
    font-weight: bold;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.playertable {&lt;br /&gt;
    position: absolute;&lt;br /&gt;
    text-align: center;&lt;br /&gt;
    width: 180px;&lt;br /&gt;
    height: 130px;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.playertable_N {&lt;br /&gt;
    left: 50%;&lt;br /&gt;
    top: 0px;&lt;br /&gt;
    margin-left: -90px; /* half of 180 */&lt;br /&gt;
}&lt;br /&gt;
.playertable_S {&lt;br /&gt;
    left: 50%;&lt;br /&gt;
    bottom: 0px;&lt;br /&gt;
    margin-left: -90px; /* half of 180 */&lt;br /&gt;
}&lt;br /&gt;
.playertable_W {&lt;br /&gt;
    left: 0px;&lt;br /&gt;
    top: 50%;&lt;br /&gt;
    margin-top: -55px; /* half of 130 */&lt;br /&gt;
}&lt;br /&gt;
.playertable_E {&lt;br /&gt;
    right: 0px;&lt;br /&gt;
    top: 50%;&lt;br /&gt;
    margin-top: -55px; /* half of 130 */&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now you force Reload and you should see this:&lt;br /&gt;
[[File:Heartsla-tpl5.png]]&lt;br /&gt;
&lt;br /&gt;
This is almost all we need for graphics and layout, there are few tweaks left there but lets do some more heavy lifting now.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;Note: if you did not see changes you may have not force reloaded, force means you use Ctrl+F5 or Cltr+Shift-R, if you don&#039;t &amp;quot;force&amp;quot; browser will use cached version of .css and images! Which is not what you just changed&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;Another Note: In general if you have auto-sync you don&#039;t need to reload if you change game.php file, you need normal reload if you change js, and force reload for css and images. If you changed state machine or database you likely need to restart the game.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Game Interface JS Stock ==&lt;br /&gt;
&lt;br /&gt;
The BGA framework provides a few out of the box classes to deal with cards. The client side&lt;br /&gt;
contains a class called [[Stock]] and it can be used for any dynamic html &amp;quot;pieces&amp;quot; management that uses&lt;br /&gt;
common sprite images. On the server side we will use the [[Deck]] class which we discuss later.&lt;br /&gt;
&lt;br /&gt;
If you open cards.jpg in an image viewer you will see that it is a &amp;quot;sprite&amp;quot; image - a 13x4 grid of images stitched together,&lt;br /&gt;
which is a very efficient way to transport images. So we will use the Stock class to mark up these images and create&lt;br /&gt;
&amp;quot;card&amp;quot; divs for us.&lt;br /&gt;
&lt;br /&gt;
First, we need to add &#039;&#039;&#039;ebg/stock&#039;&#039;&#039; as a dependency in the hearts.js file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
define([&lt;br /&gt;
    &amp;quot;dojo&amp;quot;,&amp;quot;dojo/_base/declare&amp;quot;,&lt;br /&gt;
    &amp;quot;ebg/core/gamegui&amp;quot;,&lt;br /&gt;
    &amp;quot;ebg/counter&amp;quot;,&lt;br /&gt;
    &amp;quot;ebg/stock&amp;quot;     /// &amp;lt;==== HERE&lt;br /&gt;
],&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then add this to the Javascript constructor, this will define size of our cards&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
            console.log(&#039;hearts constructor&#039;);&lt;br /&gt;
            this.cardwidth = 72;&lt;br /&gt;
            this.cardheight = 96;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The stock is initialized in the Javascript &amp;quot;setup&amp;quot; method like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    // TODO: Set up your game interface here, according to &amp;quot;gamedatas&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    // Player hand&lt;br /&gt;
    this.playerHand = new ebg.stock(); // new stock object for hand&lt;br /&gt;
    this.playerHand.create( this, $(&#039;myhand&#039;), this.cardwidth, this.cardheight );&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As parameters of the &amp;quot;create&amp;quot; method, we provided the width/height of an item (a card), and the container div &amp;quot;myhand&amp;quot; - which is an id of &amp;quot;div&amp;quot; element from our .tpl file representing a player hand.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Then, we must tell the stock what items it is going to display during its life: the 52 cards of a standard card game from a CSS sprite image named &amp;quot;cards.jpg&amp;quot; with all the cards arranged in 4 rows and 13 columns.&lt;br /&gt;
&lt;br /&gt;
Here&#039;s how we tell stock what item types to display:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
            this.playerHand.image_items_per_row = 13; // 13 images per row&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
            // Create cards types:&lt;br /&gt;
            for (var color = 1; color &amp;lt;= 4; color++) {&lt;br /&gt;
                for (var value = 2; value &amp;lt;= 14; value++) {&lt;br /&gt;
                    // Build card type id&lt;br /&gt;
                    var card_type_id = this.getCardUniqueId(color, value);&lt;br /&gt;
                    this.playerHand.addItemType(card_type_id, card_type_id, g_gamethemeurl + &#039;img/cards.jpg&#039;, card_type_id);&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And add this function to the utilities section&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
        // Get card unique identifier based on its color and value&lt;br /&gt;
        getCardUniqueId : function(color, value) {&lt;br /&gt;
            return (color - 1) * 13 + (value - 2);&lt;br /&gt;
        },&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Explanations:&lt;br /&gt;
* At first, we tell the stock component that our CSS sprite contains 13 items per row. This way, it can find the correct image for each card type id.&lt;br /&gt;
* Then for the 4x13 cards, we call the &#039;&#039;&#039;addItemType&#039;&#039;&#039; method that creates the type. The arguments are the type id, the weight of the card (for sorting purpose), the URL of our CSS sprite, and the position of our card image in the CSS sprite. It happens to be the same number in our case.&lt;br /&gt;
&lt;br /&gt;
Note: we need to generate a unique ID for each type of card based on its color and value.  For that we create a function &#039;&#039;&#039;getCardUniqueId&#039;&#039;&#039;. The type is the unique identifier of the TYPE of the card, e.g., the queen of spades encoded as an integer. If our deck had 2 standard card decks we would have had 2 queens of spades; they would share the same type and the same image but would have different ids. NOTE: It&#039;s unfortunate that they named this &#039;&#039;&#039;getCardUniqueId&#039;&#039;&#039;; it should have been &#039;&#039;&#039;getCardUniqueType&#039;&#039;&#039;, because it really isn&#039;t an id, but a TYPE of card. The type of the item should either be a reversible function of its properties (i.e., kind of suite * 13 + value) or just an enumerator described in material.inc.php. In this specific case it&#039;s a synthetic type id, which also the same as the number of the card in the sprite image (i.e., if you enumerate each image in sprite going left to right, then top to bottom).&lt;br /&gt;
&lt;br /&gt;
Now let&#039;s add the 5 of Hearts to the player&#039;s hand just for fun (this code will go in setup method after types initialization):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// 2 = hearts, 5 is 5, and 42 is the card id, which normally would come from db&lt;br /&gt;
this.playerHand.addToStockWithId( this.getCardUniqueId( 2, 5 ), 42 );&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will add the card with id 42 and type 16 ( (2-1)*13+(5-2)=16 ). &lt;br /&gt;
&lt;br /&gt;
Note that number 16 would not be something you can see in database, Deck database will have separate field for type and type_arg where type is suite and type_arg is number, so its not the same thing, but you can use same formula to convert. Number 42 on the other hand would be id field in database. But we get to database in the later section.&lt;br /&gt;
&lt;br /&gt;
If you reload now you should see the 5 of hearts in &amp;quot;your hand&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Stock control can handle clicking on items and forms the selection. You can immediately react to selection&lt;br /&gt;
or you can query it later; for example when user presses some other button.&lt;br /&gt;
&lt;br /&gt;
Let&#039;s hook it up. Add this in the setup method in .js file, after this.playerHand is initialised:&lt;br /&gt;
&lt;br /&gt;
     dojo.connect( this.playerHand, &#039;onChangeSelection&#039;, this, &#039;onPlayerHandSelectionChanged&#039; );&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Then find the Player&#039;s action comment section in .js file and add a handler after the comment:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
        onPlayerHandSelectionChanged: function() {&lt;br /&gt;
            var items = this.playerHand.getSelectedItems();&lt;br /&gt;
&lt;br /&gt;
            if (items.length &amp;gt; 0) {&lt;br /&gt;
                if (this.checkAction(&#039;playCard&#039;, true)) {&lt;br /&gt;
                    // Can play a card&lt;br /&gt;
&lt;br /&gt;
                    var card_id = items[0].id;&lt;br /&gt;
                    console.log(&amp;quot;on playCard &amp;quot;+card_id);&lt;br /&gt;
&lt;br /&gt;
                    this.playerHand.unselectAll();&lt;br /&gt;
                } else if (this.checkAction(&#039;giveCards&#039;)) {&lt;br /&gt;
                    // Can give cards =&amp;gt; let the player select some cards&lt;br /&gt;
                } else {&lt;br /&gt;
                    this.playerHand.unselectAll();&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
        },&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The function name of the handler is 4th parameter of the dojo.connect function. Make sure you spell it correctly or there will be unpredictable effects.&lt;br /&gt;
&lt;br /&gt;
Now if you reload, open the Javascript Console (F12), and then click on the card in My Hand, you should see:&lt;br /&gt;
  on playCard 42&lt;br /&gt;
printed on the console&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note : You need to be the active player to have rights to play a card and so log your message in the console&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Game Database and Game Initialisation ==&lt;br /&gt;
&lt;br /&gt;
Next step, you want to design a game database and setup a new game (on the server side).&lt;br /&gt;
For that we need to a) modify the database schema to add our cards data b) add some global variables into&lt;br /&gt;
the existing globals table.&lt;br /&gt;
&lt;br /&gt;
To modify the schema, first exit your existing game(s). Open &#039;&#039;&#039;dbmodel.sql&#039;&#039;&#039; file and uncomment the card table creation.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CREATE TABLE IF NOT EXISTS `card` (&lt;br /&gt;
  `card_id` int(10) unsigned NOT NULL AUTO_INCREMENT,&lt;br /&gt;
  `card_type` varchar(16) NOT NULL,&lt;br /&gt;
  `card_type_arg` int(11) NOT NULL,&lt;br /&gt;
  `card_location` varchar(16) NOT NULL,&lt;br /&gt;
  `card_location_arg` int(11) NOT NULL,&lt;br /&gt;
  PRIMARY KEY (`card_id`)&lt;br /&gt;
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is the &amp;quot;card&amp;quot; table which will be managed by the Deck php class.&lt;br /&gt;
&lt;br /&gt;
In addition we want a little piece of information in the players table:&lt;br /&gt;
&lt;br /&gt;
  -- add info about first player&lt;br /&gt;
  ALTER TABLE `player` ADD `player_first` BOOLEAN NOT NULL DEFAULT &#039;0&#039;;&lt;br /&gt;
&lt;br /&gt;
Not sure why they put this into the player table, as we could use a global db variable to hold first player as easily.&lt;br /&gt;
But I am just following the existing code more-or-less.&lt;br /&gt;
&lt;br /&gt;
Next we finally get into .game.php class, where the main logic and db interaction would be. Find php constructor which should be &lt;br /&gt;
  function __construct( )&lt;br /&gt;
This is first function in a file. Add this code to constructor.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
        parent::__construct();&lt;br /&gt;
        self::initGameStateLabels( array( &lt;br /&gt;
                         &amp;quot;currentHandType&amp;quot; =&amp;gt; 10, &lt;br /&gt;
                         &amp;quot;trickColor&amp;quot; =&amp;gt; 11, &lt;br /&gt;
                         &amp;quot;alreadyPlayedHearts&amp;quot; =&amp;gt; 12,&lt;br /&gt;
                          ) );&lt;br /&gt;
&lt;br /&gt;
        $this-&amp;gt;cards = self::getNew( &amp;quot;module.common.deck&amp;quot; );&lt;br /&gt;
        $this-&amp;gt;cards-&amp;gt;init( &amp;quot;card&amp;quot; );&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here we are initializing three &amp;quot;Game State Variables&amp;quot; which are variables stored in the database. They are integers.&lt;br /&gt;
It must start with values higher or equal to 10 since values lower than 10 are reserved. These values are stored by numeric ids&lt;br /&gt;
in the database, but in the php we associate them with string labels for convenience of access. The variables are &amp;quot;trickColor&amp;quot;: numbers from 1 to 4 that map to card suit (not sure why it&#039;s called color; maybe it&#039;s a translation from French); &amp;quot;alreadyPlayedHearts&amp;quot;: a boolean flag (0 or 1) indicating whether somebody used hearts on the trick; &amp;quot;currentHandType&amp;quot;: stores the value to indicate who to give cards to during exchange.&lt;br /&gt;
&lt;br /&gt;
The next 2 lines are creating $this-&amp;gt;cards object and associating it with &amp;quot;card&amp;quot; table in the the database.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;If we called db table &#039;foo&#039; instead of &#039;card&#039; the last statement would have been  $this-&amp;gt;cards-&amp;gt;init( &amp;quot;foo&amp;quot; )&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
At this point I would start a new game and make sure it starts, then exit. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;&lt;br /&gt;
If you made a mistake&lt;br /&gt;
in the .sql or php constructor the game won&#039;t start, and good luck debugging it. (That is why it&#039;s important to check&lt;br /&gt;
once in a while to make sure it still starts while you remember what you have changed.)&lt;br /&gt;
&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Code Rev [https://github.com/elaskavaia/bga-heartsla/tree/e3a049257b592ff6167688d4d344f8a83d349b08]&lt;br /&gt;
&lt;br /&gt;
Now we can go to game initialization &#039;&#039;&#039;setupNewGame&#039;&#039;&#039; in game.php. This method is called only once when the game is created.&lt;br /&gt;
&lt;br /&gt;
In your template project you should have code that deals with player table, just leave it as is. Start inserting the&lt;br /&gt;
other code after &amp;quot;Start the game initialization&amp;quot; comment.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
        // Init global values with their initial values&lt;br /&gt;
&lt;br /&gt;
        // Note: hand types: 0 = give 3 cards to player on the left&lt;br /&gt;
        //                   1 = give 3 cards to player on the right&lt;br /&gt;
        //                   2 = give 3 cards to player opposite&lt;br /&gt;
        //                   3 = keep cards&lt;br /&gt;
        self::setGameStateInitialValue( &#039;currentHandType&#039;, 0 );&lt;br /&gt;
        &lt;br /&gt;
        // Set current trick color to zero (= no trick color)&lt;br /&gt;
        self::setGameStateInitialValue( &#039;trickColor&#039;, 0 );&lt;br /&gt;
        &lt;br /&gt;
        // Mark if we already played hearts during this hand&lt;br /&gt;
        self::setGameStateInitialValue( &#039;alreadyPlayedHearts&#039;, 0 );&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here we initialize all the globals to 0.&lt;br /&gt;
&lt;br /&gt;
Next is to create our cards in the database. We have one deck of cards so it&#039;s pretty simple.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
        // Create cards&lt;br /&gt;
        $cards = array ();&lt;br /&gt;
        foreach ( $this-&amp;gt;colors as $color_id =&amp;gt; $color ) {&lt;br /&gt;
            // spade, heart, diamond, club&lt;br /&gt;
            for ($value = 2; $value &amp;lt;= 14; $value ++) {&lt;br /&gt;
                //  2, 3, 4, ... K, A&lt;br /&gt;
                $cards [] = array (&#039;type&#039; =&amp;gt; $color_id,&#039;type_arg&#039; =&amp;gt; $value,&#039;nbr&#039; =&amp;gt; 1 );&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
        $this-&amp;gt;cards-&amp;gt;createCards( $cards, &#039;deck&#039; );&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This code that will create one of each card. But don&#039;t run it yet, because we missing $this-&amp;gt;colors.&lt;br /&gt;
So we have state of the game in the database, but there is some static game information which never changes.&lt;br /&gt;
This information should be stored in material.inc.php and this way it can be accessed from all .php files (and .js if you send it via getAllDatas()).&lt;br /&gt;
We will edit this file now by adding these lines&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$this-&amp;gt;colors = array(&lt;br /&gt;
    1 =&amp;gt; array( &#039;name&#039; =&amp;gt; clienttranslate(&#039;spade&#039;),&lt;br /&gt;
                &#039;nametr&#039; =&amp;gt; self::_(&#039;spade&#039;) ),&lt;br /&gt;
    2 =&amp;gt; array( &#039;name&#039; =&amp;gt; clienttranslate(&#039;heart&#039;),&lt;br /&gt;
                &#039;nametr&#039; =&amp;gt; self::_(&#039;heart&#039;) ),&lt;br /&gt;
    3 =&amp;gt; array( &#039;name&#039; =&amp;gt; clienttranslate(&#039;club&#039;),&lt;br /&gt;
                &#039;nametr&#039; =&amp;gt; self::_(&#039;club&#039;) ),&lt;br /&gt;
    4 =&amp;gt; array( &#039;name&#039; =&amp;gt; clienttranslate(&#039;diamond&#039;),&lt;br /&gt;
                &#039;nametr&#039; =&amp;gt; self::_(&#039;diamond&#039;) )&lt;br /&gt;
);&lt;br /&gt;
&lt;br /&gt;
$this-&amp;gt;values_label = array(&lt;br /&gt;
    2 =&amp;gt;&#039;2&#039;,&lt;br /&gt;
    3 =&amp;gt; &#039;3&#039;,&lt;br /&gt;
    4 =&amp;gt; &#039;4&#039;,&lt;br /&gt;
    5 =&amp;gt; &#039;5&#039;,&lt;br /&gt;
    6 =&amp;gt; &#039;6&#039;,&lt;br /&gt;
    7 =&amp;gt; &#039;7&#039;,&lt;br /&gt;
    8 =&amp;gt; &#039;8&#039;,&lt;br /&gt;
    9 =&amp;gt; &#039;9&#039;,&lt;br /&gt;
    10 =&amp;gt; &#039;10&#039;,&lt;br /&gt;
    11 =&amp;gt; clienttranslate(&#039;J&#039;),&lt;br /&gt;
    12 =&amp;gt; clienttranslate(&#039;Q&#039;),&lt;br /&gt;
    13 =&amp;gt; clienttranslate(&#039;K&#039;),&lt;br /&gt;
    14 =&amp;gt; clienttranslate(&#039;A&#039;)&lt;br /&gt;
);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where $this-&amp;gt;colors will define Suit labels and $this-&amp;gt;values_label will define value labels.&lt;br /&gt;
If you noticed, we have two of each label for suits. This is because sometimes we need translated values on the php&lt;br /&gt;
side and sometimes we don&#039;t. In this case &#039;&#039;&#039;nametr&#039;&#039;&#039; will return a translated value in php, which is only useful when you throw exceptions to show the right strings. If you pass a value to the client via notification you should always use untranslated strings, and the client will translate it. &#039;clienttranslate&#039; marks the value for translation but does not actually change it for php. For more about this wonderful translation stuff see [[Translations]].&lt;br /&gt;
&lt;br /&gt;
== Full game model synchronisation ==&lt;br /&gt;
&lt;br /&gt;
Now at any point in the game we need to make sure that database information can be reflected back in the UI, so we must fix the &#039;&#039;&#039;getAllDatas&#039;&#039;&#039; function&lt;br /&gt;
to return all possible data we need to reconstruct the game. This is in the game.php file. The template for getAllDatas() already takes care of player info. Let&#039;s just&lt;br /&gt;
add hand and tableau data before we return a result.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
        // Cards in player hand&lt;br /&gt;
        $result[&#039;hand&#039;] = $this-&amp;gt;cards-&amp;gt;getCardsInLocation( &#039;hand&#039;, $current_player_id );&lt;br /&gt;
        &lt;br /&gt;
        // Cards played on the table&lt;br /&gt;
        $result[&#039;cardsontable&#039;] = $this-&amp;gt;cards-&amp;gt;getCardsInLocation( &#039;cardsontable&#039; );&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now on the client side we should display this data, so in your .js file in the setup function (which is the receiver of getAllDatas) replace our hack of putting 5 of Hearts directly into the hand with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
            // Cards in player&#039;s hand&lt;br /&gt;
            for ( var i in this.gamedatas.hand) {&lt;br /&gt;
                var card = this.gamedatas.hand[i];&lt;br /&gt;
                var color = card.type;&lt;br /&gt;
                var value = card.type_arg;&lt;br /&gt;
                this.playerHand.addToStockWithId(this.getCardUniqueId(color, value), card.id);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            // Cards played on table&lt;br /&gt;
            for (i in this.gamedatas.cardsontable) {&lt;br /&gt;
                var card = this.gamedatas.cardsontable[i];&lt;br /&gt;
                var color = card.type;&lt;br /&gt;
                var value = card.type_arg;&lt;br /&gt;
                var player_id = card.location_arg;&lt;br /&gt;
                this.playCardOnTable(player_id, color, value, card.id);&lt;br /&gt;
            }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This should show hand and tableau cards now, except we are missing the &#039;&#039;&#039;playCardOnTable&#039;&#039;&#039; function. So find the &#039;&#039;&#039;getCardUniqueId&#039;&#039;&#039; function which&lt;br /&gt;
should be in the utilities section and add this after it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
        playCardOnTable : function(player_id, color, value, card_id) {&lt;br /&gt;
            // player_id =&amp;gt; direction&lt;br /&gt;
            dojo.place(this.format_block(&#039;jstpl_cardontable&#039;, {&lt;br /&gt;
                x : this.cardwidth * (value - 2),&lt;br /&gt;
                y : this.cardheight * (color - 1),&lt;br /&gt;
                player_id : player_id&lt;br /&gt;
            }), &#039;playertablecard_&#039; + player_id);&lt;br /&gt;
&lt;br /&gt;
            if (player_id != this.player_id) {&lt;br /&gt;
                // Some opponent played a card&lt;br /&gt;
                // Move card from player panel&lt;br /&gt;
                this.placeOnObject(&#039;cardontable_&#039; + player_id, &#039;overall_player_board_&#039; + player_id);&lt;br /&gt;
            } else {&lt;br /&gt;
                // You played a card. If it exists in your hand, move card from there and remove&lt;br /&gt;
                // corresponding item&lt;br /&gt;
&lt;br /&gt;
                if ($(&#039;myhand_item_&#039; + card_id)) {&lt;br /&gt;
                    this.placeOnObject(&#039;cardontable_&#039; + player_id, &#039;myhand_item_&#039; + card_id);&lt;br /&gt;
                    this.playerHand.removeFromStockById(card_id);&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            // In any case: move it to its final destination&lt;br /&gt;
            this.slideToObject(&#039;cardontable_&#039; + player_id, &#039;playertablecard_&#039; + player_id).play();&lt;br /&gt;
        },&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For this to work we also need to add a card template in the .tpl file&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// Javascript HTML templates&lt;br /&gt;
&lt;br /&gt;
var jstpl_cardontable = &#039;&amp;lt;div class=&amp;quot;cardontable&amp;quot; id=&amp;quot;cardontable_${player_id}&amp;quot; style=&amp;quot;background-position:-${x}px -${y}px&amp;quot;&amp;gt;\&lt;br /&gt;
                        &amp;lt;/div&amp;gt;&#039;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
What this does is basically create another card object, because if it is not our card it&#039;s not in our hand (Stock) so&lt;br /&gt;
we have to create it out of thin air. The technique to do that is to implement a Javascript template object defined in the .tpl file with some&lt;br /&gt;
parameters, which will basically create a &amp;quot;div&amp;quot; string (yes you could have used string concatenation but it would not be fancy).&lt;br /&gt;
Now dojo.place places it (the div) on top of a placeholder. Now we have an object with an id of &#039;cardontable_&#039; + player_id. Depending&lt;br /&gt;
on who is playing it we either place it on the player miniboard or in hand (and remove it from hand stock). Then we animate the card move.&lt;br /&gt;
&lt;br /&gt;
We also should fix our .css file now to add style for cardontable and REMOVE background for playertablecard which really is a placeholder div and not a card. (Don&#039;t miss the remove step; it will be all screwy if you do!)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
.playertablecard {&lt;br /&gt;
    display: inline-block;&lt;br /&gt;
    position: relative;&lt;br /&gt;
    margin-top: 5px;&lt;br /&gt;
    width: 72px;&lt;br /&gt;
    height: 96px;&lt;br /&gt;
    /* we remove background-image here */&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/*** cards on table ***/&lt;br /&gt;
&lt;br /&gt;
.cardontable {&lt;br /&gt;
    position: absolute;&lt;br /&gt;
    width: 72px;&lt;br /&gt;
    height: 96px;&lt;br /&gt;
    background-image: url(&#039;img/cards.jpg&#039;); &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now to test that it actually works let&#039;s deal cards to players during game initialization:&lt;br /&gt;
&lt;br /&gt;
Add this after createCards in setupNewGame function in the game.php file&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
        // Shuffle deck&lt;br /&gt;
        $this-&amp;gt;cards-&amp;gt;shuffle(&#039;deck&#039;);&lt;br /&gt;
        // Deal 13 cards to each players&lt;br /&gt;
        $players = self::loadPlayersBasicInfos();&lt;br /&gt;
        foreach ( $players as $player_id =&amp;gt; $player ) {&lt;br /&gt;
            $cards = $this-&amp;gt;cards-&amp;gt;pickCards(13, &#039;deck&#039;, $player_id);&lt;br /&gt;
        } &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now when you start the game you should see 13 cards in your hand!&lt;br /&gt;
&lt;br /&gt;
We just need to hook-up clicking on card and test if our playCardOnTable works.&lt;br /&gt;
&lt;br /&gt;
Find onPlayerHandSelectionChanged function in the JS file, we should have logging there like  console.log(&amp;quot;on playCard &amp;quot;+card_id);&lt;br /&gt;
So after that insert this (Note: this code is for testing we will replace it with server interaction after we test it.):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
                    console.log(&amp;quot;on playCard &amp;quot;+card_id);&lt;br /&gt;
                    // type is (color - 1) * 13 + (value - 2)&lt;br /&gt;
                    var type = items[0].type;&lt;br /&gt;
                    var color = Math.floor(type / 13) + 1;&lt;br /&gt;
                    var value = type % 13 + 2;&lt;br /&gt;
                    &lt;br /&gt;
                    this.playCardOnTable(this.player_id,color,value,card_id);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now if you force reload (because we changed .css before) you should be able to click on card from your hand and see it moving,&lt;br /&gt;
you can click on few cards this way. When you done enjoying the animation, press F5 to get your hand back.&lt;br /&gt;
&lt;br /&gt;
[[File:Heartsla-sync.png]]&lt;br /&gt;
&lt;br /&gt;
Code Rev [https://github.com/elaskavaia/bga-heartsla/tree/01d4e2f595fd14c2adcc97a957d21bb2766f78a8]&lt;br /&gt;
&lt;br /&gt;
== State Machine ==&lt;br /&gt;
&lt;br /&gt;
Now we need to create a game state machine. So the states are (excluding two more states we will add later to handle the exchange of cards at the beginning of the rounds):&lt;br /&gt;
&lt;br /&gt;
* Cards are dealt to all players (lets call it &amp;quot;newHand&amp;quot;)&lt;br /&gt;
* Player is selected who will start a new trick (&amp;quot;newTrick&amp;quot;)&lt;br /&gt;
* Player start or respond to played card (&amp;quot;playerTurn&amp;quot;)&lt;br /&gt;
* Game control is passed to next player or trick is ended (&amp;quot;nextPlayer&amp;quot;)&lt;br /&gt;
* End of hand processing (scoring and check for end of game) (&amp;quot;nextHand&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The state handling spread across 4 files, so you have to make sure all pieces are connected together.&lt;br /&gt;
The state machine states.php defines all the states, and function handlers on php side in a form of string,&lt;br /&gt;
and if any of these functions are not implemented it would be very hard to debug because it will break in random places.&lt;br /&gt;
&lt;br /&gt;
So .states.php&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$machinestates = array(&lt;br /&gt;
&lt;br /&gt;
    // The initial state. Please do not modify.&lt;br /&gt;
    1 =&amp;gt; array(&lt;br /&gt;
        &amp;quot;name&amp;quot; =&amp;gt; &amp;quot;gameSetup&amp;quot;,&lt;br /&gt;
        &amp;quot;description&amp;quot; =&amp;gt; clienttranslate(&amp;quot;Game setup&amp;quot;),&lt;br /&gt;
        &amp;quot;type&amp;quot; =&amp;gt; &amp;quot;manager&amp;quot;,&lt;br /&gt;
        &amp;quot;action&amp;quot; =&amp;gt; &amp;quot;stGameSetup&amp;quot;,&lt;br /&gt;
        &amp;quot;transitions&amp;quot; =&amp;gt; array( &amp;quot;&amp;quot; =&amp;gt; 2 )&lt;br /&gt;
    ),&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    /// New hand&lt;br /&gt;
    2 =&amp;gt; array(&lt;br /&gt;
        &amp;quot;name&amp;quot; =&amp;gt; &amp;quot;newHand&amp;quot;,&lt;br /&gt;
        &amp;quot;description&amp;quot; =&amp;gt; &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot; =&amp;gt; &amp;quot;game&amp;quot;,&lt;br /&gt;
        &amp;quot;action&amp;quot; =&amp;gt; &amp;quot;stNewHand&amp;quot;,&lt;br /&gt;
        &amp;quot;updateGameProgression&amp;quot; =&amp;gt; true,   &lt;br /&gt;
        &amp;quot;transitions&amp;quot; =&amp;gt; array( &amp;quot;&amp;quot; =&amp;gt; 30 )&lt;br /&gt;
    ),    &lt;br /&gt;
&lt;br /&gt;
    21 =&amp;gt; array(       &lt;br /&gt;
        &amp;quot;name&amp;quot; =&amp;gt; &amp;quot;giveCards&amp;quot;,&lt;br /&gt;
        &amp;quot;description&amp;quot; =&amp;gt; clienttranslate(&#039;Some players must choose 3 cards to give to ${direction}&#039;),&lt;br /&gt;
        &amp;quot;descriptionmyturn&amp;quot; =&amp;gt; clienttranslate(&#039;${you} must choose 3 cards to give to ${direction}&#039;),&lt;br /&gt;
        &amp;quot;type&amp;quot; =&amp;gt; &amp;quot;multipleactiveplayer&amp;quot;,&lt;br /&gt;
        &amp;quot;action&amp;quot; =&amp;gt; &amp;quot;stGiveCards&amp;quot;,&lt;br /&gt;
        &amp;quot;args&amp;quot; =&amp;gt; &amp;quot;argGiveCards&amp;quot;,&lt;br /&gt;
        &amp;quot;possibleactions&amp;quot; =&amp;gt; array( &amp;quot;giveCards&amp;quot; ),&lt;br /&gt;
        &amp;quot;transitions&amp;quot; =&amp;gt; array( &amp;quot;giveCards&amp;quot; =&amp;gt; 22, &amp;quot;skip&amp;quot; =&amp;gt; 22 )        &lt;br /&gt;
    ), &lt;br /&gt;
    &lt;br /&gt;
    22 =&amp;gt; array(&lt;br /&gt;
        &amp;quot;name&amp;quot; =&amp;gt; &amp;quot;takeCards&amp;quot;,&lt;br /&gt;
        &amp;quot;description&amp;quot; =&amp;gt; &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot; =&amp;gt; &amp;quot;game&amp;quot;,&lt;br /&gt;
        &amp;quot;action&amp;quot; =&amp;gt; &amp;quot;stTakeCards&amp;quot;,&lt;br /&gt;
        &amp;quot;transitions&amp;quot; =&amp;gt; array( &amp;quot;startHand&amp;quot; =&amp;gt; 30, &amp;quot;skip&amp;quot; =&amp;gt; 30  )&lt;br /&gt;
    ),        &lt;br /&gt;
      &lt;br /&gt;
    &lt;br /&gt;
    // Trick&lt;br /&gt;
    &lt;br /&gt;
    30 =&amp;gt; array(&lt;br /&gt;
        &amp;quot;name&amp;quot; =&amp;gt; &amp;quot;newTrick&amp;quot;,&lt;br /&gt;
        &amp;quot;description&amp;quot; =&amp;gt; &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot; =&amp;gt; &amp;quot;game&amp;quot;,&lt;br /&gt;
        &amp;quot;action&amp;quot; =&amp;gt; &amp;quot;stNewTrick&amp;quot;,&lt;br /&gt;
        &amp;quot;transitions&amp;quot; =&amp;gt; array( &amp;quot;&amp;quot; =&amp;gt; 31 )&lt;br /&gt;
    ),       &lt;br /&gt;
    31 =&amp;gt; array(&lt;br /&gt;
        &amp;quot;name&amp;quot; =&amp;gt; &amp;quot;playerTurn&amp;quot;,&lt;br /&gt;
        &amp;quot;description&amp;quot; =&amp;gt; clienttranslate(&#039;${actplayer} must play a card&#039;),&lt;br /&gt;
        &amp;quot;descriptionmyturn&amp;quot; =&amp;gt; clienttranslate(&#039;${you} must play a card&#039;),&lt;br /&gt;
        &amp;quot;type&amp;quot; =&amp;gt; &amp;quot;activeplayer&amp;quot;,&lt;br /&gt;
        &amp;quot;possibleactions&amp;quot; =&amp;gt; array( &amp;quot;playCard&amp;quot; ),&lt;br /&gt;
        &amp;quot;transitions&amp;quot; =&amp;gt; array( &amp;quot;playCard&amp;quot; =&amp;gt; 32 )&lt;br /&gt;
    ), &lt;br /&gt;
    32 =&amp;gt; array(&lt;br /&gt;
        &amp;quot;name&amp;quot; =&amp;gt; &amp;quot;nextPlayer&amp;quot;,&lt;br /&gt;
        &amp;quot;description&amp;quot; =&amp;gt; &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot; =&amp;gt; &amp;quot;game&amp;quot;,&lt;br /&gt;
        &amp;quot;action&amp;quot; =&amp;gt; &amp;quot;stNextPlayer&amp;quot;,&lt;br /&gt;
        &amp;quot;transitions&amp;quot; =&amp;gt; array( &amp;quot;nextPlayer&amp;quot; =&amp;gt; 31, &amp;quot;nextTrick&amp;quot; =&amp;gt; 30, &amp;quot;endHand&amp;quot; =&amp;gt; 40 )&lt;br /&gt;
    ), &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    // End of the hand (scoring, etc...)&lt;br /&gt;
    40 =&amp;gt; array(&lt;br /&gt;
        &amp;quot;name&amp;quot; =&amp;gt; &amp;quot;endHand&amp;quot;,&lt;br /&gt;
        &amp;quot;description&amp;quot; =&amp;gt; &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot; =&amp;gt; &amp;quot;game&amp;quot;,&lt;br /&gt;
        &amp;quot;action&amp;quot; =&amp;gt; &amp;quot;stEndHand&amp;quot;,&lt;br /&gt;
        &amp;quot;transitions&amp;quot; =&amp;gt; array( &amp;quot;nextHand&amp;quot; =&amp;gt; 2, &amp;quot;endGame&amp;quot; =&amp;gt; 99 )&lt;br /&gt;
    ),     &lt;br /&gt;
   &lt;br /&gt;
    // Final state.&lt;br /&gt;
    // Please do not modify.&lt;br /&gt;
    99 =&amp;gt; array(&lt;br /&gt;
        &amp;quot;name&amp;quot; =&amp;gt; &amp;quot;gameEnd&amp;quot;,&lt;br /&gt;
        &amp;quot;description&amp;quot; =&amp;gt; clienttranslate(&amp;quot;End of game&amp;quot;),&lt;br /&gt;
        &amp;quot;type&amp;quot; =&amp;gt; &amp;quot;manager&amp;quot;,&lt;br /&gt;
        &amp;quot;action&amp;quot; =&amp;gt; &amp;quot;stGameEnd&amp;quot;,&lt;br /&gt;
        &amp;quot;args&amp;quot; =&amp;gt; &amp;quot;argGameEnd&amp;quot;&lt;br /&gt;
    )&lt;br /&gt;
&lt;br /&gt;
);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The full details on these fields are in [[Your_game_state_machine:_states.inc.php]].&lt;br /&gt;
&lt;br /&gt;
But basically we have Player states, in which a human player has to perform an &amp;quot;action&amp;quot; by pressing some button in the UI or selecting some game item, which will trigger js handler, which will do an ajax call to the server into API defined&lt;br /&gt;
by .action.php file. All functions in this file are API between client and server and have very simple&lt;br /&gt;
and repetitive structures. In this case there are only two actions player can do - play a card or pass cards to other player. So these 2 functions go into .action.php file, we will only define one now since we have not implemented card passing states yet:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    public function playCard() {&lt;br /&gt;
        self::setAjaxMode();&lt;br /&gt;
        $card_id = self::getArg(&amp;quot;id&amp;quot;, AT_posint, true);&lt;br /&gt;
        $this-&amp;gt;game-&amp;gt;playCard($card_id);&lt;br /&gt;
        self::ajaxResponse();&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now to make it run we have to define all the handler functions that we referenced in states, which are - one function for state arguments argGiveCards, 4 functions for robot states (where the game performs some action)&lt;br /&gt;
and 1 function for player actions handling.&lt;br /&gt;
In .game.php, find &#039;Game state arguments&#039; section and paste this in:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    function argGiveCards() {&lt;br /&gt;
        return array ();&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This normally passes some parameters to states, but we don&#039;t need anything yet. It&#039;s good to have a placeholder there anyway, so we can fix it later.&lt;br /&gt;
Important: even when it&#039;s a stub, this function must return an array not a scalar.&lt;br /&gt;
&lt;br /&gt;
Let&#039;s do stubs for other functions, find the game state actions section in .game.php file and insert these&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    function stNewHand() {&lt;br /&gt;
        // Take back all cards (from any location =&amp;gt; null) to deck&lt;br /&gt;
        $this-&amp;gt;cards-&amp;gt;moveAllCardsInLocation(null, &amp;quot;deck&amp;quot;);&lt;br /&gt;
        $this-&amp;gt;cards-&amp;gt;shuffle(&#039;deck&#039;);&lt;br /&gt;
        // Deal 13 cards to each players&lt;br /&gt;
        // Create deck, shuffle it and give 13 initial cards&lt;br /&gt;
        $players = self::loadPlayersBasicInfos();&lt;br /&gt;
        foreach ( $players as $player_id =&amp;gt; $player ) {&lt;br /&gt;
            $cards = $this-&amp;gt;cards-&amp;gt;pickCards(13, &#039;deck&#039;, $player_id);&lt;br /&gt;
            // Notify player about his cards&lt;br /&gt;
            self::notifyPlayer($player_id, &#039;newHand&#039;, &#039;&#039;, array (&#039;cards&#039; =&amp;gt; $cards ));&lt;br /&gt;
        }&lt;br /&gt;
        self::setGameStateValue(&#039;alreadyPlayedHearts&#039;, 0);&lt;br /&gt;
        $this-&amp;gt;gamestate-&amp;gt;nextState(&amp;quot;&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    function stNewTrick() {&lt;br /&gt;
        // New trick: active the player who wins the last trick, or the player who own the club-2 card&lt;br /&gt;
        // Reset trick color to 0 (= no color)&lt;br /&gt;
        self::setGameStateInitialValue(&#039;trickColor&#039;, 0);&lt;br /&gt;
        $this-&amp;gt;gamestate-&amp;gt;nextState();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    function stNextPlayer() {&lt;br /&gt;
        // Active next player OR end the trick and go to the next trick OR end the hand&lt;br /&gt;
        if ($this-&amp;gt;cards-&amp;gt;countCardInLocation(&#039;cardsontable&#039;) == 4) {&lt;br /&gt;
            // This is the end of the trick&lt;br /&gt;
            // Move all cards to &amp;quot;cardswon&amp;quot; of the given player&lt;br /&gt;
            $best_value_player_id = self::activeNextPlayer(); // TODO figure out winner of trick&lt;br /&gt;
            $this-&amp;gt;cards-&amp;gt;moveAllCardsInLocation(&#039;cardsontable&#039;, &#039;cardswon&#039;, null, $best_value_player_id);&lt;br /&gt;
        &lt;br /&gt;
            if ($this-&amp;gt;cards-&amp;gt;countCardInLocation(&#039;hand&#039;) == 0) {&lt;br /&gt;
                // End of the hand&lt;br /&gt;
                $this-&amp;gt;gamestate-&amp;gt;nextState(&amp;quot;endHand&amp;quot;);&lt;br /&gt;
            } else {&lt;br /&gt;
                // End of the trick&lt;br /&gt;
                $this-&amp;gt;gamestate-&amp;gt;nextState(&amp;quot;nextTrick&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
        } else {&lt;br /&gt;
            // Standard case (not the end of the trick)&lt;br /&gt;
            // =&amp;gt; just active the next player&lt;br /&gt;
            $player_id = self::activeNextPlayer();&lt;br /&gt;
            self::giveExtraTime($player_id);&lt;br /&gt;
            $this-&amp;gt;gamestate-&amp;gt;nextState(&#039;nextPlayer&#039;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    function stEndHand() {&lt;br /&gt;
        $this-&amp;gt;gamestate-&amp;gt;nextState(&amp;quot;nextHand&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Important: All state actions game or player must end with state transition (or thrown exception). Also make sure it&#039;s ONLY one state transition,&lt;br /&gt;
if you accidentally fall through after state transition and do another one it will be a real mess and head scratching for long time.&lt;br /&gt;
&lt;br /&gt;
Now find &#039;player actions&#039; section and paste this code there&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    function playCard($card_id) {&lt;br /&gt;
        self::checkAction(&amp;quot;playCard&amp;quot;);&lt;br /&gt;
        $player_id = self::getActivePlayerId();&lt;br /&gt;
        throw new BgaUserException(self::_(&amp;quot;Not implemented: &amp;quot;) . &amp;quot;$player_id plays $card_id&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
We won&#039;t implement it yet but throw an exception which we will see if interaction is working properly&lt;br /&gt;
&lt;br /&gt;
Now the game should start but it would not be any different than before because we have to implement actual interactions.&lt;br /&gt;
It&#039;s good to check if it&#039;s still working though (and if it was running before you have to exit because we changed state machine and normally it will break stuff)&lt;br /&gt;
&lt;br /&gt;
== Client - Server interactions ==&lt;br /&gt;
&lt;br /&gt;
Now to implement things for real we have hook UI actions to ajax calls, and process notifications sent by the server.&lt;br /&gt;
So previously we hooked playCardOnTable right into js handler which caused client animation, in real game its a two&lt;br /&gt;
step operation. When user clicks on game element js client sends an ajax call to server, server processes it and updates database, server sends&lt;br /&gt;
notification in response, client hooks animations to server notification.&lt;br /&gt;
&lt;br /&gt;
So in .js code replace onPlayerHandSelectionChanged with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
        onPlayerHandSelectionChanged : function() {&lt;br /&gt;
            var items = this.playerHand.getSelectedItems();&lt;br /&gt;
&lt;br /&gt;
            if (items.length &amp;gt; 0) {&lt;br /&gt;
                var action = &#039;playCard&#039;;&lt;br /&gt;
                if (this.checkAction(action, true)) {&lt;br /&gt;
                    // Can play a card&lt;br /&gt;
                    var card_id = items[0].id;                    &lt;br /&gt;
                    this.ajaxcall(&amp;quot;/&amp;quot; + this.game_name + &amp;quot;/&amp;quot; + this.game_name + &amp;quot;/&amp;quot; + action + &amp;quot;.html&amp;quot;, {&lt;br /&gt;
                        id : card_id,&lt;br /&gt;
                        lock : true&lt;br /&gt;
                    }, this, function(result) {&lt;br /&gt;
                    }, function(is_error) {&lt;br /&gt;
                    });&lt;br /&gt;
&lt;br /&gt;
                    this.playerHand.unselectAll();&lt;br /&gt;
                } else if (this.checkAction(&#039;giveCards&#039;)) {&lt;br /&gt;
                    // Can give cards =&amp;gt; let the player select some cards&lt;br /&gt;
                } else {&lt;br /&gt;
                    this.playerHand.unselectAll();&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
        },&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now when you click on card you should get a server response: Not implemented...&lt;br /&gt;
&lt;br /&gt;
Lets implement it, in .game.php&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    function playCard($card_id) {&lt;br /&gt;
        self::checkAction(&amp;quot;playCard&amp;quot;);&lt;br /&gt;
        $player_id = self::getActivePlayerId();&lt;br /&gt;
        $this-&amp;gt;cards-&amp;gt;moveCard($card_id, &#039;cardsontable&#039;, $player_id);&lt;br /&gt;
        // XXX check rules here&lt;br /&gt;
        $currentCard = $this-&amp;gt;cards-&amp;gt;getCard($card_id);&lt;br /&gt;
        // And notify&lt;br /&gt;
        self::notifyAllPlayers(&#039;playCard&#039;, clienttranslate(&#039;${player_name} plays ${value_displayed} ${color_displayed}&#039;), array (&lt;br /&gt;
                &#039;i18n&#039; =&amp;gt; array (&#039;color_displayed&#039;,&#039;value_displayed&#039; ),&#039;card_id&#039; =&amp;gt; $card_id,&#039;player_id&#039; =&amp;gt; $player_id,&lt;br /&gt;
                &#039;player_name&#039; =&amp;gt; self::getActivePlayerName(),&#039;value&#039; =&amp;gt; $currentCard [&#039;type_arg&#039;],&lt;br /&gt;
                &#039;value_displayed&#039; =&amp;gt; $this-&amp;gt;values_label [$currentCard [&#039;type_arg&#039;]],&#039;color&#039; =&amp;gt; $currentCard [&#039;type&#039;],&lt;br /&gt;
                &#039;color_displayed&#039; =&amp;gt; $this-&amp;gt;colors [$currentCard [&#039;type&#039;]] [&#039;name&#039;] ));&lt;br /&gt;
        // Next player&lt;br /&gt;
        $this-&amp;gt;gamestate-&amp;gt;nextState(&#039;playCard&#039;);&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We get the card from client, we move it to the table (moveCard is hooked to database directly, its part of deck class),&lt;br /&gt;
we notify all players and we change state. What we are missing here is bunch of checks (rule enforcements), we will add it later.&lt;br /&gt;
&lt;br /&gt;
Interesting part about this notify is that we use i18n array for strings that needs to be translated by client, so&lt;br /&gt;
they are sent as English text in notification, then client has to know which parameters needs translating.&lt;br /&gt;
&lt;br /&gt;
On the client side .js we have to implement a notification handler to do the animation&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
        setupNotifications : function() {&lt;br /&gt;
            console.log(&#039;notifications subscriptions setup&#039;);&lt;br /&gt;
&lt;br /&gt;
            dojo.subscribe(&#039;newHand&#039;, this, &amp;quot;notif_newHand&amp;quot;);&lt;br /&gt;
            dojo.subscribe(&#039;playCard&#039;, this, &amp;quot;notif_playCard&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        },&lt;br /&gt;
&lt;br /&gt;
        notif_newHand : function(notif) {&lt;br /&gt;
            // We received a new full hand of 13 cards.&lt;br /&gt;
            this.playerHand.removeAll();&lt;br /&gt;
&lt;br /&gt;
            for ( var i in notif.args.cards) {&lt;br /&gt;
                var card = notif.args.cards[i];&lt;br /&gt;
                var color = card.type;&lt;br /&gt;
                var value = card.type_arg;&lt;br /&gt;
                this.playerHand.addToStockWithId(this.getCardUniqueId(color, value), card.id);&lt;br /&gt;
            }&lt;br /&gt;
        },&lt;br /&gt;
&lt;br /&gt;
        notif_playCard : function(notif) {&lt;br /&gt;
            // Play a card on the table&lt;br /&gt;
            this.playCardOnTable(notif.args.player_id, notif.args.color, notif.args.value, notif.args.card_id);&lt;br /&gt;
        },&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now it actually works through the server when you click on card - the move is recorded. If you test it now you will notice&lt;br /&gt;
after trick is done all cards remains on the table, but if you press F5 they would disappear, this is because&lt;br /&gt;
we updated database to pick-up the cards but did not send notification about it, so we need to send notification about it&lt;br /&gt;
and have a handler for it&lt;br /&gt;
&lt;br /&gt;
So in .game.php file add notification in stNextPlayer function after moveAllCardsInLocation call:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
            // Notify&lt;br /&gt;
            // Note: we use 2 notifications here in order we can pause the display during the first notification&lt;br /&gt;
            //  before we move all cards to the winner (during the second)&lt;br /&gt;
            $players = self::loadPlayersBasicInfos();&lt;br /&gt;
            self::notifyAllPlayers( &#039;trickWin&#039;, clienttranslate(&#039;${player_name} wins the trick&#039;), array(&lt;br /&gt;
                &#039;player_id&#039; =&amp;gt; $best_value_player_id,&lt;br /&gt;
                &#039;player_name&#039; =&amp;gt; $players[ $best_value_player_id ][&#039;player_name&#039;]&lt;br /&gt;
            ) );            &lt;br /&gt;
            self::notifyAllPlayers( &#039;giveAllCardsToPlayer&#039;,&#039;&#039;, array(&lt;br /&gt;
                &#039;player_id&#039; =&amp;gt; $best_value_player_id&lt;br /&gt;
            ) );&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And in .js file add 2 more notification handlers.&lt;br /&gt;
&lt;br /&gt;
This is to subscribe in setupNotifications function&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
            dojo.subscribe( &#039;trickWin&#039;, this, &amp;quot;notif_trickWin&amp;quot; );&lt;br /&gt;
            this.notifqueue.setSynchronous( &#039;trickWin&#039;, 1000 );&lt;br /&gt;
            dojo.subscribe( &#039;giveAllCardsToPlayer&#039;, this, &amp;quot;notif_giveAllCardsToPlayer&amp;quot; );&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And these are handlers&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
        notif_trickWin : function(notif) {&lt;br /&gt;
            // We do nothing here (just wait in order players can view the 4 cards played before they&#039;re gone.&lt;br /&gt;
        },&lt;br /&gt;
        notif_giveAllCardsToPlayer : function(notif) {&lt;br /&gt;
            // Move all cards on table to given table, then destroy them&lt;br /&gt;
            var winner_id = notif.args.player_id;&lt;br /&gt;
            for ( var player_id in this.gamedatas.players) {&lt;br /&gt;
                var anim = this.slideToObject(&#039;cardontable_&#039; + player_id, &#039;overall_player_board_&#039; + winner_id);&lt;br /&gt;
                dojo.connect(anim, &#039;onEnd&#039;, function(node) {&lt;br /&gt;
                    dojo.destroy(node);&lt;br /&gt;
                });&lt;br /&gt;
                anim.play();&lt;br /&gt;
            }&lt;br /&gt;
        },&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So &#039;trickWin&#039; notification does not do much except it will delay the processing of next notification by 1 second (1000 ms)&lt;br /&gt;
and it will log the message (that happens independently of what handler does).&lt;br /&gt;
&amp;lt;i&amp;gt;Note: if on the other hand you don&#039;t want to log but want to do something else, send an empty message&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now after the trick you see all cards move towards the &amp;quot;player&#039;s stash&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Scoring and End of game handling ==&lt;br /&gt;
&lt;br /&gt;
Now we should calculate scoring and for that we need to actually track who wins the trick.&lt;br /&gt;
Trick is won by the player with highest card (no trump). We just need to remember what is trick suite.&lt;br /&gt;
For which we will use state variable &#039;trickColor&#039; which we already conveniently created.&lt;br /&gt;
&lt;br /&gt;
In .game.php file find playCard function and add this before notify functions&lt;br /&gt;
        $currentTrickColor = self::getGameStateValue( &#039;trickColor&#039; ) ;&lt;br /&gt;
        if( $currentTrickColor == 0 )&lt;br /&gt;
            self::setGameStateValue( &#039;trickColor&#039;, $currentCard[&#039;type&#039;] );&lt;br /&gt;
&lt;br /&gt;
This will make sure we remember first suit being played, now to use it modify stNextPlayer function to fix our TODO comment&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    function stNextPlayer() {&lt;br /&gt;
        // Active next player OR end the trick and go to the next trick OR end the hand&lt;br /&gt;
        if ($this-&amp;gt;cards-&amp;gt;countCardInLocation(&#039;cardsontable&#039;) == 4) {&lt;br /&gt;
            // This is the end of the trick&lt;br /&gt;
            $cards_on_table = $this-&amp;gt;cards-&amp;gt;getCardsInLocation(&#039;cardsontable&#039;);&lt;br /&gt;
            $best_value = 0;&lt;br /&gt;
            $best_value_player_id = null;&lt;br /&gt;
            $currentTrickColor = self::getGameStateValue(&#039;trickColor&#039;);&lt;br /&gt;
            foreach ( $cards_on_table as $card ) {&lt;br /&gt;
                // Note: type = card color&lt;br /&gt;
                if ($card [&#039;type&#039;] == $currentTrickColor) {&lt;br /&gt;
                    if ($best_value_player_id === null || $card [&#039;type_arg&#039;] &amp;gt; $best_value) {&lt;br /&gt;
                        $best_value_player_id = $card [&#039;location_arg&#039;]; // Note: location_arg = player who played this card on table&lt;br /&gt;
                        $best_value = $card [&#039;type_arg&#039;]; // Note: type_arg = value of the card&lt;br /&gt;
                    }&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
            &lt;br /&gt;
            // Active this player =&amp;gt; he&#039;s the one who starts the next trick&lt;br /&gt;
            $this-&amp;gt;gamestate-&amp;gt;changeActivePlayer( $best_value_player_id );&lt;br /&gt;
            &lt;br /&gt;
            // Move all cards to &amp;quot;cardswon&amp;quot; of the given player&lt;br /&gt;
            $this-&amp;gt;cards-&amp;gt;moveAllCardsInLocation(&#039;cardsontable&#039;, &#039;cardswon&#039;, null, $best_value_player_id);&lt;br /&gt;
        &lt;br /&gt;
            // Notify&lt;br /&gt;
            // ... same code here as before&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The scoring rule in the studio example code is huge multi-page function, for this tutorial we will make simplier.&lt;br /&gt;
Lets score -1 point per heart and call it a day. And game will end when somebody goes -100 or below.&lt;br /&gt;
&lt;br /&gt;
As UI goes for scoring, the main thing to update is the scoring on the mini boards represented by stars, also&lt;br /&gt;
we want to show that in the log. &lt;br /&gt;
In addition scoring can be shown in [[Game_interface_logic:_yourgamename.js#Scoring_dialogs|Scoring Dialog]] using tableWindow notification, but it is a tutorial on its own and you can do it as homework (it is part of original heart game).&lt;br /&gt;
&lt;br /&gt;
In .js file we need to add one more subscription and notification handler:&lt;br /&gt;
            dojo.subscribe( &#039;newScores&#039;, this, &amp;quot;notif_newScores&amp;quot; );&lt;br /&gt;
in setupNotifications&lt;br /&gt;
&lt;br /&gt;
and &lt;br /&gt;
        notif_newScores : function(notif) {&lt;br /&gt;
            // Update players&#039; scores&lt;br /&gt;
            for ( var player_id in notif.args.newScores) {&lt;br /&gt;
                this.scoreCtrl[player_id].toValue(notif.args.newScores[player_id]);&lt;br /&gt;
            }&lt;br /&gt;
        },&lt;br /&gt;
somewhere after. this.scoreCtrl is pre-existing object that shows the scoring and this function will update score values per player from notification argument&lt;br /&gt;
&lt;br /&gt;
so in .game.php our stEndHand function will look like&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    function stEndHand() {&lt;br /&gt;
            // Count and score points, then end the game or go to the next hand.&lt;br /&gt;
        $players = self::loadPlayersBasicInfos();&lt;br /&gt;
        // Gets all &amp;quot;hearts&amp;quot; + queen of spades&lt;br /&gt;
&lt;br /&gt;
        $player_to_points = array ();&lt;br /&gt;
        foreach ( $players as $player_id =&amp;gt; $player ) {&lt;br /&gt;
            $player_to_points [$player_id] = 0;&lt;br /&gt;
        }&lt;br /&gt;
        $cards = $this-&amp;gt;cards-&amp;gt;getCardsInLocation(&amp;quot;cardswon&amp;quot;);&lt;br /&gt;
        foreach ( $cards as $card ) {&lt;br /&gt;
            $player_id = $card [&#039;location_arg&#039;];&lt;br /&gt;
            // Note: 2 = heart&lt;br /&gt;
            if ($card [&#039;type&#039;] == 2) {&lt;br /&gt;
                $player_to_points [$player_id] ++;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        // Apply scores to player&lt;br /&gt;
        foreach ( $player_to_points as $player_id =&amp;gt; $points ) {&lt;br /&gt;
            if ($points != 0) {&lt;br /&gt;
                $sql = &amp;quot;UPDATE player SET player_score=player_score-$points  WHERE player_id=&#039;$player_id&#039;&amp;quot;;&lt;br /&gt;
                self::DbQuery($sql);&lt;br /&gt;
                $heart_number = $player_to_points [$player_id];&lt;br /&gt;
                self::notifyAllPlayers(&amp;quot;points&amp;quot;, clienttranslate(&#039;${player_name} gets ${nbr} hearts and looses ${nbr} points&#039;), array (&lt;br /&gt;
                        &#039;player_id&#039; =&amp;gt; $player_id,&#039;player_name&#039; =&amp;gt; $players [$player_id] [&#039;player_name&#039;],&lt;br /&gt;
                        &#039;nbr&#039; =&amp;gt; $heart_number ));&lt;br /&gt;
            } else {&lt;br /&gt;
                // No point lost (just notify)&lt;br /&gt;
                self::notifyAllPlayers(&amp;quot;points&amp;quot;, clienttranslate(&#039;${player_name} did not get any hearts&#039;), array (&lt;br /&gt;
                        &#039;player_id&#039; =&amp;gt; $player_id,&#039;player_name&#039; =&amp;gt; $players [$player_id] [&#039;player_name&#039;] ));&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        $newScores = self::getCollectionFromDb(&amp;quot;SELECT player_id, player_score FROM player&amp;quot;, true );&lt;br /&gt;
        self::notifyAllPlayers( &amp;quot;newScores&amp;quot;, &#039;&#039;, array( &#039;newScores&#039; =&amp;gt; $newScores ) );&lt;br /&gt;
&lt;br /&gt;
        ///// Test if this is the end of the game&lt;br /&gt;
        foreach ( $newScores as $player_id =&amp;gt; $score ) {&lt;br /&gt;
            if ($score &amp;lt;= -100) {&lt;br /&gt;
                // Trigger the end of the game !&lt;br /&gt;
                $this-&amp;gt;gamestate-&amp;gt;nextState(&amp;quot;endGame&amp;quot;);&lt;br /&gt;
                return;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        &lt;br /&gt;
        $this-&amp;gt;gamestate-&amp;gt;nextState(&amp;quot;nextHand&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So it should more less work now, including end of game condition. Try to play it!&lt;br /&gt;
&lt;br /&gt;
== Additional stuff ==&lt;br /&gt;
&lt;br /&gt;
The following things were not implemented and can add them yourself by looking at the code of original hearts game:&lt;br /&gt;
&lt;br /&gt;
* Remove debug code from setupNewGame to deal cards, cards are now dealt in stNewHand state handler&lt;br /&gt;
* Rule checking and rule enforcements in playCard function&lt;br /&gt;
* Start scoring with 100 points each and end when &amp;lt;= 0&lt;br /&gt;
* Fix scoring rules with Q of spades and 26 point reverse scoring&lt;br /&gt;
* First player one with 2 club&lt;br /&gt;
* Add progress handling&lt;br /&gt;
* Add statistics&lt;br /&gt;
* Add card exchange states&lt;br /&gt;
* Add game option to start with 75 points instead of 100&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Studio]]&lt;/div&gt;</summary>
		<author><name>Fenadoruk</name></author>
	</entry>
	<entry>
		<id>https://en.doc.boardgamearena.com/index.php?title=Tutorial_hearts&amp;diff=19508</id>
		<title>Tutorial hearts</title>
		<link rel="alternate" type="text/html" href="https://en.doc.boardgamearena.com/index.php?title=Tutorial_hearts&amp;diff=19508"/>
		<updated>2024-01-10T14:50:18Z</updated>

		<summary type="html">&lt;p&gt;Fenadoruk: /* Layout and Graphics */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Studio_Framework_Navigation}}&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
Using this tutorial, you can build a complete working game on the BGA environment: Hearts.&lt;br /&gt;
&lt;br /&gt;
Before you read this tutorial, you must:&lt;br /&gt;
* Read the overall presentations of the BGA Framework ([[Studio|see here]]).&lt;br /&gt;
* Know the rules for Hearts&lt;br /&gt;
* Some-what know the languages used on BGA: PHP, SQL, HTML, CSS, Javascript&lt;br /&gt;
* Set up your development environment [http://en.doc.boardgamearena.com/First_steps_with_BGA_Studio First Steps with BGA Studio]&lt;br /&gt;
* As part of setup you have to have access to your ftp home folder in studio, which would have the full &#039;hearts&#039; game source code. We will be using some resources of this game in this tutorial, so copy it over to local disk if you have not done so.&lt;br /&gt;
&lt;br /&gt;
If you are stuck or have question about this tutorial, post on [https://forum.boardgamearena.com/viewforum.php?f=12 BGA Developers forum]&lt;br /&gt;
&lt;br /&gt;
== Create your first game ==&lt;br /&gt;
&lt;br /&gt;
If you have not already, you have to create a project in BGA Studio. For this tutorial you can create a project heartsYOURNAME where&lt;br /&gt;
YOURNAME is your developer login name. You can also re-use the project you have created for the &amp;quot;First Steps&amp;quot; tutorial above.&lt;br /&gt;
With the initial skeleton of code provided, you can already start a game from the BGA Studio. &lt;br /&gt;
&lt;br /&gt;
1. Find and express start the game in turn-based mode with 4 players. Make sure it works. If you want to see the game as 2nd player press red arrow button on the player panel to switch to that player. More details can be found in [[First_steps_with_BGA_Studio]]&lt;br /&gt;
&lt;br /&gt;
2. Modify the text in heartsYOURNAME_heartsYOURNAME.tpl, reload the page in the browser and make sure your ftp sync works as expected.&lt;br /&gt;
Note: if you have not setup auto-sync do it now, manually copying files is a no-starter.&lt;br /&gt;
&lt;br /&gt;
3. Express stop from settings menu (the gear icon).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;Note: please do &#039;&#039;&#039;not&#039;&#039;&#039; use the hearts project code as a base. This tutorial assumes you started with a TEMPLATE project with no prior modifications. Using the hearts project as a base will be very confusing and you won&#039;t be able to follow all the steps.&lt;br /&gt;
&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;b&amp;gt;Attention!!!&amp;lt;/b&amp;gt; Very important note about reloading, if you don&#039;t remember this you may spent hours debugging. Browser caches .css files and images. If you change any of these files you have to do &amp;quot;full reload&amp;quot; which is usually Ctrl+F5 (or Ctrl+reload button on browser) not just a regular reload.&lt;br /&gt;
&lt;br /&gt;
== Hook version control system ==&lt;br /&gt;
&lt;br /&gt;
For a real game, or even for this tutorial, we recommend committing the code to version control right from the start. You are going to find yourself in a situation where the game doesn&#039;t even start anymore and no way of debugging it, unless you have a way to revert. That is where version control becomes very handy. If you are not familiar with version control (e.g. [https://git-scm.com/docs/gittutorial git]) then at least back up your files after each major change. Start now.&lt;br /&gt;
&lt;br /&gt;
Code for this tutorial available is on github: https://github.com/elaskavaia/bga-heartsla&lt;br /&gt;
&lt;br /&gt;
Different revisions represent different steps along the process, starting from original template to a PARTIAL game. The full game can be found in your FTP home folder.&lt;br /&gt;
&lt;br /&gt;
== Update game infos and box graphics ==&lt;br /&gt;
&lt;br /&gt;
Even it does nothing yet, always start by making sure the game looks decent in the game selector, meaning it has nice box graphics and its information is correct. For that we need to edit [[Game_meta-information: gameinfos.inc.php|gameinfos.inc.php]].&lt;br /&gt;
&lt;br /&gt;
For a real game, you would go to [http://boardgamegeek.com BoardGameGeek], find the game, and use the information from BGG to fill in the gameinfos.&lt;br /&gt;
&lt;br /&gt;
So let&#039;s do that. Find &amp;quot;hearts&amp;quot; on BoardGameGeek. (Hint: Original release 1850 :))&lt;br /&gt;
&lt;br /&gt;
You can fill in the year of publishing and bgg id, put &#039;&#039;Public Domain&#039;&#039; under publisher (for a real game, leave an empty string so it won&#039;t be displayed), and a publisher id of 171 for public domain. And as designer and author you can just put your own name just for fun. Set number of players to 4.&lt;br /&gt;
&lt;br /&gt;
  // Players configuration that can be played (ex: 2 to 4 players)&lt;br /&gt;
  &#039;players&#039; =&amp;gt; array( 4 ),  &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Important step&#039;&#039;&#039;: you have to refresh the information in the Studio website through the control panel. So go to Control Panel -&amp;gt; Manage Games -&amp;gt; heartsYOURNAME&lt;br /&gt;
and press Reload for &#039;Reload game informations&#039;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The next step would be to replace &#039;&#039;&#039;game_box.png&#039;&#039;&#039; with nicer images. This can be done from the [[Game metadata manager]]. &lt;br /&gt;
&lt;br /&gt;
Now try to start the game again. If you somehow introduced a syntax error in the gameinfos file it may not work (the game won&#039;t start).&lt;br /&gt;
Always use the &amp;quot;Express Start&amp;quot; button to start the game. You should see a standard state prompt from the template. You should see 4 players on the right: testdude0 .. testdude3.&lt;br /&gt;
To switch between them press the red arrow button near their names, it will open another tab. This way you don&#039;t need to login and logout from multiple accounts!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;Note: if you had run the game before with less than 4 players there is a bug that will prevent you from running it with 4 only (if you did not run it before or run it with 4 players as instructed stop reading this note), to workaround revert back to original players array (i.e. 1,2,3,4), reload game options, then create a table with 4 players, exit that game table, then change gameoptions to 4 only as above, reload game options, create table again.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Code Rev [https://github.com/elaskavaia/bga-heartsla/tree/4b3a73eeb5acae961ade18473af119e8ce8d1a8f]&lt;br /&gt;
&lt;br /&gt;
== Layout and Graphics ==&lt;br /&gt;
&lt;br /&gt;
In this section we will do graphics of the game, and main layout of the game.&lt;br /&gt;
&lt;br /&gt;
First copy a sprite with cards image from [https://github.com/elaskavaia/bga-heartsla/blob/4b3a73eeb5acae961ade18473af119e8ce8d1a8f/img/cards.jpg hearts img/cards.jpg]  into img/ folder of your project. Project hearts is mounted to your home directory on bga server.&lt;br /&gt;
&amp;lt;blockquote&amp;gt;There are better quality deck of cards image at https://en.doc.boardgamearena.com/Common_board_game_elements_image_resources&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Details about images can be found here: [[Game art: img directory]].&lt;br /&gt;
&lt;br /&gt;
Edit .tpl to add some divs to represent player table and hand area&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;div id=&amp;quot;myhand_wrap&amp;quot; class=&amp;quot;whiteblock&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;h3&amp;gt;My Hand&amp;lt;/h3&amp;gt;&lt;br /&gt;
    &amp;lt;div id=&amp;quot;myhand&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you refresh you should see now white area with My Hand title.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Heartsla-tpl2.png]]&lt;br /&gt;
&lt;br /&gt;
Now lets add a card into the hand, just so you can feel it. Edit .tpl and a playertablecard div inside a hand div&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
    &amp;lt;div id=&amp;quot;myhand&amp;quot;&amp;gt;&lt;br /&gt;
       &amp;lt;div class=&amp;quot;playertablecard&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit .css file&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
.playertablecard {&lt;br /&gt;
    display: inline-block;&lt;br /&gt;
    position: relative;&lt;br /&gt;
    margin-top: 5px;&lt;br /&gt;
    width: 72px;&lt;br /&gt;
    height: 96px;&lt;br /&gt;
    background-image: url(&#039;img/cards.jpg&#039;); /* temp hack to see it */&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you edit CSS remember that you have to FORCE-reload page, i.e. Ctrl-F5, otherwise its cached.&lt;br /&gt;
&amp;lt;i&amp;gt;Same when you change existing graphics files&amp;lt;/i&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You should see this:&lt;br /&gt;
&lt;br /&gt;
[[File:Heartsla-tpl3.png]]&lt;br /&gt;
&lt;br /&gt;
Awesome! Now lets do the rest of layout.&lt;br /&gt;
&lt;br /&gt;
There are few ways of how html could have been generated, you could have start with nothing and generate&lt;br /&gt;
all by java script. Or you could have started with complete game markup in html and make java script just hide and move pieces around. BGA framework provides also a third way which is mix of both plus template engine to generate HTML using php. So lets do that.&lt;br /&gt;
&lt;br /&gt;
Change .tpl file to have this inside&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;div id=&amp;quot;playertables&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;!-- BEGIN playerhandblock --&amp;gt;&lt;br /&gt;
    &amp;lt;div class=&amp;quot;playertable whiteblock playertable_{DIR}&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;div class=&amp;quot;playertablename&amp;quot; style=&amp;quot;color:#{PLAYER_COLOR}&amp;quot;&amp;gt;&lt;br /&gt;
            {PLAYER_NAME}&lt;br /&gt;
        &amp;lt;/div&amp;gt;&lt;br /&gt;
        &amp;lt;div class=&amp;quot;playertablecard&amp;quot; id=&amp;quot;playertablecard_{PLAYER_ID}&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;!-- END playerhandblock --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;myhand_wrap&amp;quot; class=&amp;quot;whiteblock&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;h3&amp;gt;{MY_HAND}&amp;lt;/h3&amp;gt;&lt;br /&gt;
    &amp;lt;div id=&amp;quot;myhand&amp;quot;&amp;gt;&lt;br /&gt;
       &amp;lt;div class=&amp;quot;playertablecard&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What we did is we added &amp;quot;block&amp;quot; playerhandblock, it is marked up using html comments. {VAR} notation is used&lt;br /&gt;
to inject variables and &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  &amp;lt;!-- BEGIN xxx --&amp;gt; &lt;br /&gt;
   inside &lt;br /&gt;
  &amp;lt;!-- END xxx --&amp;gt; &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
effectively allows us to do template loops.&lt;br /&gt;
&lt;br /&gt;
In .view.php insert this code after &#039;Place your code below&#039; comment&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
        $template = self::getGameName() . &amp;quot;_&amp;quot; . self::getGameName();&lt;br /&gt;
        &lt;br /&gt;
        $directions = array( &#039;S&#039;, &#039;W&#039;, &#039;N&#039;, &#039;E&#039; );&lt;br /&gt;
        &lt;br /&gt;
        // this will inflate our player block with actual players data&lt;br /&gt;
        $this-&amp;gt;page-&amp;gt;begin_block($template, &amp;quot;playerhandblock&amp;quot;);&lt;br /&gt;
        foreach ( $players as $player_id =&amp;gt; $info ) {&lt;br /&gt;
            $dir = array_shift($directions);&lt;br /&gt;
            $this-&amp;gt;page-&amp;gt;insert_block(&amp;quot;playerhandblock&amp;quot;, array (&amp;quot;PLAYER_ID&amp;quot; =&amp;gt; $player_id,&lt;br /&gt;
                    &amp;quot;PLAYER_NAME&amp;quot; =&amp;gt; $players [$player_id] [&#039;player_name&#039;],&lt;br /&gt;
                    &amp;quot;PLAYER_COLOR&amp;quot; =&amp;gt; $players [$player_id] [&#039;player_color&#039;],&lt;br /&gt;
                    &amp;quot;DIR&amp;quot; =&amp;gt; $dir ));&lt;br /&gt;
        }&lt;br /&gt;
        // this will make our My Hand text translatable&lt;br /&gt;
        $this-&amp;gt;tpl[&#039;MY_HAND&#039;] = self::_(&amp;quot;My hand&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What it does is for each player we have it will replicate the html between &amp;lt;!-- BEGIN playerhandblock --&amp;gt; and &amp;lt;!-- END playerhandblock --&amp;gt; tags, substituting the variable denoted by {XXX}&lt;br /&gt;
with the values you provide. The DIR variable in this case we pulling from directions array (where array_shift will take first element and remove it from the array).&lt;br /&gt;
&lt;br /&gt;
Reload. If everything went well you should see this:&lt;br /&gt;
&lt;br /&gt;
[[File:Hearts all rows.png|alt=Display a list of all players, with a dummy card in each position]]&lt;br /&gt;
&lt;br /&gt;
These are &amp;quot;tableau&amp;quot; areas for 4 players plus My hand visible only to one player. They are not exactly how we wanted them to be because we did not edit .css yet.&lt;br /&gt;
&lt;br /&gt;
Now edit .css, add these lines after import before our previous definition&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/** Table layout **/&lt;br /&gt;
&lt;br /&gt;
#playertables {&lt;br /&gt;
    position: relative;&lt;br /&gt;
    width: 710px;&lt;br /&gt;
    height: 340px;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.playertablename {&lt;br /&gt;
    font-weight: bold;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.playertable {&lt;br /&gt;
    position: absolute;&lt;br /&gt;
    text-align: center;&lt;br /&gt;
    width: 180px;&lt;br /&gt;
    height: 130px;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.playertable_N {&lt;br /&gt;
    left: 50%;&lt;br /&gt;
    top: 0px;&lt;br /&gt;
    margin-left: -90px; /* half of 180 */&lt;br /&gt;
}&lt;br /&gt;
.playertable_S {&lt;br /&gt;
    left: 50%;&lt;br /&gt;
    bottom: 0px;&lt;br /&gt;
    margin-left: -90px; /* half of 180 */&lt;br /&gt;
}&lt;br /&gt;
.playertable_W {&lt;br /&gt;
    left: 0px;&lt;br /&gt;
    top: 50%;&lt;br /&gt;
    margin-top: -55px; /* half of 130 */&lt;br /&gt;
}&lt;br /&gt;
.playertable_E {&lt;br /&gt;
    right: 0px;&lt;br /&gt;
    top: 50%;&lt;br /&gt;
    margin-top: -55px; /* half of 130 */&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now you force Reload and you should see this:&lt;br /&gt;
[[File:Heartsla-tpl5.png]]&lt;br /&gt;
&lt;br /&gt;
This is almost all we need for graphics and layout, there are few tweaks left there but lets do some more heavy lifting now.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;Note: if you did not see changes you may have not force reloaded, force means you use Ctrl+F5 or Cltr+Shift-R, if you don&#039;t &amp;quot;force&amp;quot; browser will use cached version of .css and images! Which is not what you just changed&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;Another Note: In general if you have auto-sync you don&#039;t need to reload if you change game.php file, you need normal reload if you change js, and force reload for css and images. If you changed state machine or database you likely need to restart the game.&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Game Interface JS Stock ==&lt;br /&gt;
&lt;br /&gt;
The BGA framework provides a few out of the box classes to deal with cards. The client side&lt;br /&gt;
contains a class called [[Stock]] and it can be used for any dynamic html &amp;quot;pieces&amp;quot; management that uses&lt;br /&gt;
common sprite images. On the server side we will use the [[Deck]] class which we discuss later.&lt;br /&gt;
&lt;br /&gt;
If you open cards.jpg in an image viewer you will see that it is a &amp;quot;sprite&amp;quot; image - a 13x4 grid of images stitched together,&lt;br /&gt;
which is a very efficient way to transport images. So we will use the Stock class to mark up these images and create&lt;br /&gt;
&amp;quot;card&amp;quot; divs for us.&lt;br /&gt;
&lt;br /&gt;
First, we need to add &#039;&#039;&#039;ebg/stock&#039;&#039;&#039; as a dependency in the hearts.js file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
define([&lt;br /&gt;
    &amp;quot;dojo&amp;quot;,&amp;quot;dojo/_base/declare&amp;quot;,&lt;br /&gt;
    &amp;quot;ebg/core/gamegui&amp;quot;,&lt;br /&gt;
    &amp;quot;ebg/counter&amp;quot;,&lt;br /&gt;
    &amp;quot;ebg/stock&amp;quot;     /// &amp;lt;==== HERE&lt;br /&gt;
],&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then add this to the Javascript constructor, this will define size of our cards&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
            console.log(&#039;hearts constructor&#039;);&lt;br /&gt;
            this.cardwidth = 72;&lt;br /&gt;
            this.cardheight = 96;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The stock is initialized in the Javascript &amp;quot;setup&amp;quot; method like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    // TODO: Set up your game interface here, according to &amp;quot;gamedatas&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    // Player hand&lt;br /&gt;
    this.playerHand = new ebg.stock(); // new stock object for hand&lt;br /&gt;
    this.playerHand.create( this, $(&#039;myhand&#039;), this.cardwidth, this.cardheight );&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As parameters of the &amp;quot;create&amp;quot; method, we provided the width/height of an item (a card), and the container div &amp;quot;myhand&amp;quot; - which is an id of &amp;quot;div&amp;quot; element from our .tpl file representing a player hand.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Then, we must tell the stock what items it is going to display during its life: the 52 cards of a standard card game from a CSS sprite image named &amp;quot;cards.jpg&amp;quot; with all the cards arranged in 4 rows and 13 columns.&lt;br /&gt;
&lt;br /&gt;
Here&#039;s how we tell stock what item types to display:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
            this.playerHand.image_items_per_row = 13; // 13 images per row&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
            // Create cards types:&lt;br /&gt;
            for (var color = 1; color &amp;lt;= 4; color++) {&lt;br /&gt;
                for (var value = 2; value &amp;lt;= 14; value++) {&lt;br /&gt;
                    // Build card type id&lt;br /&gt;
                    var card_type_id = this.getCardUniqueId(color, value);&lt;br /&gt;
                    this.playerHand.addItemType(card_type_id, card_type_id, g_gamethemeurl + &#039;img/cards.jpg&#039;, card_type_id);&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And add this function to the utilities section&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
        // Get card unique identifier based on its color and value&lt;br /&gt;
        getCardUniqueId : function(color, value) {&lt;br /&gt;
            return (color - 1) * 13 + (value - 2);&lt;br /&gt;
        },&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Explanations:&lt;br /&gt;
* At first, we tell the stock component that our CSS sprite contains 13 items per row. This way, it can find the correct image for each card type id.&lt;br /&gt;
* Then for the 4x13 cards, we call the &#039;&#039;&#039;addItemType&#039;&#039;&#039; method that creates the type. The arguments are the type id, the weight of the card (for sorting purpose), the URL of our CSS sprite, and the position of our card image in the CSS sprite. It happens to be the same number in our case.&lt;br /&gt;
&lt;br /&gt;
Note: we need to generate a unique ID for each type of card based on its color and value.  For that we create a function &#039;&#039;&#039;getCardUniqueId&#039;&#039;&#039;. The type is the unique identifier of the TYPE of the card, e.g., the queen of spades encoded as an integer. If our deck had 2 standard card decks we would have had 2 queens of spades; they would share the same type and the same image but would have different ids. NOTE: It&#039;s unfortunate that they named this &#039;&#039;&#039;getCardUniqueId&#039;&#039;&#039;; it should have been &#039;&#039;&#039;getCardUniqueType&#039;&#039;&#039;, because it really isn&#039;t an id, but a TYPE of card. The type of the item should either be a reversible function of its properties (i.e., kind of suite * 13 + value) or just an enumerator described in material.inc.php. In this specific case it&#039;s a synthetic type id, which also the same as the number of the card in the sprite image (i.e., if you enumerate each image in sprite going left to right, then top to bottom).&lt;br /&gt;
&lt;br /&gt;
Now let&#039;s add the 5 of Hearts to the player&#039;s hand just for fun (this code will go in setup method after types initialization):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// 2 = hearts, 5 is 5, and 42 is the card id, which normally would come from db&lt;br /&gt;
this.playerHand.addToStockWithId( this.getCardUniqueId( 2, 5 ), 42 );&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will add the card with id 42 and type 16 ( (2-1)*13+(5-2)=16 ). &lt;br /&gt;
&lt;br /&gt;
Note that number 16 would not be something you can see in database, Deck database will have separate field for type and type_arg where type is suite and type_arg is number, so its not the same thing, but you can use same formula to convert. Number 42 on the other hand would be id field in database. But we get to database in the later section.&lt;br /&gt;
&lt;br /&gt;
If you reload now you should see the 5 of hearts in &amp;quot;your hand&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Stock control can handle clicking on items and forms the selection. You can immediately react to selection&lt;br /&gt;
or you can query it later; for example when user presses some other button.&lt;br /&gt;
&lt;br /&gt;
Let&#039;s hook it up. Add this in the setup method in .js file, after this.playerHand is initialised:&lt;br /&gt;
&lt;br /&gt;
     dojo.connect( this.playerHand, &#039;onChangeSelection&#039;, this, &#039;onPlayerHandSelectionChanged&#039; );&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Then find the Player&#039;s action comment section in .js file and add a handler after the comment:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
        onPlayerHandSelectionChanged: function() {&lt;br /&gt;
            var items = this.playerHand.getSelectedItems();&lt;br /&gt;
&lt;br /&gt;
            if (items.length &amp;gt; 0) {&lt;br /&gt;
                if (this.checkAction(&#039;playCard&#039;, true)) {&lt;br /&gt;
                    // Can play a card&lt;br /&gt;
&lt;br /&gt;
                    var card_id = items[0].id;&lt;br /&gt;
                    console.log(&amp;quot;on playCard &amp;quot;+card_id);&lt;br /&gt;
&lt;br /&gt;
                    this.playerHand.unselectAll();&lt;br /&gt;
                } else if (this.checkAction(&#039;giveCards&#039;)) {&lt;br /&gt;
                    // Can give cards =&amp;gt; let the player select some cards&lt;br /&gt;
                } else {&lt;br /&gt;
                    this.playerHand.unselectAll();&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
        },&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The function name of the handler is 4th parameter of the dojo.connect function. Make sure you spell it correctly or there will be unpredictable effects.&lt;br /&gt;
&lt;br /&gt;
Now if you reload, open the Javascript Console (F12), and then click on the card in My Hand, you should see:&lt;br /&gt;
  on playCard 42&lt;br /&gt;
printed on the console&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note : You need to be the active player to have rights to play a card and so log your message in the console&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Game Database and Game Initialisation ==&lt;br /&gt;
&lt;br /&gt;
Next step, you want to design a game database and setup a new game (on the server side).&lt;br /&gt;
For that we need to a) modify the database schema to add our cards data b) add some global variables into&lt;br /&gt;
the existing globals table.&lt;br /&gt;
&lt;br /&gt;
To modify the schema, first exit your existing game(s). Open &#039;&#039;&#039;dbmodel.sql&#039;&#039;&#039; file and uncomment the card table creation.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CREATE TABLE IF NOT EXISTS `card` (&lt;br /&gt;
  `card_id` int(10) unsigned NOT NULL AUTO_INCREMENT,&lt;br /&gt;
  `card_type` varchar(16) NOT NULL,&lt;br /&gt;
  `card_type_arg` int(11) NOT NULL,&lt;br /&gt;
  `card_location` varchar(16) NOT NULL,&lt;br /&gt;
  `card_location_arg` int(11) NOT NULL,&lt;br /&gt;
  PRIMARY KEY (`card_id`)&lt;br /&gt;
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is the &amp;quot;card&amp;quot; table which will be managed by the Deck php class.&lt;br /&gt;
&lt;br /&gt;
In addition we want a little piece of information in the players table:&lt;br /&gt;
&lt;br /&gt;
  -- add info about first player&lt;br /&gt;
  ALTER TABLE `player` ADD `player_first` BOOLEAN NOT NULL DEFAULT &#039;0&#039;;&lt;br /&gt;
&lt;br /&gt;
Not sure why they put this into the player table, as we could use a global db variable to hold first player as easily.&lt;br /&gt;
But I am just following the existing code more-or-less.&lt;br /&gt;
&lt;br /&gt;
Next we finally get into .game.php class, where the main logic and db interaction would be. Find php constructor which should be &lt;br /&gt;
  function __construct( )&lt;br /&gt;
This is first function in a file. Add this code to constructor.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
        parent::__construct();&lt;br /&gt;
        self::initGameStateLabels( array( &lt;br /&gt;
                         &amp;quot;currentHandType&amp;quot; =&amp;gt; 10, &lt;br /&gt;
                         &amp;quot;trickColor&amp;quot; =&amp;gt; 11, &lt;br /&gt;
                         &amp;quot;alreadyPlayedHearts&amp;quot; =&amp;gt; 12,&lt;br /&gt;
                          ) );&lt;br /&gt;
&lt;br /&gt;
        $this-&amp;gt;cards = self::getNew( &amp;quot;module.common.deck&amp;quot; );&lt;br /&gt;
        $this-&amp;gt;cards-&amp;gt;init( &amp;quot;card&amp;quot; );&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here we are initializing three &amp;quot;Game State Variables&amp;quot; which are variables stored in the database. They are integers.&lt;br /&gt;
It must start with values higher or equal to 10 since values lower than 10 are reserved. These values are stored by numeric ids&lt;br /&gt;
in the database, but in the php we associate them with string labels for convenience of access. The variables are &amp;quot;trickColor&amp;quot;: numbers from 1 to 4 that map to card suit (not sure why it&#039;s called color; maybe it&#039;s a translation from French); &amp;quot;alreadyPlayedHearts&amp;quot;: a boolean flag (0 or 1) indicating whether somebody used hearts on the trick; &amp;quot;currentHandType&amp;quot;: stores the value to indicate who to give cards to during exchange.&lt;br /&gt;
&lt;br /&gt;
The next 2 lines are creating $this-&amp;gt;cards object and associating it with &amp;quot;card&amp;quot; table in the the database.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;If we called db table &#039;foo&#039; instead of &#039;card&#039; the last statement would have been  $this-&amp;gt;cards-&amp;gt;init( &amp;quot;foo&amp;quot; )&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
At this point I would start a new game and make sure it starts, then exit. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;i&amp;gt;&lt;br /&gt;
If you made a mistake&lt;br /&gt;
in the .sql or php constructor the game won&#039;t start, and good luck debugging it. (That is why it&#039;s important to check&lt;br /&gt;
once in a while to make sure it still starts while you remember what you have changed.)&lt;br /&gt;
&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Code Rev [https://github.com/elaskavaia/bga-heartsla/tree/e3a049257b592ff6167688d4d344f8a83d349b08]&lt;br /&gt;
&lt;br /&gt;
Now we can go to game initialization &#039;&#039;&#039;setupNewGame&#039;&#039;&#039; in game.php. This method is called only once when the game is created.&lt;br /&gt;
&lt;br /&gt;
In your template project you should have code that deals with player table, just leave it as is. Start inserting the&lt;br /&gt;
other code after &amp;quot;Start the game initialization&amp;quot; comment.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
        // Init global values with their initial values&lt;br /&gt;
&lt;br /&gt;
        // Note: hand types: 0 = give 3 cards to player on the left&lt;br /&gt;
        //                   1 = give 3 cards to player on the right&lt;br /&gt;
        //                   2 = give 3 cards to player opposite&lt;br /&gt;
        //                   3 = keep cards&lt;br /&gt;
        self::setGameStateInitialValue( &#039;currentHandType&#039;, 0 );&lt;br /&gt;
        &lt;br /&gt;
        // Set current trick color to zero (= no trick color)&lt;br /&gt;
        self::setGameStateInitialValue( &#039;trickColor&#039;, 0 );&lt;br /&gt;
        &lt;br /&gt;
        // Mark if we already played hearts during this hand&lt;br /&gt;
        self::setGameStateInitialValue( &#039;alreadyPlayedHearts&#039;, 0 );&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here we initialize all the globals to 0.&lt;br /&gt;
&lt;br /&gt;
Next is to create our cards in the database. We have one deck of cards so it&#039;s pretty simple.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
        // Create cards&lt;br /&gt;
        $cards = array ();&lt;br /&gt;
        foreach ( $this-&amp;gt;colors as $color_id =&amp;gt; $color ) {&lt;br /&gt;
            // spade, heart, diamond, club&lt;br /&gt;
            for ($value = 2; $value &amp;lt;= 14; $value ++) {&lt;br /&gt;
                //  2, 3, 4, ... K, A&lt;br /&gt;
                $cards [] = array (&#039;type&#039; =&amp;gt; $color_id,&#039;type_arg&#039; =&amp;gt; $value,&#039;nbr&#039; =&amp;gt; 1 );&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
        $this-&amp;gt;cards-&amp;gt;createCards( $cards, &#039;deck&#039; );&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This code that will create one of each card. But don&#039;t run it yet, because we missing $this-&amp;gt;colors.&lt;br /&gt;
So we have state of the game in the database, but there is some static game information which never changes.&lt;br /&gt;
This information should be stored in material.inc.php and this way it can be accessed from all .php files (and .js if you send it via getAllDatas()).&lt;br /&gt;
We will edit this file now by adding these lines&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$this-&amp;gt;colors = array(&lt;br /&gt;
    1 =&amp;gt; array( &#039;name&#039; =&amp;gt; clienttranslate(&#039;spade&#039;),&lt;br /&gt;
                &#039;nametr&#039; =&amp;gt; self::_(&#039;spade&#039;) ),&lt;br /&gt;
    2 =&amp;gt; array( &#039;name&#039; =&amp;gt; clienttranslate(&#039;heart&#039;),&lt;br /&gt;
                &#039;nametr&#039; =&amp;gt; self::_(&#039;heart&#039;) ),&lt;br /&gt;
    3 =&amp;gt; array( &#039;name&#039; =&amp;gt; clienttranslate(&#039;club&#039;),&lt;br /&gt;
                &#039;nametr&#039; =&amp;gt; self::_(&#039;club&#039;) ),&lt;br /&gt;
    4 =&amp;gt; array( &#039;name&#039; =&amp;gt; clienttranslate(&#039;diamond&#039;),&lt;br /&gt;
                &#039;nametr&#039; =&amp;gt; self::_(&#039;diamond&#039;) )&lt;br /&gt;
);&lt;br /&gt;
&lt;br /&gt;
$this-&amp;gt;values_label = array(&lt;br /&gt;
    2 =&amp;gt;&#039;2&#039;,&lt;br /&gt;
    3 =&amp;gt; &#039;3&#039;,&lt;br /&gt;
    4 =&amp;gt; &#039;4&#039;,&lt;br /&gt;
    5 =&amp;gt; &#039;5&#039;,&lt;br /&gt;
    6 =&amp;gt; &#039;6&#039;,&lt;br /&gt;
    7 =&amp;gt; &#039;7&#039;,&lt;br /&gt;
    8 =&amp;gt; &#039;8&#039;,&lt;br /&gt;
    9 =&amp;gt; &#039;9&#039;,&lt;br /&gt;
    10 =&amp;gt; &#039;10&#039;,&lt;br /&gt;
    11 =&amp;gt; clienttranslate(&#039;J&#039;),&lt;br /&gt;
    12 =&amp;gt; clienttranslate(&#039;Q&#039;),&lt;br /&gt;
    13 =&amp;gt; clienttranslate(&#039;K&#039;),&lt;br /&gt;
    14 =&amp;gt; clienttranslate(&#039;A&#039;)&lt;br /&gt;
);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where $this-&amp;gt;colors will define Suit labels and $this-&amp;gt;values_label will define value labels.&lt;br /&gt;
If you noticed, we have two of each label for suits. This is because sometimes we need translated values on the php&lt;br /&gt;
side and sometimes we don&#039;t. In this case &#039;&#039;&#039;nametr&#039;&#039;&#039; will return a translated value in php, which is only useful when you throw exceptions to show the right strings. If you pass a value to the client via notification you should always use untranslated strings, and the client will translate it. &#039;clienttranslate&#039; marks the value for translation but does not actually change it for php. For more about this wonderful translation stuff see [[Translations]].&lt;br /&gt;
&lt;br /&gt;
== Full game model synchronisation ==&lt;br /&gt;
&lt;br /&gt;
Now at any point in the game we need to make sure that database information can be reflected back in the UI, so we must fix the &#039;&#039;&#039;getAllDatas&#039;&#039;&#039; function&lt;br /&gt;
to return all possible data we need to reconstruct the game. This is in the game.php file. The template for getAllDatas() already takes care of player info. Let&#039;s just&lt;br /&gt;
add hand and tableau data before we return a result.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
        // Cards in player hand&lt;br /&gt;
        $result[&#039;hand&#039;] = $this-&amp;gt;cards-&amp;gt;getCardsInLocation( &#039;hand&#039;, $current_player_id );&lt;br /&gt;
        &lt;br /&gt;
        // Cards played on the table&lt;br /&gt;
        $result[&#039;cardsontable&#039;] = $this-&amp;gt;cards-&amp;gt;getCardsInLocation( &#039;cardsontable&#039; );&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now on the client side we should display this data, so in your .js file in the setup function (which is the receiver of getAllDatas) replace our hack of putting 5 of Hearts directly into the hand with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
            // Cards in player&#039;s hand&lt;br /&gt;
            for ( var i in this.gamedatas.hand) {&lt;br /&gt;
                var card = this.gamedatas.hand[i];&lt;br /&gt;
                var color = card.type;&lt;br /&gt;
                var value = card.type_arg;&lt;br /&gt;
                this.playerHand.addToStockWithId(this.getCardUniqueId(color, value), card.id);&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            // Cards played on table&lt;br /&gt;
            for (i in this.gamedatas.cardsontable) {&lt;br /&gt;
                var card = this.gamedatas.cardsontable[i];&lt;br /&gt;
                var color = card.type;&lt;br /&gt;
                var value = card.type_arg;&lt;br /&gt;
                var player_id = card.location_arg;&lt;br /&gt;
                this.playCardOnTable(player_id, color, value, card.id);&lt;br /&gt;
            }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This should show hand and tableau cards now, except we are missing the &#039;&#039;&#039;playCardOnTable&#039;&#039;&#039; function. So find the &#039;&#039;&#039;getCardUniqueId&#039;&#039;&#039; function which&lt;br /&gt;
should be in the utilities section and add this after it:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
        playCardOnTable : function(player_id, color, value, card_id) {&lt;br /&gt;
            // player_id =&amp;gt; direction&lt;br /&gt;
            dojo.place(this.format_block(&#039;jstpl_cardontable&#039;, {&lt;br /&gt;
                x : this.cardwidth * (value - 2),&lt;br /&gt;
                y : this.cardheight * (color - 1),&lt;br /&gt;
                player_id : player_id&lt;br /&gt;
            }), &#039;playertablecard_&#039; + player_id);&lt;br /&gt;
&lt;br /&gt;
            if (player_id != this.player_id) {&lt;br /&gt;
                // Some opponent played a card&lt;br /&gt;
                // Move card from player panel&lt;br /&gt;
                this.placeOnObject(&#039;cardontable_&#039; + player_id, &#039;overall_player_board_&#039; + player_id);&lt;br /&gt;
            } else {&lt;br /&gt;
                // You played a card. If it exists in your hand, move card from there and remove&lt;br /&gt;
                // corresponding item&lt;br /&gt;
&lt;br /&gt;
                if ($(&#039;myhand_item_&#039; + card_id)) {&lt;br /&gt;
                    this.placeOnObject(&#039;cardontable_&#039; + player_id, &#039;myhand_item_&#039; + card_id);&lt;br /&gt;
                    this.playerHand.removeFromStockById(card_id);&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            // In any case: move it to its final destination&lt;br /&gt;
            this.slideToObject(&#039;cardontable_&#039; + player_id, &#039;playertablecard_&#039; + player_id).play();&lt;br /&gt;
        },&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For this to work we also need to add a card template in the .tpl file&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
// Javascript HTML templates&lt;br /&gt;
&lt;br /&gt;
var jstpl_cardontable = &#039;&amp;lt;div class=&amp;quot;cardontable&amp;quot; id=&amp;quot;cardontable_${player_id}&amp;quot; style=&amp;quot;background-position:-${x}px -${y}px&amp;quot;&amp;gt;\&lt;br /&gt;
                        &amp;lt;/div&amp;gt;&#039;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
What this does is basically create another card object, because if it is not our card it&#039;s not in our hand (Stock) so&lt;br /&gt;
we have to create it out of thin air. The technique to do that is to implement a Javascript template object defined in the .tpl file with some&lt;br /&gt;
parameters, which will basically create a &amp;quot;div&amp;quot; string (yes you could have used string concatenation but it would not be fancy).&lt;br /&gt;
Now dojo.place places it (the div) on top of a placeholder. Now we have an object with an id of &#039;cardontable_&#039; + player_id. Depending&lt;br /&gt;
on who is playing it we either place it on the player miniboard or in hand (and remove it from hand stock). Then we animate the card move.&lt;br /&gt;
&lt;br /&gt;
We also should fix our .css file now to add style for cardontable and REMOVE background for playertablecard which really is a placeholder div and not a card. (Don&#039;t miss the remove step; it will be all screwy if you do!)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
.playertablecard {&lt;br /&gt;
    display: inline-block;&lt;br /&gt;
    position: relative;&lt;br /&gt;
    margin-top: 5px;&lt;br /&gt;
    width: 72px;&lt;br /&gt;
    height: 96px;&lt;br /&gt;
    /* we remove background-image here */&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/*** cards on table ***/&lt;br /&gt;
&lt;br /&gt;
.cardontable {&lt;br /&gt;
    position: absolute;&lt;br /&gt;
    width: 72px;&lt;br /&gt;
    height: 96px;&lt;br /&gt;
    background-image: url(&#039;img/cards.jpg&#039;); &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now to test that it actually works let&#039;s deal cards to players during game initialization:&lt;br /&gt;
&lt;br /&gt;
Add this after createCards in setupNewGame function in the game.php file&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
        // Shuffle deck&lt;br /&gt;
        $this-&amp;gt;cards-&amp;gt;shuffle(&#039;deck&#039;);&lt;br /&gt;
        // Deal 13 cards to each players&lt;br /&gt;
        $players = self::loadPlayersBasicInfos();&lt;br /&gt;
        foreach ( $players as $player_id =&amp;gt; $player ) {&lt;br /&gt;
            $cards = $this-&amp;gt;cards-&amp;gt;pickCards(13, &#039;deck&#039;, $player_id);&lt;br /&gt;
        } &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now when you start the game you should see 13 cards in your hand!&lt;br /&gt;
&lt;br /&gt;
We just need to hook-up clicking on card and test if our playCardOnTable works.&lt;br /&gt;
&lt;br /&gt;
Find onPlayerHandSelectionChanged function in the JS file, we should have logging there like  console.log(&amp;quot;on playCard &amp;quot;+card_id);&lt;br /&gt;
So after that insert this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
                    console.log(&amp;quot;on playCard &amp;quot;+card_id);&lt;br /&gt;
                    // type is (color - 1) * 13 + (value - 2)&lt;br /&gt;
                    var type = items[0].type;&lt;br /&gt;
                    var color = Math.floor(type / 13) + 1;&lt;br /&gt;
                    var value = type % 13 + 2;&lt;br /&gt;
                    &lt;br /&gt;
                    this.playCardOnTable(this.player_id,color,value,card_id);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Note: this code is for testing we will replace it with server interaction after we test it.&lt;br /&gt;
&lt;br /&gt;
Now if you force reload (because we changed .css before) you should be able to click on card from your hand and see it moving,&lt;br /&gt;
you can click on few cards this way. When you done enjoying the animation, press F5 to get your hand back.&lt;br /&gt;
&lt;br /&gt;
[[File:Heartsla-sync.png]]&lt;br /&gt;
&lt;br /&gt;
Code Rev [https://github.com/elaskavaia/bga-heartsla/tree/01d4e2f595fd14c2adcc97a957d21bb2766f78a8]&lt;br /&gt;
&lt;br /&gt;
== State Machine ==&lt;br /&gt;
&lt;br /&gt;
Now we need to create a game state machine. So the states are:&lt;br /&gt;
&lt;br /&gt;
* Cards are dealt to all players (lets call it &amp;quot;newHand&amp;quot;)&lt;br /&gt;
* Player is selected who will start a new trick (&amp;quot;newTrick&amp;quot;)&lt;br /&gt;
* Player start or respond to played card (&amp;quot;playerTurn&amp;quot;)&lt;br /&gt;
* Game control is passed to next player or trick is ended (&amp;quot;nextPlayer&amp;quot;)&lt;br /&gt;
* End of hand processing (scoring and check for end of game) (&amp;quot;nextHand&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
In addition players can exchange cards so we need two more states for that but we will skip it for now.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The state handling spread across 4 files, so you have to make sure all pieces are connected together.&lt;br /&gt;
The state machine states.php defines all the states, and function handlers on php side in a form of string,&lt;br /&gt;
and if any of these functions are not implemented it would be very hard to debug because it will break in random places.&lt;br /&gt;
&lt;br /&gt;
So .states.php&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$machinestates = array(&lt;br /&gt;
&lt;br /&gt;
    // The initial state. Please do not modify.&lt;br /&gt;
    1 =&amp;gt; array(&lt;br /&gt;
        &amp;quot;name&amp;quot; =&amp;gt; &amp;quot;gameSetup&amp;quot;,&lt;br /&gt;
        &amp;quot;description&amp;quot; =&amp;gt; clienttranslate(&amp;quot;Game setup&amp;quot;),&lt;br /&gt;
        &amp;quot;type&amp;quot; =&amp;gt; &amp;quot;manager&amp;quot;,&lt;br /&gt;
        &amp;quot;action&amp;quot; =&amp;gt; &amp;quot;stGameSetup&amp;quot;,&lt;br /&gt;
        &amp;quot;transitions&amp;quot; =&amp;gt; array( &amp;quot;&amp;quot; =&amp;gt; 2 )&lt;br /&gt;
    ),&lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    /// New hand&lt;br /&gt;
    2 =&amp;gt; array(&lt;br /&gt;
        &amp;quot;name&amp;quot; =&amp;gt; &amp;quot;newHand&amp;quot;,&lt;br /&gt;
        &amp;quot;description&amp;quot; =&amp;gt; &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot; =&amp;gt; &amp;quot;game&amp;quot;,&lt;br /&gt;
        &amp;quot;action&amp;quot; =&amp;gt; &amp;quot;stNewHand&amp;quot;,&lt;br /&gt;
        &amp;quot;updateGameProgression&amp;quot; =&amp;gt; true,   &lt;br /&gt;
        &amp;quot;transitions&amp;quot; =&amp;gt; array( &amp;quot;&amp;quot; =&amp;gt; 30 )&lt;br /&gt;
    ),    &lt;br /&gt;
&lt;br /&gt;
    21 =&amp;gt; array(       &lt;br /&gt;
        &amp;quot;name&amp;quot; =&amp;gt; &amp;quot;giveCards&amp;quot;,&lt;br /&gt;
        &amp;quot;description&amp;quot; =&amp;gt; clienttranslate(&#039;Some players must choose 3 cards to give to ${direction}&#039;),&lt;br /&gt;
        &amp;quot;descriptionmyturn&amp;quot; =&amp;gt; clienttranslate(&#039;${you} must choose 3 cards to give to ${direction}&#039;),&lt;br /&gt;
        &amp;quot;type&amp;quot; =&amp;gt; &amp;quot;multipleactiveplayer&amp;quot;,&lt;br /&gt;
        &amp;quot;action&amp;quot; =&amp;gt; &amp;quot;stGiveCards&amp;quot;,&lt;br /&gt;
        &amp;quot;args&amp;quot; =&amp;gt; &amp;quot;argGiveCards&amp;quot;,&lt;br /&gt;
        &amp;quot;possibleactions&amp;quot; =&amp;gt; array( &amp;quot;giveCards&amp;quot; ),&lt;br /&gt;
        &amp;quot;transitions&amp;quot; =&amp;gt; array( &amp;quot;giveCards&amp;quot; =&amp;gt; 22, &amp;quot;skip&amp;quot; =&amp;gt; 22 )        &lt;br /&gt;
    ), &lt;br /&gt;
    &lt;br /&gt;
    22 =&amp;gt; array(&lt;br /&gt;
        &amp;quot;name&amp;quot; =&amp;gt; &amp;quot;takeCards&amp;quot;,&lt;br /&gt;
        &amp;quot;description&amp;quot; =&amp;gt; &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot; =&amp;gt; &amp;quot;game&amp;quot;,&lt;br /&gt;
        &amp;quot;action&amp;quot; =&amp;gt; &amp;quot;stTakeCards&amp;quot;,&lt;br /&gt;
        &amp;quot;transitions&amp;quot; =&amp;gt; array( &amp;quot;startHand&amp;quot; =&amp;gt; 30, &amp;quot;skip&amp;quot; =&amp;gt; 30  )&lt;br /&gt;
    ),        &lt;br /&gt;
      &lt;br /&gt;
    &lt;br /&gt;
    // Trick&lt;br /&gt;
    &lt;br /&gt;
    30 =&amp;gt; array(&lt;br /&gt;
        &amp;quot;name&amp;quot; =&amp;gt; &amp;quot;newTrick&amp;quot;,&lt;br /&gt;
        &amp;quot;description&amp;quot; =&amp;gt; &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot; =&amp;gt; &amp;quot;game&amp;quot;,&lt;br /&gt;
        &amp;quot;action&amp;quot; =&amp;gt; &amp;quot;stNewTrick&amp;quot;,&lt;br /&gt;
        &amp;quot;transitions&amp;quot; =&amp;gt; array( &amp;quot;&amp;quot; =&amp;gt; 31 )&lt;br /&gt;
    ),       &lt;br /&gt;
    31 =&amp;gt; array(&lt;br /&gt;
        &amp;quot;name&amp;quot; =&amp;gt; &amp;quot;playerTurn&amp;quot;,&lt;br /&gt;
        &amp;quot;description&amp;quot; =&amp;gt; clienttranslate(&#039;${actplayer} must play a card&#039;),&lt;br /&gt;
        &amp;quot;descriptionmyturn&amp;quot; =&amp;gt; clienttranslate(&#039;${you} must play a card&#039;),&lt;br /&gt;
        &amp;quot;type&amp;quot; =&amp;gt; &amp;quot;activeplayer&amp;quot;,&lt;br /&gt;
        &amp;quot;possibleactions&amp;quot; =&amp;gt; array( &amp;quot;playCard&amp;quot; ),&lt;br /&gt;
        &amp;quot;transitions&amp;quot; =&amp;gt; array( &amp;quot;playCard&amp;quot; =&amp;gt; 32 )&lt;br /&gt;
    ), &lt;br /&gt;
    32 =&amp;gt; array(&lt;br /&gt;
        &amp;quot;name&amp;quot; =&amp;gt; &amp;quot;nextPlayer&amp;quot;,&lt;br /&gt;
        &amp;quot;description&amp;quot; =&amp;gt; &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot; =&amp;gt; &amp;quot;game&amp;quot;,&lt;br /&gt;
        &amp;quot;action&amp;quot; =&amp;gt; &amp;quot;stNextPlayer&amp;quot;,&lt;br /&gt;
        &amp;quot;transitions&amp;quot; =&amp;gt; array( &amp;quot;nextPlayer&amp;quot; =&amp;gt; 31, &amp;quot;nextTrick&amp;quot; =&amp;gt; 30, &amp;quot;endHand&amp;quot; =&amp;gt; 40 )&lt;br /&gt;
    ), &lt;br /&gt;
    &lt;br /&gt;
    &lt;br /&gt;
    // End of the hand (scoring, etc...)&lt;br /&gt;
    40 =&amp;gt; array(&lt;br /&gt;
        &amp;quot;name&amp;quot; =&amp;gt; &amp;quot;endHand&amp;quot;,&lt;br /&gt;
        &amp;quot;description&amp;quot; =&amp;gt; &amp;quot;&amp;quot;,&lt;br /&gt;
        &amp;quot;type&amp;quot; =&amp;gt; &amp;quot;game&amp;quot;,&lt;br /&gt;
        &amp;quot;action&amp;quot; =&amp;gt; &amp;quot;stEndHand&amp;quot;,&lt;br /&gt;
        &amp;quot;transitions&amp;quot; =&amp;gt; array( &amp;quot;nextHand&amp;quot; =&amp;gt; 2, &amp;quot;endGame&amp;quot; =&amp;gt; 99 )&lt;br /&gt;
    ),     &lt;br /&gt;
   &lt;br /&gt;
    // Final state.&lt;br /&gt;
    // Please do not modify.&lt;br /&gt;
    99 =&amp;gt; array(&lt;br /&gt;
        &amp;quot;name&amp;quot; =&amp;gt; &amp;quot;gameEnd&amp;quot;,&lt;br /&gt;
        &amp;quot;description&amp;quot; =&amp;gt; clienttranslate(&amp;quot;End of game&amp;quot;),&lt;br /&gt;
        &amp;quot;type&amp;quot; =&amp;gt; &amp;quot;manager&amp;quot;,&lt;br /&gt;
        &amp;quot;action&amp;quot; =&amp;gt; &amp;quot;stGameEnd&amp;quot;,&lt;br /&gt;
        &amp;quot;args&amp;quot; =&amp;gt; &amp;quot;argGameEnd&amp;quot;&lt;br /&gt;
    )&lt;br /&gt;
&lt;br /&gt;
);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The full details on these fields are in [[Your_game_state_machine:_states.inc.php]].&lt;br /&gt;
&lt;br /&gt;
But basically we have Player states, in which a human player has to perform an &amp;quot;action&amp;quot; by pressing some button in the UI or selecting some game item, which will trigger js handler, which will do an ajax call to the server into API defined&lt;br /&gt;
by .action.php file. All functions in this file are API between client and server and have very simple&lt;br /&gt;
and repetitive structures. In this case there are only two actions player can do - play a card or pass cards to other player. So these 2 functions go into .action.php file, we will only define one now since we have not implemented card passing states yet:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    public function playCard() {&lt;br /&gt;
        self::setAjaxMode();&lt;br /&gt;
        $card_id = self::getArg(&amp;quot;id&amp;quot;, AT_posint, true);&lt;br /&gt;
        $this-&amp;gt;game-&amp;gt;playCard($card_id);&lt;br /&gt;
        self::ajaxResponse();&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now to make it run we have to define all the handler functions that we referenced in states, which are - one function for state arguments argGiveCards, 4 functions for robot states (where the game performs some action)&lt;br /&gt;
and 1 function for player actions handling.&lt;br /&gt;
In .game.php, find &#039;Game state arguments&#039; section and paste this in:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    function argGiveCards() {&lt;br /&gt;
        return array ();&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This normally passes some parameters to states, but we don&#039;t need anything yet. It&#039;s good to have a placeholder there anyway, so we can fix it later.&lt;br /&gt;
Important: even when it&#039;s a stub, this function must return an array not a scalar.&lt;br /&gt;
&lt;br /&gt;
Let&#039;s do stubs for other functions, find the game state actions section in .game.php file and insert these&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    function stNewHand() {&lt;br /&gt;
        // Take back all cards (from any location =&amp;gt; null) to deck&lt;br /&gt;
        $this-&amp;gt;cards-&amp;gt;moveAllCardsInLocation(null, &amp;quot;deck&amp;quot;);&lt;br /&gt;
        $this-&amp;gt;cards-&amp;gt;shuffle(&#039;deck&#039;);&lt;br /&gt;
        // Deal 13 cards to each players&lt;br /&gt;
        // Create deck, shuffle it and give 13 initial cards&lt;br /&gt;
        $players = self::loadPlayersBasicInfos();&lt;br /&gt;
        foreach ( $players as $player_id =&amp;gt; $player ) {&lt;br /&gt;
            $cards = $this-&amp;gt;cards-&amp;gt;pickCards(13, &#039;deck&#039;, $player_id);&lt;br /&gt;
            // Notify player about his cards&lt;br /&gt;
            self::notifyPlayer($player_id, &#039;newHand&#039;, &#039;&#039;, array (&#039;cards&#039; =&amp;gt; $cards ));&lt;br /&gt;
        }&lt;br /&gt;
        self::setGameStateValue(&#039;alreadyPlayedHearts&#039;, 0);&lt;br /&gt;
        $this-&amp;gt;gamestate-&amp;gt;nextState(&amp;quot;&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    function stNewTrick() {&lt;br /&gt;
        // New trick: active the player who wins the last trick, or the player who own the club-2 card&lt;br /&gt;
        // Reset trick color to 0 (= no color)&lt;br /&gt;
        self::setGameStateInitialValue(&#039;trickColor&#039;, 0);&lt;br /&gt;
        $this-&amp;gt;gamestate-&amp;gt;nextState();&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    function stNextPlayer() {&lt;br /&gt;
        // Active next player OR end the trick and go to the next trick OR end the hand&lt;br /&gt;
        if ($this-&amp;gt;cards-&amp;gt;countCardInLocation(&#039;cardsontable&#039;) == 4) {&lt;br /&gt;
            // This is the end of the trick&lt;br /&gt;
            // Move all cards to &amp;quot;cardswon&amp;quot; of the given player&lt;br /&gt;
            $best_value_player_id = self::activeNextPlayer(); // TODO figure out winner of trick&lt;br /&gt;
            $this-&amp;gt;cards-&amp;gt;moveAllCardsInLocation(&#039;cardsontable&#039;, &#039;cardswon&#039;, null, $best_value_player_id);&lt;br /&gt;
        &lt;br /&gt;
            if ($this-&amp;gt;cards-&amp;gt;countCardInLocation(&#039;hand&#039;) == 0) {&lt;br /&gt;
                // End of the hand&lt;br /&gt;
                $this-&amp;gt;gamestate-&amp;gt;nextState(&amp;quot;endHand&amp;quot;);&lt;br /&gt;
            } else {&lt;br /&gt;
                // End of the trick&lt;br /&gt;
                $this-&amp;gt;gamestate-&amp;gt;nextState(&amp;quot;nextTrick&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
        } else {&lt;br /&gt;
            // Standard case (not the end of the trick)&lt;br /&gt;
            // =&amp;gt; just active the next player&lt;br /&gt;
            $player_id = self::activeNextPlayer();&lt;br /&gt;
            self::giveExtraTime($player_id);&lt;br /&gt;
            $this-&amp;gt;gamestate-&amp;gt;nextState(&#039;nextPlayer&#039;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    function stEndHand() {&lt;br /&gt;
        $this-&amp;gt;gamestate-&amp;gt;nextState(&amp;quot;nextHand&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Important: All state actions game or player must end with state transition (or thrown exception). Also make sure it&#039;s ONLY one state transition,&lt;br /&gt;
if you accidentally fall through after state transition and do another one it will be a real mess and head scratching for long time.&lt;br /&gt;
&lt;br /&gt;
Now find &#039;player actions&#039; section and paste this code there&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    function playCard($card_id) {&lt;br /&gt;
        self::checkAction(&amp;quot;playCard&amp;quot;);&lt;br /&gt;
        $player_id = self::getActivePlayerId();&lt;br /&gt;
        throw new BgaUserException(self::_(&amp;quot;Not implemented: &amp;quot;) . &amp;quot;$player_id plays $card_id&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
We won&#039;t implement it yet but throw an exception which we will see if interaction is working properly&lt;br /&gt;
&lt;br /&gt;
Now the game should start but it would not be any different than before because we have to implement actual interactions.&lt;br /&gt;
It&#039;s good to check if it&#039;s still working though (and if it was running before you have to exit because we changed state machine and normally it will break stuff)&lt;br /&gt;
&lt;br /&gt;
== Client - Server interactions ==&lt;br /&gt;
&lt;br /&gt;
Now to implement things for real we have hook UI actions to ajax calls, and process notifications sent by the server.&lt;br /&gt;
So previously we hooked playCardOnTable right into js handler which caused client animation, in real game its a two&lt;br /&gt;
step operation. When user clicks on game element js client sends an ajax call to server, server processes it and updates database, server sends&lt;br /&gt;
notification in response, client hooks animations to server notification.&lt;br /&gt;
&lt;br /&gt;
So in .js code replace onPlayerHandSelectionChanged with&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
        onPlayerHandSelectionChanged : function() {&lt;br /&gt;
            var items = this.playerHand.getSelectedItems();&lt;br /&gt;
&lt;br /&gt;
            if (items.length &amp;gt; 0) {&lt;br /&gt;
                var action = &#039;playCard&#039;;&lt;br /&gt;
                if (this.checkAction(action, true)) {&lt;br /&gt;
                    // Can play a card&lt;br /&gt;
                    var card_id = items[0].id;                    &lt;br /&gt;
                    this.ajaxcall(&amp;quot;/&amp;quot; + this.game_name + &amp;quot;/&amp;quot; + this.game_name + &amp;quot;/&amp;quot; + action + &amp;quot;.html&amp;quot;, {&lt;br /&gt;
                        id : card_id,&lt;br /&gt;
                        lock : true&lt;br /&gt;
                    }, this, function(result) {&lt;br /&gt;
                    }, function(is_error) {&lt;br /&gt;
                    });&lt;br /&gt;
&lt;br /&gt;
                    this.playerHand.unselectAll();&lt;br /&gt;
                } else if (this.checkAction(&#039;giveCards&#039;)) {&lt;br /&gt;
                    // Can give cards =&amp;gt; let the player select some cards&lt;br /&gt;
                } else {&lt;br /&gt;
                    this.playerHand.unselectAll();&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
        },&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now when you click on card you should get a server response: Not implemented...&lt;br /&gt;
&lt;br /&gt;
Lets implement it, in .game.php&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    function playCard($card_id) {&lt;br /&gt;
        self::checkAction(&amp;quot;playCard&amp;quot;);&lt;br /&gt;
        $player_id = self::getActivePlayerId();&lt;br /&gt;
        $this-&amp;gt;cards-&amp;gt;moveCard($card_id, &#039;cardsontable&#039;, $player_id);&lt;br /&gt;
        // XXX check rules here&lt;br /&gt;
        $currentCard = $this-&amp;gt;cards-&amp;gt;getCard($card_id);&lt;br /&gt;
        // And notify&lt;br /&gt;
        self::notifyAllPlayers(&#039;playCard&#039;, clienttranslate(&#039;${player_name} plays ${value_displayed} ${color_displayed}&#039;), array (&lt;br /&gt;
                &#039;i18n&#039; =&amp;gt; array (&#039;color_displayed&#039;,&#039;value_displayed&#039; ),&#039;card_id&#039; =&amp;gt; $card_id,&#039;player_id&#039; =&amp;gt; $player_id,&lt;br /&gt;
                &#039;player_name&#039; =&amp;gt; self::getActivePlayerName(),&#039;value&#039; =&amp;gt; $currentCard [&#039;type_arg&#039;],&lt;br /&gt;
                &#039;value_displayed&#039; =&amp;gt; $this-&amp;gt;values_label [$currentCard [&#039;type_arg&#039;]],&#039;color&#039; =&amp;gt; $currentCard [&#039;type&#039;],&lt;br /&gt;
                &#039;color_displayed&#039; =&amp;gt; $this-&amp;gt;colors [$currentCard [&#039;type&#039;]] [&#039;name&#039;] ));&lt;br /&gt;
        // Next player&lt;br /&gt;
        $this-&amp;gt;gamestate-&amp;gt;nextState(&#039;playCard&#039;);&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We get the card from client, we move it to the table (moveCard is hooked to database directly, its part of deck class),&lt;br /&gt;
we notify all players and we change state. What we are missing here is bunch of checks (rule enforcements), we will add it later.&lt;br /&gt;
&lt;br /&gt;
Interesting part about this notify is that we use i18n array for strings that needs to be translated by client, so&lt;br /&gt;
they are sent as English text in notification, then client has to know which parameters needs translating.&lt;br /&gt;
&lt;br /&gt;
On the client side .js we have to implement a notification handler to do the animation&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
        setupNotifications : function() {&lt;br /&gt;
            console.log(&#039;notifications subscriptions setup&#039;);&lt;br /&gt;
&lt;br /&gt;
            dojo.subscribe(&#039;newHand&#039;, this, &amp;quot;notif_newHand&amp;quot;);&lt;br /&gt;
            dojo.subscribe(&#039;playCard&#039;, this, &amp;quot;notif_playCard&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
        },&lt;br /&gt;
&lt;br /&gt;
        notif_newHand : function(notif) {&lt;br /&gt;
            // We received a new full hand of 13 cards.&lt;br /&gt;
            this.playerHand.removeAll();&lt;br /&gt;
&lt;br /&gt;
            for ( var i in notif.args.cards) {&lt;br /&gt;
                var card = notif.args.cards[i];&lt;br /&gt;
                var color = card.type;&lt;br /&gt;
                var value = card.type_arg;&lt;br /&gt;
                this.playerHand.addToStockWithId(this.getCardUniqueId(color, value), card.id);&lt;br /&gt;
            }&lt;br /&gt;
        },&lt;br /&gt;
&lt;br /&gt;
        notif_playCard : function(notif) {&lt;br /&gt;
            // Play a card on the table&lt;br /&gt;
            this.playCardOnTable(notif.args.player_id, notif.args.color, notif.args.value, notif.args.card_id);&lt;br /&gt;
        },&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now it actually works through the server when you click on card - the move is recorded. If you test it now you will notice&lt;br /&gt;
after trick is done all cards remains on the table, but if you press F5 they would disappear, this is because&lt;br /&gt;
we updated database to pick-up the cards but did not send notification about it, so we need to send notification about it&lt;br /&gt;
and have a handler for it&lt;br /&gt;
&lt;br /&gt;
So in .game.php file add notification in stNextPlayer function after moveAllCardsInLocation call:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
            // Notify&lt;br /&gt;
            // Note: we use 2 notifications here in order we can pause the display during the first notification&lt;br /&gt;
            //  before we move all cards to the winner (during the second)&lt;br /&gt;
            $players = self::loadPlayersBasicInfos();&lt;br /&gt;
            self::notifyAllPlayers( &#039;trickWin&#039;, clienttranslate(&#039;${player_name} wins the trick&#039;), array(&lt;br /&gt;
                &#039;player_id&#039; =&amp;gt; $best_value_player_id,&lt;br /&gt;
                &#039;player_name&#039; =&amp;gt; $players[ $best_value_player_id ][&#039;player_name&#039;]&lt;br /&gt;
            ) );            &lt;br /&gt;
            self::notifyAllPlayers( &#039;giveAllCardsToPlayer&#039;,&#039;&#039;, array(&lt;br /&gt;
                &#039;player_id&#039; =&amp;gt; $best_value_player_id&lt;br /&gt;
            ) );&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And in .js file add 2 more notification handlers.&lt;br /&gt;
&lt;br /&gt;
This is to subscribe in setupNotifications function&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
            dojo.subscribe( &#039;trickWin&#039;, this, &amp;quot;notif_trickWin&amp;quot; );&lt;br /&gt;
            this.notifqueue.setSynchronous( &#039;trickWin&#039;, 1000 );&lt;br /&gt;
            dojo.subscribe( &#039;giveAllCardsToPlayer&#039;, this, &amp;quot;notif_giveAllCardsToPlayer&amp;quot; );&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And these are handlers&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
        notif_trickWin : function(notif) {&lt;br /&gt;
            // We do nothing here (just wait in order players can view the 4 cards played before they&#039;re gone.&lt;br /&gt;
        },&lt;br /&gt;
        notif_giveAllCardsToPlayer : function(notif) {&lt;br /&gt;
            // Move all cards on table to given table, then destroy them&lt;br /&gt;
            var winner_id = notif.args.player_id;&lt;br /&gt;
            for ( var player_id in this.gamedatas.players) {&lt;br /&gt;
                var anim = this.slideToObject(&#039;cardontable_&#039; + player_id, &#039;overall_player_board_&#039; + winner_id);&lt;br /&gt;
                dojo.connect(anim, &#039;onEnd&#039;, function(node) {&lt;br /&gt;
                    dojo.destroy(node);&lt;br /&gt;
                });&lt;br /&gt;
                anim.play();&lt;br /&gt;
            }&lt;br /&gt;
        },&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So &#039;trickWin&#039; notification does not do much except it will delay the processing of next notification by 1 second (1000 ms)&lt;br /&gt;
and it will log the message (that happens independently of what handler does).&lt;br /&gt;
&amp;lt;i&amp;gt;Note: if on the other hand you don&#039;t want to log but want to do something else, send an empty message&amp;lt;/i&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now after the trick you see all cards move towards the &amp;quot;player&#039;s stash&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Scoring and End of game handling ==&lt;br /&gt;
&lt;br /&gt;
Now we should calculate scoring and for that we need to actually track who wins the trick.&lt;br /&gt;
Trick is won by the player with highest card (no trump). We just need to remember what is trick suite.&lt;br /&gt;
For which we will use state variable &#039;trickColor&#039; which we already conveniently created.&lt;br /&gt;
&lt;br /&gt;
In .game.php file find playCard function and add this before notify functions&lt;br /&gt;
        $currentTrickColor = self::getGameStateValue( &#039;trickColor&#039; ) ;&lt;br /&gt;
        if( $currentTrickColor == 0 )&lt;br /&gt;
            self::setGameStateValue( &#039;trickColor&#039;, $currentCard[&#039;type&#039;] );&lt;br /&gt;
&lt;br /&gt;
This will make sure we remember first suit being played, now to use it modify stNextPlayer function to fix our TODO comment&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    function stNextPlayer() {&lt;br /&gt;
        // Active next player OR end the trick and go to the next trick OR end the hand&lt;br /&gt;
        if ($this-&amp;gt;cards-&amp;gt;countCardInLocation(&#039;cardsontable&#039;) == 4) {&lt;br /&gt;
            // This is the end of the trick&lt;br /&gt;
            $cards_on_table = $this-&amp;gt;cards-&amp;gt;getCardsInLocation(&#039;cardsontable&#039;);&lt;br /&gt;
            $best_value = 0;&lt;br /&gt;
            $best_value_player_id = null;&lt;br /&gt;
            $currentTrickColor = self::getGameStateValue(&#039;trickColor&#039;);&lt;br /&gt;
            foreach ( $cards_on_table as $card ) {&lt;br /&gt;
                // Note: type = card color&lt;br /&gt;
                if ($card [&#039;type&#039;] == $currentTrickColor) {&lt;br /&gt;
                    if ($best_value_player_id === null || $card [&#039;type_arg&#039;] &amp;gt; $best_value) {&lt;br /&gt;
                        $best_value_player_id = $card [&#039;location_arg&#039;]; // Note: location_arg = player who played this card on table&lt;br /&gt;
                        $best_value = $card [&#039;type_arg&#039;]; // Note: type_arg = value of the card&lt;br /&gt;
                    }&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
            &lt;br /&gt;
            // Active this player =&amp;gt; he&#039;s the one who starts the next trick&lt;br /&gt;
            $this-&amp;gt;gamestate-&amp;gt;changeActivePlayer( $best_value_player_id );&lt;br /&gt;
            &lt;br /&gt;
            // Move all cards to &amp;quot;cardswon&amp;quot; of the given player&lt;br /&gt;
            $this-&amp;gt;cards-&amp;gt;moveAllCardsInLocation(&#039;cardsontable&#039;, &#039;cardswon&#039;, null, $best_value_player_id);&lt;br /&gt;
        &lt;br /&gt;
            // Notify&lt;br /&gt;
            // ... same code here as before&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The scoring rule in the studio example code is huge multi-page function, for this tutorial we will make simplier.&lt;br /&gt;
Lets score -1 point per heart and call it a day. And game will end when somebody goes -100 or below.&lt;br /&gt;
&lt;br /&gt;
As UI goes for scoring, the main thing to update is the scoring on the mini boards represented by stars, also&lt;br /&gt;
we want to show that in the log. &lt;br /&gt;
In addition scoring can be shown in [[Game_interface_logic:_yourgamename.js#Scoring_dialogs|Scoring Dialog]] using tableWindow notification, but it is a tutorial on its own and you can do it as homework (it is part of original heart game).&lt;br /&gt;
&lt;br /&gt;
In .js file we need to add one more subscription and notification handler:&lt;br /&gt;
            dojo.subscribe( &#039;newScores&#039;, this, &amp;quot;notif_newScores&amp;quot; );&lt;br /&gt;
in setupNotifications&lt;br /&gt;
&lt;br /&gt;
and &lt;br /&gt;
        notif_newScores : function(notif) {&lt;br /&gt;
            // Update players&#039; scores&lt;br /&gt;
            for ( var player_id in notif.args.newScores) {&lt;br /&gt;
                this.scoreCtrl[player_id].toValue(notif.args.newScores[player_id]);&lt;br /&gt;
            }&lt;br /&gt;
        },&lt;br /&gt;
somewhere after. this.scoreCtrl is pre-existing object that shows the scoring and this function will update score values per player from notification argument&lt;br /&gt;
&lt;br /&gt;
so in .game.php our stEndHand function will look like&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    function stEndHand() {&lt;br /&gt;
            // Count and score points, then end the game or go to the next hand.&lt;br /&gt;
        $players = self::loadPlayersBasicInfos();&lt;br /&gt;
        // Gets all &amp;quot;hearts&amp;quot; + queen of spades&lt;br /&gt;
&lt;br /&gt;
        $player_to_points = array ();&lt;br /&gt;
        foreach ( $players as $player_id =&amp;gt; $player ) {&lt;br /&gt;
            $player_to_points [$player_id] = 0;&lt;br /&gt;
        }&lt;br /&gt;
        $cards = $this-&amp;gt;cards-&amp;gt;getCardsInLocation(&amp;quot;cardswon&amp;quot;);&lt;br /&gt;
        foreach ( $cards as $card ) {&lt;br /&gt;
            $player_id = $card [&#039;location_arg&#039;];&lt;br /&gt;
            // Note: 2 = heart&lt;br /&gt;
            if ($card [&#039;type&#039;] == 2) {&lt;br /&gt;
                $player_to_points [$player_id] ++;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        // Apply scores to player&lt;br /&gt;
        foreach ( $player_to_points as $player_id =&amp;gt; $points ) {&lt;br /&gt;
            if ($points != 0) {&lt;br /&gt;
                $sql = &amp;quot;UPDATE player SET player_score=player_score-$points  WHERE player_id=&#039;$player_id&#039;&amp;quot;;&lt;br /&gt;
                self::DbQuery($sql);&lt;br /&gt;
                $heart_number = $player_to_points [$player_id];&lt;br /&gt;
                self::notifyAllPlayers(&amp;quot;points&amp;quot;, clienttranslate(&#039;${player_name} gets ${nbr} hearts and looses ${nbr} points&#039;), array (&lt;br /&gt;
                        &#039;player_id&#039; =&amp;gt; $player_id,&#039;player_name&#039; =&amp;gt; $players [$player_id] [&#039;player_name&#039;],&lt;br /&gt;
                        &#039;nbr&#039; =&amp;gt; $heart_number ));&lt;br /&gt;
            } else {&lt;br /&gt;
                // No point lost (just notify)&lt;br /&gt;
                self::notifyAllPlayers(&amp;quot;points&amp;quot;, clienttranslate(&#039;${player_name} did not get any hearts&#039;), array (&lt;br /&gt;
                        &#039;player_id&#039; =&amp;gt; $player_id,&#039;player_name&#039; =&amp;gt; $players [$player_id] [&#039;player_name&#039;] ));&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        $newScores = self::getCollectionFromDb(&amp;quot;SELECT player_id, player_score FROM player&amp;quot;, true );&lt;br /&gt;
        self::notifyAllPlayers( &amp;quot;newScores&amp;quot;, &#039;&#039;, array( &#039;newScores&#039; =&amp;gt; $newScores ) );&lt;br /&gt;
&lt;br /&gt;
        ///// Test if this is the end of the game&lt;br /&gt;
        foreach ( $newScores as $player_id =&amp;gt; $score ) {&lt;br /&gt;
            if ($score &amp;lt;= -100) {&lt;br /&gt;
                // Trigger the end of the game !&lt;br /&gt;
                $this-&amp;gt;gamestate-&amp;gt;nextState(&amp;quot;endGame&amp;quot;);&lt;br /&gt;
                return;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        &lt;br /&gt;
        $this-&amp;gt;gamestate-&amp;gt;nextState(&amp;quot;nextHand&amp;quot;);&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So it should more less work now, including end of game condition. Try to play it!&lt;br /&gt;
&lt;br /&gt;
== Additional stuff ==&lt;br /&gt;
&lt;br /&gt;
The following things were not implemented and can add them yourself by looking at the code of original hearts game:&lt;br /&gt;
&lt;br /&gt;
* Remove debug code from setupNewGame to deal cards, cards are now dealt in stNewHand state handler&lt;br /&gt;
* Rule checking and rule enforcements in playCard function&lt;br /&gt;
* Start scoring with 100 points each and end when &amp;lt;= 0&lt;br /&gt;
* Fix scoring rules with Q of spades and 26 point reverse scoring&lt;br /&gt;
* First player one with 2 club&lt;br /&gt;
* Add progress handling&lt;br /&gt;
* Add statistics&lt;br /&gt;
* Add card exchange states&lt;br /&gt;
* Add game option to start with 75 points instead of 100&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Studio]]&lt;/div&gt;</summary>
		<author><name>Fenadoruk</name></author>
	</entry>
</feed>