本文整理汇总了PHP中rules_checkDependencies函数的典型用法代码示例。如果您正苦于以下问题:PHP rules_checkDependencies函数的具体用法?PHP rules_checkDependencies怎么用?PHP rules_checkDependencies使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rules_checkDependencies函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wonders_getContent
function wonders_getContent()
{
global $template;
// open template
$template->setFile('wonder.tmpl');
$id = request_var('wondersID', 0);
if (!isset($GLOBALS['wonderTypeList'][$id]) || $GLOBALS['wonderTypeList'][$id]->nodocumentation || $GLOBALS['wonderTypeList'][$id]->isTribeCaveWonder) {
$wonder = $GLOBALS['wonderTypeList'][0];
} else {
$wonder = $GLOBALS['wonderTypeList'][$id];
}
$uaWonderTargetText = WonderTarget::getWonderTargets();
$resourceCost = array();
foreach ($wonder->resourceProductionCost as $key => $value) {
if ($value != "" && $value != "0") {
array_push($resourceCost, array('dbFieldName' => $GLOBALS['resourceTypeList'][$key]->dbFieldName, 'name' => $GLOBALS['resourceTypeList'][$key]->name, 'amount' => formula_parseToReadable($value)));
}
}
$unitCost = array();
foreach ($wonder->unitProductionCost as $key => $value) {
if ($value != "" && $value != "0") {
array_push($unitCost, array('dbFieldName' => $GLOBALS['unitTypeList'][$key]->dbFieldName, 'name' => $GLOBALS['unitTypeList'][$key]->name, 'amount' => formula_parseToReadable($value)));
}
}
$moreCost = array_merge($unitCost);
$template->addVars(array('name' => $wonder->name, 'offensiveness' => $wonder->offensiveness, 'description' => $wonder->description, 'chance' => round(eval('return ' . formula_parseBasic($wonder->chance) . ';'), 3), 'target' => $uaWonderTargetText[$wonder->target], 'resource_cost' => $resourceCost, 'dependencies' => rules_checkDependencies($wonder), 'more_cost' => sizeof($moreCost) ? $moreCost : false));
}
示例2: resources_getContent
function resources_getContent()
{
global $template;
// open template
$template->setFile('resource.tmpl');
$id = request_var('resourcesID', 0);
if (!isset($GLOBALS['resourceTypeList'][$id]) || $GLOBALS['resourceTypeList'][$id]->nodocumentation) {
$resource = $GLOBALS['resourceTypeList'][0];
} else {
$resource = $GLOBALS['resourceTypeList'][$id];
}
$template->addVars(array('name' => $resource->name, 'description' => '', 'production' => formula_parseToReadable($resource->resProdFunction), 'max_storage' => formula_parseToReadable($resource->maxLevel), 'dbFieldName' => $resource->dbFieldName, 'DEPENDENCIES' => rules_checkDependencies($resource)));
}
示例3: defenses_getContent
function defenses_getContent()
{
global $template;
$defenseSystemTypeList = $GLOBALS['defenseSystemTypeList'];
$resourceTypeList = $GLOBALS['resourceTypeList'];
$unitTypeList = $GLOBALS['unitTypeList'];
// open template
$template->setFile('defenseSystem.tmpl');
$id = request_var('defensesID', 0);
if (!isset($defenseSystemTypeList[$id]) || $defenseSystemTypeList[$id]->nodocumentation) {
$defenseSystem = $defenseSystemTypeList[0];
} else {
$defenseSystem = $defenseSystemTypeList[$id];
}
$resourceCost = array();
foreach ($defenseSystem->resourceProductionCost as $key => $value) {
if ($value != "" && $value != "0") {
array_push($resourceCost, array('dbFieldName' => $resourceTypeList[$key]->dbFieldName, 'name' => $resourceTypeList[$key]->name, 'amount' => formula_parseToReadable($value)));
}
}
$unitCost = array();
foreach ($defenseSystem->unitProductionCost as $key => $value) {
if ($value != "" && $value != "0") {
array_push($unitCost, array('dbFieldName' => $unitTypeList[$key]->dbFieldName, 'name' => $unitTypeList[$key]->name, 'amount' => formula_parseToReadable($value)));
}
}
$defenseCost = array();
foreach ($defenseSystem->defenseProductionCost as $key => $value) {
if ($value != "" && $value != "0") {
array_push($defenseCost, array('dbFieldName' => $defenseSystemTypeList[$key]->dbFieldName, 'name' => $defenseSystemTypeList[$key]->name, 'amount' => formula_parseToReadable($value)));
}
}
$buildingCost = array();
foreach ($defenseSystem->buildingProductionCost as $key => $value) {
if ($value != "" && $value != "0") {
array_push($externalCost, array('dbFieldName' => $buildingTypeList[$key]->dbFieldName, 'name' => $buildingTypeList[$key]->name, 'amount' => formula_parseToReadable($value)));
}
}
$moreCost = array_merge($unitCost, $defenseCost, $buildingCost);
$template->addVars(array('name' => $defenseSystem->name, 'description' => $defenseSystem->description, 'maximum' => formula_parseToReadable($defenseSystem->maxLevel), 'productionTime' => "(" . formula_parseToReadable($defenseSystem->productionTimeFunction) . ")*" . DEFENSESYSTEM_TIME_BASE_FACTOR . " (in Sekunden)", 'rangeAttack' => $defenseSystem->attackRange, 'attackRate' => $defenseSystem->attackRate, 'defenseRate' => $defenseSystem->defenseRate, 'size' => $defenseSystem->hitPoints, 'antiSpyChance' => $defenseSystem->antiSpyChance, 'dbFieldName' => $defenseSystem->dbFieldName, 'warpoints' => $defenseSystem->warPoints, 'resource_cost' => $resourceCost, 'dependencies' => rules_checkDependencies($defenseSystem), 'more_cost' => sizeof($moreCost) ? $moreCost : false));
}
示例4: buildings_getContent
function buildings_getContent()
{
global $template;
$buildingTypeList = $GLOBALS['buildingTypeList'];
$resourceTypeList = $GLOBALS['resourceTypeList'];
$unitTypeList = $GLOBALS['unitTypeList'];
// open template
$template->setFile('building.tmpl');
$id = request_var('buildingsID', 0);
if (!isset($buildingTypeList[$id]) || $buildingTypeList[$id]->nodocumentation) {
$building = $buildingTypeList[0];
} else {
$building = $buildingTypeList[$id];
}
$resourceCost = array();
foreach ($building->resourceProductionCost as $key => $value) {
if ($value != "" && $value != "0") {
array_push($resourceCost, array('dbFieldName' => $resourceTypeList[$key]->dbFieldName, 'name' => $resourceTypeList[$key]->name, 'amount' => formula_parseToReadable($value)));
}
}
$unitCost = array();
foreach ($building->unitProductionCost as $key => $value) {
if ($value != "" && $value != "0") {
array_push($unitCost, array('dbFieldName' => $unitTypeList[$key]->dbFieldName, 'name' => $unitTypeList[$key]->name, 'amount' => formula_parseToReadable($value)));
}
}
$defenseCost = array();
foreach ($building->defenseProductionCost as $key => $value) {
if ($value != "" && $value != "0") {
array_push($defenseCost, array('dbFieldName' => $defenseSystemTypeList[$key]->dbFieldName, 'name' => $defenseSystemTypeList[$key]->name, 'amount' => formula_parseToReadable($value)));
}
}
$buildingCost = array();
foreach ($building->buildingProductionCost as $key => $value) {
if ($value != "" && $value != "0") {
array_push($buildingCost, array('dbFieldName' => $buildingTypeList[$key]->dbFieldName, 'name' => $buildingTypeList[$key]->name, 'amount' => formula_parseToReadable($value)));
}
}
$moreCost = array_merge($unitCost, $defenseCost, $buildingCost);
$template->addVars(array('name' => $building->name, 'description' => $building->description, 'maximum' => formula_parseToReadable($building->maxLevel), 'productionTime' => "(" . formula_parseToReadable($building->productionTimeFunction) . ")*" . BUILDING_TIME_BASE_FACTOR . " (in Sekunden)", 'dbFieldName' => $building->dbFieldName, 'resource_cost' => $resourceCost, 'dependencies' => rules_checkDependencies($building), 'more_cost' => sizeof($moreCost) ? $moreCost : false));
}
示例5: units_getContent
function units_getContent()
{
global $template;
// open template
$template->setFile('unit.tmpl');
$id = request_var('unitsID', 0);
if (!isset($GLOBALS['unitTypeList'][$id]) || $GLOBALS['unitTypeList'][$id]->nodocumentation) {
$unit = $GLOBALS['unitTypeList'][0];
} else {
$unit = $GLOBALS['unitTypeList'][$id];
}
$resourceCost = array();
foreach ($unit->resourceProductionCost as $key => $value) {
if ($value != "" && $value != 0) {
array_push($resourceCost, array('dbFieldName' => $GLOBALS['resourceTypeList'][$key]->dbFieldName, 'name' => $GLOBALS['resourceTypeList'][$key]->name, 'amount' => $value));
}
}
$unitCost = array();
foreach ($unit->unitProductionCost as $key => $value) {
if ($value != "" && $value != 0) {
array_push($unitCost, array('dbFieldName' => $GLOBALS['unitTypeList'][$key]->dbFieldName, 'name' => $GLOBALS['unitTypeList'][$key]->name, 'amount' => formula_parseToReadable($value)));
}
}
$defenseCost = array();
foreach ($unit->defenseProductionCost as $key => $value) {
if ($value != "" && $value != "0") {
array_push($defenseCost, array('dbFieldName' => $GLOBALS['defenseSystemTypeList'][$key]->dbFieldName, 'name' => $GLOBALS['defenseSystemTypeList'][$key]->name, 'amount' => formula_parseToReadable($value)));
}
}
$buildingCost = array();
foreach ($unit->buildingProductionCost as $key => $value) {
if ($value != "" && $value != "0") {
array_push($externalCost, array('dbFieldName' => $GLOBALS['buildingTypeList'][$key]->dbFieldName, 'name' => $GLOBALS['buildingTypeList'][$key]->name, 'amount' => formula_parseToReadable($value)));
}
}
$moreCost = array_merge($unitCost, $defenseCost, $buildingCost);
$template->addVars(array('name' => $unit->name, 'description' => $unit->description, 'productionTime' => "(" . formula_parseToReadable($unit->productionTimeFunction) . ")*" . BUILDING_TIME_BASE_FACTOR . " (in Sekunden)", 'rangeAttack' => $unit->attackRange, 'arealAttack' => $unit->attackAreal, 'attackRate' => $unit->attackRate, 'meleeDefenseRate' => $unit->defenseRate, 'rangedDefenseRate' => $unit->rangedDamageResistance, 'size' => $unit->hitPoints, 'warpoints' => $unit->warpoints, 'antiSpyChance' => $unit->antiSpyChance, 'spyChance' => $unit->spyChance, 'spyValue' => $unit->spyValue, 'spyQuality' => $unit->spyQuality, 'dbFieldName' => $unit->dbFieldName, 'movement_speed' => $unit->wayCost, 'movement_cost' => $unit->foodCost, 'normalDamageProbabilit' => 100 * (1 - ($unit->heavyDamageProbability + $unit->criticalDamageProbability)), 'heavyDamageProbability' => 100 * $unit->heavyDamageProbability, 'criticalDamageProbability' => 100 * $unit->criticalDamageProbability, 'resource_cost' => $resourceCost, 'dependencies' => rules_checkDependencies($unit), 'more_cost' => sizeof($moreCost) ? $moreCost : false));
}
示例6: defense_showProperties
function defense_showProperties($defenseID, $cave, $method)
{
global $template;
// open template
if ($method == 'ajax') {
$shortVersion = true;
$template->setFile('defenseDetailAjax.tmpl');
} else {
$shortVersion = false;
$template->setFile('defenseDetail.tmpl');
}
// first check whether that unit should be displayed...
if (!isset($GLOBALS['defenseSystemTypeList'][$defenseID])) {
$template->addVar('status_msg', array('type' => 'error', 'message' => _('Die Verteidigung wurde nicht gefunden oder ist derzeit nicht baubar.')));
return;
}
$defense = $GLOBALS['defenseSystemTypeList'][$defenseID];
$maxLevel = round(eval('return ' . formula_parseToPHP("{$defense->maxLevel};", '$cave')));
$maxLevel = $maxLevel < 0 ? 0 : $maxLevel;
$maxReadable = formula_parseToReadable($defense->maxLevel);
if ($defense->nodocumentation && !$cave[$defense->dbFieldName] && rules_checkDependencies($defense, $cave) !== true) {
$template->addVar('status_msg', array('type' => 'error', 'message' => _('Die Erweiterung wurde nicht gefunden oder ist derzeit nicht baubar.')));
return;
}
$currentlevel = $cave[$defense->dbFieldName];
$levels = $costTimeLvl = array();
for ($level = $cave[$defense->dbFieldName], $count = 0; $level < $maxLevel && $count < ($shortVersion ? 3 : 10); ++$count, ++$level, ++$cave[$defense->dbFieldName]) {
$duration = time_formatDuration(eval('return ' . formula_parseToPHP($defense->productionTimeFunction . ";", '$cave')) * DEFENSESYSTEM_TIME_BASE_FACTOR);
// iterate ressourcecosts
$resourceCost = array();
foreach ($defense->resourceProductionCost as $resourceID => $function) {
$cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$cave')));
if ($cost) {
array_push($resourceCost, array('name' => $GLOBALS['resourceTypeList'][$resourceID]->name, 'dbFieldName' => $GLOBALS['resourceTypeList'][$resourceID]->dbFieldName, 'value' => $cost));
}
}
// iterate unitcosts
$unitCost = array();
foreach ($defense->unitProductionCost as $unitID => $function) {
$cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$cave')));
if ($cost) {
array_push($unitCost, array('name' => $GLOBALS['unitTypeList'][$unitID]->name, 'dbFieldName' => $GLOBALS['unitTypeList'][$unitID]->dbFieldName, 'value' => $cost));
}
}
// iterate buildingCost
$buildingCost = array();
foreach ($defense->buildingProductionCost as $buildingID => $function) {
$cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$caveData')));
if ($cost) {
array_push($buildingCost, array('name' => $GLOBALS['buildingTypeList'][$buildingID]->name, 'dbFieldName' => $GLOBALS['buildingTypeList'][$buildingID]->dbFieldName, 'value' => $cost));
}
}
// iterate defenseCost
$defenseCost = array();
foreach ($defense->defenseProductionCost as $defenseID => $function) {
$cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$caveData')));
if ($cost) {
array_push($defenseCost, array('name' => $GLOBALS['defenseSystemTypeList'][$defenseID]->name, 'dbFieldName' => $GLOBALS['defenseSystemTypeList'][$defenseID]->dbFieldName, 'value' => $cost));
}
}
if (rules_checkDependencies($defense, $cave) === true) {
$levels[$count] = array('level' => $level + 1, 'time' => $duration, 'resource_cost' => $resourceCost, 'unit_cost' => $unitCost, 'building_cost' => $buildingCost, 'defense_cost' => $defenseCost);
}
}
if (sizeof($levels)) {
$costTimeLvl = array('population' => $cave['population'], 'item' => $levels);
}
$dependencies = array();
$buildingdep = array();
$defensesystemdep = array();
$resourcedep = array();
$sciencedep = array();
$unitdep = array();
foreach ($defense->buildingDepList as $key => $level) {
if ($level) {
array_push($buildingdep, array('name' => $GLOBALS['buildingTypeList'][$key]->name, 'level' => ">= " . $level));
}
}
foreach ($defense->defenseSystemDepList as $key => $level) {
if ($level) {
array_push($defensesystemdep, array('name' => $GLOBALS['defenseSystemTypeList'][$key]->name, 'level' => ">= " . $level));
}
}
foreach ($defense->resourceDepList as $key => $level) {
if ($level) {
array_push($resourcedep, array('name' => $GLOBALS['resourceTypeList'][$key]->name, 'level' => ">= " . $level));
}
}
foreach ($defense->scienceDepList as $key => $level) {
if ($level) {
array_push($sciencedep, array('name' => $GLOBALS['scienceTypeList'][$key]->name, 'level' => ">= " . $level));
}
}
foreach ($defense->unitDepList as $key => $level) {
if ($level) {
array_push($unitdep, array('name' => $GLOBALS['unitTypeList'][$key]->name, 'level' => ">= " . $level));
}
}
foreach ($defense->maxBuildingDepList as $key => $level) {
if ($level != -1) {
//.........这里部分代码省略.........
示例7: wonder_getWonderDetailContent
function wonder_getWonderDetailContent($wonderID, $caveData, $method)
{
global $config, $template;
// get wonder target text
$uaWonderTargetText = WonderTarget::getWonderTargets();
// first check whether that wonder should be displayed...
$wonder = $GLOBALS['wonderTypeList'][$wonderID];
if (!$wonder || $wonder->nodocumentation && rules_checkDependencies($wonder, $caveData) !== TRUE) {
$wonder = current($GLOBALS['wonderTypeList']);
}
// open template
if ($method == 'ajax') {
$shortVersion = true;
$template->setFile('wonderDetailAjax.tmpl');
} else {
$shortVersion = false;
$template->setFile('wonderDetail.tmpl');
$template->setShowRresource(false);
}
// iterate ressourcecosts
$resourceCost = array();
foreach ($wonder->resourceProductionCost as $resourceID => $function) {
$cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$caveData')));
if ($cost) {
array_push($resourceCost, array('name' => $GLOBALS['resourceTypeList'][$resourceID]->name, 'dbFieldName' => $GLOBALS['resourceTypeList'][$resourceID]->dbFieldName, 'value' => $cost));
}
}
// iterate unitcosts
$unitcost = array();
foreach ($wonder->unitProductionCost as $unitID => $function) {
$cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$caveData')));
if ($cost) {
array_push($unitcost, array('name' => $GLOBALS['unitTypeList'][$unitID]->name, 'dbFieldName' => $GLOBALS['unitTypeList'][$unitID]->dbFieldName, 'value' => $cost));
}
}
$dependencies = array();
$buildingdep = array();
$defensesystemdep = array();
$resourcedep = array();
$sciencedep = array();
$unitdep = array();
foreach ($wonder->buildingDepList as $key => $level) {
if ($level) {
array_push($buildingdep, array('name' => $GLOBALS['buildingTypeList'][$key]->name, 'level' => ">= " . $level));
}
}
foreach ($wonder->defenseSystemDepList as $key => $level) {
if ($level) {
array_push($defensesystemdep, array('name' => $GLOBALS['defenseSystemTypeList'][$key]->name, 'level' => ">= " . $level));
}
}
foreach ($wonder->resourceDepList as $key => $level) {
if ($level) {
array_push($resourcedep, array('name' => $GLOBALS['resourceTypeList'][$key]->name, 'level' => ">= " . $level));
}
}
foreach ($wonder->scienceDepList as $key => $level) {
if ($level) {
array_push($sciencedep, array('name' => $GLOBALS['scienceTypeList'][$key]->name, 'level' => ">= " . $level));
}
}
foreach ($wonder->unitDepList as $key => $level) {
if ($level) {
array_push($unitdep, array('name' => $GLOBALS['unitTypeList'][$key]->name, 'level' => ">= " . $level));
}
}
foreach ($wonder->maxBuildingDepList as $key => $level) {
if ($level != -1) {
array_push($buildingdep, array('name' => $GLOBALS['buildingTypeList'][$key]->name, 'level' => "<= " . $level));
}
}
foreach ($wonder->maxDefenseSystemDepList as $key => $level) {
if ($level != -1) {
array_push($defensesystemdep, array('name' => $GLOBALS['defenseSystemTypeList'][$key]->name, 'level' => "<= " . $level));
}
}
foreach ($wonder->maxResourceDepList as $key => $level) {
if ($level != -1) {
array_push($resourcedep, array('name' => $GLOBALS['resourceTypeList'][$key]->name, 'level' => "<= " . $level));
}
}
foreach ($wonder->maxScienceDepList as $key => $level) {
if ($level != -1) {
array_push($sciencedep, array('name' => $GLOBALS['scienceTypeList'][$key]->name, 'level' => "<= " . $level));
}
}
foreach ($wonder->maxUnitDepList as $key => $level) {
if ($level != -1) {
array_push($unitdep, array('name' => $GLOBALS['unitTypeList'][$key]->name, 'level' => "<= " . $level));
}
}
if (sizeof($buildingdep)) {
array_push($dependencies, array('name' => _('Erweiterungen'), 'dep' => $buildingdep));
}
if (sizeof($defensesystemdep)) {
array_push($dependencies, array('name' => _('Verteidigungsanlagen'), 'dep' => $defensesystemdep));
}
if (sizeof($resourcedep)) {
array_push($dependencies, array('name' => _('Rohstoffe'), 'dep' => $resourcedep));
}
//.........这里部分代码省略.........
示例8: science_getScienceDetail
function science_getScienceDetail($caveID, &$details)
{
global $template;
// open template
$template->setFile('scienceBuilder.tmpl');
// messages
$messageText = array(0 => array('type' => 'success', 'message' => _('Der Forschungsauftrag wurde erfolgreich gestoppt.')), 1 => array('type' => 'error', 'message' => _('Es konnte kein Forschungsauftrag gestoppt werden.')), 2 => array('type' => 'error', 'message' => _('Der Auftrag konnte nicht erteilt werden. Es fehlen die notwendigen Voraussetzungen.')), 3 => array('type' => 'success', 'message' => _('Der Auftrag wurde erteilt')), 4 => array('type' => 'info', 'message' => _('Dieses Wissen wird schon in einer anderen Höhle erforscht.')), 5 => array('type' => 'info', 'message' => _('Es wird gerade in einer anderen Höhle Wissen erforscht, das dieses Wissen ausschließt.')));
// get this cave's queue
$queue = science_getQueue($_SESSION['player']->playerID, $caveID);
$action = Request::getVar('action', '');
switch ($action) {
/****************************************************************************************************
*
* Forschung starten
*
****************************************************************************************************/
case 'build':
$scienceID = Request::getVar('scienceID', -1);
if ($scienceID == -1) {
$messageID = 2;
break;
}
// check queue exist
if (sizeof($queue)) {
$messageID = 2;
break;
}
$messageID = science_processOrder($scienceID, $caveID, $details);
$details = getCaveSecure($caveID, $_SESSION['player']->playerID);
$queue = science_getQueue($_SESSION['player']->playerID, $caveID);
break;
/****************************************************************************************************
*
* Forschung abbrechen
*
****************************************************************************************************/
/****************************************************************************************************
*
* Forschung abbrechen
*
****************************************************************************************************/
case 'cancelOrder':
$eventID = Request::getVar('id', 0);
if ($eventID == 0) {
$messageID = 2;
break;
}
// check queue exist
if (!sizeof($queue) || $queue['event_scienceID'] != $eventID) {
$messageID = 2;
break;
}
if (Request::isPost('cancelOrderConfirm')) {
$messageID = science_cancelOrder($eventID, $caveID);
if ($messageID == 0) {
$queue = null;
}
} else {
$template->addVars(array('cancelOrder_box' => true, 'confirm_action' => 'cancelOrder', 'confirm_id' => $eventID, 'confirm_mode' => SCIENCE_BUILDER, 'confirm_msg' => sprintf(_('Möchtest die Forschung von <span class="bold">%s</span> abbrechen?'), $GLOBALS['scienceTypeList'][$queue['scienceID']]->name)));
}
break;
}
$sciences = $sciencesUnqualified = array();
foreach ($GLOBALS['scienceTypeList'] as $id => $science) {
$maxLevel = round(eval('return ' . formula_parseToPHP("{$science->maxLevel};", '$details')));
$notenough = FALSE;
$result = rules_checkDependencies($science, $details);
/****************************************************************************************************
*
* Forschungen die man forschen kann.
*
****************************************************************************************************/
if ($result === TRUE) {
$sciences[$science->scienceID] = array('name' => $science->name, 'dbFieldName' => $science->dbFieldName, 'science_id' => $science->scienceID, 'modus' => SCIENCE_BUILDER, 'cave_id' => $caveID, 'time' => time_formatDuration(eval('return ' . formula_parseToPHP($science->productionTimeFunction . ";", '$details')) * SCIENCE_TIME_BASE_FACTOR), 'maxlevel' => $maxLevel, 'currentlevel' => "0" + $details[$science->dbFieldName], 'description' => $science->description, 'duration_formula' => formula_parseToReadable($science->productionTimeFunction));
$sciences[$science->scienceID] = array_merge($sciences[$science->scienceID], parseCost($science, $details));
// show the building link ?!
if (sizeof($queue)) {
$sciences[$science->scienceID]['no_build_msg'] = _('Erforschung im Gange');
} else {
if ($sciences[$science->scienceID]['notenough'] && $maxLevel > $details[$science->dbFieldName]) {
$sciences[$science->scienceID]['no_build_msg'] = _('Zu wenig Rohstoffe');
} else {
if ($maxLevel > $details[$science->dbFieldName]) {
$sciences[$science->scienceID]['build_link'] = true;
} else {
$sciences[$science->scienceID]['no_build_msg'] = _('Max. Stufe');
}
}
}
/****************************************************************************************************
*
* Forschungen die noch nicht geforscht werden können.
*
****************************************************************************************************/
} else {
if ($result !== FALSE && !$science->nodocumentation) {
$sciencesUnqualified[$science->scienceID] = array('name' => $science->name, 'dbFieldName' => $science->dbFieldName, 'science_id' => $science->scienceID, 'modus' => SCIENCE_DETAIL, 'caveID' => $caveID, 'dependencies' => $result, 'description' => $science->description, 'duration_formula' => formula_parseToReadable($science->productionTimeFunction));
}
}
}
//.........这里部分代码省略.........
示例9: wonder_getWonderContent
function wonder_getWonderContent($caveID, &$details)
{
global $template;
// open template
$template->setFile('wonder.tmpl');
// messages
$messageText = array(-3 => array('type' => 'error', 'message' => _('Die angegebene Zielhöhle wurde nicht gefunden.')), -2 => array('type' => 'error', 'message' => _('Das Wunder kann nicht auf die angegbene Zielhöhle erwirkt werden.')), -1 => array('type' => 'error', 'message' => _('Es ist ein Fehler bei der Verarbeitung Ihrer Anfrage aufgetreten. Bitte wenden Sie sich an die Administratoren')), 0 => array('type' => 'error', 'message' => _('Das Wunder kann nicht erwirkt werden. Es fehlen die notwendigen Voraussetzungen')), 1 => array('type' => 'success', 'message' => _('Das Erflehen des Wunders scheint Erfolg zu haben.')), 2 => array('type' => 'info', 'message' => _('Die Götter haben Ihr Flehen nicht erhört! Die eingesetzten Opfergaben sind natürlich dennoch verloren. Mehr Glück beim nächsten Mal!')));
$action = Request::getVar('action', '');
switch ($action) {
/****************************************************************************************************
*
* "wundern" xD
*
****************************************************************************************************/
case 'wonder':
$wonderID = Request::getVar('wonderID', -1);
$caveName = Request::getVar('CaveName', '');
$xCoord = Request::getVar('xCoord', 0);
$yCoord = Request::getVar('yCoord', 0);
if ($wonderID != -1) {
if (!empty($caveName)) {
$caveData = getCaveByName($caveName);
$xCoord = $caveData['xCoord'];
$yCoord = $caveData['yCoord'];
} else {
if ($xCoord == 0 && $yCoord == 0) {
$messageID = -3;
break;
}
}
} else {
$messageID = -1;
break;
}
$messageID = wonder_processOrder($_SESSION['player']->playerID, $wonderID, $caveID, $xCoord, $yCoord, $details);
$details = getCaveSecure($caveID, $_SESSION['player']->playerID);
if ($messageID == 1 || $messageID == 2) {
wonder_addStatistic($wonderID, $messageID);
}
break;
}
// Show the wonder table
$wonders = $wondersUnqualified = array();
foreach ($GLOBALS['wonderTypeList'] as $id => $wonder) {
// exclude tribeWonders
if ($wonder->isTribeWonder) {
continue;
}
$result = rules_checkDependencies($wonder, $details);
/****************************************************************************************************
*
* Wunder die gebetet werden können.
*
****************************************************************************************************/
if ($result === TRUE && !$wonder->nodocumentation) {
$wonders[$wonder->wonderCategory]['items'][$wonder->wonderID] = array('dbFieldName' => $wonder->wonderID, 'name' => $wonder->name, 'wonder_id' => $wonder->wonderID, 'wonderCategory' => $wonder->wonderCategory, 'description' => $wonder->description, 'same' => $wonder->target == 'same' ? true : false);
$wonders[$wonder->wonderCategory]['items'][$wonder->wonderID] = array_merge($wonders[$wonder->wonderCategory]['items'][$wonder->wonderID], parseCost($wonder, $details));
// show the building link ?!
if ($wonders[$wonder->wonderCategory]['items'][$wonder->wonderID]['notenough']) {
$wonders[$wonder->wonderCategory]['items'][$wonder->wonderID]['no_build_msg'] = _('Zu wenig Rohstoffe');
} else {
$wonders[$wonder->wonderCategory]['items'][$wonder->wonderID]['build_link'] = true;
}
/****************************************************************************************************
*
* Wunder die nicht gewundert werden können.
*
****************************************************************************************************/
} else {
if ($result !== FALSE && !$wonder->nodocumentation) {
$wondersUnqualified[$wonder->wonderCategory]['items'][$wonder->wonderID] = array('name' => $wonder->name, 'wonder_id' => $wonder->wonderID, 'wonderCategory' => $wonder->wonderCategory, 'description' => $wonder->description, 'dependencies' => $result);
}
}
}
/****************************************************************************************************
*
* Namen zu den Kategorien hinzufügen & sortieren
*
****************************************************************************************************/
$tmpWonders = $tmpWondersUnqualified = array();
foreach ($GLOBALS['wonderCategoryTypeList'] as $wonderCategory) {
if (isset($wonders[$wonderCategory->id])) {
$tmpWonders[$wonderCategory->sortID] = array('name' => $wonderCategory->name, 'items' => $wonders[$wonderCategory->id]['items']);
unset($wonders[$wonderCategory->id]);
}
if (isset($wondersUnqualified[$wonderCategory->id])) {
$tmpWondersUnqualified[$wonderCategory->sortID] = array('name' => $wonderCategory->name, 'items' => $wondersUnqualified[$wonderCategory->id]['items']);
unset($wondersUnqualified[$wonderCategory->id]);
}
}
$wonders = $tmpWonders;
$wondersUnqualified = $tmpWondersUnqualified;
unset($tmpWonders, $tmpWondersUnqualified);
ksort($wonders);
ksort($wondersUnqualified);
/****************************************************************************************************
*
* Übergeben ans Template
*
****************************************************************************************************/
//.........这里部分代码省略.........
示例10: unit_getUnitDetail
function unit_getUnitDetail($caveID, &$details)
{
global $buildingTypeList, $defenseSystemTypeList, $resourceTypeList, $unitTypeList, $config, $params, $db, $MAX_RESOURCE;
// messages
$messageText = array(0 => "Der Arbeitsauftrag wurde erfolgreich gestoppt.", 1 => "Es konnte kein Arbeitsauftrag gestoppt werden.", 2 => "Der Auftrag konnte nicht erteilt werden. Es fehlen die " . "notwendigen Voraussetzungen.", 3 => "Der Auftrag wurde erteilt", 4 => "Bitte korrekte Anzahl der Einheiten Angeben (1 ... " . MAX_SIMULTAN_BUILDED_UNITS . ")");
// proccess a cancel-order request
if (isset($params->POST->eventID)) {
$messageID = unit_processOrderCancel($params->POST->eventID, $caveID, $db);
}
// proccess a new order request
if (isset($params->POST->unitID)) {
$messageID = unit_processOrder($params->POST->unitID, intval($params->POST->quantity), $caveID, $db, $details);
$r = getCaveSecure($caveID, $params->SESSION->user['playerID']);
if ($r->isEmpty()) {
page_dberror();
}
$details = $r->nextRow();
}
$queue = unit_getUnitQueueForCave($params->SESSION->user['playerID'], $caveID);
$template = @tmpl_open("./templates/" . $config->template_paths[$params->SESSION->user['template']] . "/unitbuild.ihtml");
// Show a special message
if (isset($messageID)) {
tmpl_set($template, '/MESSAGE/message', $messageText[$messageID]);
}
// Show the unit table
for ($i = 0; $i < sizeof($unitTypeList); $i++) {
$notenough = FALSE;
$unit = $unitTypeList[$i];
// the current unit
$result = rules_checkDependencies($unit, $details);
if ($result === TRUE) {
tmpl_iterate($template, '/UNIT');
tmpl_set($template, "UNIT/alternate", $count++ % 2 ? "alternate" : "");
tmpl_set($template, 'UNIT', array('name' => $unit->name, 'dbFieldName' => $unit->dbFieldName, 'unitID' => $i, 'modus' => UNIT_PROPERTIES, 'caveID' => $caveID, 'size' => "0" + $details[$unit->dbFieldName], 'time' => time_formatDuration(eval('return ' . formula_parseToPHP($unit->productionTimeFunction . ";", '$details')) * BUILDING_TIME_BASE_FACTOR)));
// iterate ressourcecosts
foreach ($unit->resourceProductionCost as $resourceID => $function) {
$cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details')));
if ($cost) {
tmpl_iterate($template, "UNIT/RESSOURCECOST");
if ($details[$resourceTypeList[$resourceID]->dbFieldName] >= $cost) {
tmpl_set($template, "UNIT/RESSOURCECOST/ENOUGH/value", $cost);
} else {
tmpl_set($template, "UNIT/RESSOURCECOST/LESS/value", $cost);
$notenough = TRUE;
}
tmpl_set($template, "UNIT/RESSOURCECOST/dbFieldName", $resourceTypeList[$resourceID]->dbFieldName);
tmpl_set($template, "UNIT/RESSOURCECOST/name", $resourceTypeList[$resourceID]->name);
}
}
// iterate unitcosts
foreach ($unit->unitProductionCost as $unitID => $function) {
$cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details')));
if ($cost) {
tmpl_iterate($template, "UNIT/UNITCOST");
if ($details[$unitTypeList[$unitID]->dbFieldName] >= $cost) {
tmpl_set($template, "UNIT/UNITCOST/ENOUGH/value", $cost);
} else {
tmpl_set($template, "UNIT/UNITCOST/LESS/value", $cost);
$notenough = TRUE;
}
tmpl_set($template, "UNIT/UNITCOST/name", $unitTypeList[$unitID]->name);
}
}
// iterate buildingcosts
foreach ($unit->buildingProductionCost as $buildingID => $function) {
$cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details')));
if ($cost) {
tmpl_iterate($template, "DEFENSESYSTEM/BUILDINGCOST");
if ($details[$buildingTypeList[$buildingID]->dbFieldName] >= $cost) {
tmpl_set($template, "DEFENSESYSTEM/BUILDINGCOST/ENOUGH/value", $cost);
} else {
tmpl_set($template, "DEFENSESYSTEM/BUILDINGCOST/LESS/value", $cost);
$notenough = TRUE;
}
tmpl_set($template, "DEFENSESYSTEM/BUILDINGCOST/name", $buildingTypeList[$buildingID]->name);
}
}
// iterate externalcosts
foreach ($unit->externalProductionCost as $externalID => $function) {
$cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details')));
if ($cost) {
tmpl_iterate($template, "DEFENSESYSTEM/EXTERNALCOST");
if ($details[$defenseSystemTypeList[$externalID]->dbFieldName] >= $cost) {
tmpl_set($template, "DEFENSESYSTEM/EXTERNALCOST/ENOUGH/value", $cost);
} else {
tmpl_set($template, "DEFENSESYSTEM/EXTERNALCOST/LESS/value", $cost);
$notenough = TRUE;
}
tmpl_set($template, "DEFENSESYSTEM/EXTERNALCOST/name", $defenseSystemTypeList[$externalID]->name);
}
}
// show the improvement link ?!
if ($queue) {
tmpl_set($template, "UNIT/UNIT_LINK_NO/message", "Ausbildung im Gange");
} else {
if ($notenough) {
tmpl_set($template, "UNIT/UNIT_LINK_NO/message", "");
} else {
$formParams = array(array('name' => 'modus', 'value' => UNIT_BUILDER), array('name' => 'caveID', 'value' => $caveID), array('name' => 'unitID', 'value' => $unit->unitID));
tmpl_set($template, "UNIT/UNIT_LINK/PARAMS", $formParams);
//.........这里部分代码省略.........
示例11: wonder_getWonderContent
function wonder_getWonderContent($playerID, $caveID, &$details)
{
global $buildingTypeList, $resourceTypeList, $wonderTypeList, $unitTypeList, $config, $params, $db;
// messages
$messageText = array(-4 => "Die Zielsiedlung steht unter Schutz. Der Zauber kann nicht erwirkt werden.", -3 => "Die angegebene Zielsiedlung wurde nicht gefunden.", -2 => "Der Zauber kann nicht auf die angegbene Zielsiedlung erwirkt " . "werden.", -1 => "Es ist ein Fehler bei der Verarbeitung Ihrer Anfrage aufgetreten. " . "Bitte wenden Sie sich an die Administratoren.", 0 => "Der Zauber kann nicht erwirkt werden. Es fehlen die " . "notwendigen Voraussetzungen.", 1 => "Das Erwirken des Zaubers scheint Erfolg zu haben.", 2 => "Die Götter haben Ihr Flehen nicht erhört! Die " . "eingesetzten Opfergaben sind natürlich dennoch verloren. " . "Mehr Glück beim nächsten Mal!");
// ADDED by chris--- for cavebook -----------------------
if ($params->POST->targetCaveID != -1) {
$targetCave = getCaveByID($params->POST->targetCaveID);
$x = $targetCave[xCoord];
$y = $targetCave[yCoord];
} else {
$x = $params->POST->xCoord;
$y = $params->POST->yCoord;
}
// ------------------------------------------------------
// and changed $params->POST->xCoord to $x etc
if (isset($params->POST->wonderID)) {
$messageID = wonder_processOrder($playerID, $params->POST->wonderID, $caveID, $x, $y, $details, $db);
$reload = 1;
}
if ($reload) {
// this isn't that elegant...
$r = getCaveSecure($caveID, $params->SESSION->user['playerID']);
if ($r->isEmpty()) {
page_dberror();
}
$details = $r->nextRow();
}
$template = @tmpl_open("./templates/" . $config->template_paths[$params->SESSION->user['template']] . "/wonder.ihtml");
// Show a special message
if (isset($messageID)) {
tmpl_set($template, '/MESSAGE/message', $messageText[$messageID]);
}
// ADDED by chris--- for cavebook ---------------------------------
// Getting entries
$cavelist = cavebook_getEntries($params->SESSION->user['playerID']);
// Show the cave table
$cavebook = array();
for ($ix = 0; $ix < sizeof($cavelist[id]); $ix++) {
$cavebook[$ix][cavebook_entry] = $cavelist[name][$ix];
$cavebook[$ix][cavebook_id] = $cavelist[id][$ix];
$cavebook[$ix][cavebook_x] = $cavelist[x][$ix];
$cavebook[$ix][cavebook_y] = $cavelist[y][$ix];
}
// --------------------------------------------------------------
// Show the wonder table
for ($i = 0; $i < sizeof($wonderTypeList); $i++) {
$wonder = $wonderTypeList[$i];
// the current building
$result = rules_checkDependencies($wonder, $details);
if ($result === TRUE) {
tmpl_iterate($template, 'WONDER');
tmpl_set($template, "WONDER/alternate", $count++ % 2 ? "alternate" : "");
tmpl_set($template, 'WONDER', array('name' => $wonder->name, 'wonderID' => $i, 'modus' => WONDER_DETAIL, 'caveID' => $caveID));
// iterate ressourcecosts
foreach ($wonder->resourceProductionCost as $resourceID => $function) {
$cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details')));
if ($cost) {
tmpl_iterate($template, "WONDER/RESSOURCECOST");
if ($details[$resourceTypeList[$resourceID]->dbFieldName] >= $cost) {
tmpl_set($template, "WONDER/RESSOURCECOST/ENOUGH/value", $cost);
} else {
tmpl_set($template, "WONDER/RESSOURCECOST/LESS/value", $cost);
}
tmpl_set($template, "WONDER/RESSOURCECOST/dbFieldName", $resourceTypeList[$resourceID]->dbFieldName);
tmpl_set($template, "WONDER/RESSOURCECOST/name", $resourceTypeList[$resourceID]->name);
}
}
// iterate unitcosts
foreach ($wonder->unitProductionCost as $unitID => $function) {
$cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details')));
if ($cost) {
tmpl_iterate($template, "WONDER/UNITCOST");
if ($details[$unitTypeList[$unitID]->dbFieldName] >= $cost) {
tmpl_set($template, "WONDER/UNITCOST/ENOUGH/value", $cost);
} else {
tmpl_set($template, "WONDER/UNITCOST/LESS/value", $cost);
}
tmpl_set($template, "WONDER/UNITCOST/name", $unitTypeList[$unitID]->name);
}
}
// show the wonder link
tmpl_set($template, 'WONDER/BUILD_LINK', array('action' => WONDER, 'wonderID' => $wonder->wonderID, 'cave_book_link' => CAVE_BOOK, 'BOOKENTRY' => $cavebook, 'caveID' => $caveID));
} else {
if ($params->SESSION->user['show_unqualified'] && $result !== FALSE && !$wonder->nodocumentation) {
tmpl_iterate($template, '/UNQUALIFIEDWONDERS/WONDER');
tmpl_set($template, '/UNQUALIFIEDWONDERS/WONDER', array('alternate' => $count_unqualified++ % 2 ? "" : "alternate", 'modus' => WONDER_DETAIL, 'wonderID' => $i, 'caveID' => $caveID, 'name' => $wonder->name, 'dependencies' => $result));
}
}
}
return tmpl_parse($template);
}
示例12: unit_showUnitProperties
function unit_showUnitProperties($unitID, $caveData)
{
global $buildingTypeList, $defenseSystemTypeList, $resourceTypeList, $scienceTypeList, $unitTypeList, $no_resource_flag, $config, $params;
$no_resource_flag = 1;
// first check whether that unit should be displayed...
$unit = $unitTypeList[$unitID];
if (!$unit || $unit->nodocumentation && !$caveData[$unit->dbFieldName] && rules_checkDependencies($unit, $caveData) !== TRUE) {
$unit = current($unitTypeList);
}
$template = tmpl_open($params->SESSION->player->getTemplatePath() . 'unit_properties.ihtml');
$resourceCost = array();
foreach ($unit->resourceProductionCost as $key => $value) {
if ($value != "" && $value != 0) {
array_push($resourceCost, array('dbFieldName' => $resourceTypeList[$key]->dbFieldName, 'name' => $resourceTypeList[$key]->name, 'value' => ceil(eval('return ' . formula_parseToPHP($unit->resourceProductionCost[$key] . ';', '$details')))));
}
}
$unitCost = array();
foreach ($unit->unitProductionCost as $key => $value) {
if ($value != "" && $value != 0) {
array_push($unitCost, array('dbFieldName' => $unitTypeList[$key]->dbFieldName, 'name' => $unitTypeList[$key]->name, 'value' => ceil(eval('return ' . formula_parseToPHP($unit->unitProductionCost[$key] . ';', '$details')))));
}
}
$buildingCost = array();
foreach ($unit->buildingProductionCost as $key => $value) {
if ($value != "" && $value != 0) {
array_push($buildingCost, array('dbFieldName' => $buildingTypeList[$key]->dbFieldName, 'name' => $buildingTypeList[$key]->name, 'value' => ceil(eval('return ' . formula_parseToPHP($unit->buildingProductionCost[$key] . ';', '$details')))));
}
}
$externalCost = array();
foreach ($unit->externalProductionCost as $key => $value) {
if ($value != "" && $value != 0) {
array_push($externalCost, array('dbFieldName' => $defenseSystemTypeList[$key]->dbFieldName, 'name' => $defenseSystemTypeList[$key]->name, 'value' => ceil(eval('return ' . formula_parseToPHP($unit->externalProductionCost[$key] . ';', '$details')))));
}
}
$dependencies = array();
$buildingdep = array();
foreach ($unit->buildingDepList as $key => $level) {
if ($level) {
array_push($buildingdep, array('name' => $buildingTypeList[$key]->name, 'level' => ">= " . $level));
}
}
$defensesystemdep = array();
foreach ($unit->defenseSystemDepList as $key => $level) {
if ($level) {
array_push($defensesystemdep, array('name' => $defenseSystemTypeList[$key]->name, 'level' => ">= " . $level));
}
}
$resourcedep = array();
foreach ($unit->resourceDepList as $key => $level) {
if ($level) {
array_push($resourcedep, array('name' => $resourceTypeList[$key]->name, 'level' => ">= " . $level));
}
}
$sciencedep = array();
foreach ($unit->scienceDepList as $key => $level) {
if ($level) {
array_push($sciencedep, array('name' => $scienceTypeList[$key]->name, 'level' => ">= " . $level));
}
}
$unitdep = array();
foreach ($unit->unitDepList as $key => $level) {
if ($level) {
array_push($unitdep, array('name' => $unitTypeList[$key]->name, 'level' => ">= " . $level));
}
}
foreach ($unit->maxBuildingDepList as $key => $level) {
if ($level != -1) {
array_push($buildingdep, array('name' => $buildingTypeList[$key]->name, 'level' => "<= " . $level));
}
}
foreach ($unit->maxDefenseSystemDepList as $key => $level) {
if ($level != -1) {
array_push($defensesystemdep, array('name' => $defenseSystemTypeList[$key]->name, 'level' => "<= " . $level));
}
}
foreach ($unit->maxResourceDepList as $key => $level) {
if ($level != -1) {
array_push($resourcedep, array('name' => $resourceTypeList[$key]->name, 'level' => "<= " . $level));
}
}
foreach ($unit->maxScienceDepList as $key => $level) {
if ($level != -1) {
array_push($sciencedep, array('name' => $scienceTypeList[$key]->name, 'level' => "<= " . $level));
}
}
foreach ($unit->maxUnitDepList as $key => $level) {
if ($level != -1) {
array_push($unitdep, array('name' => $unitTypeList[$key]->name, 'level' => "<= " . $level));
}
}
if (sizeof($buildingdep)) {
array_push($dependencies, array('name' => _('Erweiterungen'), 'DEP' => $buildingdep));
}
if (sizeof($defensesystemdep)) {
array_push($dependencies, array('name' => _('Verteidigungsanlagen'), 'DEP' => $defensesystemdep));
}
if (sizeof($resourcedep)) {
array_push($dependencies, array('name' => _('Rohstoffe'), 'DEP' => $resourcedep));
}
if (sizeof($sciencedep)) {
//.........这里部分代码省略.........
示例13: unit_getUnitDetails
function unit_getUnitDetails($unitID, $caveData, $method)
{
global $template;
global $buildingTypeList, $defenseSystemTypeList, $resourceTypeList, $scienceTypeList, $unitTypeList;
$details = $caveData;
// first check whether that unit should be displayed...
$unit = $unitTypeList[$unitID];
if (!$unit || $unit->nodocumentation && !$caveData[$unit->dbFieldName] && rules_checkDependencies($unit, $caveData) !== TRUE) {
$unit = current($unitTypeList);
}
// open template
if ($method == 'ajax') {
$shortVersion = true;
$template->setFile('unitDetailAjax.tmpl');
} else {
$shortVersion = false;
$template->setFile('unitDetail.tmpl');
$template->setShowRresource(false);
}
// iterate ressourcecosts
$resourceCost = array();
foreach ($unit->resourceProductionCost as $resourceID => $function) {
$cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$caveData')));
if ($cost) {
array_push($resourceCost, array('name' => $GLOBALS['resourceTypeList'][$resourceID]->name, 'dbFieldName' => $GLOBALS['resourceTypeList'][$resourceID]->dbFieldName, 'value' => $cost));
}
}
// iterate unitcosts
$unitCost = array();
foreach ($unit->unitProductionCost as $unitID => $function) {
$cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$caveData')));
if ($cost) {
array_push($unitCost, array('name' => $GLOBALS['unitTypeList'][$unitID]->name, 'dbFieldName' => $GLOBALS['unitTypeList'][$unitID]->dbFieldName, 'value' => $cost));
}
}
// iterate buildingCost
$buildingCost = array();
foreach ($unit->buildingProductionCost as $buildingID => $function) {
$cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$caveData')));
if ($cost) {
array_push($buildingCost, array('name' => $GLOBALS['buildingTypeList'][$buildingID]->name, 'dbFieldName' => $GLOBALS['buildingTypeList'][$buildingID]->dbFieldName, 'value' => $cost));
}
}
// iterate defenseCost
$defenseCost = array();
foreach ($unit->defenseProductionCost as $defenseID => $function) {
$cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$caveData')));
if ($cost) {
array_push($defenseCost, array('name' => $GLOBALS['defenseSystemTypeList'][$defenseID]->name, 'dbFieldName' => $GLOBALS['defenseSystemTypeList'][$defenseID]->dbFieldName, 'value' => $cost));
}
}
$dependencies = array();
$buildingdep = array();
$defensesystemdep = array();
$resourcedep = array();
$sciencedep = array();
$unitdep = array();
foreach ($unit->buildingDepList as $key => $level) {
if ($level) {
array_push($buildingdep, array('name' => $GLOBALS['buildingTypeList'][$key]->name, 'level' => ">= " . $level));
}
}
foreach ($unit->defenseSystemDepList as $key => $level) {
if ($level) {
array_push($defensesystemdep, array('name' => $GLOBALS['defenseSystemTypeList'][$key]->name, 'level' => ">= " . $level));
}
}
foreach ($unit->resourceDepList as $key => $level) {
if ($level) {
array_push($resourcedep, array('name' => $GLOBALS['resourceTypeList'][$key]->name, 'level' => ">= " . $level));
}
}
foreach ($unit->scienceDepList as $key => $level) {
if ($level) {
array_push($sciencedep, array('name' => $GLOBALS['scienceTypeList'][$key]->name, 'level' => ">= " . $level));
}
}
foreach ($unit->unitDepList as $key => $level) {
if ($level) {
array_push($unitdep, array('name' => $GLOBALS['unitTypeList'][$key]->name, 'level' => ">= " . $level));
}
}
foreach ($unit->maxBuildingDepList as $key => $level) {
if ($level != -1) {
array_push($buildingdep, array('name' => $GLOBALS['buildingTypeList'][$key]->name, 'level' => "<= " . $level));
}
}
foreach ($unit->maxDefenseSystemDepList as $key => $level) {
if ($level != -1) {
array_push($defensesystemdep, array('name' => $GLOBALS['defenseSystemTypeList'][$key]->name, 'level' => "<= " . $level));
}
}
foreach ($unit->maxResourceDepList as $key => $level) {
if ($level != -1) {
array_push($resourcedep, array('name' => $GLOBALS['resourceTypeList'][$key]->name, 'level' => "<= " . $level));
}
}
foreach ($unit->maxScienceDepList as $key => $level) {
if ($level != -1) {
array_push($sciencedep, array('name' => $GLOBALS['scienceTypeList'][$key]->name, 'level' => "<= " . $level));
//.........这里部分代码省略.........
示例14: science_getScienceDetail
function science_getScienceDetail($caveID, &$details)
{
global $buildingTypeList, $defenseSystemTypeList, $resourceTypeList, $unitTypeList, $scienceTypeList, $config, $params, $db;
// messages
$messageText = array(0 => _('Der Forschungsauftrag wurde erfolgreich gestoppt.'), 1 => _('Es konnte kein Forschungsauftrag gestoppt werden.'), 2 => _('Der Auftrag konnte nicht erteilt werden. Es fehlen die notwendigen Voraussetzungen.'), 3 => _('Der Auftrag wurde erteilt'), 4 => _('Dieses Wissen wird schon in einer anderen Höhle erforscht.'), 5 => _('Es wird gerade in einer anderen Höhle Wissen erforscht, dass dieses Wissen ausschließt.'));
// proccess a cancel-order request
if (isset($params->POST->eventID)) {
$messageID = science_processOrderCancel($params->POST->eventID, $caveID, $db);
}
if (isset($params->POST->scienceID)) {
$messageID = science_processOrder($params->POST->scienceID, $caveID, $params->SESSION->player->playerID, $details, $db);
$r = getCaveSecure($caveID, $params->SESSION->player->playerID);
if ($r->isEmpty()) {
page_dberror();
}
$details = $r->nextRow();
}
$queue = science_getScienceQueueForCave($params->SESSION->player->playerID, $caveID);
$template = tmpl_open($params->SESSION->player->getTemplatePath() . 'science.ihtml');
// Show a special message
if (isset($messageID)) {
tmpl_set($template, '/MESSAGE/message', $messageText[$messageID]);
}
// Show the science table
for ($i = 0; $i < sizeof($scienceTypeList); $i++) {
$science = $scienceTypeList[$i];
// the current science
$maxLevel = round(eval('return ' . formula_parseToPHP("{$science->maxLevel};", '$details')));
$notenough = FALSE;
$result = rules_checkDependencies($science, $details);
if ($result === TRUE) {
tmpl_iterate($template, 'SCIENCE');
tmpl_set($template, "SCIENCE/alternate", $count++ % 2 ? "alternate" : "");
tmpl_set($template, 'SCIENCE', array('dbFieldName' => $science->dbFieldName, 'name' => $science->name, 'scienceID' => $i, 'modus' => SCIENCE_DETAIL, 'caveID' => $caveID, 'size' => "0" + $details[$science->dbFieldName], 'time' => time_formatDuration(eval('return ' . formula_parseToPHP($science->productionTimeFunction . ";", '$details')) * SCIENCE_TIME_BASE_FACTOR)));
// iterate ressourcecosts
foreach ($science->resourceProductionCost as $resourceID => $function) {
$cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details')));
if ($cost) {
tmpl_iterate($template, "SCIENCE/RESSOURCECOST");
if ($details[$resourceTypeList[$resourceID]->dbFieldName] >= $cost) {
tmpl_set($template, "SCIENCE/RESSOURCECOST/ENOUGH/value", $cost);
} else {
tmpl_set($template, "SCIENCE/RESSOURCECOST/LESS/value", $cost);
$notenough = TRUE;
}
tmpl_set($template, "SCIENCE/RESSOURCECOST/dbFieldName", $resourceTypeList[$resourceID]->dbFieldName);
tmpl_set($template, "SCIENCE/RESSOURCECOST/name", $resourceTypeList[$resourceID]->name);
}
}
// iterate unitcosts
foreach ($science->unitProductionCost as $unitID => $function) {
$cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details')));
if ($cost) {
tmpl_iterate($template, "SCIENCE/UNITCOST");
if ($details[$unitTypeList[$unitID]->dbFieldName] >= $cost) {
tmpl_set($template, "SCIENCE/UNITCOST/ENOUGH/value", $cost);
} else {
tmpl_set($template, "SCIENCE/UNITCOST/LESS/value", $cost);
$notenough = TRUE;
}
tmpl_set($template, "SCIENCE/UNITCOST/name", $unitTypeList[$unitID]->name);
}
}
// iterate buildingcosts
foreach ($science->buildingProductionCost as $buildingID => $function) {
$cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details')));
if ($cost) {
tmpl_iterate($template, "DEFENSESYSTEM/BUILDINGCOST");
if ($details[$buildingTypeList[$buildingID]->dbFieldName] >= $cost) {
tmpl_set($template, "DEFENSESYSTEM/BUILDINGCOST/ENOUGH/value", $cost);
} else {
tmpl_set($template, "DEFENSESYSTEM/BUILDINGCOST/LESS/value", $cost);
$notenough = TRUE;
}
tmpl_set($template, "DEFENSESYSTEM/BUILDINGCOST/name", $buildingTypeList[$buildingID]->name);
}
}
// iterate externalcosts
foreach ($science->externalProductionCost as $externalID => $function) {
$cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details')));
if ($cost) {
tmpl_iterate($template, "DEFENSESYSTEM/EXTERNALCOST");
if ($details[$defenseSystemTypeList[$externalID]->dbFieldName] >= $cost) {
tmpl_set($template, "DEFENSESYSTEM/EXTERNALCOST/ENOUGH/value", $cost);
} else {
tmpl_set($template, "DEFENSESYSTEM/EXTERNALCOST/LESS/value", $cost);
$notenough = TRUE;
}
tmpl_set($template, "DEFENSESYSTEM/EXTERNALCOST/name", $defenseSystemTypeList[$externalID]->name);
}
}
// show the science link ?!
if ($queue) {
tmpl_set($template, 'SCIENCE/RESEARCH_LINK_NO/message', _('Erforschung im Gange'));
} else {
if ($notenough && $maxLevel > $details[$science->dbFieldName]) {
tmpl_set($template, 'SCIENCE/RESEARCH_LINK_NO/message', _('Zu wenig Rohstoffe'));
} else {
if ($maxLevel > $details[$science->dbFieldName]) {
tmpl_set($template, 'SCIENCE/RESEARCH_LINK', array('action' => SCIENCE, 'scienceID' => $science->scienceID, 'caveID' => $caveID));
//.........这里部分代码省略.........
示例15: wonder_getWonderContent
function wonder_getWonderContent($playerID, $caveID, &$details)
{
global $buildingTypeList, $resourceTypeList, $wonderTypeList, $unitTypeList, $config, $params, $db;
// messages
$messageText = array(-3 => "Die angegebene Zielhöhle wurde nicht gefunden.", -2 => "Das Wunder kann nicht auf die angegbene Zielhöhle erwirkt " . "werden.", -1 => "Es ist ein Fehler bei der Verarbeitung Ihrer Anfrage aufgetreten. " . "Bitte wenden Sie sich an die Administratoren.", 0 => "Das Wunder kann nicht erwirkt werden. Es fehlen die " . "notwendigen Voraussetzungen.", 1 => "Das Erflehen des Wunders scheint Erfolg zu haben.", 2 => "Die Götter haben Ihr Flehen nicht erhört! Die " . "eingesetzten Opfergaben sind natürlich dennoch verloren. " . "Mehr Glück beim nächsten Mal!");
if (isset($params->POST->wonderID)) {
$messageID = wonder_processOrder($playerID, $params->POST->wonderID, $caveID, $params->POST->xCoord, $params->POST->yCoord, $details, $db);
$reload = 1;
}
if ($reload) {
// this isn't that elegant...
$r = getCaveSecure($caveID, $params->SESSION->player->playerID);
if ($r->isEmpty()) {
page_dberror();
}
$details = $r->nextRow();
}
$template = tmpl_open($params->SESSION->player->getTemplatePath() . 'wonder.ihtml');
// Show a special message
if (isset($messageID)) {
tmpl_set($template, '/MESSAGE/message', $messageText[$messageID]);
}
// Show the wonder table
for ($i = 0; $i < sizeof($wonderTypeList); $i++) {
$wonder = $wonderTypeList[$i];
// the current wonder
$result = rules_checkDependencies($wonder, $details);
if ($result === TRUE && !$wonder->nodocumentation) {
tmpl_iterate($template, 'WONDER');
tmpl_set($template, "WONDER/alternate", $count++ % 2 ? "alternate" : "");
tmpl_set($template, 'WONDER', array('name' => $wonder->name, 'wonderID' => $i, 'modus' => WONDER_DETAIL, 'caveID' => $caveID));
// iterate ressourcecosts
foreach ($wonder->resourceProductionCost as $resourceID => $function) {
$cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details')));
if ($cost) {
tmpl_iterate($template, "WONDER/RESSOURCECOST");
if ($details[$resourceTypeList[$resourceID]->dbFieldName] >= $cost) {
tmpl_set($template, "WONDER/RESSOURCECOST/ENOUGH/value", $cost);
} else {
tmpl_set($template, "WONDER/RESSOURCECOST/LESS/value", $cost);
}
tmpl_set($template, "WONDER/RESSOURCECOST/dbFieldName", $resourceTypeList[$resourceID]->dbFieldName);
tmpl_set($template, "WONDER/RESSOURCECOST/name", $resourceTypeList[$resourceID]->name);
}
}
// iterate unitcosts
foreach ($wonder->unitProductionCost as $unitID => $function) {
$cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details')));
if ($cost) {
tmpl_iterate($template, "WONDER/UNITCOST");
if ($details[$unitTypeList[$unitID]->dbFieldName] >= $cost) {
tmpl_set($template, "WONDER/UNITCOST/ENOUGH/value", $cost);
} else {
tmpl_set($template, "WONDER/UNITCOST/LESS/value", $cost);
}
tmpl_set($template, "WONDER/UNITCOST/name", $unitTypeList[$unitID]->name);
}
}
foreach ($wonder->buildingProductionCost as $unitID => $function) {
$cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details')));
if ($cost) {
tmpl_iterate($template, "WONDER/UNITCOST");
if ($details[$buildingTypeList[$unitID]->dbFieldName] >= $cost) {
tmpl_set($template, "WONDER/UNITCOST/ENOUGH/value", $cost);
} else {
tmpl_set($template, "WONDER/UNITCOST/LESS/value", $cost);
}
tmpl_set($template, "WONDER/UNITCOST/name", $buildingTypeList[$unitID]->name);
}
}
// show the wonder link
tmpl_set($template, 'WONDER/BUILD_LINK', array('action' => WONDER, 'wonderID' => $wonder->wonderID, 'caveID' => $caveID));
if ($wonder->target != "same") {
// show input field of target cave iff wonder may be cast on another cave
tmpl_iterate($template, 'WONDER/BUILD_LINK/TARGET');
}
} else {
if ($result !== FALSE && !$wonder->nodocumentation) {
tmpl_iterate($template, '/UNQUALIFIEDWONDERS/WONDER');
tmpl_set($template, '/UNQUALIFIEDWONDERS/WONDER', array('alternate' => $count_unqualified++ % 2 ? "" : "alternate", 'modus' => WONDER_DETAIL, 'wonderID' => $i, 'caveID' => $caveID, 'name' => $wonder->name, 'dependencies' => $result));
}
}
}
tmpl_set($template, "rules_path", RULES_PATH);
return tmpl_parse($template);
}