Ejemplo n.º 1
0
   Please check the BGA Studio presentation about game state to understand this, and associated documentation.

   Summary:

   States types:
   _ activeplayer: in this type of state, we expect some action from the active player.
   _ multipleactiveplayer: in this type of state, we expect some action from multiple players (the active players)
   _ game: this is an intermediary state where we don't expect any actions from players. Your game logic must decide what is the next game state.
   _ manager: special type for initial and final state

   Arguments of game states:
   _ name: the name of the GameState, in order you can recognize it on your own code.
   _ description: the description of the current game state is always displayed in the action status bar on
                  the top of the game. Most of the time this is useless for game state with "game" type.
   _ descriptionmyturn: the description of the current game state when it's your turn.
   _ type: defines the type of game states (activeplayer / multipleactiveplayer / game / manager)
   _ action: name of the method to call when this game state become the current game state. Usually, the
             action method is prefixed by "st" (ex: "stMyGameStateName").
   _ possibleactions: array that specify possible player actions on this step. It allows you to use "checkAction"
                      method on both client side (Javacript: this.checkAction) and server side (PHP: self::checkAction).
   _ transitions: the transitions are the possible paths to go from a game state to another. You must name
                  transitions in order to use transition names in "nextState" PHP method, and use IDs to
                  specify the next game state for each transition.
   _ args: name of the method to call to retrieve arguments for this gamestate. Arguments are sent to the
           client side to be used on "onEnteringState" or to set arguments in the gamestate description.
   _ updateGameProgression: when specified, the game progression is updated (=> call to your getGameProgression
                            method).
*/
//    !! It is not a good idea to modify this file when a game is running !!
$machinestates = array(1 => array("name" => "gameSetup", "description" => clienttranslate("Game setup"), "type" => "manager", "action" => "stGameSetup", "transitions" => array("" => 2)), 2 => array("name" => "flood", "type" => "game", "action" => "stFlood", "updateGameProgression" => true, "transitions" => array("plague" => 3, "harvest" => 5, "gameEnd" => 90)), 3 => array("name" => "floodPlague", "type" => "game", "action" => "stPlague", "updateGameProgression" => true, "transitions" => array("" => 2)), 5 => array("name" => "harvest", "type" => "game", "action" => "stHarvest", "updateGameProgression" => true, "transitions" => array("" => 10)), 10 => array("name" => "playerTrade", "description" => clienttranslate('${actplayer} must trade or pass'), "descriptionmyturn" => clienttranslate('${you} must trade or pass'), "type" => "activeplayer", "possibleactions" => array("market", "offering", "pass", "zombiePass"), "updateGameProgression" => true, "transitions" => array("plague" => 13, "market" => 10, "offering" => 2, "pass" => 15, "zombiePass" => 15, "gameEnd" => 90)), 13 => array("name" => "marketCardPlague", "type" => "game", "action" => "stPlague", "transitions" => array("" => 10)), 15 => array("name" => "playerPlantOrSpeculate", "description" => clienttranslate('${actplayer} must plant or speculate'), "descriptionmyturn" => clienttranslate('${you} must plant or speculate'), "type" => "activeplayer", "possibleactions" => array("plant", "speculate", "pass", "zombiePass"), "transitions" => array("plant" => 20, "speculate" => 20, "pass" => 20, "zombiePass" => 20)), 20 => array("name" => "drawCards", "type" => "game", "action" => "stDrawCards", "transitions" => array("plague" => 22, "nextPlayer" => 25, "gameEnd" => 90)), 22 => array("name" => "drawCardPlague", "type" => "game", "action" => "stPlague", "transitions" => array("" => 25)), 25 => array("name" => "nextPlayer", "type" => "game", "action" => "stNextPlayer", "updateGameProgression" => true, "transitions" => array("" => 2)), 90 => array("name" => "gameEndScoring", "type" => "game", "action" => "stGameEndScoring", "updateGameProgression" => true, "transitions" => array("" => 99)), 99 => array("name" => "gameEnd", "description" => clienttranslate("End of game"), "type" => "manager", "action" => "stGameEnd", "args" => "argGameEnd"));
Ejemplo n.º 2
0
/**
 *------
 * BGA framework: © Gregory Isabelli <*****@*****.**> & Emmanuel Colin <*****@*****.**>
 * aknile implementation : © Andrew Kerrison <*****@*****.**>
 * 
 * This code has been produced on the BGA studio platform for use on http://boardgamearena.com.
 * See http://en.boardgamearena.com/#!doc/Studio for more information.
 * -----
 *
 * material.inc.php
 *
 * aknile game material description
 *
 * Here, you can describe the material of your game with PHP variables.
 *   
 * This file is loaded in your game logic class constructor, ie these variables
 * are available everywhere in your game logic code.
 *
 */
