Exemple #1
0
                                 } else {
                                     echo "<tr> <th> {$i}</th> ";
                                 }
                                 echo "<th> " . nicenum($prod) . "</th> ";
                                 echo "<th> " . rgnum($prod - $prod_now) . "</th> \n";
                                 echo "<th> " . nicenum($cons) . "</th> ";
                                 echo "<th> " . rgnum($cons - $cons_now) . "</th> </tr> \n";
                             }
                             echo "</table></center></tr></th>";
                         } else {
                             if ($gid == 22 || $gid == 23 || $gid == 24) {
                                 echo "<tr><th><p><center><table border=1 ><tr><td class='c'>Уровень</td><td class='c'>Вместимость</td><td class='c'>Разница</td></tr>\n";
                                 $level = $aktplanet['b' . $gid];
                                 $cap_now = store_capacity($aktplanet['b' . $gid]) / 1000;
                                 for ($i = $level; $i < $level + 15; $i++) {
                                     $cap = store_capacity($i) / 1000;
                                     if ($i == $aktplanet['b' . $gid]) {
                                         echo "<tr> <th> <font color=#FF0000>{$i}</font></th> <th>" . nicenum($cap) . " k</th> <th>0</th> </tr>\n";
                                     } else {
                                         echo "<tr> <th> {$i}</th> <th>" . nicenum($cap) . " k</th> <th> <font color=\"#00FF00\">" . nicenum($cap - $cap_now) . " k</font></th> </tr>\n";
                                     }
                                 }
                                 echo "</table>";
                             } else {
                                 if ($gid == 34) {
                                     $depot_cap = 10000 * pow(2, $aktplanet['b34']);
                                     if ($aktplanet['b34']) {
                                         $deut_avail = min(floor($aktplanet['d']), $depot_cap);
                                     }
                                     ?>
 </th>
Exemple #2
0
function GetPlanet($planet_id)
{
    global $db_prefix;
    $query = "SELECT * FROM " . $db_prefix . "planets WHERE planet_id = '" . $planet_id . "' LIMIT 1";
    $result = dbquery($query);
    if (dbrows($result) == 0) {
        return NULL;
    }
    $planet = dbarray($result);
    $user = LoadUser($planet['owner_id']);
    $prem = PremiumStatus($user);
    if ($prem['engineer']) {
        $e_factor = 1.1;
    } else {
        $e_factor = 1.0;
    }
    $planet['mmax'] = store_capacity($planet['b22']);
    $planet['kmax'] = store_capacity($planet['b23']);
    $planet['dmax'] = store_capacity($planet['b24']);
    $planet['emax'] = prod_solar($planet['b4'], $planet['sprod']) * $e_factor + prod_fusion($planet['b12'], $user['r113'], $planet['fprod']) * $e_factor + prod_sat($planet['temp'] + 40) * $planet['f212'] * $planet['ssprod'] * $e_factor;
    $planet['econs'] = cons_metal($planet['b1']) * $planet['mprod'] + cons_crys($planet['b2']) * $planet['kprod'] + cons_deut($planet['b3']) * $planet['dprod'];
    $planet['e'] = floor($planet['emax'] - $planet['econs']);
    $planet['factor'] = 1;
    if ($planet['e'] < 0) {
        $planet['factor'] = max(0, 1 - abs($planet['e']) / $planet['econs']);
    }
    return $planet;
}