本文整理汇总了PHP中Card::csvResources方法的典型用法代码示例。如果您正苦于以下问题:PHP Card::csvResources方法的具体用法?PHP Card::csvResources怎么用?PHP Card::csvResources使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Card
的用法示例。
在下文中一共展示了Card::csvResources方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadWonders
private function loadWonders()
{
$wonders = json_decode(file_get_contents("cards/wonders.json"), true);
foreach ($wonders as &$wonder) {
foreach ($wonder as $side => &$value) {
if ($side == 'name') {
continue;
}
if (isset($value['resource'])) {
$value['resource'] = Card::csvResources($value['resource'], true)[0];
}
foreach ($value['stages'] as &$stage) {
if (isset($stage['resource'])) {
$stage['resource'] = Card::csvResources($stage['resource'], false)[0];
}
$stage['requirements'] = Card::csvResources($stage['requirements'], false);
}
}
}
return $wonders;
}
示例2: play
function play(Player $user)
{
switch ($this->color) {
case Card::RED:
$user->military->add(intval($this->command));
break;
case Card::BLUE:
// do nothing, calculate points later (see Player::calcPoints)
break;
case Card::YELLOW:
if ($this->getAge() == 1) {
if (preg_match('/[0-9]/', $this->command)) {
$user->addCoins(intval($this->command));
} else {
$args = explode(' ', $this->command);
$directions = arrowsToDirection($args[0]);
$resources = Card::csvResources($args[1], false);
foreach ($resources as $resource) {
foreach ($directions as $dir) {
$user->addDiscount($dir, $resource);
}
}
}
} elseif ($this->getAge() == 2) {
// check for yellow non-buyable resources
if (strpos($this->command, '/') !== false) {
$res = Card::csvResources($this->command, false);
$user->addResource($res[0]);
} else {
$args = explode(' ', $this->command);
$directions = arrowsToDirection($args[0]);
$coins = 0;
$color = $args[1];
$mult = intval($args[2]);
foreach ($directions as $dir) {
$pl = $user->neighbor($dir);
foreach ($pl->cardsPlayed as $c) {
if ($c->getColor() == $color) {
$coins += $mult;
}
}
}
$user->addCoins($coins);
}
} elseif ($this->getAge() == 3) {
$coins = $this->thirdAgeYellowCoins();
$color = $this->thirdAgeYellowColor();
// Be sure to count this yellow card for coin increase if
// we get coins per yellow card.
$coinsToGive = $color == Card::YELLOW ? $coins : 0;
if ($color == 'wonder') {
$coinsToGive = $coins * $user->wonderStage;
} else {
foreach ($user->cardsPlayed as $card) {
if ($card->getColor() == $color) {
$coinsToGive += $coins;
}
}
}
if ($coinsToGive > 0) {
$user->addCoins($coinsToGive);
}
}
break;
case Card::GREEN:
$user->science->add(intval($this->command));
break;
case Card::PURPLE:
if ($this->getName() == 'Scientists Guild') {
$user->science->add(Science::ANY);
}
// none of these give coins or anything, so don't need to check
// until the end
break;
case Card::BROWN:
case Card::GREY:
foreach (Card::csvResources($this->command, true) as $r) {
$user->addResource($r);
}
break;
}
}