本文整理汇总了PHP中formula_parseToPHP函数的典型用法代码示例。如果您正苦于以下问题:PHP formula_parseToPHP函数的具体用法?PHP formula_parseToPHP怎么用?PHP formula_parseToPHP使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了formula_parseToPHP函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: science_processOrder
function science_processOrder($scienceID, $caveID, $cave)
{
global $defenseSystemTypeList, $buildingTypeList, $scienceTypeList, $resourceTypeList, $unitTypeList;
global $config, $db;
$science = $scienceTypeList[$scienceID];
$maxLevel = round(eval('return ' . formula_parseToPHP("{$science->maxLevel};", '$cave')));
// check, that this science isn't researched in an other cave at the
// same time
$sql = $db->prepare("SELECT event_scienceID\n FROM " . EVENT_SCIENCE_TABLE . "\n WHERE playerID = :playerID \n AND scienceID = :scienceID");
$sql->bindValue('playerID', $_SESSION['player']->playerID, PDO::PARAM_INT);
$sql->bindValue('scienceID', $scienceID, PDO::PARAM_INT);
if ($sql->rowCountSelect() != 0) {
return 4;
}
// check for scienceMaxDeps in Event_Handler
$dep_count = 0;
$deps = '';
foreach ($science->maxScienceDepList as $key => $value) {
if ($value != -1 && $cave[$scienceTypeList[$key]->dbFieldName] > $value - 1) {
if ($dep_count) {
$deps .= ", ";
}
$deps .= $key;
$dep_count++;
}
}
if ($dep_count) {
$sql = $db->prepare("SELECT event_scienceID\n FROM " . EVENT_SCIENCE_TABLE . "\n WHERE playerID = :playerID\n AND scienceID IN ({$deps})");
$sql->bindValue('playerID', $_SESSION['player']->playerID, PDO::PARAM_INT);
if ($sql->rowCountSelect() != 0) {
return 5;
}
}
// take production costs from cave
if (!processProductionCost($science, $caveID, $cave)) {
return 2;
}
$prodTime = 0;
// calculate the production time;
if ($time_formula = $science->productionTimeFunction) {
$time_eval_formula = formula_parseToPHP($time_formula, '$cave');
$time_eval_formula = "\$prodTime={$time_eval_formula};";
eval($time_eval_formula);
}
$prodTime *= SCIENCE_TIME_BASE_FACTOR;
$now = time();
$sql = $db->prepare("INSERT INTO " . EVENT_SCIENCE_TABLE . " (caveID, playerID, scienceID, " . "start, end) VALUES (:caveID, :playerID, :scienceID, :start, :end)");
$sql->bindValue('caveID', $caveID, PDO::PARAM_INT);
$sql->bindValue('playerID', $_SESSION['player']->playerID, PDO::PARAM_INT);
$sql->bindValue('scienceID', $scienceID, PDO::PARAM_INT);
$sql->bindValue('start', time_toDatetime($now), PDO::PARAM_STR);
$sql->bindValue('end', time_toDatetime($now + $prodTime), PDO::PARAM_STR);
if (!$sql->execute() || !$sql->rowCount() == 1) {
processProductionCostSetBack($science, $caveID, $cave);
return 2;
}
return 3;
}
开发者ID:microlefes,项目名称:Game,代码行数:58,代码来源:science.inc.php
示例2: unit_processOrder
function unit_processOrder($unitID, $quantity, $caveID, $details)
{
global $db;
if ($quantity == -1) {
$quantity = MAX_SIMULTAN_BUILDED_UNITS;
while (!processProductionCost($GLOBALS['unitTypeList'][$unitID], $caveID, $details, $quantity) && $quantity != 0) {
$quantity--;
}
if ($quantity <= 0) {
return 4;
}
} else {
if ($quantity > MAX_SIMULTAN_BUILDED_UNITS || $quantity <= 0) {
return 4;
}
// take the production costs from cave
if (!processProductionCost($GLOBALS['unitTypeList'][$unitID], $caveID, $details, $quantity)) {
return 2;
}
}
$prodTime = 0;
// calculate the production time;
if ($time_formula = $GLOBALS['unitTypeList'][$unitID]->productionTimeFunction) {
$time_eval_formula = formula_parseToPHP($time_formula, '$details');
eval('$prodTime=' . $time_eval_formula . ';');
}
$prodTime *= BUILDING_TIME_BASE_FACTOR * $quantity;
$now = time();
$sql = $db->prepare("INSERT INTO " . EVENT_UNIT_TABLE . " (caveID, unitID, quantity, " . "start, end) VALUES (:caveID, :unitID, :quantity, :start, :end)");
$sql->bindValue('caveID', $caveID, PDO::PARAM_INT);
$sql->bindValue('unitID', $unitID, PDO::PARAM_INT);
$sql->bindValue('quantity', $quantity, PDO::PARAM_INT);
$sql->bindValue('start', time_toDatetime($now), PDO::PARAM_STR);
$sql->bindValue('end', time_toDatetime($now + $prodTime), PDO::PARAM_STR);
if (!$sql->execute() || $sql->rowCount() == 0) {
processProductionCostSetBack($GLOBALS['unitTypeList'][$unitID], $caveID, $details, $quantity);
return 2;
}
return 3;
}
开发者ID:norter,项目名称:Game,代码行数:40,代码来源:unit.inc.php
示例3: unitAction
function unitAction($caveID, &$meineHoehlen)
{
global $config, $db, $MAX_RESOURCE, $MOVEMENTCOSTCONSTANT, $MOVEMENTSPEEDCONSTANT, $params, $resourceTypeList, $unitTypeList, $FUELRESOURCEID;
// get movements
$ua_movements = Movement::getMovements();
$details = $meineHoehlen[$caveID];
/***************************************************************************/
/** **/
/** CHECK ARTEFACTS **/
/** **/
/***************************************************************************/
// artefact moving: get ID if any
//
// $params->POST->myartefacts will be
// NULL, if it is not set at all
// -1 when choosing no artefact to move
// 0 if there was a real choice
// default: Move No Artefact (this var holds the artefactID to move)
$moveArtefact = 0;
// this array shall contain the artefacts if any
$myartefacts = array();
// does the cave contain an artefact at least?
if ($details['artefacts'] > 0) {
// get artefacts
$myartefacts = artefact_getArtefactsReadyForMovement($caveID);
// was an artefact chosen?
if ((int) $params->POST->myartefacts > 0) {
$tempID = (int) $params->POST->myartefacts;
// now check, whether this artefactID belongs to this cave
foreach ($myartefacts as $key => $value) {
// if found, set it
if ($tempID == $value['artefactID']) {
$moveArtefact = $tempID;
break;
}
}
}
}
// now $moveArtefact should contain 0 for 'move no artefact'
// or the artefactID of the artefact to be moved
/***************************************************************************/
/***************************************************************************/
/***************************************************************************/
// put user, its session and nogfx flag into session
$_SESSION['player'] = Player::getPlayer($params->SESSION->player->playerID);
$params->SESSION->player = $_SESSION['player'];
// get Map Size
$size = getMapSize();
$dim_x = ($size['maxX'] - $size['minX'] + 1) / 2;
$dim_y = ($size['maxY'] - $size['minY'] + 1) / 2;
$foodPerCave = eval('return ' . formula_parseToPHP($MOVEMENTCOSTCONSTANT . ';', '$details'));
$minutesPerCave = eval('return ' . formula_parseToPHP($MOVEMENTSPEEDCONSTANT . ';', '$details'));
$minutesPerCave *= MOVEMENT_TIME_BASE_FACTOR / 60;
if (isset($params->POST->moveit) && sizeof($params->POST->unit)) {
$targetXCoord = intval($params->POST->targetXCoord);
$targetYCoord = intval($params->POST->targetYCoord);
$targetCaveName = $params->POST->targetCaveName;
$targetCaveID = intval($params->POST->targetCaveID);
$movementID = intval($params->POST->movementID);
// check for scripters
check_timestamp($params->POST->tstamp);
$validCaveName = FALSE;
// targetCaveID >>> coords
if (isset($targetCaveID) && $targetCaveID > 0) {
$result = getCaveByID(intval($targetCaveID));
if (sizeof($result) != 0) {
$targetXCoord = $result['xCoord'];
$targetYCoord = $result['yCoord'];
$validCaveName = TRUE;
}
// name >>> coords
} else {
if (isset($targetCaveName)) {
$result = getCaveByName($targetCaveName);
if (sizeof($result) != 0) {
$targetXCoord = $result['xCoord'];
$targetYCoord = $result['yCoord'];
$validCaveName = TRUE;
}
}
}
// get target player
$result = getCaveByCoords(intval($targetXCoord), intval($targetYCoord));
if (sizeof($result) != 0) {
$targetPlayer = new Player(getPlayerByID($result['playerID']));
}
// Array von Nullwerten befreien
$unit = array_filter($params->POST->unit, "filterZeros");
$unit = array_map("checkFormValues", $unit);
$resource = array_map("checkFormValues", $params->POST->rohstoff);
// Test, ob Einheitentragekapazität ausgelastet
foreach ($resource as $resKey => $aRes) {
$capacity = 0;
foreach ($unit as $unitKey => $aUnit) {
$capacity += $aUnit * $unitTypeList[$unitKey]->encumbranceList[$resKey];
}
if ($capacity < $aRes) {
$overloaded = 1;
break;
}
//.........这里部分代码省略.........
开发者ID:agatho,项目名称:uaenhanced,代码行数:101,代码来源:unitaction.html.php
示例4: 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);
}
开发者ID:agatho,项目名称:uaenhanced,代码行数:92,代码来源:wonder.html.php
示例5: 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));
//.........这里部分代码省略.........
开发者ID:norter,项目名称:Game,代码行数:101,代码来源:unitDetail.html.php
示例6: improvement_getImprovementDetail
function improvement_getImprovementDetail($caveID, &$details)
{
global $template;
// open template
$template->setFile('improvementBuilder.tmpl');
// messages
$messageText = array(0 => array('type' => 'success', 'message' => _('Der Arbeitsauftrag wurde erfolgreich gestoppt.')), 1 => array('type' => 'error', 'message' => _('Es konnte kein Arbeitsauftrag gestoppt werden.')), 2 => array('type' => 'error', 'message' => _('Der Auftrag konnte nicht erteilt werden. Es fehlen die notwendigen Voraussetzungen.')), 3 => array('type' => 'success', 'message' => _('Der Arbeitsauftrag wurde erfolgreich erteilt.')), 5 => array('type' => 'success', 'message' => _('Das Gebäude wurde erfolgreich abgerissen.')), 6 => array('type' => 'error', 'message' => _('Das Gebäude konnte nicht abgerissen werden.')), 7 => array('type' => 'error', 'message' => _('Sie haben von der Sorte gar keine Gebäude.')), 8 => array('type' => 'error', 'message' => sprintf(_('Sie können derzeit kein Gebäude oder Verteidigungen abreißen, weil erst vor Kurzem etwas in dieser Höhle abgerissen wurde. Generell muss zwischen zwei Abrissen eine Zeitspanne von %d Minuten liegen.'), TORE_DOWN_TIMEOUT)), 9 => array('type' => 'error', 'message' => _('Der Arbeitsauftrag konnte nicht erteilt werden. Ein Arbeitsauftrag ist schon im Gange.')));
// get this cave's queue
$queue = improvement_getQueue($_SESSION['player']->playerID, $caveID);
$action = Request::getVar('action', '');
switch ($action) {
/****************************************************************************************************
*
* Erweiterung bauen
*
****************************************************************************************************/
case 'build':
$buildingID = Request::getVar('buildingID', -1);
if ($buildingID == -1) {
$messageID = 2;
break;
}
// check queue exist
if (sizeof($queue)) {
$messageID = 9;
break;
}
$messageID = improvement_processOrder($buildingID, $caveID, $details);
$details = getCaveSecure($caveID, $_SESSION['player']->playerID);
$queue = improvement_getQueue($_SESSION['player']->playerID, $caveID);
break;
/****************************************************************************************************
*
* Ausbau der Erweiterung abbrechen
*
****************************************************************************************************/
/****************************************************************************************************
*
* Ausbau der Erweiterung abbrechen
*
****************************************************************************************************/
case 'cancelOrder':
$eventID = Request::getVar('id', 0);
if ($eventID == 0) {
$messageID = 1;
break;
}
// check queue exist
if (!sizeof($queue) || $queue['event_expansionID'] != $eventID) {
$messageID = 1;
break;
}
if (Request::isPost('cancelOrderConfirm')) {
$messageID = improvement_cancelOrder($eventID, $caveID);
if ($messageID == 0) {
$queue = null;
}
} else {
$template->addVars(array('cancelOrder_box' => true, 'confirm_action' => 'cancelOrder', 'confirm_id' => $eventID, 'confirm_mode' => IMPROVEMENT_BUILDER, 'confirm_msg' => sprintf(_('Möchtest du den Arbeitsauftrag von <span class="bold">%s</span> abbrechen?'), $GLOBALS['buildingTypeList'][$queue['expansionID']]->name)));
}
break;
/****************************************************************************************************
*
* Erweiterung abreißen
*
****************************************************************************************************/
/****************************************************************************************************
*
* Erweiterung abreißen
*
****************************************************************************************************/
case 'demolishing':
$improvementID = Request::getVar('id', -1);
if ($improvementID == -1) {
$messageID = 4;
break;
}
if (!isset($GLOBALS['buildingTypeList'][$improvementID])) {
$messageID = 4;
break;
}
if (Request::isPost('cancelOrderConfirm')) {
$messageID = improvement_Demolishing($improvementID, $caveID, $details);
$details = getCaveSecure($caveID, $_SESSION['player']->playerID);
} else {
$template->addVars(array('cancelOrder_box' => true, 'confirm_action' => 'demolishing', 'confirm_id' => $improvementID, 'confirm_mode' => IMPROVEMENT_BUILDER, 'confirm_msg' => sprintf(_('Möchtest du <span class="bold">%s</span> einmal abreißen?'), $GLOBALS['buildingTypeList'][$improvementID]->name)));
}
break;
}
$improvement = $improvementRelict = $improvementUnqualified = array();
foreach ($GLOBALS['buildingTypeList'] as $id => $building) {
$maxLevel = round(eval('return ' . formula_parseToPHP("{$building->maxLevel};", '$details')));
$notenough = FALSE;
$result = rules_checkDependencies($building, $details);
/****************************************************************************************************
*
* Erweiterungen die gebaut werden können.
*
****************************************************************************************************/
if ($result === TRUE) {
//.........这里部分代码省略.........
开发者ID:norter,项目名称:Game,代码行数:101,代码来源:improvement.html.php
示例7: 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));
//.........这里部分代码省略.........
开发者ID:agatho,项目名称:uaenhanced,代码行数:101,代码来源:science.html.php
示例8: parseCost
function parseCost($building, &$details)
{
$ret = array();
$notenough = false;
if (isset($building->resourceProductionCost)) {
foreach ($building->resourceProductionCost as $resourceID => $function) {
$cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details')));
if ($cost) {
$ret['resource_cost'][] = array('dbFieldName' => $GLOBALS['resourceTypeList'][$resourceID]->dbFieldName, 'name' => $GLOBALS['resourceTypeList'][$resourceID]->name, 'value' => $cost, 'enough' => $details[$GLOBALS['resourceTypeList'][$resourceID]->dbFieldName] >= $cost ? true : false, 'missing' => $cost - $details[$GLOBALS['resourceTypeList'][$resourceID]->dbFieldName]);
if ($details[$GLOBALS['resourceTypeList'][$resourceID]->dbFieldName] < $cost) {
$notenough = true;
}
}
}
}
if (isset($building->unitProductionCost)) {
foreach ($building->unitProductionCost as $unitID => $function) {
$cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details')));
if ($cost) {
$ret['unit_cost'][] = array('dbFieldName' => $GLOBALS['unitTypeList'][$unitID]->dbFieldName, 'name' => $GLOBALS['unitTypeList'][$unitID]->name, 'value' => $cost, 'enough' => $details[$GLOBALS['unitTypeList'][$unitID]->dbFieldName] >= $cost ? true : false, 'missing' => $cost - $details[$GLOBALS['unitTypeList'][$unitID]->dbFieldName]);
if ($details[$GLOBALS['unitTypeList'][$unitID]->dbFieldName] < $cost) {
$notenough = true;
}
}
}
}
if (isset($building->buildingProductionCost)) {
foreach ($building->buildingProductionCost as $buildingID => $function) {
$cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details')));
if ($cost) {
$ret['building_cost'][] = array('dbFieldName' => $GLOBALS['buildingTypeList'][$buildingID]->dbFieldName, 'name' => $GLOBALS['buildingTypeList'][$buildingID]->name, 'value' => $cost, 'enough' => $details[$GLOBALS['buildingTypeList'][$buildingID]->dbFieldName] >= $cost ? true : false, 'missing' => $cost - $details[$GLOBALS['buildingTypeList'][$buildingID]->dbFieldName]);
if ($details[$GLOBALS['buildingTypeList'][$buildingID]->dbFieldName] < $cost) {
$notenough = true;
}
}
}
}
if (isset($building->defenseProductionCost)) {
foreach ($building->defenseProductionCost as $defenseID => $function) {
$cost = ceil(eval('return ' . formula_parseToPHP($function . ';', '$details')));
if ($cost) {
$ret['defense_cost'][] = array('dbFieldName' => $GLOBALS['defenseSystemTypeList'][$defenseID]->dbFieldName, 'name' => $GLOBALS['defenseSystemTypeList'][$defenseID]->name, 'value' => $cost, 'enough' => $details[$GLOBALS['defenseSystemTypeList'][$defenseID]->dbFieldName] >= $cost ? true : false, 'missing' => $cost - $details[$GLOBALS['defenseSystemTypeList'][$defenseID]->dbFieldName]);
if ($details[$GLOBALS['defenseSystemTypeList'][$defenseID]->dbFieldName] < $cost) {
$notenough = true;
}
}
}
}
$ret['notenough'] = $notenough;
return $ret;
}
开发者ID:norter,项目名称:Game,代码行数:51,代码来源:basic.lib.php
示例9: improvement_getBuildingDetails
function improvement_getBuildingDetails($buildingID, $caveData, $method)
{
global $template;
// first check whether that building should be displayed...
$building = $GLOBALS['buildingTypeList'][$buildingID];
$maxLevel = round(eval('return ' . formula_parseToPHP("{$building->maxLevel};", '$caveData')));
$maxLevel = $maxLevel < 0 ? 0 : $maxLevel;
$maxReadable = formula_parseToReadable($building->maxLevel);
if (!$building || $building->nodocumentation && !$caveData[$building->dbFieldName] && rules_checkDependencies($building, $caveData) !== TRUE) {
$building = current($GLOBALS['buildingTypeList']);
}
// open template
if ($method == 'ajax') {
$shortVersion = true;
$template->setFile('improvementDetailAjax.tmpl');
} else {
$shortVersion = false;
$template->setFile('improvementDetail.tmpl');
$template->setShowRresource(false);
}
$currentlevel = $caveData[$building->dbFieldName];
$levels = $costTimeLvl = array();
for ($level = $caveData[$building->dbFieldName], $count = 0; $level < $maxLevel && $count < ($shortVersion ? 3 : 10); ++$count, ++$level, ++$caveData[$building->dbFieldName]) {
$duration = time_formatDuration(eval('return ' . formula_parseToPHP($GLOBALS['buildingTypeList'][$buildingID]->productionTimeFunction . ";", '$caveData')) * BUILDING_TIME_BASE_FACTOR);
// iterate ressourcecosts
$resourceCost = array();
foreach ($building->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 ($building->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 ($building->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 ($building->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));
}
}
$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' => $caveData['population'], 'item' => $levels);
}
$dependencies = array();
$buildingdep = array();
$defensesystemdep = array();
$resourcedep = array();
$sciencedep = array();
$unitdep = array();
foreach ($building->buildingDepList as $key => $level) {
if ($level) {
array_push($buildingdep, array('name' => $GLOBALS['buildingTypeList'][$key]->name, 'level' => ">= " . $level));
}
}
foreach ($building->defenseSystemDepList as $key => $level) {
if ($level) {
array_push($defensesystemdep, array('name' => $GLOBALS['defenseSystemTypeList'][$key]->name, 'level' => ">= " . $level));
}
}
foreach ($building->resourceDepList as $key => $level) {
if ($level) {
array_push($resourcedep, array('name' => $GLOBALS['resourceTypeList'][$key]->name, 'level' => ">= " . $level));
}
}
foreach ($building->scienceDepList as $key => $level) {
if ($level) {
array_push($sciencedep, array('name' => $GLOBALS['scienceTypeList'][$key]->name, 'level' => ">= " . $level));
}
}
foreach ($building->unitDepList as $key => $level) {
if ($level) {
array_push($unitdep, array('name' => $GLOBALS['unitTypeList'][$key]->name, 'level' => ">= " . $level));
}
}
foreach ($building->maxBuildingDepList as $key => $level) {
if ($level != -1) {
array_push($buildingdep, array('name' => $GLOBALS['buildingTypeList'][$key]->name, 'level' => "<= " . $level));
}
}
foreach ($building->maxDefenseSystemDepList as $key => $level) {
if ($level != -1) {
array_push($defensesystemdep, array('name' => $GLOBALS['defenseSystemTypeList'][$key]->name, 'level' => "<= " . $level));
//.........这里部分代码省略.........
开发者ID:norter,项目名称:Game,代码行数:101,代码来源:improvementDetail.html.php
示例10: getAllCavesDetailsContent
function getAllCavesDetailsContent($ownCaves)
{
global $db, $template;
// open template
$template->setFile('cavesDetail.tmpl');
$mycaves = array();
foreach ($ownCaves as $caveID => $caveDetails) {
$mycaves[] = array('cave_name_url' => urlencode($caveDetails['name']), 'cave_name' => $caveDetails['name'], 'cave_id' => $caveID, 'cave_x' => $caveDetails['xCoord'], 'cave_y' => $caveDetails['yCoord']);
}
$template->addVar('caves', $mycaves);
$template->addVar('cave_count', count($mycaves));
$sum = $alt = 0;
$myres = array();
foreach ($GLOBALS['resourceTypeList'] as $resource) {
$temp = array('name' => $resource->name, 'dbFieldName' => $resource->dbFieldName, 'cave' => array());
$row_sum = $row_sum_delta = $row_sum_max = 0;
foreach ($ownCaves as $caveID => $caveDetails) {
$amount = $caveDetails[$resource->dbFieldName];
$delta = $caveDetails[$resource->dbFieldName . '_delta'];
$max = round(eval('return ' . formula_parseToPHP("{$resource->maxLevel};", '$caveDetails')));
$row_sum += $amount;
$row_sum_delta += $delta;
$row_sum_max += $max;
if ($delta >= 0) {
$delta = "+" . $delta;
}
$temp['cave'][] = array('amount' => $amount, 'delta' => $delta);
}
if (!$row_sum) {
continue;
}
$alt++;
$sum += $row_sum;
$temp['sum'] = $row_sum;
if ($row_sum_delta >= 0) {
$row_sum_delta = "+" . $row_sum_delta;
}
$temp['sum_delta'] = $row_sum_delta;
$temp['sum_max'] = $row_sum_max;
$myres[] = $temp;
}
if ($sum > 0) {
$template->addVar('resource', $myres);
}
$sum = $alt = 0;
$myunits = array();
foreach ($GLOBALS['unitTypeList'] as $unit) {
$temp = array('name' => $unit->name, 'dbFieldName' => $unit->dbFieldName, 'cave' => array());
$row_sum = 0;
foreach ($ownCaves as $caveID => $caveDetails) {
$amount = $caveDetails[$unit->dbFieldName];
$row_sum += $amount;
$temp['cave'][] = array('amount' => $amount);
}
if (!$row_sum) {
continue;
}
$alt++;
$sum += $row_sum;
$temp['sum'] = $row_sum;
$myunits[] = $temp;
}
if ($sum > 0) {
$template->addVar('unit', $myunits);
}
$sum = $alt = 0;
$mybuildings = array();
foreach ($GLOBALS['buildingTypeList'] as $building) {
$temp = array('name' => $building->name, 'dbFieldName' => $building->dbFieldName, 'CAVE' => array());
$row_sum = 0;
foreach ($ownCaves as $caveID => $caveDetails) {
$amount = $caveDetails[$building->dbFieldName];
$row_sum += $amount;
$temp['cave'][] = array('amount' => $amount);
}
if (!$row_sum) {
continue;
}
$alt++;
$sum += $row_sum;
$temp['sum'] = $row_sum;
$mybuildings[] = $temp;
}
if ($sum > 0) {
$template->addVar('building', $mybuildings);
}
$sum = $alt = 0;
$mydefenses = array();
foreach ($GLOBALS['defenseSystemTypeList'] as $defense) {
$temp = array('name' => $defense->name, 'dbFieldName' => $defense->dbFieldName, 'cave' => array());
$row_sum = 0;
foreach ($ownCaves as $caveID => $caveDetails) {
$amount = $caveDetails[$defense->dbFieldName];
$row_sum += $amount;
$temp['cave'][] = array('amount' => $amount);
}
if (!$row_sum) {
continue;
}
$alt++;
//.........这里部分代码省略.........
开发者ID:microlefes,项目名称:Game,代码行数:101,代码来源:cave.html.php
示例11: improvement_getImprovementDetail
function improvement_getImprovementDetail($caveID, &$details)
{
global $buildingTypeList, $defenseSystemTypeList, $resourceTypeList, $unitTypeList, $config, $params, $db;
// 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", 5 => "Das Gebäude wurde erfolgreich abgerissen", 6 => "Das Gebäude konnte nicht abgerissen werden", 7 => "Sie haben von der Sorte gar keine Gebäude", 8 => "Sie können derzeit kein Gebäude abreissen, weil erst vor Kurzem etwas in dieser Siedlung abgerissen wurde. Generell muss zwischen zwei Abrissen eine Zeitspanne von " . TORE_DOWN_TIMEOUT . " Minuten liegen.");
// proccess a cancel-order request
if (isset($params->POST->eventID)) {
$messa
|
请发表评论