当前位置: 首页>>代码示例>>PHP>>正文


PHP Globals::getRaces方法代码示例

本文整理汇总了PHP中Globals::getRaces方法的典型用法代码示例。如果您正苦于以下问题:PHP Globals::getRaces方法的具体用法?PHP Globals::getRaces怎么用?PHP Globals::getRaces使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Globals的用法示例。


在下文中一共展示了Globals::getRaces方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_file_loc

<?php

require_once get_file_loc('menu.inc');
if (!isset($var['race_id'])) {
    SmrSession::updateVar('race_id', $player->getRaceID());
}
$raceID = $var['race_id'];
$template->assign('PageTopic', 'Ruling Council Of ' . Globals::getRaceName($raceID));
// echo menu
create_council_menu($raceID);
$RACES =& Globals::getRaces();
$raceRelations =& Globals::getRaceRelations($player->getGameID(), $raceID);
$peaceRaces = array();
$neutralRaces = array();
$warRaces = array();
foreach ($RACES as $otherRaceID => $raceInfo) {
    if ($otherRaceID != RACE_NEUTRAL && $raceID != $otherRaceID) {
        if ($raceRelations[$otherRaceID] >= 300) {
            $peaceRaces[$otherRaceID] = $raceInfo;
        } else {
            if ($raceRelations[$otherRaceID] <= -300) {
                $warRaces[$otherRaceID] = $raceInfo;
            } else {
                $neutralRaces[$otherRaceID] = $raceInfo;
            }
        }
    }
}
$template->assignByRef('PeaceRaces', $peaceRaces);
$template->assignByRef('NeutralRaces', $neutralRaces);
$template->assignByRef('WarRaces', $warRaces);
开发者ID:smrealms,项目名称:smrv2.0,代码行数:31,代码来源:council_politics.php

示例2: debug

function &findRoutes(&$player)
{
    debug('Finding Routes');
    $galaxies =& SmrGalaxy::getGameGalaxies($player->getGameID());
    $tradeGoods = array(GOOD_NOTHING => false);
    $goods =& Globals::getGoods();
    foreach ($goods as $goodID => &$good) {
        if ($player->meetsAlignmentRestriction($good['AlignRestriction'])) {
            $tradeGoods[$goodID] = true;
        } else {
            $tradeGoods[$goodID] = false;
        }
    }
    unset($good);
    $tradeRaces = array();
    $races =& Globals::getRaces();
    foreach ($races as $raceID => &$race) {
        $tradeRaces[$raceID] = false;
    }
    unset($race);
    $tradeRaces[$player->getRaceID()] = true;
    $galaxy =& $player->getSector()->getGalaxy();
    $maxNumberOfPorts = 2;
    $routesForPort = -1;
    $numberOfRoutes = 1000;
    $maxDistance = 15;
    $startSectorID = $galaxy->getStartSector();
    $endSectorID = $galaxy->getEndSector();
    $db = new SmrMySqlDatabase();
    $db->query('SELECT routes FROM route_cache WHERE game_id=' . $db->escapeNumber($player->getGameID()) . ' AND max_ports=' . $db->escapeNumber($maxNumberOfPorts) . ' AND goods_allowed=' . $db->escapeObject($tradeGoods) . ' AND races_allowed=' . $db->escapeObject($tradeRaces) . ' AND start_sector_id=' . $db->escapeNumber($startSectorID) . ' AND end_sector_id=' . $db->escapeNumber($endSectorID) . ' AND routes_for_port=' . $db->escapeNumber($routesForPort) . ' AND max_distance=' . $db->escapeNumber($maxDistance));
    if ($db->nextRecord()) {
        $routes = unserialize(gzuncompress($db->getField('routes')));
        debug('Using Cached Routes: #' . count($routes));
        return $routes;
    } else {
        debug('Generating Routes');
        $allSectors = array();
        foreach ($galaxies as &$galaxy) {
            $allSectors += $galaxy->getSectors();
            //Merge arrays
        }
        unset($galaxy);
        $distances =& Plotter::calculatePortToPortDistances($allSectors, $maxDistance, $startSectorID, $endSectorID);
        if ($maxNumberOfPorts == 1) {
            $allRoutes = RouteGenerator::generateOneWayRoutes($allSectors, $distances, $tradeGoods, $tradeRaces, $routesForPort);
        } else {
            $allRoutes = RouteGenerator::generateMultiPortRoutes($maxNumberOfPorts, $allSectors, $tradeGoods, $tradeRaces, $distances, $routesForPort, $numberOfRoutes);
        }
        unset($distances);
        $allRoutes =& $allRoutes[RouteGenerator::EXP_ROUTE];
        $routesMerged = array();
        foreach ($allRoutes as $multi => &$routesByMulti) {
            $routesMerged += $routesByMulti;
            //Merge arrays
        }
        unset($routesByMulti);
        unset($allSectors);
        SmrPort::clearCache();
        SmrSector::clearCache();
        $db->query('INSERT INTO route_cache ' . '(game_id, max_ports, goods_allowed, races_allowed, start_sector_id, end_sector_id, routes_for_port, max_distance, routes)' . ' VALUES (' . $db->escapeNumber($player->getGameID()) . ', ' . $db->escapeNumber($maxNumberOfPorts) . ', ' . $db->escapeObject($tradeGoods) . ', ' . $db->escapeObject($tradeRaces) . ', ' . $db->escapeNumber($startSectorID) . ', ' . $db->escapeNumber($endSectorID) . ', ' . $db->escapeNumber($routesForPort) . ', ' . $db->escapeNumber($maxDistance) . ', ' . $db->escapeObject($routesMerged, true) . ')');
        debug('Found Routes: #' . count($routesMerged));
        return $routesMerged;
    }
}
开发者ID:smrealms,项目名称:smrv2.0,代码行数:64,代码来源:npc.php