//trasnslatable text will go here for convenience
$this->resources = array("plague" => clienttranslate('Plague'), "papyrus" => clienttranslate('Papyrus'), "wheat" => clienttranslate('Wheat'), "lettuce" => clienttranslate('Lettuce'), "castor" => clienttranslate('Castor'), "flax" => clienttranslate('Flax'), "papyrus_wheat" => clienttranslate('Papyrus/Wheat'), "papyrus_lettuce" => clienttranslate('Papyrus/Lettuce'), "papyrus_castor" => clienttranslate('Papyrus/Castor'), "papyrus_flax" => clienttranslate('Papyrus/Flax'), "wheat_lettuce" => clienttranslate('Wheat/Lettuce'), "wheat_castor" => clienttranslate('Wheat/Castor'), "wheat_flax" => clienttranslate('Wheat/Flax'), "lettuce_castor" => clienttranslate('Lettuce/Castor'), "lettuce_flax" => clienttranslate('Lettuce/Flax'), "castor_flax" => clienttranslate('Castor/Flax'), "score_window_title" => clienttranslate('Final Scoring'), "win_condition" => clienttranslate('Each player\'s final score is the crop type they have fewest of in storage'));
//Papyrus (Red), Wheat (Yellow), Lettuce (Green), Castor (Brown), and Flax (Lavender),
$this->card_types = array(1 => array('name' => $this->resources["papyrus"], 'type_id' => 1, 'harvestTypes' => array(1), 'isSpeculation' => 0, 'isPlague' => 0), 2 => array('name' => $this->resources["wheat"], 'type_id' => 2, 'harvestTypes' => array(2), 'isSpeculation' => 0, 'isPlague' => 0), 3 => array('name' => $this->resources["lettuce"], 'type_id' => 3, 'harvestTypes' => array(3), 'isSpeculation' => 0, 'isPlague' => 0), 4 => array('name' => $this->resources["castor"], 'type_id' => 4, 'harvestTypes' => array(4), 'isSpeculation' => 0, 'isPlague' => 0), 5 => array('name' => $this->resources["flax"], 'type_id' => 5, 'harvestTypes' => array(5), 'isSpeculation' => 0, 'isPlague' => 0), 6 => array('name' => $this->resources["papyrus_wheat"], 'type_id' => 6, 'harvestTypes' => array(1, 2), 'isSpeculation' => 1, 'isPlague' => 0), 7 => array('name' => $this->resources["papyrus_lettuce"], 'type_id' => 7, 'harvestTypes' => array(1, 3), 'isSpeculation' => 1, 'isPlague' => 0), 8 => array('name' => $this->resources["papyrus_castor"], 'type_id' => 8, 'harvestTypes' => array(1, 4), 'isSpeculation' => 1, 'isPlague' => 0), 9 => array('name' => $this->resources["papyrus_flax"], 'type_id' => 9, 'harvestTypes' => array(1, 5), 'isSpeculation' => 1, 'isPlague' => 0), 10 => array('name' => $this->resources["wheat_lettuce"], 'type_id' => 10, 'harvestTypes' => array(2, 3), 'isSpeculation' => 1, 'isPlague' => 0), 11 => array('name' => $this->resources["wheat_castor"], 'type_id' => 11, 'harvestTypes' => array(2, 4), 'isSpeculation' => 1, 'isPlague' => 0), 12 => array('name' => $this->resources["wheat_flax"], 'type_id' => 12, 'harvestTypes' => array(2, 5), 'isSpeculation' => 1, 'isPlague' => 0), 13 => array('name' => $this->resources["lettuce_castor"], 'type_id' => 13, 'harvestTypes' => array(3, 4), 'isSpeculation' => 1, 'isPlague' => 0), 14 => array('name' => $this->resources["lettuce_flax"], 'type_id' => 14, 'harvestTypes' => array(3, 5), 'isSpeculation' => 1, 'isPlague' => 0), 15 => array('name' => $this->resources["castor_flax"], 'type_id' => 15, 'harvestTypes' => array(4, 5), 'isSpeculation' => 1, 'isPlague' => 0), 16 => array('name' => $this->resources["plague"], 'type_id' => 16, 'harvestTypes' => array(), 'isSpeculation' => 0, 'isPlague' => 1));
/*
Example:
$this->card_types = array(
    1 => array( "card_name" => ...,
                ...
              )
);
*/
Ejemplo n.º 3
0
<?php

/**
 *------
 * BGA framework: © Gregory Isabelli <*****@*****.**> & Emmanuel Colin <*****@*****.**>
 * aktestox implementation : © <Your name here> <Your email address here>
 * 
 * This code has been produced on the BGA studio platform for use on http://boardgamearena.com.
 * See http://en.boardgamearena.com/#!doc/Studio for more information.
 * -----
 *
 * material.inc.php
 *
 * aktestox game material description
 *
 * Here, you can describe the material of your game with PHP variables.
 *   
 * This file is loaded in your game logic class constructor, ie these variables
 * are available everywhere in your game logic code.
 *
 */
$this->text = array('playDisc' => clienttranslate('${player_name} plays a disc at ${x}, ${y}'));
$this->teststring = "test string";
/*
Example:
$this->card_types = array(
    1 => array( "card_name" => ...,
                ...
              )
);
*/
Ejemplo n.º 4
0
<?php

