function Show_Main() { global $db; global $game; global $NUM_BUILDING, $BUILDING_DESCRIPTION, $BUILDING_NAME, $BUILDING_DATA, $MAX_BUILDING_LVL, $NEXT_TICK, $ACTUAL_TICK; $capital = $game->player['user_capital'] == $game->planet['planet_id'] ? 1 : 0; if ($game->player['pending_capital_choice']) { $capital = 0; } // Clickids: $game->register_click_id(11); // Retrieve construction queue for the planet ordered by time $sql = 'SELECT * FROM scheduler_instbuild WHERE planet_id="' . $game->planet['planet_id'] . '" ORDER by build_start ASC'; $schedulerquery = $db->query($sql); if (($queued = $db->num_rows()) > 0) { // Timer ID $t = 3; while ($scheduler = $db->fetchrow($schedulerquery)) { // From now on the level of the building is currently developed at the final stage: $game->planet['building_' . ($scheduler['installation_type'] + 1)]++; $game->out('<table border=0 cellpadding=1 cellspacing=1 width=330 class="style_outer"><tr><td> <table border=0 cellpadding=1 cellspacing=1 width=330 class="style_inner"><tr><td> ' . constant($game->sprache("TEXT11")) . ' <b>' . $BUILDING_NAME[$game->player['user_race']][$scheduler['installation_type']] . ' (' . constant($game->sprache("TEXT12")) . ' ' . $game->planet['building_' . ($scheduler['installation_type'] + 1)] . ')</b><br> ' . constant($game->sprache("TEXT13")) . ' <b id="timer' . $t . '" title="time1_' . ($NEXT_TICK + TICK_DURATION * 60 * ($scheduler['build_finish'] - $ACTUAL_TICK)) . '_type1_1"> </b><br> <a href="' . parse_link_ex('a=building&a2=abort_build&id=' . $scheduler['installation_type'], LINK_CLICKID) . '"><b>' . constant($game->sprache("TEXT14")) . '</b></a> </td></tr></table> </td></tr></table><br>'); // Prepare another timer $t++; $game->set_autorefresh($NEXT_TICK + TICK_DURATION * 60 * ($scheduler['build_finish'] - $ACTUAL_TICK) + TICK_DURATION); } } // Calculate available energy power $avail = $game->planet['building_5'] * 11 + 14; if (!$capital) { $avail = $game->planet['building_5'] * 15 + 3; } // Calculate energy power consumption $used = $game->planet['building_1'] + $game->planet['building_2'] + $game->planet['building_3'] + $game->planet['building_4'] + $game->planet['building_10'] + $game->planet['building_6'] + $game->planet['building_7'] + $game->planet['building_8'] + $game->planet['building_9'] + $game->planet['building_11'] + $game->planet['building_12'] + $game->planet['building_13']; $game->out(constant($game->sprache("TEXT16")) . ' <b id="timer2" title="time1_' . $NEXT_TICK . '_type1_3"> </b> ' . constant($game->sprache("TEXT17")) . '<br>' . constant($game->sprache("TEXT18")) . ' ' . $used . '/' . $avail . ' ' . constant($game->sprache("TEXT19")) . '<br><br>'); $game->out('<span class="sub_caption">' . constant($game->sprache($queued ? "TEXT21" : "TEXT20")) . ' ' . HelpPopup('building_1') . ' :</span><br><br>'); $game->out('<table border=0 cellpadding=2 cellspacing=2 width=90% class="style_outer"> <tr><td width=100%> <table border=0 cellpadding=2 cellspacing=2 width=100% class="style_inner"> <tr> <td width=130><b>' . constant($game->sprache("TEXT29")) . '</b></td> <td width=155><b>' . constant($game->sprache("TEXT22")) . '</b></td> <td width=75><b>' . constant($game->sprache("TEXT23")) . '</b></td> <td width=130><b>' . constant($game->sprache("TEXT24")) . '</b></td> </tr>'); for ($tt = 0; $tt <= $NUM_BUILDING; $tt++) { if ($tt > 9) { $t = $tt - 1; } else { $t = $tt; } if ($tt == 9) { $t = 12; } if (areRequirementsMet($t)) { // Check if building has reached maximum level if ($game->planet['building_' . ($t + 1)] >= $MAX_BUILDING_LVL[$capital][$t]) { $met = $min = $lat = $build_time = 0; $build_text = constant($game->sprache("TEXT28")); } else { // Calculate required resources for next building level $met = GetBuildingPrice($t, 0); $min = GetBuildingPrice($t, 1); $lat = GetBuildingPrice($t, 2); $fut = GetFuturePts($t); // Calculate points gained for this building $points = round(pow($game->planet['building_' . ($t + 1)] + 1, 1.5) - pow($game->planet['building_' . ($t + 1)], 1.5)); if ($game->planet['resource_1'] >= $met && $game->planet['resource_2'] >= $min && $game->planet['resource_3'] >= $lat && $game->planet['planet_available_points'] >= $fut) { $build_text = '<a href="' . parse_link_ex('a=building&a2=start_build&id=' . $t, LINK_CLICKID) . '"><span style="color: green">' . constant($game->sprache("TEXT25")) . ' (~' . $points . ' ' . constant($game->sprache("TEXT26")) . ')</span></a>'; if ($game->planet['building_' . ($t + 1)] > 0) { $build_text = '<a href="' . parse_link_ex('a=building&a2=start_build&id=' . $t, LINK_CLICKID) . '"><span style="color: green">' . constant($game->sprache("TEXT27")) . ' ' . ($game->planet['building_' . ($t + 1)] + 1) . ' (~' . $points . ' ' . constant($game->sprache("TEXT26")) . ')</span></a>'; } } else { $build_text = '<span style="color: red">' . constant($game->sprache("TEXT25")) . ' (~' . $points . ' ' . constant($game->sprache("TEXT26")) . ')</span>'; if ($game->planet['building_' . ($t + 1)] > 0) { $build_text = '<span style="color: red">' . constant($game->sprache("TEXT27")) . ' ' . ($game->planet['building_' . ($t + 1)] + 1) . ' (~' . $points . ' ' . constant($game->sprache("TEXT26")) . ')</span>'; } } // Calculate required construction time $build_time = GetBuildingTime($t); } $game->out(' <tr> <td><b><a href="javascript:void(0);" onmouseover="return overlib(\'' . $BUILDING_DESCRIPTION[$game->player['user_race']][$t] . '\', CAPTION, \'' . $BUILDING_NAME[$game->player['user_race']][$t] . '\', WIDTH, 400, ' . OVERLIB_STANDARD . ');" onmouseout="return nd();">' . $BUILDING_NAME[$game->player['user_race']][$t] . '</b></td> <td><img src="' . $game->GFX_PATH . 'menu_metal_small.gif"> ' . $met . ' <img src="' . $game->GFX_PATH . 'menu_mineral_small.gif">' . $min . ' <img src="' . $game->GFX_PATH . 'menu_latinum_small.gif"> ' . $lat . ' </td> <td>' . $build_time . '</td> <td>' . $build_text . '</td> </tr>'); } } $game->out('</table></td></tr></table>'); }
function Show_Main() { global $db; global $game; global $ship_components; global $TECH_DATA, $TECH_DESCRIPTION, $TECH_NAME, $MAX_RESEARCH_LVL, $NEXT_TICK, $ACTUAL_TICK, $BUILDING_NAME; $pow_factor = 2; // Clickids: $game->register_click_id(12); $capital = $game->player['user_capital'] == $game->planet['planet_id'] ? 1 : 0; if ($game->player['pending_capital_choice']) { $capital = 0; } $schedulerquery = $db->query('SELECT * FROM scheduler_research WHERE planet_id="' . $game->planet['planet_id'] . '"'); while ($scheduler = $db->fetchrow($schedulerquery)) { $game->out('<table border=0 cellpadding=1 cellspacing=1 width=300 class="style_outer"><tr><td> <table border=0 cellpadding=2 cellspacing=2 width=300 class="style_inner"><tr><td>'); if ($scheduler['research_id'] < 5) { $game->out(constant($game->sprache("TEXT20")) . ' <b>' . $TECH_NAME[$game->player['user_race']][$scheduler['research_id']] . '</b><br>'); $timer = 'timer3'; } else { $game->out(constant($game->sprache("TEXT20")) . ' <b>' . $ship_components[$game->player['user_race']][$scheduler['research_id'] - 5][$game->planet['catresearch_' . ($scheduler['research_id'] - 4)]]['name'] . '</b><br>'); $timer = 'timer4'; } $game->out(constant($game->sprache("TEXT21")) . ' <b id="' . $timer . '" title="time1_' . ($NEXT_TICK + TICK_DURATION * 60 * ($scheduler['research_finish'] - $ACTUAL_TICK)) . '_type1_1"> </b><br> <a href="' . parse_link_ex('a=researchlabs&a2=abort_research&id=' . $scheduler['research_id'], LINK_CLICKID) . '"><b>' . constant($game->sprache("TEXT22")) . '</b></a> </td></tr></table></td></tr></table><br>'); $game->set_autorefresh($NEXT_TICK + TICK_DURATION * 60 * ($scheduler['research_finish'] - $ACTUAL_TICK)); } $game->out('' . constant($game->sprache("TEXT23")) . ' <b id="timer2" title="time1_' . $NEXT_TICK . '_type1_3"> </b> ' . constant($game->sprache("TEXT24")) . '<br><br><br>'); // Ship components research: $game->out('<span class="sub_caption">' . constant($game->sprache("TEXT25")) . ' ' . HelpPopup('research_catresearch') . ' :</span><br><br>'); $game->out('<table border=0 cellpadding=2 cellspacing=2 width=90% class="style_outer">'); $game->out(' <tr><td width=100%> <table border=0 cellpadding=2 cellspacing=2 width=100% class="style_inner"> <tr> <td width=18%><b>' . constant($game->sprache("TEXT26")) . '</b></td> <td width=24%><b>' . constant($game->sprache("TEXT27")) . '</b></td> <td width=30%><b>' . constant($game->sprache("TEXT0")) . '</b></td> <td width=14%><b>' . constant($game->sprache("TEXT28")) . '</b></td> <td width=14%> </td></tr> '); // 30/05/12 - AC: Retrieve research times for all the categories at ONE time $cat_times = GetCatsResearchTimes(); foreach ($ship_components[$game->player['user_race']] as $key => $components) { //if ($game->planet['catresearch_'.($key+1)]>=$components['num']) continue; if ($game->planet['catresearch_' . ($key + 1)] >= $game->planet['building_9'] && $game->planet['building_9'] < 9) { $components[$game->planet['catresearch_' . ($key + 1)]]['name'] = constant($game->sprache("TEXT29")); $build_text = '<span style="color: red">' . constant($game->sprache("TEXT30")) . '</span>'; } elseif ($game->planet['resource_1'] >= GetCatResearchPrice($game->planet['catresearch_' . ($key + 1)], 0) && $game->planet['resource_2'] >= GetCatResearchPrice($game->planet['catresearch_' . ($key + 1)], 1) && $game->planet['resource_3'] >= GetCatResearchPrice($game->planet['catresearch_' . ($key + 1)], 2)) { $build_text = '<a href="' . parse_link_ex('a=researchlabs&a2=start_catresearch&id=' . $key, LINK_CLICKID) . '"><span style="color: green">' . constant($game->sprache("TEXT30")) . '</span></a>'; } else { $build_text = '<span style="color: red">' . constant($game->sprache("TEXT30")) . '</span>'; } // 03/04/08 - AC: Show "Completed" instead of remove completely the line if ($game->planet['catresearch_' . ($key + 1)] >= $components['num']) { $build_text = constant($game->sprache("TEXT39")); } /* 22/04/08 - AC: Translate HTML code into plain char */ $trans = array("’" => "'"); $tmp = strtr(html_entity_decode($components[$game->planet['catresearch_' . ($key + 1)]]['name']), $trans); /* */ if (strlen($tmp) > 18) { //$compname=substr($components[$game->planet['catresearch_'.($key+1)]]['name'], 0,16); $compname = substr($tmp, 0, 16); $compname = $compname . '...'; } else { $compname = $components[$game->planet['catresearch_' . ($key + 1)]]['name']; } /* 22/04/08 - AC: Translate HTML code into plain char */ $trans = array("’" => "'"); $tmp = strtr(html_entity_decode($components['name']), $trans); /* */ if (strlen($tmp) > 13) { /*if($components['text_category'] !=null) { //$catname='<a href="javascript:void(0);" onmouseover="return overlib(\''.$components['text_category'].'\',CAPTION,\''.$components['name'].'\', '.OVERLIB_STANDARD.');" onmouseout="return nd();"><font color="#FFFFFF">'.substr($components['name'], 0,11); $catname='<a href="javascript:void(0);" onmouseover="return overlib(\''.$components['text_category'].'\',CAPTION,\''.$components['name'].'\', '.OVERLIB_STANDARD.');" onmouseout="return nd();"><font color="#FFFFFF">'.substr($tmp, 0,11); $catname=$catname.'...</font></a>'; }else{*/ //$catname='<a href="javascript:void(0);" onmouseover="return overlib(\'\',CAPTION,\''.$components['name'].'\', '.OVERLIB_STANDARD.');" onmouseout="return nd();"><font color="#FFFFFF">'.substr($components['name'], 0,11); $catname = '<a href="javascript:void(0);" onmouseover="return overlib(\'\',CAPTION,\'' . $components['name'] . '\', ' . OVERLIB_STANDARD . ');" onmouseout="return nd();"><font color="#FFFFFF">' . substr($tmp, 0, 11); $catname = $catname . '...</font></a>'; /*}*/ } else { /*if($components['text_category'] !=null) { $catname='<a href="javascript:void(0);" onmouseover="return overlib(\''.$components['text_category'].'\',CAPTION,\''.$components['name'].'\', '.OVERLIB_STANDARD.');" onmouseout="return nd();"><font color="#FFFFFF">'.$components['name'].'</font></a>'; }else{*/ $catname = $components['name']; /*}*/ } if ($game->planet['catresearch_' . ($key + 1)] >= $game->planet['building_9'] && $game->planet['building_9'] < 9) { // Wenn man nicht erst Forschungszentrum hochbauen muss $game->out('<tr><td><b>' . $catname . '</b></td><td><b><a href="javascript:void(0);" onmouseover="return overlib(\'' . constant($game->sprache("TEXT31")) . ' ' . $BUILDING_NAME[$game->player['user_race']]['8'] . ' ' . constant($game->sprache("TEXT32")) . '\', CAPTION, \'' . $components[$game->planet['catresearch_' . ($key + 1)]]['name'] . '\', WIDTH, 400, ' . OVERLIB_STANDARD . ');" onmouseout="return nd();">' . $compname . '</a></b></td><td>'); } else { $game->out('<tr><td><b>' . $catname . '</b></td><td><b><a href="javascript:void(0);" onmouseover="return overlib(\'' . CreateInfoText($components[$game->planet['catresearch_' . ($key + 1)]]) . '\', CAPTION, \'' . $components[$game->planet['catresearch_' . ($key + 1)]]['name'] . '\', WIDTH, 400, ' . OVERLIB_STANDARD . ');" onmouseout="return nd();">' . $compname . '</a></b></td><td>'); } $game->out('<img src="' . $game->GFX_PATH . 'menu_metal_small.gif"> ' . GetCatResearchPrice($game->planet['catresearch_' . ($key + 1)], 0) . ' <img src="' . $game->GFX_PATH . 'menu_mineral_small.gif">' . GetCatResearchPrice($game->planet['catresearch_' . ($key + 1)], 1) . ' <img src="' . $game->GFX_PATH . 'menu_latinum_small.gif"> ' . GetCatResearchPrice($game->planet['catresearch_' . ($key + 1)], 2) . ' </td><td>' . $cat_times[$key] . '</td><td>' . $build_text . '</td></tr>'); } // while $game->out('</table></td></tr></table>'); $game->out('<br><br>'); $game->out('<span class="sub_caption">' . constant($game->sprache("TEXT33")) . ' ' . HelpPopup('research_localresearch') . ' :</span><br><br>'); $game->out('<table border=0 cellpadding=2 cellspacing=2 width=90% class="style_outer">'); $game->out(' <tr> <td width=100%> <table border=0 cellpadding=2 cellspacing=2 width=100% class="style_inner"> <tr><td width=25%><b>' . constant($game->sprache("TEXT34")) . '</b></td><td width=25%><b>' . constant($game->sprache("TEXT35")) . '</b></td><td width=25%><b>' . constant($game->sprache("TEXT36")) . '</b></td><td width=25%> </td></tr>'); // Local research: for ($t = 0; $t < 5; $t++) { if ($t == 0 && $game->planet['building_9'] < 1 || $t == 1 && $game->planet['building_9'] < 1 || $t == 2 && $game->planet['building_9'] < 1 || $t == 3 && $game->planet['building_9'] < 1 || $t == 4 && ($game->planet['building_9'] < 3 || $game->planet['building_2'] < 5 || $game->planet['building_3'] < 5 || $game->planet['building_4'] < 5)) { } else { if ($game->planet['resource_1'] >= GetResearchPrice($t, 0) && $game->planet['resource_2'] >= GetResearchPrice($t, 1) && $game->planet['resource_3'] >= GetResearchPrice($t, 2)) { $build_text = '<a href="' . parse_link_ex('a=researchlabs&a2=start_research&id=' . $t, LINK_CLICKID) . '"><span style="color: green">' . constant($game->sprache("TEXT30")) . ' (~' . round(pow($game->planet['research_' . ($t + 1)] + 1, 1.5) - pow($game->planet['research_' . ($t + 1)], 1.5)) . ' ' . constant($game->sprache("TEXT37")) . ')</span></a>'; if ($game->planet['research_' . ($t + 1)] > 0) { $build_text = '<a href="' . parse_link_ex('a=researchlabs&a2=start_research&id=' . $t, LINK_CLICKID) . '"><span style="color: green">' . constant($game->sprache("TEXT38")) . ' ' . ($game->planet['research_' . ($t + 1)] + 1) . ' (~' . round(pow($game->planet['research_' . ($t + 1)] + 1, 1.5) - pow($game->planet['research_' . ($t + 1)], 1.5)) . ' ' . constant($game->sprache("TEXT37")) . ')</span></a>'; } if ($game->planet['research_' . ($t + 1)] >= $MAX_RESEARCH_LVL[$capital][$t]) { $build_text = constant($game->sprache("TEXT39")); } } else { $build_text = '<span style="color: red">' . constant($game->sprache("TEXT30")) . ' (~' . round(pow($game->planet['research_' . ($t + 1)] + 1, 1.5) - pow($game->planet['research_' . ($t + 1)], 1.5)) . ' ' . constant($game->sprache("TEXT30")) . ')</span>'; if ($game->planet['research_' . ($t + 1)] > 0) { $build_text = '<span style="color: red">' . constant($game->sprache("TEXT38")) . ' ' . ($game->planet['research_' . ($t + 1)] + 1) . ' (~' . round(pow($game->planet['research_' . ($t + 1)] + 1, 1.5) - pow($game->planet['research_' . ($t + 1)], 1.5)) . ' ' . constant($game->sprache("TEXT37")) . ')</span>'; } if ($game->planet['research_' . ($t + 1)] >= $MAX_RESEARCH_LVL[$capital][$t]) { $build_text = constant($game->sprache("TEXT39")); } } $game->out('<tr><td><b><a href="javascript:void(0);" onmouseover="return overlib(\'' . CreateResearchInfoText($t) . '\', CAPTION, \'' . $TECH_NAME[$game->player['user_race']][$t] . '\', WIDTH, 400, ' . OVERLIB_STANDARD . ');" onmouseout="return nd();">' . $TECH_NAME[$game->player['user_race']][$t] . '</b></td><td><img src="' . $game->GFX_PATH . 'menu_metal_small.gif">' . GetResearchPrice($t, 0) . ' <img src="' . $game->GFX_PATH . 'menu_mineral_small.gif">' . GetResearchPrice($t, 1) . ' <img src="' . $game->GFX_PATH . 'menu_latinum_small.gif">' . GetResearchPrice($t, 2) . '</td><td> ' . GetResearchTime($t) . '</td><td>' . $build_text . '</td></tr>'); } } $game->out('</td></tr></table></td></tr></table>'); }