本文整理汇总了PHP中Card::hasPrereq方法的典型用法代码示例。如果您正苦于以下问题:PHP Card::hasPrereq方法的具体用法?PHP Card::hasPrereq怎么用?PHP Card::hasPrereq使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Card
的用法示例。
在下文中一共展示了Card::hasPrereq方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: calculateCost
private function calculateCost(Card $card, $type)
{
if ($type == 'play') {
// check for duplicates
foreach ($this->cardsPlayed as $cardPlayed) {
if ($cardPlayed->getName() == $card->getName()) {
return array();
}
}
// check if it's a prerequisite for being free
foreach ($this->cardsPlayed as $cardPlayed) {
if ($card->hasPrereq($cardPlayed)) {
return array(array());
}
}
$required = $card->getResourceCost();
} else {
// $type == 'wonder'
// Can't over-build the wonder
if ($this->wonderStage == count($this->wonder['stages'])) {
return array();
}
$stage = $this->wonder['stages'][$this->wonderStage];
$required = $stage['requirements'];
}
// Otherwise, we're going to have to pay for this card somehow
$have = array();
// We get all our resources for free
foreach ($this->permResources as $resource) {
$have[] = ResourceOption::me($resource);
}
// Add in all the left player's resources, factoring in discounts
foreach ($this->leftPlayer->permResources as $resource) {
if (!$resource->buyable()) {
continue;
}
$have[] = ResourceOption::left($resource, $resource->discount($this->discounts['left']));
}
// Add in all the right player's resources, factoring discounts
foreach ($this->rightPlayer->permResources as $resource) {
if (!$resource->buyable()) {
continue;
}
$have[] = ResourceOption::right($resource, $resource->discount($this->discounts['right']));
}
// Figure out how we can pay neighbors to satisfy our requirements
$possible = Resource::satisfy($required, $have, $this->coins - $card->getMoneyCost());
return $possible;
}