/**
 *------
 * BGA framework: © Gregory Isabelli <*****@*****.**> & Emmanuel Colin <*****@*****.**>
 * Tichu implementation : © Bryan McGinnis <*****@*****.**>
 *
 * This code has been produced on the BGA studio platform for use on http://boardgamearena.com.
 * See http://en.boardgamearena.com/#!doc/Studio for more information.
 * -----
 * material.inc.php
 *
 * Hearts game material description
 * Here, you can describe the material of your game with PHP variables.
 * This file is loaded in your game logic class constructor, ie these variables
 * are available everywhere in your game logic code. *
 */
$this->colors = array(1 => array('name' => clienttranslate('Club'), 'nametr' => self::_('Club')), 2 => array('name' => clienttranslate('Spade'), 'nametr' => self::_('Spade')), 3 => array('name' => clienttranslate('Heart'), 'nametr' => self::_('Heart')), 4 => array('name' => clienttranslate('Diamond'), 'nametr' => self::_('Diamond')));
$this->values_label = array(2 => '2', 3 => '3', 4 => '4', 5 => '5', 6 => '6', 7 => '7', 8 => '8', 9 => '9', 10 => '10', 11 => clienttranslate('Jack'), 12 => clienttranslate('Queen'), 13 => clienttranslate('King'), 14 => clienttranslate('Ace'));
$this->specials_label = array(1 => clienttranslate('Dog'), 2 => clienttranslate('Mah Jong'), 3 => clienttranslate('Phoenix'), 4 => clienttranslate('Dragon'));
$this->specials_value = array(1 => clienttranslate('0.5'), 2 => clienttranslate('1'), 3 => clienttranslate('1.5'), 4 => clienttranslate('15'));
$this->play_type = array(0 => 'Single', 1 => 'Doubles', 2 => 'Triples', 3 => 'Full House', 4 => 'Consecutive Doubles', 5 => 'Run of 5', 6 => 'Run of 6', 7 => 'Run of 7', 8 => 'Run of 8', 9 => 'Run of 9', 10 => 'Run of 10', 11 => 'Run of 11', 12 => 'Run of 12', 13 => 'Run of 13', 14 => 'Run of 14', 15 => 'Dog', 20 => 'Bomb');
Ejemplo n.º 5
0
   _ description: the description of the current game state is always displayed in the action status bar on
                  the top of the game. Most of the time this is useless for game state with "game" type.
   _ descriptionmyturn: the description of the current game state when it's your turn.
   _ type: defines the type of game states (activeplayer / multipleactiveplayer / game / manager)
   _ action: name of the method to call when this game state become the current game state. Usually, the
             action method is prefixed by "st" (ex: "stMyGameStateName").
   _ possibleactions: array that specify possible player actions on this step. It allows you to use "checkAction"
                      method on both client side (Javacript: this.checkAction) and server side (PHP: self::checkAction).
   _ transitions: the transitions are the possible paths to go from a game state to another. You must name
                  transitions in order to use transition names in "nextState" PHP method, and use IDs to
                  specify the next game state for each transition.
   _ args: name of the method to call to retrieve arguments for this gamestate. Arguments are sent to the
           client side to be used on "onEnteringState" or to set arguments in the gamestate description.
   _ updateGameProgression: when specified, the game progression is updated (=> call to your getGameProgression
                            method).
