本文整理汇总了PHP中city::unit_count方法的典型用法代码示例。如果您正苦于以下问题:PHP city::unit_count方法的具体用法?PHP city::unit_count怎么用?PHP city::unit_count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类city
的用法示例。
在下文中一共展示了city::unit_count方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: foreach
foreach ($user->getValue('cities') as $city) {
if ($city->getValue('id') == $data || @preg_match('/^' . $data . '$/i', $city->getValue('name'))) {
$close_upper_bound = intval($city->getValue('id')) + 30000;
$dbcities = mysql_query("SELECT city_id FROM server_cities WHERE server_id=" . $server->getID() . " AND city_id < {$close_upper_bound} ORDER BY city_id DESC LIMIT 10", $db) or die(mysql_error());
$reply = 'On ' . $server->getName() . ' near ' . $city->getValue('name') . '@' . $city->getValue('id') . ' : ';
while ($icity = mysql_fetch_assoc($dbcities)) {
$cityo = new city($icity['city_id']);
$reply .= $cityo->getValue('name') . '@' . $cityo->getValue('id') . ' ';
}
break;
}
}
} else {
foreach ($user->getValue('cities') as $city) {
if ($city->getValue('id') == $data || @preg_match('/^' . $data . '$/i', $city->getValue('name'))) {
$reply = $city->getValue('name') . '@' . $city->getValue('id') . ' Population: ' . $city->getValue('population') . ' / Defense: ' . ($city->getValue('defense') + 1) . ' / Units: ' . $city->unit_count();
break;
}
}
//end foreach
}
}
break;
case 'attack':
case 'move':
preg_match('/^([^\\s]+)[\\s]+from[\\s]+([^\\s]+)[\\s]+with[\\s]+([\\d]+)[\\s]+([^\\s]+)$/', trim($data), $data);
var_dump($data);
if (!count($data)) {
$reply = 'I do not understand your troop movement request.';
} else {
foreach ($user->getValue('cities') as $city) {
示例2: foreach
}
//end while cities
echo '</ul>';
}
//end if ! tocity
if (!$fromcity) {
echo '<h2>Select a City to Attack/Move From</h2><ul>';
foreach ($current_user->getValue('cities') as $city) {
echo '<li>';
echo '<a href="/server/' . $server->getID() . '/attack/' . $cities[0] . '+' . $city->getValue('id') . '">';
if ($city->getValue('name')) {
echo htmlentities($city->getValue('name')) . ' / ';
}
echo 'Location: ' . $city->getValue('id');
echo '</a> / Population: ' . $city->getValue('population') . ' / Defense: ' . (intval($city->getValue('defense')) + 1);
echo ' / Units: ' . intval($city->unit_count());
echo '</li>';
}
//end foreach cities
echo '</ul>';
}
//end if ! fromcity
if ($fromcity && $tocity) {
$units = mysql_query("SELECT unit_id,name,cost FROM units WHERE server_id=" . $server->getID(), $db) or die(mysql_query());
while ($unit = mysql_fetch_assoc($units)) {
$unit_list .= "\t\t\t<li>";
$unit_list .= htmlentities($unit['name']);
$unit_list .= ' (' . intval($fromcity->getValue('unit_' . $unit['unit_id'])) . ')';
$unit_list .= '<form method="post" action="">';
$unit_list .= ' <input type="hidden" name="attack_id" value="' . $unit['unit_id'] . '" />';
$unit_list .= ' <input type="text" name="attack_count" value="Number to attack with" onclick="this.value=\'\'" />';
示例3: ceil
}
if (!$can_access) {
$can_access = $this_city->getValue('user_' . $LOGIN_DATA['user_id'] . '_access');
if ($can_access !== true && intval($can_access) > time()) {
$can_access_time = ceil(($can_access - time()) / 60);
}
$can_access = $can_access === true || intval($can_access) > time();
}
//end if ! can_access
if ($can_access) {
if (!$server) {
$server = new server($_REQUEST['server_id']);
}
$units = mysql_query("SELECT unit_id,name,description,cost FROM units WHERE server_id=" . $server->getID(), $db) or die(mysql_query());
while ($unit = mysql_fetch_assoc($units)) {
$unit_options .= "\t\t\t" . '<option value="' . $unit['unit_id'] . '">' . htmlentities($unit['name']) . ' (' . $unit['cost'] . ' Gold)</option>' . "\n";
$unit_list .= "\t\t\t<li>";
$unit_list .= htmlentities($unit['name']);
$unit_list .= ' (' . intval($this_city->getValue('unit_' . $unit['unit_id'])) . ')';
if ($unit['description']) {
$unit_list .= ' - ' . htmlentities($unit['description']);
}
$unit_list .= "</li>\n";
}
//end while unit
echo '<h3>Units (' . $this_city->unit_count() . ')</h3>';
echo '<ul>';
echo $unit_list;
echo '</ul>';
}
//end if can_access