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


PHP PlayerUtil::createMoon方法代码示例

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


在下文中一共展示了PlayerUtil::createMoon方法的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);
//.........这里部分代码省略.........
开发者ID:tatarysh,项目名称:2Moons,代码行数:101,代码来源:ShowCreatorPage.php

示例2: TargetEvent


//.........这里部分代码省略.........
                    $sql = 'UPDATE %%PLANETS%% SET ' . implode(', ', $fleetArray) . ' WHERE id = :planetId;';
                    $db->update($sql, $params);
                }
            }
        }
        if ($combatResult['won'] == "a") {
            require_once 'includes/classes/missions/functions/calculateSteal.php';
            $stealResource = calculateSteal($fleetAttack, $targetPlanet);
        }
        if ($this->_fleet['fleet_end_type'] == 3) {
            // Use planet debris, if attack on moons
            $sql = "SELECT der_metal, der_crystal FROM %%PLANETS%% WHERE id_luna = :moonId;";
            $targetDebris = $db->selectSingle($sql, array(':moonId' => $this->_fleet['fleet_end_id']));
            $targetPlanet += $targetDebris;
        }
        foreach ($debrisResource as $elementID) {
            $debris[$elementID] = $combatResult['debris']['attacker'][$elementID] + $combatResult['debris']['defender'][$elementID];
            $planetDebris[$elementID] = $targetPlanet['der_' . $resource[$elementID]] + $debris[$elementID];
        }
        $debrisTotal = array_sum($debris);
        $moonFactor = $config->moon_factor;
        $maxMoonChance = $config->moon_chance;
        if ($targetPlanet['id_luna'] == 0 && $targetPlanet['planet_type'] == 1) {
            $chanceCreateMoon = round($debrisTotal / 100000 * $moonFactor);
            $chanceCreateMoon = min($chanceCreateMoon, $maxMoonChance);
        } else {
            $chanceCreateMoon = 0;
        }
        $reportInfo = array('thisFleet' => $this->_fleet, 'debris' => $debris, 'stealResource' => $stealResource, 'moonChance' => $chanceCreateMoon, 'moonDestroy' => false, 'moonName' => NULL, 'moonDestroyChance' => NULL, 'moonDestroySuccess' => NULL, 'fleetDestroyChance' => NULL, 'fleetDestroySuccess' => NULL);
        $randChance = mt_rand(1, 100);
        if ($randChance <= $chanceCreateMoon) {
            $LNG = $this->getLanguage($targetUser['lang']);
            $reportInfo['moonName'] = $LNG['type_planet'][3];
            PlayerUtil::createMoon($this->_fleet['fleet_universe'], $this->_fleet['fleet_end_galaxy'], $this->_fleet['fleet_end_system'], $this->_fleet['fleet_end_planet'], $targetUser['id'], $reportInfo['moonName'], $chanceCreateMoon, $this->_fleet['fleet_start_time']);
            if (Config::get($this->_fleet['fleet_universe'])->debris_moon == 1) {
                foreach ($debrisResource as $elementID) {
                    $planetDebris[$elementID] = 0;
                }
            }
        }
        require_once 'includes/classes/missions/functions/GenerateReport.php';
        $reportData = GenerateReport($combatResult, $reportInfo);
        switch ($combatResult['won']) {
            case "a":
                // Win
                $attackStatus = 'wons';
                $defendStatus = 'loos';
                $class = array('raportWin', 'raportLose');
                break;
            case "r":
                // Lose
                $attackStatus = 'loos';
                $defendStatus = 'wons';
                $class = array('raportLose', 'raportWin');
                break;
            case "w":
            default:
                // Draw
                $attackStatus = 'draws';
                $defendStatus = 'draws';
                $class = array('raportDraw', 'raportDraw');
                break;
        }
        $reportID = md5(uniqid('', true) . TIMESTAMP);
        $sql = 'INSERT INTO %%RW%% SET
		rid 		= :reportId,
开发者ID:Hetachi,项目名称:2Moons,代码行数:67,代码来源:MissionCaseAttack.class.php


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