function res($type, $amt, $one) { $ret = new Resource($one, false); for ($i = 0; $i < $amt; $i++) { $ret->add($type); } return $ret; }
public static function csvResources($str, $buyable) { $resources = array('S' => Resource::STONE, 'T' => Resource::WOOD, 'W' => Resource::WOOD, 'O' => Resource::ORE, 'C' => Resource::CLAY, 'L' => Resource::LINEN, 'G' => Resource::GLASS, 'P' => Resource::PAPER); $cost = array(); if (strpos($str, '/') !== false) { $resource = new Resource(true, $buyable); for ($i = 0; $i < strlen($str); $i++) { if (isset($resources[$str[$i]])) { $resource->add($resources[$str[$i]]); } } return array($resource); } $ret = array(); for ($i = 0; $i < strlen($str); $i++) { if (isset($resources[$str[$i]])) { $res = new Resource(false, $buyable); $res->add($resources[$str[$i]]); $ret[] = $res; } } return $ret; }
public function playWonderStage() { $stage = $this->wonder['stages'][$this->wonderStage]; $this->wonderStage++; // Do all the easy things first if (isset($stage['military'])) { $this->military->add($stage['military']); } if (isset($stage['coins'])) { $this->addCoins($stage['coins']); } if (isset($stage['science'])) { $this->science->add(Science::ANY); } // only babylon for now if (isset($stage['resource'])) { $this->addResource($stage['resource']); } if (!isset($stage['custom'])) { return; } switch ($stage['custom']) { case '1free': // olympia's 1 free card per age $this->getFreeCard(); break; case 'guild': // olympia's steal a guild at the end of the game $this->canStealGuild = true; break; case 'discard': // halikarnassus's play from the discard pile if (count($this->_game->discard) > 0) { $tojson = function ($a) { return $a->json(); }; $this->state = Player::USINGDISCARD; $this->send('discard', array('cards' => array_map($tojson, $this->_game->discard))); } break; case 'play2': // babylon's play both cards at the end of a hand $this->canPlayTwoBuilt = true; $this->send('canplay2', ''); break; case 'discount': // olympia's discount COWS for both L/R $resource = new Resource(false, false); $resource->add(Resource::CLAY); $resource->add(Resource::ORE); $resource->add(Resource::WOOD); $resource->add(Resource::STONE); $this->addDiscount('left', $resource); $this->addDiscount('right', $resource); break; } }