*/
//    !! It is not a good idea to modify this file when a game is running !!
class StateEnumerator
{
    const gameSetup = 1;
    const firstRoundBegin = 2;
    const roundBegin = 3;
    const roundEnd = 4;
    const playerTurn = 5;
    const mandatoryState = 6;
    const bonusState = 7;
    const nextPlayer = 8;
    const gameEnd = 99;
}
$machinestates = array(1 => array("name" => "gameSetup", "description" => "", "type" => "manager", "action" => "stGameSetup", "transitions" => array("" => 2)), StateEnumerator::firstRoundBegin => array("name" => "firstRoundBegin", "description" => clienttranslate('This is the first Round, every player must choose a Character and Destination Cards'), "descriptionmyturn" => clienttranslate('This is the first Round, ${you} must choose your Character and your Destination Cards'), "type" => "multipleactiveplayer", "possibleactions" => array("chooseCharacterAndDestinations"), "transitions" => array("playerTurn" => StateEnumerator::playerTurn)), StateEnumerator::roundBegin => array("name" => "roundBegin", "description" => clienttranslate('${actplayer} must make a mandatory action or bonus action'), "descriptionmyturn" => clienttranslate('${you} must make a mandatory action or bonus action'), "type" => "multipleactiveplayer", "action" => "stRoundBegin", "possibleactions" => array("mandatory", "bonus", "pass"), "transitions" => array("playerTurn" => StateEnumerator::playerTurn)), StateEnumerator::playerTurn => array("name" => "playerTurn", "description" => clienttranslate('${actplayer} must make a mandatory action or bonus action'), "descriptionmyturn" => clienttranslate('${you} must make a mandatory action or bonus action'), "type" => "activeplayer", "possibleactions" => array("mandatory", "bonus", "pass"), "transitions" => array("mandatoryState" => StateEnumerator::mandatoryState, "bonusState" => StateEnumerator::bonusState, "nextPlayer" => StateEnumerator::nextPlayer)), StateEnumerator::mandatoryState => array("name" => "mandatoryState", "description" => clienttranslate('${actplayer} must make a mandatory action'), "descriptionmyturn" => clienttranslate('${you} must make a mandatory action'), "type" => "activeplayer", "possibleactions" => array("take5Gold", "goToTheBazaar", "seekTheKhansFavor", "TakeAContract", "Travel", "cityCard"), "transitions" => array("playerTurn" => StateEnumerator::playerTurn)), StateEnumerator::bonusState => array("name" => "bonusState", "description" => clienttranslate('${actplayer} must make a bonus action'), "descriptionmyturn" => clienttranslate('${you} must make a bonus action'), "type" => "activeplayer", "possibleactions" => array("pass", "completeContract", "take3Coins", "rerollDie", "adjustDieResultByOne", "take1BlackDie"), "transitions" => array("playerTurn" => StateEnumerator::playerTurn, "nextPlayer" => StateEnumerator::nextPlayer)), StateEnumerator::nextPlayer => array("name" => "nextPlayer", "description" => clienttranslate('${actplayer} ended his/her turn'), "descriptionmyturn" => clienttranslate('${you} ended your turn'), "type" => "game", "action" => "stNextPlayer", "updateGameProgression" => true, "transitions" => array("playerTurn" => StateEnumerator::playerTurn, "nextPlayer" => StateEnumerator::nextPlayer, "roundBegin" => StateEnumerator::roundEnd)), StateEnumerator::roundEnd => array("name" => "nextPlayer", "description" => clienttranslate('Round Ended'), "descriptionmyturn" => clienttranslate('Round Ended'), "type" => "game", "action" => "stRoundEnd", "updateGameProgression" => true, "transitions" => array("roundBegin" => StateEnumerator::roundBegin, "gameEnd" => StateEnumerator::gameEnd)), 99 => array("name" => "gameEnd", "description" => clienttranslate("End of game"), "type" => "manager", "action" => "stGameEnd", "args" => "argGameEnd"));
Ejemplo n.º 6
0
<?php

/**
 *------
 * BGA framework: © Gregory Isabelli <*****@*****.**> & Emmanuel Colin <*****@*****.**>
 * nineteensixtynine implementation : © <Your name here> <Your email address here>
 * 
 * This code has been produced on the BGA studio platform for use on http://boardgamearena.com.
 * See http://en.boardgamearena.com/#!doc/Studio for more information.
 * -----
 *
 * material.inc.php
 *
 * nineteensixtynine game material description
 *
 * Here, you can describe the material of your game with PHP variables.
 *   
 * This file is loaded in your game logic class constructor, ie these variables
 * are available everywhere in your game logic code.
 *
 */
$this->matScientistList = array('rookie' => array('name' => clienttranslate('rookie'), 'nametr' => self::_('rookie'), 'price' => 3, 'quantity' => 40), 'basic' => array('name' => clienttranslate('basic'), 'nametr' => self::_('basic'), 'price' => 5, 'quantity' => 10), 'genious' => array('name' => clienttranslate('genious'), 'nametr' => self::_('genious'), 'price' => 11, 'quantity' => 10), 'famous' => array('name' => clienttranslate('famous'), 'nametr' => self::_('famouse'), 'price' => 9, 'quantity' => 10));
$this->matSpy = array('name' => clienttranslate('spy'), 'nametr' => self::_('spy'), 'price' => 7, 'quantity' => 10);
$this->matIntelligenceCards = array(array('point' => 1, 'quantity' => 13), array('point' => 2, 'quantity' => 13), array('point' => 3, 'quantity' => 13));
$this->matCountries = array('usa', 'france', 'russia', 'germany', 'canada');
 function stBeforeRound()
 {
     $currentRound = $this->incGameStateValue("current_round", 1);
     $this->setGameStateValue("current_income_turn", 0);
     $this->setGameStateValue("current_purchase_turn", 0);
     $this->notifyAllPlayers("message", clienttranslate('Round ${currentRound} started!'), array("currentRound" => $currentRound));
     $this->notifyAllPlayers("newRound", "", array("currentRound" => $currentRound));
     $this->activeNextPlayer();
     //to activate the next from the previous first player
     $this->gamestate->nextState("beforeIncome");
 }
Ejemplo n.º 8
0
 function stPlague()
 {
     self::setGameStateValue("plagueTrigger", 0);
     //a bit like a harvest gone wrong.
     $max = 0;
     $players = self::loadPlayersBasicInfos();
     foreach ($players as $player) {
         foreach ($this->card_types as $cardType) {
             if ($cardType['isSpeculation'] == 0 && $cardType['isPlague'] == 0) {
                 $count = $this->getFieldCount($player['player_id'], $cardType['type_id']);
                 $max = max($max, $count);
             }
         }
     }
     if ($max > 0) {
         foreach ($players as $player) {
             foreach ($this->card_types as $cardType) {
                 $count = $this->getFieldCount($player['player_id'], $cardType['type_id']);
                 if ($cardType['isSpeculation'] == 0 && $cardType['isPlague'] == 0 && $count == $max) {
                     $cards = $this->getCardsInLocationByType('field', $player['player_id'], $cardType['type_id']);
                     self::notifyAllPlayers("destroyField", clienttranslate('The Plague of Locusts wipes out the ${resource_name} field of ${player_name}'), array('resource_name' => $cardType["name"], 'playerId' => $player['player_id'], 'player_name' => $player['player_name'], 'cards' => $cards));
                     $cardIdsToDiscard = $this->getCardIds($cards);
                     $this->cards->moveCards($cardIdsToDiscard, "discard");
                 }
             }
         }
     } else {
         self::notifyAllPlayers("plagueFail", clienttranslate('The Plague of Locusts has no effect'), array());
     }
     self::notifyAllPlayers("plagueEnd", "", array());
     $this->gamestate->nextState('');
 }
