コード例 #1
0
ファイル: module_wonders.php プロジェクト: microlefes/Game
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
0
ファイル: module_misc.php プロジェクト: norter/Game
function getWondersStats()
{
    global $template;
    require_once 'wonder.inc.php';
    $uaWonderTargetText = WonderTarget::getWonderTargets();
    // open template
    $template->setFile('wondersStats.tmpl');
    // get a copy of the wonderTypeList
    $wondersList = $GLOBALS['wonderTypeList'];
    // sort that copy by names
    usort($wondersList, "nameCompare");
    $wonders = array();
    foreach ($wondersList as $value) {
        if (!$value->nodocumentation) {
            $wonders[] = array('id' => $value->wonderID, 'name' => $value->name, 'offensiveness' => $value->offensiveness, 'chance' => round(eval('return ' . formula_parseBasic($value->chance) . ';'), 3), 'target' => $uaWonderTargetText[$value->target], 'remark' => $value->remark);
        }
    }
    $template->addVar('wonders_list', $wonders);
}
コード例 #3
0
ファイル: parser.inc.php プロジェクト: microlefes/Game
function formula_parseBasic($formula)
{
    global $FORMULA_SYMBOLS, $FORMULA_PHP_FUNCTIONS;
    foreach ($FORMULA_PHP_FUNCTIONS as $key => $value) {
        $formula = str_replace($key, $value, $formula);
    }
    $sql = '';
    // parse symbols
    for ($i = 0; $i < strlen($formula); $i++) {
        // opening brace
        if ($formula[$i] == '[') {
            $symbol = $formula[++$i];
            $index = 0;
            while ($formula[++$i] != '.') {
                $index = $index * 10 + ($formula[$i] + 0);
            }
            $field = substr($formula, ++$i, 3);
            // 'ACT]' or 'MAX]'
            $i += 3;
            if (strncasecmp($field, "ACT", 3) == 0) {
                $sql .= "0";
            } else {
                if (strncasecmp($field, "MAX", 3) == 0) {
                    $sql .= formula_parseBasic($FORMULA_SYMBOLS[$symbol][$index]->maxLevel);
                }
            }
        } else {
            $sql .= $formula[$i];
        }
    }
    return $sql;
}