Exemplo n.º 1
0
/**
 * BuildingPage.php
 *
 * @version 1.0
 * @copyright 2009 by MadnessRed for XNova Redesigned
 */
function BuildingPage($a = 0, $b = 0)
{
    global $lang, $resource, $reslist, $pricelist, $dpath, $game_config, $_GET, $user, $planetrow;
    CheckPlanetUsedFields($planetrow);
    if (!$_GET['page']) {
        return false;
        die;
    }
    // Tables des batiments possibles par type de planete
    if ($_GET['page'] == 'station') {
        $Allowed[1] = array(14, 15, 21, 31, 33, 34, 44);
        $Allowed[3] = array(14, 21, 34, 41, 42, 43);
    } elseif ($_GET['page'] == 'resources') {
        $Allowed[1] = array(1, 2, 3, 4, 12, 212, 22, 23, 24);
        $Allowed[3] = array(212, 22, 23, 24);
    } else {
        die("Hacking attempt");
    }
    //Right, lets see what he has an generate him an image.
    $imgnum = '';
    if ($planetrow[$resource[1]] > 0) {
        $imgnum .= "_1";
    }
    if ($planetrow[$resource[2]] > 0) {
        $imgnum .= "_2";
    }
    if ($planetrow[$resource[3]] > 0) {
        $imgnum .= "_3";
    }
    if ($planetrow[$resource[4]] > 0) {
        $imgnum .= "_4";
    }
    // Boucle d'interpretation des eventuelles commandes
    if (isset($_GET['cmd'])) {
        // On passe une commande
        $bThisIsCheated = false;
        $bDoItNow = false;
        $TheCommand = $_GET['cmd'];
        $Element = $_GET['building'];
        $ListID = $_GET['listid'];
        if (isset($Element)) {
            if (!strchr($Element, " ")) {
                if (!strchr($Element, ",")) {
                    if (in_array(trim($Element), $Allowed[$planetrow['planet_type']])) {
                        $bDoItNow = true;
                    } else {
                        //$bThisIsCheated = true;
                        $bDoItNow = true;
                    }
                } else {
                    $bThisIsCheated = true;
                }
            } else {
                $bThisIsCheated = true;
            }
        } elseif (isset($ListID)) {
            $bDoItNow = true;
        }
        if ($bDoItNow == true) {
            switch ($TheCommand) {
                case 'cancel':
                    //Remove last queue item
                    RemoveFromQueue();
                    break;
                case 'remove':
                    //Remove a specific queue item
                    RemoveFromQueue($ListID);
                    break;
                case 'insert':
                    //Insert into the queue a build
                    $fields_rem = $planetrow['field_max'] - $planetrow['field_current'] + $planetrow[$resource[33]] * 5;
                    if ($fields_rem >= 0) {
                        AddToQueue($Element, 1);
                    } else {
                        echo $fields_rem . " < 0";
                        die("Hacking Attempt!");
                    }
                    break;
                case 'destroy':
                    //Add a deconstrction to the queue
                    AddToQueue($Element, -1);
                    break;
            }
            // switch
        } elseif ($bThisIsCheated == true) {
            //ResetThisFuckingCheater ( $user['id'] );
        }
        //If they want axah_section
        if ($_GET['axah_box']) {
            $q = ShowQueue(false);
            makeAXAH($q['buildlist']);
            die;
        }
    }
    $Queue = ShowQueue(true);
    // On enregistre ce que l'on a modifi� dans planet !
    BuildingSavePlanetRecord($planetrow);
    // On enregistre ce que l'on a eventuellement modifi� dans users
    BuildingSaveUserRecord($user);
    $max_qs = MAX_BUILDING_QUEUE_SIZE;
    if ($max_qs > 0) {
        //fine :)
    } else {
        $max_qs = 10;
    }
    if ($Queue['length'] < $max_qs) {
        $CanBuildElement = true;
    } else {
        $CanBuildElement = false;
    }
    if ($_GET['page'] == 'station') {
        if ($planetrow['planet_type'] == 3) {
            $SubTemplate = gettemplate('buildings/station-moon_buttonz');
        } else {
            $SubTemplate = gettemplate('buildings/station_buttonz');
        }
    } elseif ($_GET['page'] == 'resources') {
        $SubTemplate = gettemplate('buildings/resources_buttonz');
    } else {
        die("Hacking attempt");
    }
    $parse = array();
    $infopg = array();
    foreach ($lang['names'] as $Element => $ElementName) {
        if (!$planetrow['planet_type']) {
            die("no planet type");
        }
        if (in_array($Element, $Allowed[$planetrow['planet_type']]) || $_GET['page'] == 'station') {
            if (@in_array($Element, $Allowed[$planetrow['planet_type']])) {
                if (!IsTechnologieAccessible($user, $planetrow, $Element)) {
                    $parse['state_' . $Element] = "off";
                    $parse['mes_' . $Element] = "Requirements are not met";
                    $parse['canbuild_' . $Element] = "";
                } elseif (!IsElementBuyable($user, $planetrow, $Element, true, false) && $Queue['length'] == 0) {
                    $parse['state_' . $Element] = "disabled";
                    $parse['mes_' . $Element] = "Not enough resources!";
                    $parse['canbuild_' . $Element] = "";
                } elseif (!$CanBuildElement) {
                    $parse['state_' . $Element] = "disabled";
                    $parse['mes_' . $Element] = "Queue is full!";
                    $parse['canbuild_' . $Element] = "";
                } else {
                    $parse['state_' . $Element] = "on";
                    $parse['mes_' . $Element] = "";
                    $parse['canbuild_' . $Element] = "\n\t\t\t\t\t\t<a class=\"fastBuild tips\" href=\"#\" onclick=\"loadpage('./?page=" . $_GET['page'] . "&cmd=insert&building={$Element}&id={$Element}',document.title,document.body.id);\">\n\t\t\t\t\t\t\t<img src=\"" . GAME_SKIN . "/img/layout/sofort_bauen.gif\" height=\"14\" width=\"22\">\n\t\t\t\t\t\t</a>";
                }
            } else {
                $parse['state_' . $Element] = "off";
                $parse['mes_' . $Element] = "Not availble";
                $parse['canbuild_' . $Element] = "";
            }
            $parse['name_' . $Element] = $ElementName;
            $parse['count_' . $Element] = $planetrow[$resource[$Element]];
        }
    }
    //Countdowns
    if ($planetrow['b_building'] > 0) {
        $BuildQueue = explode(";", $planetrow['b_building_id']);
        $CurrBuild = explode(",", $BuildQueue[0]);
        $parse['countdown_' . $CurrBuild[0]] = "\n\t\t\t\t\t\t\t\t\t<div class=\"construction\">\n\n\t\t\t\t\t\t\t\t\t\t<div class=\"pusher\" style=\"height: 80px; margin-bottom: -80px;\">\n\n\t\t\t\t\t\t\t\t\t\t\t<span class=\"time\" id=\"resource\">" . parsecountdown($planetrow['b_building']) . "</span>\n\n\t\t\t\t\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t\t\t\t</div>\n";
    }
    $BuildingPage = parsetemplate($SubTemplate, $parse);
    $parse = $lang;
    $Element = idstring($_GET['id']);
    $ElementName = $lang['names'][$Element];
    // Faut il afficher la liste de construction ??
    if ($Queue['length'] > 0) {
        $parse['BuildList'] = $Queue['buildlist'];
    } else {
        $parse['BuildList'] = "";
    }
    $de_planettype = PlanetType($planetrow['image']);
    $parse['type'] = $de_planettype['type'];
    if ($_GET['page'] == 'station') {
        $parse['bg'] = HEADER_CACHE . "station/" . $parse['type'] . ".png";
    } elseif ($_GET['page'] == 'resources') {
        if (url_exists(HEADER_CACHE . "resources/" . $parse['type'] . $imgnum . ".png")) {
            $parse['bg'] = HEADER_CACHE . "resources/" . $parse['type'] . $imgnum . ".png";
        } else {
            $parse['bg'] = HEADER_CACHE . "resources/default.png";
        }
    } else {
        die("Hacking attempt");
    }
    $parse['hideres'] = "display:none;";
    $parse['hidenorm'] = "";
    $parse['planetname'] = $planetrow['name'];
    if (!$Element) {
        if ($_GET['mode'] == "resources") {
            $parse['hideres'] = "";
            $parse['hidenorm'] = "display:none;";
        }
    } else {
        if (!is_array($Allowed[$planetrow['planet_type']])) {
            $message = $user['username'] . " (" . intval($user['id']) . ") does not have a propper planet_type, so \$Allowed[\$planetrow['planet_type']] was not an array, causing the error which is most likely directly below this.";
            trigger_error($message, E_USER_NOTICE);
        }
        if (in_array($Element, $Allowed[$planetrow['planet_type']])) {
            //Something else
            $HaveRessources = IsElementBuyable($user, $planetrow, $Element, true, false);
            $parse['i'] = $Element;
            $parse['dpath'] = $dpath;
            $BuildingLevel = $planetrow[$resource[$Element]];
            $parse['nivel'] = $BuildingLevel == 0 ? "" : " (" . $lang['level'] . " " . $BuildingLevel . ")";
            $parse['n'] = $ElementName;
            $parse['descriptions'] = $lang['res']['descriptions'][$Element];
            $ElementBuildTime = BuildingTime($Element, $BuildingLevel + 1, $planetrow);
            $parse['time'] = ShowBuildTime($ElementBuildTime);
            $parse['price'] = GetElementPrice($user, $planetrow, $Element);
            $parse['rest_price'] = GetRestPrice($user, $planetrow, $Element);
            $parse['click'] = '';
            $NextBuildLevel = $planetrow[$resource[$Element]] + 1;
            $CurrentMaxFields = CalculateMaxPlanetFields($planetrow);
            if ($planetrow["field_current"] < $CurrentMaxFields - $Queue['lenght']) {
                $RoomIsOk = true;
            } else {
                $RoomIsOk = false;
            }
            if ($Element == 31) {
                // Sp�cial Laboratoire
                if ($user["b_tech_planet"] != 0 && $game_config['BuildLabWhileRun'] != 1) {
                    // Variable qui contient le parametre
                    // On verifie si on a le droit d'evoluer pendant les recherches (Setting dans config)
                    $parse['click'] = "<font color=#FF0000>" . $lang['in_working'] . "</font>";
                }
            }
            if (IsTechnologieAccessible($user, $planetrow, $Element)) {
                if ($parse['click'] != '') {
                    // Bin on ne fait rien, vu que l'on l'a deja fait au dessus !!
                } elseif ($RoomIsOk && $CanBuildElement) {
                    if ($Queue['lenght'] == 0) {
                        if ($NextBuildLevel == 1) {
                            if ($HaveRessources == true) {
                                $parse['click'] = "<a href=\"./?page=" . $_GET['page'] . "&cmd=insert&building=" . $Element . "&id=" . $Element . "\"><font color=#00FF00>" . $lang['BuildFirstLevel'] . "</font></a>";
                                $infopg['build_link'] = "./?page=" . $_GET['page'] . "&cmd=insert&building=" . $Element . "&id=" . $Element;
                                $infopg['build_text'] = $lang['BuildFirstLevel'];
                            } else {
                                $parse['click'] = "<font color=#FF0000>4" . $lang['BuildFirstLevel'] . "</font>";
                                $infopg['build_text'] = $lang['BuildFirstLevel'];
                            }
                        } else {
                            if ($HaveRessources == true) {
                                $parse['click'] = "<a href=\"./?page=" . $_GET['page'] . "&cmd=insert&building=" . $Element . "&id=" . $Element . "\"><font color=#00FF00>" . $lang['BuildNextLevel'] . " " . $NextBuildLevel . "</font></a>";
                                $infopg['build_link'] = "./?page=" . $_GET['page'] . "&cmd=insert&building=" . $Element . "&id=" . $Element;
                                $infopg['build_text'] = $lang['BuildNextLevel'] . " " . $NextBuildLevel;
                            } else {
                                $parse['click'] = "<font color=#FF0000>" . $lang['BuildNextLevel'] . " " . $NextBuildLevel . "</font>";
                                $infopg['build_text'] = $lang['BuildNextLevel'] . " " . $NextBuildLevel;
                            }
                        }
                    } else {
                        $parse['click'] = "<a href=\"./?page=" . $_GET['page'] . "&cmd=insert&building=" . $Element . "&id=" . $Element . "\"><font color=#00FF00>" . $lang['InBuildQueue'] . "</font></a>";
                        $infopg['build_link'] = "./?page=" . $_GET['page'] . "&cmd=insert&building=" . $Element . "&id=" . $Element;
                        $infopg['build_text'] = $lang['InBuildQueue'];
                    }
                } elseif ($RoomIsOk && !$CanBuildElement) {
                    if ($NextBuildLevel == 1) {
                        $parse['click'] = "<font color=#FF0000>2" . $lang['BuildFirstLevel'] . "</font>";
                        $infopg['build_text'] = $lang['BuildFirstLevel'];
                    } else {
                        $parse['click'] = "<font color=#FF0000>1" . $lang['BuildNextLevel'] . " " . $NextBuildLevel . "</font>";
                        $infopg['build_text'] = $lang['BuildNextLevel'] . " " . $NextBuildLevel;
                    }
                } else {
                    $parse['click'] = "<font color=#FF0000>" . $lang['NoMoreSpace'] . "</font>";
                    $infopg['build_text'] = $lang['NoMoreSpace'];
                }
            } else {
                $parse['click'] = "<font color=#FF0000>" . $lang['NotAccessible'] . "</font>";
                $infopg['build_text'] = $lang['NotAccessible'];
            }
            //Building Info
            if ($infopg['build_link']) {
                $infopg['buildit_class'] = "build-it";
                $infopg['build_text'] = "Improve";
            } else {
                $infopg['buildit_class'] = "build-it_disabled";
                $infopg['build_text'] = "In queue";
            }
            $infopg['id'] = $Element;
            $infopg['name'] = $ElementName;
            $infopg['level'] = $planetrow[$resource[$Element]];
            if ($planetrow[$resource[$Element]] < 1) {
                $infopg['display_destroy'] = "style=\"display:none;\"";
            }
            $infopg['td_url'] = "./?page=" . $_GET['page'] . "&cmd=destroy&id=" . $Element . "&building=" . $Element;
            $infopg['title'] = "Tear down";
            $infopg['level1'] = $infopg['level'] + 1;
            $infopg['duration'] = pretty_time($ElementBuildTime);
            $infopg['shortdesc'] = $lang['sdesc'][$Element];
            $infopg['skin'] = $user['skin'];
            $infopg['cost_m'] = 1 * floor($pricelist[$Element]['metal'] * pow($pricelist[$Element]['factor'], $planetrow[$resource[$Element]]));
            $infopg['cost_c'] = 1 * floor($pricelist[$Element]['crystal'] * pow($pricelist[$Element]['factor'], $planetrow[$resource[$Element]]));
            $infopg['cost_d'] = 1 * floor($pricelist[$Element]['deuterium'] * pow($pricelist[$Element]['factor'], $planetrow[$resource[$Element]]));
            if ($infopg['cost_m'] > $planetrow['metal'] && $infopg['cost_m'] > 0) {
                $infopg['missing_resource_m'] = "missing_resource";
            }
            if ($infopg['cost_c'] > $planetrow['crystal'] && $infopg['cost_c'] > 0) {
                $infopg['missing_resource_c'] = "missing_resource";
            }
            if ($infopg['cost_d'] > $planetrow['deuterium'] && $infopg['cost_d'] > 0) {
                $infopg['missing_resource_d'] = "missing_resource";
            }
            $infopg['sh_cost_m'] = KMnumber($infopg['cost_m'], 0, 'up');
            $infopg['sh_cost_c'] = KMnumber($infopg['cost_c'], 0, 'up');
            $infopg['sh_cost_d'] = KMnumber($infopg['cost_d'], 0, 'up');
            $infopg['cost_m'] = pretty_number($infopg['cost_m']);
            $infopg['cost_c'] = pretty_number($infopg['cost_c']);
            $infopg['cost_d'] = pretty_number($infopg['cost_d']);
            $infopg['page'] = $_GET['page'];
            $parse['info'] = parsetemplate(gettemplate('buildings/info'), $infopg);
            $parse['extra'] = "style=\"display:none\"";
            if ($_GET['axah_section'] == '1') {
                makeAXAH($parse['info']);
                die;
            }
        }
    }
    $parse['planet_field_current'] = $planetrow["field_current"];
    $parse['planet_field_max'] = $planetrow['field_max'] + $planetrow[$resource[33]] * 5;
    $parse['field_libre'] = $parse['planet_field_max'] - $planetrow['field_current'];
    $parse['buttonz'] = $BuildingPage;
    $parse['BuildingsList'] = $BuildingPage;
    if ($_GET['page'] == 'station') {
        $page = parsetemplate(gettemplate('buildings/station'), $parse);
        $title = $lang['Facilities'];
    } elseif ($_GET['page'] == 'resources') {
        //Resources screen
        $parse['resources_section'] = BuildRessourcePage($user, $planetrow, $parse['hideres']);
        $page = parsetemplate(gettemplate('buildings/resources'), $parse);
        $title = $lang['Resources'];
    } else {
        die("Hacking attempt");
    }
    if ($_GET['axah']) {
        makeAXAH($page);
    } else {
        displaypage($page, $title);
    }
}
Exemplo n.º 2
0
function ShowQueue($loadpage = false)
{
    global $planetrow, $user, $lang, $resource;
    //We need to get queue into an array
    $q = explode(";", $planetrow['build_queue']);
    if ($planetrow['build_queue'] == '') {
        $q = array();
    }
    //Is there actually a queue?
    if (sizeof($q) > 0) {
        //Allow create a temporary array to store hypothetical updates
        $updates = array();
        //Create the parse array
        $parse = $lang;
        //loop through the items
        foreach ($q as $n => $row) {
            //Split the row up
            $row = explode(",", $row);
            //Add to $updates
            $updates[$row[0]] += $row[1];
            //Get current level
            $level = $planetrow[$resource[$row[0]]] + $updates[$row[0]];
            //How should it be coloured?
            if ($updates[$row[0]] > 0) {
                $colour = 'lime';
            } else {
                $colour = 'red';
            }
            //Get name
            $name = $lang['names'][$row[0]];
            //Get time
            $time = BuildingTime($row[0], $level, $planetrow, $user);
            //If we are gonan reload the whole page there will be differnt remove links
            if ($loadpage) {
                $parse['remove_link'] = "loadpage('./?page=resources&cmd=remove&listid=" . $n . "','" . $lang['Resources'] . "','resources')";
            } else {
                $parse['remove_link'] = "getAXAH('./?page=resources&cmd=remove&listid=" . $n . "&axah_box=1','resources_queue_box')";
            }
            if ($n == 0) {
                $parse['countdown'] = parsecountdown($planetrow['build_queue_start'] + $time);
                $parse['thislevel'] = pretty_number($level);
                $parse['thisname'] = $name;
                $parse['thisid'] = $row[0];
            } else {
                $parse['rest'] .= '
						<td>
							<a href="#"
								class="tips" 
								onclick="' . $parse['remove_link'] . '"
								onmouseover="mrtooltip(\'Cancel expansion of ' . $name . ' to level ' . $level . '?\');"
								onmouseout="UnTip();">
								<img class="queuePic" src="' . GAME_SKIN . '/img/tiny/tiny_' . $row[0] . '.jpg" height="28" width="28" alt="' . $name . '">
							</a>
							<br>
							<span style="color: ' . $colour . ';">' . $level . '</span>
						</td>';
            }
        }
        return array('buildlist' => parsetemplate(gettemplate('buildings/resources_queue'), $parse), 'length' => sizeof($q));
    } else {
        $queueinfo = '';
        if (!$loadpage) {
            getLang('overview');
            $queueinfo .= '<div class="content-box-s">';
            $queueinfo .= '<div class="header"><h3>Buildings</h3></div>';
            $queueinfo .= '<div class="content">';
            $queueinfo .= '<table cellpadding="0" cellspacing="0" class="construction">';
            $queueinfo .= '<tr>';
            $queueinfo .= '<td colspan="2" class="idle">';
            $queueinfo .= $lang['Free_bu'];
            $queueinfo .= '</td>';
            $queueinfo .= '</tr>';
            $queueinfo .= '</table>';
            $queueinfo .= '</div>';
            $queueinfo .= '<div class="footer"></div>';
        }
        return array('buildlist' => $queueinfo, 'length' => 0);
    }
}
Exemplo n.º 3
0
function GetFleetInfo($CurrentUser, $CurrentPlanet)
{
    global $lang, $cid;
    includeLang('tech');
    getLang('fleet');
    $parse = $lang;
    $template = '
			<table id="eventtype" style="border-collapse: collapse;" border="0" width="100%">
				<tbody>
					<tr>
						<td class="friendly col1" width="152">Own Missions: <span id="eventFriendly">{miss_own}</span></td>
						<td class="neutral col2" width="156">Friendly missions: <span id="eventNeutral">{miss_neu}</span></td>
						<td class="hostile col3" width="152">Hostile missions: <span id="eventHostile">{miss_att}</span></td>
					</tr>
				</tbody>
			</table>
			<table id="eventdetails" style="border-collapse: collapse;" border="0" width="100%">
				<tbody>
					<tr id="eventClass" class="{miss_class}">
						<td class="col1" width="152"><div class="countdown" id="countdown_start-2789-0" name="countdown">{remaining}</div></td>
						<td class="col2" width="208"><div class="text" id="eventContent"> Mission: {mission}</div></td>
						<td class="col3" width="100">
							<a class="tips thickbox" href="./?page=movement" onclick="loadpage(this.href,\'{FleetManage}\',\'movement\',\'UpdateFleetMInfo()\'); return false;">
								<span class="mrtooltip" style="width:638px;top:18px;left:-71px;border:0px;background-color:#262727;">
									{miss_all}
								</span>
							</a>
						</td>
					</tr>
				</tbody>
			</table>';
    $mhostile = array(1, 2, 6, 9);
    //10? Missile attack
    $mneutral = array(3, 5);
    $arriving_fleet = doquery("SELECT * FROM {{table}} WHERE ((`owner_userid` = '" . $CurrentUser['id'] . "' AND `fleet_mess` = 0) OR `target_userid` = '" . $CurrentUser['id'] . "') ORDER BY `arrival` ASC LIMIT 1 ;", 'fleets', true);
    if ($arriving_fleet['arrival'] > 0) {
        $parse['mission'] = $lang['type_mission'][$arriving_fleet['mission']];
        if ($arriving_fleet['owner_userid'] == $CurrentUser['id']) {
            $parse['miss_class'] = 'friendly';
        } elseif (in_array($arriving_fleet['mission'], $mhostile)) {
            $parse['miss_class'] = 'hostile';
        } elseif (in_array($arriving_fleet['mission'], $mneutral)) {
            $parse['miss_class'] = 'neutral';
        } else {
            $parse['miss_class'] = 'none';
        }
        $parse['remaining'] = parsecountdown($arriving_fleet['arrival'], true);
    }
    //All fleets now,
    $all_fleet = doquery("SELECT * FROM {{table}} WHERE ((`owner_userid` = '" . $CurrentUser['id'] . "' AND `fleet_mess` = 0) OR `target_userid` = '" . $CurrentUser['id'] . "') ORDER BY `arrival` ASC ;", 'fleets');
    $array_all = array();
    while ($row = mysql_fetch_array($all_fleet)) {
        $temp_array = array();
        //$temp_array['timea'] = parsecountdown(($row['fleet_start_time'] - time()),'!');
        //$temp_array['timee'] = parsecountdown(($row['fleet_end_time'] - time()),'!');
        $temp_array['mission'] = $lang['type_mission'][$row['mission']];
        if ($row['owner_userid'] == $CurrentUser['id'] || $row['mission'] == 0) {
            $temp_array['class'] = 'friendly';
        } elseif (in_array($row['mission'], $mhostile)) {
            $temp_array['class'] = 'hostile';
        } elseif (in_array($row['mission'], $mneutral)) {
            $temp_array['class'] = 'neutral';
        } else {
            $temp_array['class'] = 'none';
        }
        $targetplanet = doquery("SELECT `name`,`galaxy`,`system`,`planet` FROM {{table}} WHERE `id` = '" . $row['target_id'] . "' LIMIT 1;", 'planets', true);
        if (strlen($targetplanet['name']) > 0) {
            $temp_array['to'] = $targetplanet['name'] . " (" . $targetplanet['galaxy'] . ":" . $targetplanet['system'] . ":" . $targetplanet['planet'] . ")";
        } else {
            $g = strlen(MAX_GALAXY_IN_WORLD);
            $s = strlen(MAX_SYSTEM_IN_GALAXY);
            $p = strlen(MAX_PLANET_IN_SYSTEM);
            $galaxy = substr($row['target_id'], 0, $g) * 1;
            $system = substr($row['target_id'], $g, $s) * 1;
            $planet = substr($row['target_id'], $g + $s, $p) * 1;
            if ($planet == MAX_PLANET_IN_SYSTEM + 1) {
                $temp_array['to'] = $lang['OuterSpace'];
            } else {
                $temp_array['to'] = "(" . $galaxy . ":" . $system . ":" . $planet . ")";
            }
            unset($g, $s, $p, $galaxy, $system, $planet);
        }
        $startplanet = doquery("SELECT `name`,`galaxy`,`system`,`planet` FROM {{table}} WHERE `id` = '" . $row['owner_id'] . "' LIMIT 1;", 'planets', true);
        if (strlen($startplanet['name']) > 0) {
            $temp_array['from'] = $startplanet['name'] . " (" . $startplanet['galaxy'] . ":" . $startplanet['system'] . ":" . $startplanet['planet'] . ")";
        } else {
            $g = strlen(MAX_GALAXY_IN_WORLD);
            $s = strlen(MAX_SYSTEM_IN_GALAXY);
            $p = strlen(MAX_PLANET_IN_SYSTEM);
            $galaxy = substr($row['owner_id'], 0, $g) * 1;
            $system = substr($row['owner_id'], $g, $s) * 1;
            $planet = substr($row['owner_id'], $g + $s, $p) * 1;
            if ($planet == MAX_PLANET_IN_SYSTEM + 1) {
                $temp_array['from'] = $lang['OuterSpace'];
            } else {
                $temp_array['from'] = "(" . $galaxy . ":" . $system . ":" . $planet . ")";
            }
            unset($g, $s, $p, $galaxy, $system, $planet);
        }
        $array_all[] = array('to' => $temp_array['to'], 'from' => $temp_array['from'], 'in' => parsecountdown($row['arrival']), 'mission' => $temp_array['mission'], 'time' => $row['arrival'], 'class' => $temp_array['class']);
    }
    $parse['miss_all'] = '<table width="100%" id="eventdetails" style="width:95%">';
    $parse['miss_all'] .= "<tr onmouseover=\"mrtooltip('\r\n\t');\"\r\n\t onmouseour=\"UnTip();\">";
    $parse['miss_all'] .= '<td>' . $parse['fl_time'] . '</td><td>' . $parse['fl_from'] . '</td><td>' . $parse['fl_dest'] . '</td><td>' . $parse['fl_mission'] . '</td></tr>';
    foreach ($array_all as $id => $fl) {
        $parse['miss_all'] .= "<tr id=\"eventClass\" class=\"" . $fl['class'] . "\"><td>" . $fl['in'] . "</td><td>" . $fl['to'] . "</td><td>" . $fl['from'] . "</td><td>" . $fl['mission'] . "</td></tr>";
    }
    $parse['miss_all'] .= "</table>";
    $allow = '';
    foreach ($mhostile as $id) {
        $allow .= "`mission` = '" . $id . "' OR ";
    }
    $allow = substr_replace($allow, '', -4);
    $att_fleets = doquery("SELECT * FROM {{table}} WHERE `target_userid` = '" . $CurrentUser['id'] . "' AND `arrival` > '" . time() . "' AND (" . $allow . ");", 'fleets');
    $allow = '';
    foreach ($mneutral as $id) {
        $allow .= "`mission` = '" . $id . "' OR ";
    }
    $allow = substr_replace($allow, '', -4);
    $neu_fleets = doquery("SELECT * FROM {{table}} WHERE `target_userid` = '" . $CurrentUser['id'] . "' AND `arrival` > '" . time() . "' AND (" . $allow . ");", 'fleets');
    $own_fleets = doquery("SELECT * FROM {{table}} WHERE ((`owner_userid` = '" . $CurrentUser['id'] . "' AND `fleet_mess` = 0) OR `target_userid` = '" . $CurrentUser['id'] . "') AND `partner_fleet` NOT IN (SELECT `fleet_id` FROM {{table}}) ;", 'fleets');
    //<-- wow that actually works!!
    // ^ select the rows in the table, were ((its leaving your planet to go to another and not returning, (basically it on the way there)) or (its going to your planet from somewhere)) and (it doesn't have a partner fleet (this means that if for example there is a transport fleet, both the outward bound and return fleet are counted as just one))
    $parse['miss_own'] = mysql_num_rows($own_fleets);
    $parse['miss_neu'] = mysql_num_rows($neu_fleets);
    $parse['miss_att'] = mysql_num_rows($att_fleets);
    if ($arriving_fleet) {
        return array(parsetemplate($template, $parse), $parse['miss_att']);
    } else {
        return false;
    }
}
Exemplo n.º 4
0
function ShowBuildingQueue($CurrentPlanet, $CurrentUser, $reloadpage = false)
{
    global $lang;
    $CurrentQueue = $CurrentPlanet['b_building_id'];
    $QueueID = 0;
    if ($CurrentQueue != 0) {
        // Queue de fabrication documentée ... Y a au moins 1 element a construire !
        $QueueArray = explode(";", $CurrentQueue);
        // Compte le nombre d'elements
        $ActualCount = count($QueueArray);
    } else {
        // Queue de fabrication vide
        $QueueArray = "0";
        $ActualCount = 0;
    }
    $ListIDRow = "";
    $return = '';
    $n = 0;
    $parse = $lang;
    $parse['rest'] = '';
    if ($ActualCount > 0) {
        $PlanetID = $CurrentPlanet['id'];
        for ($QueueID = 0; $QueueID < $ActualCount; $QueueID++) {
            // Chaque element de la liste de fabrication est un tableau de 5 données
            // [0] -> Le batiment
            // [1] -> Le niveau du batiment
            // [2] -> La durée de construction
            // [3] -> L'heure théorique de fin de construction
            // [4] -> type d'action
            $BuildArray = explode(",", $QueueArray[$QueueID]);
            $BuildEndTime = floor($BuildArray[3]);
            $CurrentTime = floor(time());
            if ($BuildEndTime >= $CurrentTime) {
                $n++;
                $element = $BuildArray[0];
                $name = $lang['names'][$element];
                $level = $BuildArray[1];
                $mod = $BuildArray[4];
                if ($reloadpage) {
                    $parse['remove_link'] = "loadpage('./?page=resources&mode=','" . $lang['Resources'] . "','resources')";
                } else {
                    $parse['remove_link'] = "getAXAH('./?page=resources&mode=','resources_queue_box')";
                }
                if ($n == 1) {
                    $parse['countdown'] = parsecountdown($BuildEndTime);
                    $parse['thislevel'] = pretty_number($level);
                    $parse['thisname'] = $name;
                    $parse['thisid'] = $element;
                } else {
                    $parse['rest'] .= '
							<td>
								<a href="#"
									class="tips" 
									onclick="' . $parse['remove_link'] . '"
									onmouseover="mrtooltip(\'Cancel expansion of ' . $name . ' to level ' . $level . '?\');"
									onmouseout="UnTip();">
									<img class="queuePic" src="' . GAME_SKIN . '/img/tiny/tiny_' . $element . '.jpg" height="28" width="28" alt="' . $name . '">
								</a>
								<br>
								<span style="color: lime;">' . $level . '</span>
							</td>';
                }
            }
        }
        $queue = parsetemplate(gettemplate('buildings/resources_queue'), $parse);
    }
    $RetValue['lenght'] = $ActualCount;
    $RetValue['buildlist'] = $queue;
    return $RetValue;
}
Exemplo n.º 5
0
function ResearchPage(&$CurrentPlanet, $CurrentUser, $InResearch, $ThePlanet)
{
    global $lang, $resource, $reslist, $pricelist, $phpEx, $dpath, $game_config, $_GET;
    CheckPlanetUsedFields($CurrentPlanet);
    // Boucle d'interpretation des eventuelles commandes
    if (isset($_GET['cmd'])) {
        $TheCommand = $_GET['cmd'];
        $Techno = idstring($_GET['tech']);
        if (is_numeric($Techno)) {
            if (in_array($Techno, $reslist['tech'])) {
                // Bon quand on arrive ici ... On sait deja qu'on a une technologie valide
                if (is_array($ThePlanet)) {
                    $WorkingPlanet = $ThePlanet;
                } else {
                    $WorkingPlanet = $CurrentPlanet;
                }
                switch ($TheCommand) {
                    case 'cancel':
                        if ($ThePlanet['b_tech_id'] == $Techno) {
                            $costs = GetBuildingPrice($CurrentUser, $WorkingPlanet, $Techno);
                            $WorkingPlanet['metal'] += $costs['metal'];
                            $WorkingPlanet['crystal'] += $costs['crystal'];
                            $WorkingPlanet['deuterium'] += $costs['deuterium'];
                            $WorkingPlanet['b_tech_id'] = 0;
                            $WorkingPlanet["b_tech"] = 0;
                            $CurrentUser['b_tech_planet'] = 0;
                            $UpdateData = true;
                            $InResearch = false;
                        }
                        break;
                    case 'search':
                        if (IsTechnologieAccessible($CurrentUser, $WorkingPlanet, $Techno) && IsElementBuyable($CurrentUser, $WorkingPlanet, $Techno) && !$InResearch) {
                            $costs = GetBuildingPrice($CurrentUser, $WorkingPlanet, $Techno);
                            $WorkingPlanet['metal'] -= $costs['metal'];
                            $WorkingPlanet['crystal'] -= $costs['crystal'];
                            $WorkingPlanet['deuterium'] -= $costs['deuterium'];
                            $WorkingPlanet["b_tech_id"] = $Techno;
                            $WorkingPlanet["b_tech"] = time() + GetBuildingTime($CurrentUser, $WorkingPlanet, $Techno);
                            $CurrentUser["b_tech_planet"] = $WorkingPlanet["id"];
                            $UpdateData = true;
                            $InResearch = true;
                        }
                        break;
                }
                if ($UpdateData == true) {
                    $QryUpdatePlanet = "UPDATE {{table}} SET ";
                    $QryUpdatePlanet .= "`b_tech_id` = '" . $WorkingPlanet['b_tech_id'] . "', ";
                    $QryUpdatePlanet .= "`b_tech` = '" . $WorkingPlanet['b_tech'] . "', ";
                    $QryUpdatePlanet .= "`metal` = '" . $WorkingPlanet['metal'] . "', ";
                    $QryUpdatePlanet .= "`crystal` = '" . $WorkingPlanet['crystal'] . "', ";
                    $QryUpdatePlanet .= "`deuterium` = '" . $WorkingPlanet['deuterium'] . "' ";
                    $QryUpdatePlanet .= "WHERE ";
                    $QryUpdatePlanet .= "`id` = '" . $WorkingPlanet['id'] . "';";
                    doquery($QryUpdatePlanet, 'planets');
                    $QryUpdateUser = "******";
                    $QryUpdateUser .= "`b_tech_planet` = '" . $CurrentUser['b_tech_planet'] . "' ";
                    $QryUpdateUser .= "WHERE ";
                    $QryUpdateUser .= "`id` = '" . $CurrentUser['id'] . "';";
                    doquery($QryUpdateUser, 'users');
                }
                if (is_array($ThePlanet)) {
                    $ThePlanet = $WorkingPlanet;
                } else {
                    $CurrentPlanet = $WorkingPlanet;
                    if ($TheCommand == 'search') {
                        $ThePlanet = $CurrentPlanet;
                    }
                }
            }
        } else {
            $bContinue = false;
        }
    }
    $TechScrTPL = gettemplate('buildings_research_script');
    $SubTemplate = gettemplate('buildings/research_buttonz');
    $parse = array();
    $infopg = array();
    foreach ($lang['names'] as $Tech => $TechName) {
        if ($Tech > 105 && $Tech <= 199) {
            if (!IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Tech)) {
                $parse['state_' . $Tech] = "off";
                $parse['mes_' . $Tech] = "Requirements are not met";
            } elseif (!IsElementBuyable($CurrentUser, $CurrentPlanet, $Tech)) {
                $parse['state_' . $Tech] = "disabled";
                $parse['mes_' . $Tech] = "Not enough resources!";
            } else {
                $parse['state_' . $Tech] = "on";
                $parse['mes_' . $Tech] = "";
            }
        } else {
            $parse['state_' . $Tech] = "off";
            $parse['mes_' . $Tech] = "Not availble";
        }
        $parse['name_' . $Tech] = $TechName;
        $parse['count_' . $Tech] = $CurrentUser[$resource[$Tech]];
    }
    //Anything currently building?
    if ($CurrentUser['b_tech_planet']) {
        $WorkingPlanet = doquery("SELECT `id`,`name`,`b_tech_id`,`b_tech` FROM {{table}} WHERE `id` = '" . $CurrentUser['b_tech_planet'] . "';", 'planets', true);
        //Whats currently building
        $curbuild = $WorkingPlanet['b_tech_id'];
        $parse['countdown_' . $curbuild] = "\r\n\t\t\t\t\t\t\t\t\t\t<div class=\"pusher\" id=\"b_research" . $curbuild . "\" style=\"height:80px;margin-bottom:-80px;\">\n\r\n\t\t\t\t\t\t\t\t\t\t\t<a><span class=\"time\" id=\"test\" name=\"zeit\">" . parsecountdown($WorkingPlanet['b_tech']) . "</span></a>\n\r\n\t\t\t\t\t\t\t\t\t\t</div>\n";
    } else {
        $curbuild = 0;
    }
    $Buttonz = parsetemplate($SubTemplate, $parse);
    $parse = $lang;
    $Element = idstring($_GET['id']);
    $ElementName = $lang['names'][$Element];
    $de_planettype = PlanetType($CurrentPlanet['image']);
    $parse['type'] = $de_planettype['type'];
    if ($Element) {
        if (in_array($Element, $reslist['tech'])) {
            /*
            $RowParse['dpath']       = $dpath;
            $RowParse['tech_id']     = $Tech;
            $building_level          = $CurrentUser[$resource[$Tech]];
            $RowParse['tech_level']  = ($building_level == 0) ? "" : "( ". $lang['level']. " ".$building_level." )";
            $RowParse['tech_name']   = $TechName;
            $RowParse['tech_descr']  = $lang['res']['descriptions'][$Tech];
            $RowParse['tech_price']  = GetElementPrice($CurrentUser, $CurrentPlanet, $Tech);
            $SearchTime              = GetBuildingTime($CurrentUser, $CurrentPlanet, $Tech);
            $RowParse['search_time'] = ShowBuildTime($SearchTime);
            $RowParse['tech_restp']  = $lang['Rest_ress'] ." ". GetRestPrice ($CurrentUser, $CurrentPlanet, $Tech, true);
            $CanBeDone               = IsElementBuyable($CurrentUser, $CurrentPlanet, $Tech);
            */
            $HaveRessources = IsElementBuyable($CurrentUser, $CurrentPlanet, $Element);
            $parse['i'] = $Element;
            $BuildingLevel = $CurrentPlanet[$resource[$Element]];
            $parse['nivel'] = $BuildingLevel == 0 ? "" : " (" . $lang['level'] . " " . $BuildingLevel . ")";
            $parse['n'] = $ElementName;
            $parse['descriptions'] = $lang['res']['descriptions'][$Element];
            $ElementBuildTime = GetBuildingTime($CurrentUser, $CurrentPlanet, $Element);
            $parse['time'] = ShowBuildTime($ElementBuildTime);
            $parse['price'] = GetElementPrice($CurrentUser, $CurrentPlanet, $Element);
            $parse['rest_price'] = GetRestPrice($CurrentUser, $CurrentPlanet, $Element);
            $parse['click'] = '';
            $buildlink = "./?page=research&cmd=search&id=" . $Element . "&tech=" . $Element;
            if (IsTechnologieAccessible($CurrentUser, $CurrentPlanet, $Element)) {
                if ($NextBuildLevel == 1) {
                    if ($HaveRessources == true) {
                        $infopg['build_link'] = $buildlink;
                        $infopg['build_text'] = $lang['BuildFirstLevel'];
                    } else {
                        $infopg['build_text'] = $lang['BuildFirstLevel'];
                    }
                } else {
                    if ($HaveRessources == true) {
                        $infopg['build_link'] = $buildlink;
                        $infopg['build_text'] = $lang['BuildNextLevel'] . " " . $NextBuildLevel;
                    } else {
                        $infopg['build_text'] = $lang['BuildNextLevel'] . " " . $NextBuildLevel;
                    }
                }
            } elseif ($InResearch) {
                $parse['click'] = "<font color=#FF0000>" . $lang['InResearch'] . "</font>";
                $infopg['build_text'] = $lang['InResearch'];
            } else {
                $parse['click'] = "<font color=#FF0000>" . $lang['NotAccessible'] . "</font>";
                $infopg['build_text'] = $lang['NotAccessible'];
            }
            //Building Info
            if ($infopg['build_link']) {
                $infopg['buildit_class'] = "build-it";
                $infopg['build_text'] = $lang['Improve'];
            } elseif ($InResearch) {
                $infopg['buildit_class'] = "build-it_disabled";
                $infopg['build_text'] = $lang['InResearch'];
            } else {
                $infopg['buildit_class'] = "build-it_disabled";
                $infopg['build_text'] = $lang['NotAccessible'];
            }
            $infopg['id'] = $Element;
            $infopg['name'] = $ElementName;
            $infopg['level'] = $CurrentUser[$resource[$Element]];
            //Current research
            if ($curbuild == $Element) {
                $infopg['td_url'] = "./?page=" . $_GET['page'] . "&cmd=cancel&id=" . $Element . "&tech=" . $Element;
                if ($WorkingPlanet['id'] == $CurrentPlanet['id']) {
                    $infopg['title'] = "Cancel";
                } else {
                    //$infopg['title'] = "Cancel on ".$WorkingPlanet['name'];
                    $infopg['title'] = "Cancel";
                }
            } else {
                $infopg['display_destroy'] = "style=\"display:none;\"";
            }
            $infopg['level1'] = $infopg['level'] + 1;
            $infopg['duration'] = pretty_time($ElementBuildTime);
            $infopg['shortdesc'] = $lang['sdesc'][$Element];
            $infopg['skin'] = $CurrentUser['skin'];
            $infopg['cost_m'] = 1 * floor($pricelist[$Element]['metal'] * pow($pricelist[$Element]['factor'], $CurrentUser[$resource[$Element]]));
            $infopg['cost_c'] = 1 * floor($pricelist[$Element]['crystal'] * pow($pricelist[$Element]['factor'], $CurrentUser[$resource[$Element]]));
            $infopg['cost_d'] = 1 * floor($pricelist[$Element]['deuterium'] * pow($pricelist[$Element]['factor'], $CurrentUser[$resource[$Element]]));
            if ($infopg['cost_m'] > $CurrentPlanet['metal'] && $infopg['cost_m'] > 0) {
                $infopg['missing_resource_m'] = "missing_resource";
            }
            if ($infopg['cost_c'] > $CurrentPlanet['crystal'] && $infopg['cost_c'] > 0) {
                $infopg['missing_resource_c'] = "missing_resource";
            }
            if ($infopg['cost_d'] > $CurrentPlanet['deuterium'] && $infopg['cost_d'] > 0) {
                $infopg['missing_resource_d'] = "missing_resource";
            }
            $infopg['sh_cost_m'] = KMnumber($infopg['cost_m'], 0, 'up');
            $infopg['sh_cost_c'] = KMnumber($infopg['cost_c'], 0, 'up');
            $infopg['sh_cost_d'] = KMnumber($infopg['cost_d'], 0, 'up');
            $infopg['cost_m'] = pretty_number($infopg['cost_m']);
            $infopg['cost_c'] = pretty_number($infopg['cost_c']);
            $infopg['cost_d'] = pretty_number($infopg['cost_d']);
            $infopg['page'] = $_GET['page'];
            $parse['info'] = parsetemplate(gettemplate('buildings/info'), $infopg);
            $parse['extra'] = "style=\"display:none\"";
            if ($_GET['axah_section'] == '1') {
                makeAXAH($parse['info']);
                die;
            }
        }
    }
    $parse['buttonz'] = $Buttonz;
    $parse['planetname'] = $CurrentPlanet['name'];
    $page .= parsetemplate(gettemplate('buildings/research'), $parse);
    if ($_GET['axah']) {
        makeAXAH($page);
    } else {
        displaypage($page, $lang['Research']);
    }
}
Exemplo n.º 6
0
    $queueinfosy .= '</table>';
}
//Whats happening in the research lab?
if ($user['b_tech_planet'] > 0) {
    $WorkingPlanet = doquery("SELECT `b_tech_id`,`b_tech` FROM {{table}} WHERE `id` = '" . $user['b_tech_planet'] . "';", 'planets', true);
    $queueinforl = '
		<table cellpadding="0" cellspacing="0" class="construction">
			<tr>
				<th colspan="2">' . $lang['tech'][$WorkingPlanet['b_tech_id']] . '</th>
			</tr>
			<tr class="data">
				<td class="building" rowspan="2">
					<img src="' . GAME_SKIN . '/img/small/small_' . $WorkingPlanet['b_tech_id'] . '.jpg" alt="' . $lang['names'][$WorkingPlanet['b_tech_id']] . '">
				</td>
				<td class="desc">Improve to 
					<span class="level">Level ' . ($user[$resource[$WorkingPlanet['b_tech_id']]] + 1) . '</span>
				</td>
			</tr>
			<tr>
				<td class="desc">' . parsecountdown($WorkingPlanet['b_tech'], true) . '</td>
			</tr>
		</table>';
} else {
    $queueinforl = '<table cellpadding="0" cellspacing="0" class="construction">';
    $queueinforl .= '<tr>';
    $queueinforl .= '<td colspan="2" class="idle">';
    $queueinforl .= $lang['Free_rl'];
    $queueinforl .= '</td>';
    $queueinforl .= '</tr>';
    $queueinforl .= '</table>';
}