Ejemplo n.º 9
0
   Please check the BGA Studio presentation about game state to understand this, and associated documentation.

   Summary:

   States types:
   _ activeplayer: in this type of state, we expect some action from the active player.
   _ multipleactiveplayer: in this type of state, we expect some action from multiple players (the active players)
   _ game: this is an intermediary state where we don't expect any actions from players. Your game logic must decide what is the next game state.
   _ manager: special type for initial and final state

   Arguments of game states:
   _ name: the name of the GameState, in order you can recognize it on your own code.
   _ description: the description of the current game state is always displayed in the action status bar on
                  the top of the game. Most of the time this is useless for game state with "game" type.
   _ descriptionmyturn: the description of the current game state when it's your turn.
   _ type: defines the type of game states (activeplayer / multipleactiveplayer / game / manager)
   _ action: name of the method to call when this game state become the current game state. Usually, the
             action method is prefixed by "st" (ex: "stMyGameStateName").
   _ possibleactions: array that specify possible player actions on this step. It allows you to use "checkAction"
                      method on both client side (Javacript: this.checkAction) and server side (PHP: self::checkAction).
   _ transitions: the transitions are the possible paths to go from a game state to another. You must name
                  transitions in order to use transition names in "nextState" PHP method, and use IDs to
                  specify the next game state for each transition.
   _ args: name of the method to call to retrieve arguments for this gamestate. Arguments are sent to the
           client side to be used on "onEnteringState" or to set arguments in the gamestate description.
   _ updateGameProgression: when specified, the game progression is updated (=> call to your getGameProgression
                            method).