示例3:

$PHP_OUTPUT .= 'Working on Galaxy : ' . $galaxy->getName() . ' (' . $galaxy->getGalaxyID() . ')<br />';
$PHP_OUTPUT .= '<table width="100%"><tr><th>Ports</th><th>Port Races</th><th>Starting Mines</th></tr><tr><td class="center">';
$PHP_OUTPUT .= '<table class="standard">';
for ($i = 1; $i <= 9; $i++) {
    $PHP_OUTPUT .= '<tr><td class="right">Level ' . $i . ' Ports</td><td>';
    $PHP_OUTPUT .= '<input type="number" value="';
    $PHP_OUTPUT .= $totalPorts[$i];
    $PHP_OUTPUT .= '" size="5" name="port' . $i . '" onFocus="startCalc();" onBlur="stopCalc();"></td></tr>';
}
$PHP_OUTPUT .= '<tr><td type="number" class="right">Total Ports</td><td><input type="number" size="5" name="total" value="';
$PHP_OUTPUT .= $total['Ports'];
$PHP_OUTPUT .= '"></td></tr>';
$PHP_OUTPUT .= '</table>';
$PHP_OUTPUT .= '</td><td class="center">';
$PHP_OUTPUT .= '<table class="standard"><tr><th colspan="2">Port Race % Distribution</th></tr>';
$races =& Globals::getRaces();
foreach ($races as &$race) {
    $PHP_OUTPUT .= '<tr><td class="right">' . $race['Race Name'] . '</td><td><input type="number" size="5" name="race' . $race['Race ID'] . '" value="0" onFocus="startRaceCalc();" onBlur="stopRaceCalc();"></td></tr>';
}
$PHP_OUTPUT .= '<tr><td class="right">Total</td><td><input type="number" size="5" name="racedist" value="0"></td></tr>';
$PHP_OUTPUT .= '<tr><td class="center" colspan="2">';
$PHP_OUTPUT .= '<div class="buttonA"><a class="buttonA" onClick="setEven();">&nbsp;Set All Equal&nbsp;</a></div></td></tr>';
$PHP_OUTPUT .= '</table>';
$PHP_OUTPUT .= '</td><td class="center"><table class="standard">';
for ($i = 1; $i <= 20; $i++) {
    $PHP_OUTPUT .= '<tr><td class="right">Level ' . $i . ' Mines</td><td>';
    $PHP_OUTPUT .= '<input type="number" value="';
    $PHP_OUTPUT .= $totalMines[$i];
    $PHP_OUTPUT .= '" size="5" name="mine' . $i . '" onFocus="startCalcM();" onBlur="stopCalcM();"></td></tr>';
}
$PHP_OUTPUT .= '<tr><td class="right">Total Mines</td><td><input type="number" size="5" name="totalM" value="';
开发者ID:smrealms,项目名称:smrv2.0,代码行数:31,代码来源:universe_create_ports.php

示例4: create_error

    // do we have enough
    if ($account->getTotalSmrCredits() < $game['GameCreditsRequired']) {
        create_error('Sorry you do not have enough SMR Credits to play this game.<br />To get SMR credits you need to donate to SMR.');
    }
}
// is the game already full?
if (SmrGame::getGame($var['game_id'])->getTotalPlayers() >= $game['GameMaxPlayers']) {
    create_error('The maximum number of players in that game is reached!');
}
//if (TIME < $game['StartDate'])
//	create_error('You want to join a game that hasn\'t started yet?');
if (TIME > $game['EndDate']) {
    create_error('You want to join a game that is already over?');
}
$template->assign('PageTopic', 'Join Game');
$raceInfo =& Globals::getRaces();
$raceDescriptions = '';
$first = true;
foreach ($raceInfo as $race) {
    if ($first) {
        $raceDescriptions .= '\'' . str_replace('\'', '\\\'"', $race['Description']) . '\'';
        $first = false;
    } else {
        $raceDescriptions .= ', \'' . str_replace('\'', '\\\'', $race['Description']) . '\'';
    }
}
$template->assign('RaceDescriptions', $raceDescriptions);
// create a container that will hold next url and additional variables.
$container = array();
$container['game_id'] = $var['game_id'];
$container['url'] = 'game_join_processing.php';
开发者ID:smrealms,项目名称:smrv2.0,代码行数:31,代码来源:game_join.php


注:本文中的Globals::getRaces方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。