本文整理汇总了PHP中PlayerUtil::isPositionFree方法的典型用法代码示例。如果您正苦于以下问题:PHP PlayerUtil::isPositionFree方法的具体用法?PHP PlayerUtil::isPositionFree怎么用?PHP PlayerUtil::isPositionFree使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerUtil
的用法示例。
在下文中一共展示了PlayerUtil::isPositionFree方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ShowCreatorPage
function ShowCreatorPage()
{
global $LNG, $USER;
$template = new template();
switch ($_GET['mode']) {
case 'user':
$LNG->includeData(array('PUBLIC'));
if ($_POST) {
$UserName = HTTP::_GP('name', '', UTF8_SUPPORT);
$UserPass = HTTP::_GP('password', '');
$UserPass2 = HTTP::_GP('password2', '');
$UserMail = HTTP::_GP('email', '');
$UserMail2 = HTTP::_GP('email2', '');
$UserAuth = HTTP::_GP('authlevel', 0);
$Galaxy = HTTP::_GP('galaxy', 0);
$System = HTTP::_GP('system', 0);
$Planet = HTTP::_GP('planet', 0);
$Language = HTTP::_GP('lang', '');
$ExistsUser = $GLOBALS['DATABASE']->getFirstCell("SELECT (SELECT COUNT(*) FROM " . USERS . " WHERE universe = " . Universe::getEmulated() . " AND username = '" . $GLOBALS['DATABASE']->sql_escape($UserName) . "') + (SELECT COUNT(*) FROM " . USERS_VALID . " WHERE universe = " . Universe::getEmulated() . " AND username = '" . $GLOBALS['DATABASE']->sql_escape($UserName) . "')");
$ExistsMails = $GLOBALS['DATABASE']->getFirstCell("SELECT (SELECT COUNT(*) FROM " . USERS . " WHERE universe = " . Universe::getEmulated() . " AND (email = '" . $GLOBALS['DATABASE']->sql_escape($UserMail) . "' OR email_2 = '" . $GLOBALS['DATABASE']->sql_escape($UserMail) . "')) + (SELECT COUNT(*) FROM " . USERS_VALID . " WHERE universe = " . Universe::getEmulated() . " AND email = '" . $GLOBALS['DATABASE']->sql_escape($UserMail) . "')");
$errors = "";
$config = Config::get(Universe::getEmulated());
if (!PlayerUtil::isMailValid($UserMail)) {
$errors .= $LNG['invalid_mail_adress'];
}
if (empty($UserName)) {
$errors .= $LNG['empty_user_field'];
}
if (strlen($UserPass) < 6) {
$errors .= $LNG['password_lenght_error'];
}
if ($UserPass != $UserPass2) {
$errors .= $LNG['different_passwords'];
}
if ($UserMail != $UserMail2) {
$errors .= $LNG['different_mails'];
}
if (!PlayerUtil::isNameValid($UserName)) {
$errors .= $LNG['user_field_specialchar'];
}
if ($ExistsUser != 0) {
$errors .= $LNG['user_already_exists'];
}
if ($ExistsMails != 0) {
$errors .= $LNG['mail_already_exists'];
}
if (!PlayerUtil::isPositionFree(Universe::getEmulated(), $Galaxy, $System, $Planet)) {
$errors .= $LNG['planet_already_exists'];
}
if ($Galaxy > $config->max_galaxy || $System > $config->max_system || $Planet > $config->max_planets) {
$errors .= $LNG['po_complete_all2'];
}
if (!empty($errors)) {
$template->message($errors, '?page=create&mode=user', 10, true);
exit;
}
$Language = array_key_exists($Language, $LNG->getAllowedLangs(false)) ? $Language : $config->lang;
PlayerUtil::createPlayer(Universe::getEmulated(), $UserName, PlayerUtil::cryptPassword($UserPass), $UserMail, $Language, $Galaxy, $System, $Planet, $LNG['fcm_planet'], $UserAuth);
$template->message($LNG['new_user_success'], '?page=create&mode=user', 5, true);
exit;
}
$AUTH = array();
$AUTH[AUTH_USR] = $LNG['user_level'][AUTH_USR];
if ($USER['authlevel'] >= AUTH_OPS) {
$AUTH[AUTH_OPS] = $LNG['user_level'][AUTH_OPS];
}
if ($USER['authlevel'] >= AUTH_MOD) {
$AUTH[AUTH_MOD] = $LNG['user_level'][AUTH_MOD];
}
if ($USER['authlevel'] >= AUTH_ADM) {
$AUTH[AUTH_ADM] = $LNG['user_level'][AUTH_ADM];
}
$template->assign_vars(array('admin_auth' => $USER['authlevel'], 'new_add_user' => $LNG['new_add_user'], 'new_creator_refresh' => $LNG['new_creator_refresh'], 'new_creator_go_back' => $LNG['new_creator_go_back'], 'universe' => $LNG['mu_universe'], 'user_reg' => $LNG['user_reg'], 'pass_reg' => $LNG['pass_reg'], 'pass2_reg' => $LNG['pass2_reg'], 'email_reg' => $LNG['email_reg'], 'email2_reg' => $LNG['email2_reg'], 'new_coord' => $LNG['new_coord'], 'new_range' => $LNG['new_range'], 'lang_reg' => $LNG['lang_reg'], 'new_title' => $LNG['new_title'], 'Selector' => array('auth' => $AUTH, 'lang' => $LNG->getAllowedLangs(false))));
$template->show('CreatePageUser.tpl');
break;
case 'moon':
if ($_POST) {
$PlanetID = HTTP::_GP('add_moon', 0);
$MoonName = HTTP::_GP('name', '', UTF8_SUPPORT);
$Diameter = HTTP::_GP('diameter', 0);
$MoonPlanet = $GLOBALS['DATABASE']->getFirstRow("SELECT temp_max, temp_min, id_luna, galaxy, system, planet, planet_type, destruyed, id_owner FROM " . PLANETS . " WHERE id = '" . $PlanetID . "' AND universe = '" . Universe::getEmulated() . "' AND planet_type = '1' AND destruyed = '0';");
if (!isset($MoonPlanet)) {
$template->message($LNG['mo_planet_doesnt_exist'], '?page=create&mode=moon', 3, true);
exit;
}
$moonId = PlayerUtil::createMoon(Universe::getEmulated(), $MoonPlanet['galaxy'], $MoonPlanet['system'], $MoonPlanet['planet'], $MoonPlanet['id_owner'], 20, $_POST['diameter_check'] == 'on' ? NULL : $Diameter, $MoonName);
if ($moonId !== false) {
$template->message($LNG['mo_moon_added'], '?page=create&mode=moon', 3, true);
} else {
$template->message($LNG['mo_moon_unavaible'], '?page=create&mode=moon', 3, true);
}
exit;
}
$template->assign_vars(array('admin_auth' => $USER['authlevel'], 'universum' => $LNG['mu_universe'], 'po_add_moon' => $LNG['po_add_moon'], 'input_id_planet' => $LNG['input_id_planet'], 'mo_moon_name' => $LNG['mo_moon_name'], 'mo_diameter' => $LNG['mo_diameter'], 'mo_temperature' => $LNG['mo_temperature'], 'mo_fields_avaibles' => $LNG['mo_fields_avaibles'], 'button_add' => $LNG['button_add'], 'new_creator_refresh' => $LNG['new_creator_refresh'], 'mo_moon' => $LNG['fcm_moon'], 'new_creator_go_back' => $LNG['new_creator_go_back']));
$template->show('CreatePageMoon.tpl');
break;
case 'planet':
if ($_POST) {
$id = HTTP::_GP('id', 0);
$Galaxy = HTTP::_GP('galaxy', 0);
//.........这里部分代码省略.........
示例2: TargetEvent
function TargetEvent()
{
$db = Database::get();
$sql = 'SELECT * FROM %%USERS%% WHERE `id` = :userId;';
$senderUser = $db->selectSingle($sql, array(':userId' => $this->_fleet['fleet_owner']));
$senderUser['factor'] = getFactors($senderUser, 'basic', $this->_fleet['fleet_start_time']);
$LNG = $this->getLanguage($senderUser['lang']);
$checkPosition = PlayerUtil::checkPosition($this->_fleet['fleet_universe'], $this->_fleet['fleet_end_galaxy'], $this->_fleet['fleet_end_system'], $this->_fleet['fleet_end_planet']);
$isPositionFree = PlayerUtil::isPositionFree($this->_fleet['fleet_universe'], $this->_fleet['fleet_end_galaxy'], $this->_fleet['fleet_end_system'], $this->_fleet['fleet_end_planet']);
if (!$isPositionFree || !$checkPosition) {
$message = sprintf($LNG['sys_colo_notfree'], GetTargetAddressLink($this->_fleet, ''));
} else {
$allowPlanetPosition = PlayerUtil::allowPlanetPosition($this->_fleet['fleet_end_planet'], $senderUser);
if (!$allowPlanetPosition) {
$message = sprintf($LNG['sys_colo_notech'], GetTargetAddressLink($this->_fleet, ''));
} else {
$sql = 'SELECT COUNT(*) as state
FROM %%PLANETS%%
WHERE `id_owner` = :userId
AND `planet_type` = :type
AND `destruyed` = :destroyed;';
$currentPlanetCount = $db->selectSingle($sql, array(':userId' => $this->_fleet['fleet_owner'], ':type' => 1, ':destroyed' => 0), 'state');
$maxPlanetCount = PlayerUtil::maxPlanetCount($senderUser);
if ($currentPlanetCount >= $maxPlanetCount) {
$message = sprintf($LNG['sys_colo_maxcolo'], GetTargetAddressLink($this->_fleet, ''), $maxPlanetCount);
} else {
$NewOwnerPlanet = PlayerUtil::createPlanet($this->_fleet['fleet_end_galaxy'], $this->_fleet['fleet_end_system'], $this->_fleet['fleet_end_planet'], $this->_fleet['fleet_universe'], $this->_fleet['fleet_owner'], $LNG['fcp_colony'], false, $senderUser['authlevel']);
if ($NewOwnerPlanet === false) {
$message = sprintf($LNG['sys_colo_badpos'], GetTargetAddressLink($this->_fleet, ''));
$this->setState(FLEET_RETURN);
} else {
$this->_fleet['fleet_end_id'] = $NewOwnerPlanet;
$message = sprintf($LNG['sys_colo_allisok'], GetTargetAddressLink($this->_fleet, ''));
$this->StoreGoodsToPlanet();
if ($this->_fleet['fleet_amount'] == 1) {
$this->KillFleet();
} else {
$CurrentFleet = explode(";", $this->_fleet['fleet_array']);
$NewFleet = '';
foreach ($CurrentFleet as $Group) {
if (empty($Group)) {
continue;
}
$Class = explode(",", $Group);
if ($Class[0] == 208 && $Class[1] > 1) {
$NewFleet .= $Class[0] . "," . ($Class[1] - 1) . ";";
} elseif ($Class[0] != 208 && $Class[1] > 0) {
$NewFleet .= $Class[0] . "," . $Class[1] . ";";
}
}
$this->UpdateFleet('fleet_array', $NewFleet);
$this->UpdateFleet('fleet_amount', $this->_fleet['fleet_amount'] - 1);
$this->UpdateFleet('fleet_resource_metal', 0);
$this->UpdateFleet('fleet_resource_crystal', 0);
$this->UpdateFleet('fleet_resource_deuterium', 0);
}
}
}
}
}
PlayerUtil::sendMessage($this->_fleet['fleet_owner'], 0, $LNG['sys_colo_mess_from'], 4, $LNG['sys_colo_mess_report'], $message, $this->_fleet['fleet_start_time'], NULL, 1, $this->_fleet['fleet_universe']);
$this->setState(FLEET_RETURN);
$this->SaveFleet();
}