*/
//    !! It is not a good idea to modify this file when a game is running !!
$machinestates = array(1 => array("name" => "gameSetup", "description" => clienttranslate("Game setup"), "type" => "manager", "action" => "stGameSetup", "transitions" => array("" => 15)), 5 => array("name" => "beforeRound", "type" => "game", "action" => "stBeforeRound", "transitions" => array("beforeIncome" => 10)), 10 => array("name" => "beforeIncome", "type" => "game", "action" => "stBeforeIncome", "transitions" => array("income" => 15)), 15 => array("name" => "income", "description" => clienttranslate('${actplayer} must takes an income'), "descriptionmyturn" => clienttranslate('${you} must take an income'), "type" => "activeplayer", "possibleactions" => array("confirmIncome"), "transitions" => array("afterIncome" => 20)), 20 => array("name" => "afterIncome", "type" => "game", "action" => "stAfterIncome", "transitions" => array("beforeIncome" => 10, "beforePurchase" => 25)), 25 => array("name" => "beforePurchase", "type" => "game", "action" => "stBeforePurchase", "transitions" => array("purchase" => 30)), 30 => array("name" => "purchase", "description" => clienttranslate('${actplayer} must purchases scientists or intelligence cards'), "descriptionmyturn" => clienttranslate('${you} must purchase scientists or intelligence cards'), "type" => "activeplayer", "args" => "argPurchase", "possibleactions" => array("purchaseIntelligenceCard", "purchaseScientist", "purchaseSpy", "pass"), "transitions" => array("placeScientist" => 31, "placeSpy" => 32, "afterPurchase" => 35)), 31 => array("name" => "placeScientist", "description" => clienttranslate('${actplayer} must place the scientist on an empty slot on his research sheets'), "descriptionmyturn" => clienttranslate('${you} must place the scientist on an empty slot on your research sheets'), "type" => "activeplayer", "args" => "argPlaceScientist", "possibleactions" => array("confirmScientistPlace"), "transitions" => array("purchase" => 30)), 32 => array("name" => "placeSpy", "description" => clienttranslate('${actplayer} must place the spy on an empty slot on some other player\'s research sheets'), "descriptionmyturn" => clienttranslate('${you} must place the spy on an empty slot on some other player\'s research sheets'), "type" => "activeplayer", "args" => "argPlaceSpy", "possibleactions" => array("confirmSpyPlace"), "transitions" => array("purchase" => 30)), 35 => array("name" => "afterPurchase", "type" => "game", "action" => "stAfterPurchase", "transitions" => array("beforePurchase" => 25, "afterRound" => 80)), 80 => array("name" => "afterRound", "type" => "game", "action" => "stAfterRound", "transitions" => array("beforeRound" => 5, "gameEnd" => 99)), 99 => array("name" => "gameEnd", "description" => clienttranslate("End of game"), "type" => "manager", "action" => "stGameEnd", "args" => "argGameEnd"));
Ejemplo n.º 10
0
 function stEndTurn()
 {
     self::debug("stEndTurn");
     // Active next player OR end the trick and go to the next trick OR end the hand
     // Need to change this to: If it's your turn and you were the last to play then pass trick to player
     //		and pass "nextTrick" => 30
     // Figure out next player that is holding cards
     $player_nos = array(1, 2, 3, 4, 1, 2, 3);
     $current_player = self::getCurrentPlayerId();
     $playersHands = array();
     if (self::getGameStateValue('maxCardValue') == -10) {
         $dog = 1;
         self::getGameStateValue('maxCardValue', 0);
     } else {
         $dog = 0;
     }
     // Get current player number in DB
     $current_player_no = self::getUniqueValueFromDb("SELECT player_no FROM player WHERE player_id='{$current_player}'");
     $resHand = $this->getCardsInLocation('hand');
     $player_nos = array_slice($player_nos, $current_player_no - 1, 4);
     // var_dump($resHand);
     foreach ($resHand as $card) {
         $playersHands[$card['location_arg']] = $card;
     }
     if (count($playersHands[$current_player]) == 0) {
         // Player goes out on this play
         if (self::getGameStateValue('firstOutPlayer') == 0) {
             // If he is the first, record it
             self::setGameStateValue('firstOutPlayer', $current_player);
         }
     }
     // First check if him and his teammate are out
     $sql2 = "SELECT player_no, player_id, count(card_id) as num, player_team FROM player\n\t\t\t\tLEFT JOIN card ON player_id=card_location_arg\n\t\t\t\tWHERE card_location='hand'\n\t\t\t\tGROUP BY card_location_arg\n\t\t\t\tORDER BY FIELD(`player`.`player_no`," . implode(',', $player_nos) . ")";
     $result = self::DbQuery($sql2);
     if (!$result) {
         die($sql2);
     }
     $nTeam = array();
     $nTeam[0] = $nTeam[1] = $n = $next_player = $dogNextPlayer = 0;
     $playersStillIn = array();
     $dogSkip = 0;
     while ($arr1 = mysql_fetch_assoc($result)) {
         if ($arr1['num'] > 0) {
             $nTeam[$arr1['player_team']]++;
         } else {
             $playersStillIn[] = $arr1;
         }
         if (!$n) {
             $team = $arr1['player_team'];
         }
         // Get the current player's team #
         if ($n && $arr1['player_team'] == $team) {
             $dogSkip = 1;
         }
         // Get the current player's teammate
         if ($n && $arr1['num'] > 0 && $dogSkip && !$dogNextPlayer) {
             $dogNextPlayer = $arr1['player_id'];
         }
         if ($n && $arr1['num'] > 0 && $next_player == 0) {
             $next_player = $arr1['player_id'];
         }
         // Get the next player's ID
         // echo $bStartFindDogNext?'true':'false';echo " n:$n no:".$arr1['player_no'];
         //  echo " $dog $dogTeam dogNextPlayer:$dogNextPlayer ";
         //  var_dump($arr1);
         $n++;
     }
     if ($dog && !$dogNextPlayer) {
         $dogNextPlayer = $current_player;
     }
     // If north and west have no cards
     if ($dog && $dogNextPlayer) {
         self::setGameStateValue('dogNextPlayer', $dogNextPlayer);
     }
     if ($nTeam[0] == 0 || $nTeam[1] == 0) {
         // Check if one team is out
         // Figure out what kind of victory
         if ($nTeam[1] == 2) {
             self::setGameStateValue('OneTwoVictory', 0);
         } elseif ($nTeam[0] == 2) {
             self::setGameStateValue('OneTwoVictory', 1);
         } elseif (count($playersStillIn) == 1) {
             self::setGameStateValue('lastOutPlayer', $playersStillIn[0]['player_id']);
         } else {
             throw new feException("Unknown condition (game.php:560)");
         }
         $this->gamestate->nextState("endHand");
     }
     $lastPlayPlayer = self::getGameStateValue('lastPlayPlayer');
     $maxCardValue = self::getGameStateValue('maxCardValue');
     // echo $bStartFindDogNext?'true':'false';
     //  echo " $dogTeam dogNextPlayer:$dogNextPlayer nextplayer:$next_player currentplayer:$current_player lastplayplayer:$lastPlayPlayer current_player_no:$current_player_no player_nos:";print_r($player_nos);
     if ($next_player == $lastPlayPlayer && $dog == 0) {
         // Everyone in game passed, trick won
         $winTrickPlayer = $lastPlayPlayer;
         // $winTrickPlayer = self::getGameStateValue( 'lastPlayPlayer' );
         // Move all cards to "cardswon" of the given player
         if ($maxCardValue == 150) {
             // Dragon wins trick, prompt whom to pass to
             $dragon_winner = self::activeNextPlayer();
             // Set the next player as active (he won with dragon)
             $this->gamestate->nextState("passDragonTrick");
         } else {
             $cards_on_table = $this->getCardsInLocation('cardsontable');
             $this->cards->moveAllCardsInLocation('cardsontable', 'cardswon', null, $winTrickPlayer);
             // ** Also need to change notif for dragon win trick
             // Note: we use 2 notifications here in order we can pause the display during the first notification
             //  before we move all cards to the winner (during the second)
             $players = self::loadPlayersBasicInfos();
             // This sends message and changes db for cardsontable to cardswon
             self::notifyAllPlayers('trickWin', clienttranslate('${player_name} wins the trick'), array('player_id' => $winTrickPlayer, 'player_name' => $players[$winTrickPlayer]['player_name']));
             // This performs animation of moving cards to winner then destroying them
             self::notifyAllPlayers('giveAllCardsToPlayer', '', array('player_id' => $winTrickPlayer, 'cards_won' => $cards_on_table));
             // Active this player => he's the one who starts the next trick
             $this->gamestate->changeActivePlayer($lastPlayPlayer);
             //// Need to change this to
             if ($this->cards->countCardInLocation('hand') == 0) {
                 // End of the hand
                 $this->gamestate->nextState("endHand");
             } else {
                 $this->gamestate->nextState("nextTrick");
             }
             // End of the trick
         }
     } else {
         // Next player
         $x = false;
         $dogNextPlayer = self::getGameStateValue("dogNextPlayer");
         $current_player = self::getActivePlayerId();
         // $next_player = self::getPlayerAfter($current_player);
         $next_player = self::activeNextPlayer();
         // $this->gamestate->nextState( "skipPlayer" );
         // $this->gamestate->nextState( "nextPlayer" );
         $num_cards = $this->cards->countCardInLocation('hand', $next_player);
         if ($dogNextPlayer) {
             // If a dog is played is this player skipped?
             if ($next_player == $dogNextPlayer) {
                 self::setGameStateValue("dogNextPlayer", 0);
                 $dogNextPlayer = 0;
                 $this->gamestate->nextState("nextPlayer");
             } else {
                 $this->gamestate->nextState("skipPlayer");
             }
             // Dog needs to skip this player
         } elseif ($num_cards == 0) {
             $this->gamestate->nextState("skipPlayer");
             // Skip player if he has no cards
         } else {
             self::giveExtraTime($next_player);
             // Give extra time to next player
             $this->gamestate->nextState("nextPlayer");
         }
         // $next_player = self::activeNextPlayer();
         // self::giveExtraTime( $next_player ); // Give extra time to next player
         // $this->gamestate->changeActivePlayer( $next_player );
         // $this->gamestate->nextState( 'nextPlayer' );
     }
 }
