本文整理汇总了PHP中Resource::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Resource::add方法的具体用法?PHP Resource::add怎么用?PHP Resource::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Resource
的用法示例。
在下文中一共展示了Resource::add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: res
function res($type, $amt, $one)
{
$ret = new Resource($one, false);
for ($i = 0; $i < $amt; $i++) {
$ret->add($type);
}
return $ret;
}
示例2: csvResources
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;
}
示例3: playWonderStage
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;
}
}