function AddToPlanet($CurrentPlanet, $element, $mode, $charge = false)
{
global $resources, $resource, $reslist;
//Well, we need to work out the cost for the points and edit the planets table
//Standard construction
//Get the cost
$cost = BuildingCost($element, $CurrentPlanet[$resource[$element]] + $mode);
$chargestr = '';
if ($charge) {
//If we are changine
foreach ($resources as $res) {
//loop through resources
//Now add to query
$chargestr .= ", `" . $res . "` = `" . $res . "` - '" . $cost[$res] . "' ";
}
}
//And we will want a + in the query
$p_sign = "+";
//If its deconstruction though..
if ($mode < 0) {
//Deconstructon
//Get the cost
$cost = BuildingCost($element, $CurrentPlanet[$resource[$element]]);
//And we will want a - in the query
$p_sign = "-";
}
//start total cost
$tcost = 0;
//Now the resources which count towards points
foreach ($resources as $res) {
//Add them to the total
$tcost += $cost[$res];
}
//Now update the table
$qry = "UPDATE {{table}} SET `" . $resource[$element] . "` = `" . $resource[$element] . "` " . $p_sign . " " . idstring(abs($mode)) . " " . $chargestr . " WHERE `id` = '" . $CurrentPlanet['id'] . "' LIMIT 1 ;";
$return = doquery($qry, 'planets', false);
//If it is less than 100, update slots used
if ($element < 100) {
doquery("UPDATE {{table}} SET `field_current` = `field_current` " . $p_sign . " " . idstring(abs($mode)) . " WHERE `id` = '" . $CurrentPlanet['id'] . "' LIMIT 1 ;", 'planets', false);
}
//Now update the users stats
// Are we making fleet?
$fleet_points = 0;
if (in_array($element, $reslist['fleet'])) {
$fleet_points += $mode;
}
//Update in database
doquery("UPDATE {{table}} SET `total_points` = `total_points` + '" . $tcost . "', `fleet_points` = `fleet_points` + '" . $fleet_points . "' WHERE `id` = '" . $CurrentPlanet['id_owner'] . "' LIMIT 1 ;", 'users');
//Return the result
return $return;
}
/**
* ProtectNoob.php
*
* @version 1
* @copyright 2009 By MadnessRed for XNova Redesigned
*/
function ProtectNoob($input, $currentuser = false)
{
if ($currentuser) {
global $game_config;
//We need to get the current user.
if (is_array($currentuser)) {
//We have co-ords
$qry = doquery("SELECT `id_owner` FROM {{table}} WHERE `galaxy` = '" . idstring($input[0]) . "' AND `galaxy` = '" . idstring($input[1]) . "' AND `galaxy` = '" . idstring($input[2]) . "' LIMIT 1 ;", 'planets', true);
$uid = $qry['id_owner'];
} else {
//We have an id.
$uid = $currentuser;
}
$user = doquery("SELECT `total_points` FROM {{table}} WHERE `id` = '" . idstring($uid) . "' LIMIT 1 ;", 'users', true);
} else {
global $user, $game_config;
}
if (is_array($input)) {
//We have co-ords
$qry = doquery("SELECT `id_owner` FROM {{table}} WHERE `galaxy` = '" . idstring($input[0]) . "' AND `galaxy` = '" . idstring($input[1]) . "' AND `galaxy` = '" . idstring($input[2]) . "' LIMIT 1 ;", 'planets', true);
$id = $qry['id_owner'];
} else {
//We have an id.
$id = $input;
}
//How many poitns does the attack have?
$att_pts = $user['total_points'];
//How many points does the defender have?
$def_pts = doquery("SELECT `total_points` FROM {{table}} WHERE `id` = '" . idstring($id) . "' LIMIT 1 ;", 'users', true);
$def_pts = $def_pts['total_points'];
//Now what the the noob protection threshold?
$th = $game_config['stat_settings'] * $game_config['noobprotectiontime'];
if ($def_pts >= $th && $def_pts * $game_config['noobprotectionmulti'] <= $att_pts) {
//The defender is under the threshold and is less than 20% of the attackers score
return true;
} elseif ($att_pts >= $th && $att_pts * $game_config['noobprotectionmulti'] <= $def_pts) {
//The attacker is under the threshold and is less than 20% of the defenders score
return true;
} else {
//Neither of hte above to, we are clear to attack.
return false;
}
}
function DefensesBuildingPage(&$CurrentPlanet, $CurrentUser)
{
global $lang, $resource, $phpEx, $dpath, $_POST, $reslist, $pricelist;
if (isset($_POST['fmenge'])) {
// On vient de Cliquer ' Construire '
// Et y a une liste de doléances
// Ici, on sait precisement ce qu'on aimerait bien construire ...
// Gestion de la place disponible dans les silos !
$Missiles[502] = $CurrentPlanet[$resource[502]];
$Missiles[503] = $CurrentPlanet[$resource[503]];
$SiloSize = $CurrentPlanet[$resource[44]];
$MaxMissiles = $SiloSize * 10;
// On prend les missiles deja dans la queue de fabrication aussi (ca aide)
$BuildQueue = $CurrentPlanet['b_hangar_id'];
$BuildArray = explode(";", $BuildQueue);
for ($QElement = 0; $QElement < count($BuildArray); $QElement++) {
$ElmentArray = explode(",", $BuildArray[$QElement]);
if ($ElmentArray[502] != 0) {
$Missiles[502] += $ElmentArray[502];
} elseif ($ElmentArray[503] != 0) {
$Missiles[503] += $ElmentArray[503];
}
}
foreach ($_POST as $Element => $Count) {
$Element = idstring($Element);
if (in_array($Element, $reslist['fleet'])) {
$Element = intval($Element);
$Count = intval($Count);
if ($Count > MAX_FLEET_OR_DEFS_PER_ROW) {
$Count = MAX_FLEET_OR_DEFS_PER_ROW;
}
if ($Count != 0) {
// Cas particulier (Petit Bouclier et Grand Bouclier
// ne peuvent exister qu'une seule et unique fois
$InQueue = strpos($CurrentPlanet['b_hangar_id'], $Element . ",");
$IsBuild = $CurrentPlanet[$resource[407]] >= 1 ? true : false;
if ($Element == 407 || $Element == 408) {
if ($InQueue === false && !$IsBuild) {
$Count = 1;
}
}
// On verifie si on a les technologies necessaires a la construction de l'element
if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) {
// On verifie combien on sait faire de cet element au max
$MaxElements = GetMaxConstructibleElements($Element, $CurrentPlanet);
// Testons si on a de la place pour ces nouveaux missiles !
if ($Element == 502 || $Element == 503) {
// Cas particulier des missiles
$ActuMissiles = $Missiles[502] + 2 * $Missiles[503];
$MissilesSpace = $MaxMissiles - $ActuMissiles;
if ($Element == 502) {
if ($Count > $MissilesSpace) {
$Count = $MissilesSpace;
}
} else {
if ($Count > floor($MissilesSpace / 2)) {
$Count = floor($MissilesSpace / 2);
}
}
if ($Count > $MaxElements) {
$Count = $MaxElements;
}
$Missiles[$Element] += $Count;
} else {
// Si pas assez de ressources, on ajuste le nombre d'elements
if ($Count > $MaxElements) {
$Count = $MaxElements;
}
}
$Ressource = GetElementRessources($Element, $Count);
$BuildTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element);
if ($Count >= 1) {
$CurrentPlanet['metal'] -= $Ressource['metal'];
$CurrentPlanet['crystal'] -= $Ressource['crystal'];
$CurrentPlanet['deuterium'] -= $Ressource['deuterium'];
$CurrentPlanet['b_hangar_id'] .= "" . $Element . "," . $Count . ";";
}
}
}
}
}
}
// -------------------------------------------------------------------------------------------------------
// S'il n'y a pas de Chantier ...
if ($CurrentPlanet[$resource[21]] == 0) {
$shipyard = false;
} else {
$shipyard = true;
}
// -------------------------------------------------------------------------------------------------------
// Construction de la page du Chantier (car si j'arrive ici ... c'est que j'ai tout ce qu'il faut pour ...
$TabIndex = 0;
$PageTable = "";
$SubTemplate = gettemplate('buildings/defense_buttonz');
$parse = array();
$infopg = array();
foreach ($lang['tech'] as $Element => $ElementName) {
if (in_array($Element, $reslist['defense'])) {
if (!IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) {
$parse['state_' . $Element] = "off";
//.........这里部分代码省略.........
}
// Si l'on verifiait que l'adresse email n'existe pas encore ???
$ExistMail = doquery("SELECT `email` FROM {{table}} WHERE `email` = '" . mysql_escape_string($_POST['email']) . "' LIMIT 1;", 'users', true);
if ($ExistMail) {
$errorlist .= $lang['error_emailexist'];
$errors++;
}
if ($_POST['avatar'] == '') {
$avatar = "[X]";
} else {
$avatar = $_POST['avatar'];
}
if (preg_match("/[^A-z0-9]/", $_POST['ref_name']) == 1) {
$errorlist .= $lang['bad_referal'];
}
$refid = idstring($_GET['refid']);
$sec_qu = $_POST['sec_qu'];
$sec_ans = $_POST['sec_ans'];
if ($_POST['side'] == 'light') {
$ally_id = "1";
$ally_name = "Light";
} else {
$ally_id = "2";
$ally_name = "Dark";
}
$ally_register_time = time();
$ally_rank_id = 1;
if ($errors != 0) {
message($errorlist, $lang['Register']);
} else {
$newpass = $_POST['passwrd'];
开发者ID:sonicmaster,项目名称:RPG,代码行数:31,代码来源:reg.php
示例15: header
<?php
/**
* fleetrecall.php
*
* @version 2.0
* @copyright 2010 by MadnessRed for XNova Redesigned
*/
//Not really worth the file anymore, since its been moved to a function.
header('Content-Type: text/plain');
die(RecallFleet(idstring($_GET['fleet_id']), idstring($_GET['passkey']), $user['id']));
请发表评论