Ejemplo n.º 11
0
*   Summary:
*
*   States types:
*   _ activeplayer: in this type of state, we expect some action from the active player.
*   _ multipleactiveplayer: in this type of state we expect some action from multiple players (the active players)
*   _ game: this is an intermediary state where we don't expect any actions from players. Your game logic must decide what is the next game state.
*   _ manager: special type for initial and final state
*
*   Arguments of game states:
*   _ name: the name of the GameState, in order you can recognize it on your own code.
*   _ description: the description of the current game state is always displayed in the action status bar on
*                  the top of the game. Most of the time this is useless for game state with "game" type.
*   _ descriptionmyturn: the description of the current game state when it's your turn.
*   _ type: defines the type of game states (activeplayer / multipleactiveplayer / game / manager)
*   _ action: (required for type game) name of the method to call when this game state become the current game
*				state. Usually, the action method is prefixed by "st" (ex: "stMyGameStateName").
*   _ possibleactions: (required for types activeplayer & multipleactiveplayer)
*					array that specify possible player actions on this step. It allows you to use "checkAction"
*              method on both client side (Javacript: this.checkAction) and server side (PHP: self::checkAction).
*   _ transitions: the transitions are the possible paths to go from a game state to another. You must name
*                  transitions in order to use transition names in "nextState" PHP method, and use IDs to
*                  specify the next game state for each transition.
*   _ args: name of the method to call to retrieve arguments for this gamestate. Arguments are sent to the
*           client side to be used on "onEnteringState" or to set arguments in the gamestate description.
*   _ updateGameProgression: when specified, the game progression is updated (=> call to your getGameProgression
*                            method).
*		!! It is not a good idea to modify this file when a game is running !!
*		http://en.doc.boardgamearena.com/Your_game_state_machine:_states.inc.php
*/
$machinestates = array(1 => array("name" => "gameSetup", "description" => clienttranslate("Game setup"), "type" => "manager", "action" => "stGameSetup", "transitions" => array("" => 20)), 20 => array("name" => "newHand", "description" => "", "type" => "game", "action" => "stNewHand", "updateGameProgression" => true, "transitions" => array("" => 21)), 21 => array("name" => "giveCards1", "type" => "game", "action" => "stGiveCards", "transitions" => array("cardsDealt" => 120)), 120 => array("name" => "declareGrandTichu", "description" => clienttranslate('${actplayer} must choose to call Grand Tichu or Pass'), "descriptionmyturn" => clienttranslate('${you} must choose to call Grant Tichu or Pass'), "type" => "activeplayer", "possibleactions" => array("callGrandTichu", "passGrandTichu"), "transitions" => array("nextGrandTichu" => 125, "allSkipped" => 130)), 125 => array("name" => "nextPlayerDeclareGrandTichu", "type" => "game", "action" => "stNextPlayerDeclareGrandTichu", "transitions" => array("" => 120)), 130 => array("name" => "passCards", "type" => "multipleactiveplayer", "action" => "stPassCards", "description" => clienttranslate('Waiting for other players to pass cards'), "descriptionmyturn" => clienttranslate('${you} must pass a card left, right, and across'), "possibleactions" => array("passCards"), "transitions" => array("passCards" => 22)), 22 => array("name" => "takeCards", "description" => "", "type" => "game", "action" => "stTakeCards", "transitions" => array("startHand" => 30, "skip" => 30)), 30 => array("name" => "newTrick", "description" => "", "type" => "game", "action" => "stNewTrick", "transitions" => array("" => 31)), 31 => array("name" => "beforePlayerTurn", "description" => "", "type" => "game", "action" => "stBeforePlayerTurn", "transitions" => array("startTurn" => 32, "skipPlayer" => 33)), 32 => array("name" => "playerTurn", "description" => clienttranslate('Waiting for ${actplayer} to play'), "descriptionmyturn" => clienttranslate('${you} must play or pass'), "type" => "activeplayer", "args" => "argPlayerTurn", "possibleactions" => array("playCards", "passPlay"), "transitions" => array("playCards" => 34)), 33 => array("name" => "skipPlayerTurn", "description" => "", "type" => "game", "action" => "stSkipPlayerTurn", "transitions" => array("" => 34)), 34 => array("name" => "endTurn", "description" => "", "type" => "game", "action" => "stEndTurn", "transitions" => array("nextPlayer" => 31, "skipPlayer" => 33, "nextTrick" => 30, "endHand" => 40, "passDragonTrick" => 35)), 35 => array("name" => "passDragonTrickDecision", "descriptionmyturn" => clienttranslate('${you} must choose a player from other team to pass trick to'), "type" => "activeplayer", "possibleactions" => array("giveLeft", "giveRight"), "transitions" => array("nextTrick" => 30, "endHand" => 40)), 40 => array("name" => "endHand", "description" => "", "type" => "game", "action" => "stEndHand", "transitions" => array("nextHand" => 20, "endGame" => 99)), 99 => array("name" => "gameEnd", "description" => clienttranslate("End of game"), "type" => "manager", "action" => "stGameEnd", "args" => "argGameEnd"));
Ejemplo n.º 12
0
   Please check the BGA Studio presentation about game state to understand this, and associated documentation.

   Summary:

   States types:
   _ activeplayer: in this type of state, we expect some action from the active player.
   _ multipleactiveplayer: in this type of state, we expect some action from multiple players (the active players)
   _ game: this is an intermediary state where we don't expect any actions from players. Your game logic must decide what is the next game state.
   _ manager: special type for initial and final state

   Arguments of game states:
   _ name: the name of the GameState, in order you can recognize it on your own code.
   _ description: the description of the current game state is always displayed in the action status bar on
                  the top of the game. Most of the time this is useless for game state with "game" type.
   _ descriptionmyturn: the description of the current game state when it's your turn.
   _ type: defines the type of game states (activeplayer / multipleactiveplayer / game / manager)
   _ action: name of the method to call when this game state become the current game state. Usually, the
             action method is prefixed by "st" (ex: "stMyGameStateName").
   _ possibleactions: array that specify possible player actions on this step. It allows you to use "checkAction"
                      method on both client side (Javacript: this.checkAction) and server side (PHP: self::checkAction).
   _ transitions: the transitions are the possible paths to go from a game state to another. You must name
                  transitions in order to use transition names in "nextState" PHP method, and use IDs to
                  specify the next game state for each transition.
   _ args: name of the method to call to retrieve arguments for this gamestate. Arguments are sent to the
           client side to be used on "onEnteringState" or to set arguments in the gamestate description.
   _ updateGameProgression: when specified, the game progression is updated (=> call to your getGameProgression
                            method).
*/
//    !! It is not a good idea to modify this file when a game is running !!
$machinestates = array(1 => array("name" => "gameSetup", "description" => clienttranslate("Game setup"), "type" => "manager", "action" => "stGameSetup", "transitions" => array("" => 2)), 2 => array("name" => "playerTurn", "description" => clienttranslate('${actplayer} must play a disc'), "descriptionmyturn" => clienttranslate('${you} must play a disc'), "type" => "activeplayer", "args" => "argPlayerTurn", "possibleactions" => array('playDisc'), "transitions" => array("playDisc" => 11, "zombiePass" => 11)), 11 => array("name" => "nextPlayer", "type" => "game", "action" => "stNextPlayer", "updateGameProgression" => true, "transitions" => array("nextTurn" => 2, "cantPlay" => 11, "endGame" => 99)), 99 => array("name" => "gameEnd", "description" => clienttranslate("End of game"), "type" => "manager", "action" => "stGameEnd", "args" => "argGameEnd"));