예제 #1
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);
}
예제 #2
0
function ResearchDuration($id, $lvl, $reslab, $speed)
{
    if ($id == 199) {
        return 1;
    }
    $res = ResearchPrice($id, $lvl);
    $m = $res['m'];
    $k = $res['k'];
    $d = $res['d'];
    $e = $res['e'];
    $secs = floor(($m + $k) / (1000 * (1 + $reslab)) * 60 * 60 / $speed);
    if ($secs < 1) {
        $secs = 1;
    }
    return $secs;
}
예제 #3
0
     echo "    \t\t\t</td>\n";
     echo "        <td class=l >";
 } else {
     echo "        <td class=l colspan=2>";
 }
 echo "<a href=index.php?page=infos&session={$session}&gid={$id}>" . loca("NAME_{$id}") . "</a>";
 if ($GlobalUser['r' . $id]) {
     echo "</a> (уровень " . $GlobalUser['r' . $id];
 }
 if ($id == 106 && $prem['technocrat']) {
     echo " <b><font style=\"color:lime;\">+2</font></b> <img border=\"0\" src=\"img/technokrat_ikon.gif\" alt=\"Технократ\" onmouseover=\"return overlib('<font color=white>Технократ</font>', WIDTH, 100);\" onmouseout='return nd();' width=\"20\" height=\"20\" style=\"vertical-align:middle;\"> ";
 }
 if ($GlobalUser['r' . $id]) {
     echo ")";
 }
 $res = ResearchPrice($id, $level);
 $m = $res['m'];
 $k = $res['k'];
 $d = $res['d'];
 $e = $res['e'];
 echo "<br>" . loca("SHORT_{$id}") . "<br>Стоимость:";
 if ($m) {
     echo " Металл: <b>" . nicenum($m) . "</b>";
 }
 if ($k) {
     echo " Кристалл: <b>" . nicenum($k) . "</b>";
 }
 if ($d) {
     echo " Дейтерий: <b>" . nicenum($d) . "</b>";
 }
 if ($e) {
예제 #4
0
function Queue_Research_End($queue)
{
    global $db_prefix, $GlobalUser;
    $id = $queue['obj_id'];
    $lvl = $queue['level'];
    $planet_id = $queue['sub_id'];
    $player_id = $queue['owner_id'];
    // Рассчитать производство планеты с момента последнего обновления.
    $planet = GetPlanet($planet_id);
    $planet = ProdResources($planet, $planet['lastpeek'], $queue['end']);
    // Обновить уровень исследования в базе данных.
    $query = "UPDATE " . $db_prefix . "users SET " . ('r' . $id) . " = {$lvl} WHERE player_id = {$player_id}";
    dbquery($query);
    RemoveQueue($queue['task_id']);
    // Добавить очки.
    $res = ResearchPrice($id, $lvl);
    $m = $res['m'];
    $k = $res['k'];
    $d = $res['d'];
    $e = $res['e'];
    $points = $m + $k + $d;
    AdjustStats($queue['owner_id'], $points, 0, 1, '+');
    RecalcRanks();
    Debug("Исследование " . loca("NAME_{$id}") . " уровня {$lvl} для пользователя {$player_id} завершено.");
    if ($GlobalUser['player_id'] == $player_id) {
        InvalidateUserCache();
        $GlobalUser = LoadUser($player_id);
        // обновить данные текущего пользователя
    }
}