예제 #1
0
                if ($coord_g > $unitab['galaxies']) {
                    $coord_g = $unitab['galaxies'];
                }
            }
        }
    }
}
$not_enough_deut = ($aktplanet['g'] != $coord_g || $aktplanet['s'] != $coord_s) && $aktplanet['d'] < 10;
// Списать 10 дейтерия за просмотр не домашней системы (только для обычных пользователей)
if (!$not_enough_deut && $GlobalUser['admin'] == 0) {
    if ($aktplanet['g'] != $coord_g || $aktplanet['s'] != $coord_s) {
        AdjustResources(0, 0, 10, $aktplanet['planet_id'], '-');
        $aktplanet = GetPlanet($aktplanet['planet_id']);
    }
}
$result = EnumOwnFleetQueue($GlobalUser['player_id']);
$nowfleet = dbrows($result);
$maxfleet = $GlobalUser['r108'] + 1;
$prem = PremiumStatus($GlobalUser);
if ($prem['admiral']) {
    $maxfleet += 2;
}
PageHeader("galaxy", true);
echo "<!-- CONTENT AREA -->\n";
echo "<div id='content'>\n";
echo "<center>\n\n";
/***** Скрипты. *****/
?>

  <script  language="JavaScript">
  function galaxy_submit(value) {
예제 #2
0
function RecalcStats($player_id)
{
    global $db_prefix;
    $m = $k = $d = $e = 0;
    $points = $fpoints = $rpoints = 0;
    // Планеты/луны + стоящие флоты
    $query = "SELECT * FROM " . $db_prefix . "planets WHERE owner_id = '" . $player_id . "'";
    $result = dbquery($query);
    $rows = dbrows($result);
    while ($rows--) {
        $planet = dbarray($result);
        if ($planet['type'] >= 10000) {
            continue;
        }
        // считать только планеты и луны.
        $pp = PlanetPrice($planet);
        $points += $pp['points'];
        $fpoints += $pp['fpoints'];
    }
    // Исследования
    $resmap = array(106, 108, 109, 110, 111, 113, 114, 115, 117, 118, 120, 121, 122, 123, 124, 199);
    $user = LoadUser($player_id);
    if ($user != null) {
        foreach ($resmap as $i => $gid) {
            $level = $user["r{$gid}"];
            $rpoints += $level;
            if ($level > 0) {
                for ($lv = 1; $lv <= $level; $lv++) {
                    $res = ResearchPrice($gid, $lv);
                    $m = $res['m'];
                    $k = $res['k'];
                    $d = $res['d'];
                    $e = $res['e'];
                    $points += $m + $k + $d;
                }
            }
        }
    }
    // Летящие флоты
    $fleetmap = array(202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215);
    $result = EnumOwnFleetQueue($player_id, 1);
    $rows = dbrows($result);
    while ($rows--) {
        $queue = dbarray($result);
        $fleet = LoadFleet($queue['sub_id']);
        foreach ($fleetmap as $i => $gid) {
            // Флот
            $level = $fleet["ship{$gid}"];
            if ($level > 0) {
                $res = ShipyardPrice($gid);
                $m = $res['m'];
                $k = $res['k'];
                $d = $res['d'];
                $e = $res['e'];
                $points += ($m + $k + $d) * $level;
                $fpoints += $level;
            }
        }
        if ($fleet['ipm_amount'] > 0) {
            // МПР
            $res = ShipyardPrice(503);
            $m = $res['m'];
            $k = $res['k'];
            $d = $res['d'];
            $e = $res['e'];
            $points += ($m + $k + $d) * $fleet['ipm_amount'];
        }
    }
    $query = "UPDATE " . $db_prefix . "users SET ";
    $query .= "score1={$points}, score2={$fpoints}, score3={$rpoints} WHERE player_id = {$player_id} AND (banned <> 1 OR admin > 0);";
    dbquery($query);
}