Beispiel #1
0
     }
     if ($d) {
         echo "дейтерия:<b>" . nicenum($d) . "</b> ";
     }
     $t = BuildDuration($gid, $aktplanet['b' . $gid] - 1, $aktplanet['b14'], $aktplanet['b15'], $speed);
     echo "<tr><th><br>Продолжительность сноса:  " . BuildDurationFormat($t) . "<br></th></tr></table>\n";
 }
 if ($gid == 44 && $aktplanet['b' . $gid]) {
     $raknum = $aktplanet['d502'] + $aktplanet['d503'];
     echo "<table width=519 >\n";
     if ($raknum == 0) {
         echo "<tr><td class=c align=center><a href=\"index.php?page=b_building&session={$session}&techid={$gid}&modus=destroy&planet=" . $aktplanet['planet_id'] . "\">Снести: " . loca("NAME_{$gid}") . " Level " . $aktplanet['b' . $gid] . " уничтожить?</a></td></tr>\n";
     } else {
         echo "<tr><td class=c align=center>об оборонительных сооружениях</a></td></tr>";
     }
     $res = BuildPrice($gid, $aktplanet['b' . $gid] - 1);
     $m = $res['m'];
     $k = $res['k'];
     $d = $res['d'];
     $e = $res['e'];
     echo "<br><tr><th>Необходимо ";
     if ($m) {
         echo "металла:<b>" . nicenum($m) . "</b> ";
     }
     if ($k) {
         echo "кристалла:<b>" . nicenum($k) . "</b> ";
     }
     if ($d) {
         echo "дейтерия:<b>" . nicenum($d) . "</b> ";
     }
     $t = BuildDuration($gid, $aktplanet['b' . $gid] - 1, $aktplanet['b14'], $aktplanet['b15'], $speed);
Beispiel #2
0
function PlanetPrice($planet)
{
    $pp = array();
    $buildmap = array(1, 2, 3, 4, 12, 14, 15, 21, 22, 23, 24, 31, 33, 34, 41, 42, 43, 44);
    $fleetmap = array(202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215);
    $defmap = array(401, 402, 403, 404, 405, 406, 407, 408, 502, 503);
    $m = $k = $d = $e = 0;
    $pp['points'] = $pp['fpoints'] = $pp['fleet_pts'] = $pp['defense_pts'] = 0;
    foreach ($buildmap as $i => $gid) {
        // Постройки
        $level = $planet["b{$gid}"];
        if ($level > 0) {
            for ($lv = 1; $lv <= $level; $lv++) {
                $res = BuildPrice($gid, $lv);
                $m = $res['m'];
                $k = $res['k'];
                $d = $res['d'];
                $e = $res['e'];
                $pp['points'] += $m + $k + $d;
            }
        }
    }
    foreach ($fleetmap as $i => $gid) {
        // Флот
        $level = $planet["f{$gid}"];
        if ($level > 0) {
            $res = ShipyardPrice($gid);
            $m = $res['m'];
            $k = $res['k'];
            $d = $res['d'];
            $e = $res['e'];
            $pp['points'] += ($m + $k + $d) * $level;
            $pp['fleet_pts'] += ($m + $k + $d) * $level;
            $pp['fpoints'] += $level;
        }
    }
    foreach ($defmap as $i => $gid) {
        // Оборона
        $level = $planet["d{$gid}"];
        if ($level > 0) {
            $res = ShipyardPrice($gid);
            $m = $res['m'];
            $k = $res['k'];
            $d = $res['d'];
            $e = $res['e'];
            $pp['points'] += ($m + $k + $d) * $level;
            $pp['defense_pts'] += ($m + $k + $d) * $level;
        }
    }
    return $pp;
}
Beispiel #3
0
 private function __construct()
 {
     require 'core/models/class.User.php';
     require 'core/models/implement.Menu.php';
     require 'core/models/class.Planet.php';
     require 'core/models/implement.Topnav.php';
     require 'core/buildables.php';
     require 'core/functions/GeneralFunctions.php';
     global $id_user, $id_planet;
     $lng = new Lang();
     $menu = new Menu($id_user);
     $topnav = new Topnav($id_planet, $id_user);
     $user = new User($id_user);
     $planet = new Planet($id_planet);
     foreach ($provision as $id => $item) {
         $price = BuildPrice($item['metal'], $item['cristal'], $item['tritio'], $item['materia'], $item['price'], $planet->PlanetBuildsLeveles()[$item['name']]);
         if ($price[0] > 0 and $price[1] > 0 and $price[2] > 0 and $price[3] > 0) {
             $precios = 'todos';
         } else {
             if ($price[0] == 0 and $price[1] == 0 and $price[2] == 0 and $price[3] == 0) {
                 $precios = 'ninguno';
             } else {
                 if ($price[0] > 0 and $price[1] == 0 and $price[2] == 0 and $price[3] == 0) {
                     $precios = 'metal';
                 } else {
                     if ($price[0] > 0 and $price[1] > 0 and $price[2] == 0 and $price[3] == 0) {
                         $precios = 'metal_cristal';
                     } else {
                         if ($price[0] > 0 and $price[1] > 0 and $price[2] > 0 and $price[3] == 0) {
                             $precios = 'metal_cristal_tritio';
                         } else {
                             if ($price[0] > 0 and $price[1] == 0 and $price[2] == 0 and $price[3] > 0) {
                                 $precios = 'metal_materia';
                             } else {
                                 if ($price[0] > 0 and $price[1] == 0 and $price[2] > 0 and $price[3] == 0) {
                                     $precios = 'metal_tritio';
                                 } else {
                                     if ($price[0] == 0 and $price[1] > 0 and $price[2] == 0 and $price[3] == 0) {
                                         $precios = 'cristal';
                                     } else {
                                         if ($price[0] == 0 and $price[1] > 0 and $price[2] == 0 and $price[3] > 0) {
                                             $precios = 'cristal_materia';
                                         } else {
                                             if ($price[0] == 0 and $price[1] > 0 and $price[2] > 0 and $price[3] == 0) {
                                                 $precios = 'cristal_tritio';
                                             } else {
                                                 if ($price[0] == 0 and $price[1] > 0 and $price[2] > 0 and $price[3] > 0) {
                                                     $precios = 'cristal_tritio_materia';
                                                 } else {
                                                     if ($price[0] == 0 and $price[1] == 0 and $price[2] > 0 and $price[3] == 0) {
                                                         $precios = 'tritio';
                                                     } else {
                                                         if ($price[0] == 0 and $price[1] == 0 and $price[2] > 0 and $price[3] > 0) {
                                                             $precios = 'tritio_materia';
                                                         } else {
                                                             if ($price[0] == 0 and $price[1] == 0 and $price[2] == 0 and $price[3] > 0) {
                                                                 $precios = 'materia';
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         $building[] = array('id' => $id, 'name' => $item['name'], 'nivel' => $planet->PlanetBuildsLeveles()[$item['name']], 'metal' => number_format($price[0], '0', ',', '.'), 'cristal' => number_format($price[1], '0', ',', '.'), 'tritio' => number_format($price[2], '0', ',', '.'), 'materia' => number_format($price[3], '0', ',', '.'), 'tiempo_c' => BuildTime($price[0], $price[1], $planet->PlanetBuildsLeveles()['nanobots']), 'tiempo_d' => BuildTime($price[0] / 2, $price[1] / 2, $planet->PlanetBuildsLeveles()['nanobots']), 'name_lng' => $lng->{$item}['name_lng'], 'desc_lng' => $lng->{$item}['desc_lng'], 'precios' => $precios);
     }
     $template = new Smarty();
     $template->assign(array('building' => $building));
     $template->display('buildables/provision.tpl');
 }
Beispiel #4
0
function Queue_Build_End($queue)
{
    global $db_prefix, $GlobalUser;
    $id = $queue['obj_id'];
    $lvl = $queue['level'];
    $query = "SELECT * FROM " . $db_prefix . "buildqueue WHERE id = " . $queue['sub_id'] . " LIMIT 1";
    $result = dbquery($query);
    if (dbrows($result) == 0) {
        //Error ( "Нет постройки в очереди построек!");
        RemoveQueue($queue['task_id']);
        return;
    }
    $bqueue = dbarray($result);
    $planet_id = $bqueue['planet_id'];
    // Рассчитать производство планеты с момента последнего обновления.
    $planet = GetPlanet($planet_id);
    $player_id = $planet['owner_id'];
    $planet = ProdResources($planet, $planet['lastpeek'], $queue['end']);
    // Защита от дурака
    if ($queue['type'] === "Build" && $planet["b" . $id] >= $lvl || $queue['type'] === "Demolish" && $planet["b" . $id] <= $lvl) {
        RemoveQueue($queue['task_id']);
        dbquery("DELETE FROM " . $db_prefix . "buildqueue WHERE id = " . $queue['sub_id']);
        return;
    }
    // Количество полей на планете.
    if ($queue['type'] === "Build") {
        $fields = "fields = fields + 1";
        // Специальная обработка для постройки Терраформера или Лунной базы -- добавить максимальное количество полей.
        if ($id == 33) {
            $fields .= ", maxfields = maxfields + 5";
        }
        if ($id == 41) {
            $fields .= ", maxfields = maxfields + 3";
        }
    } else {
        $fields = "fields = fields - 1";
    }
    // Обновить уровень постройки и количество полей в базе данных.
    $query = "UPDATE " . $db_prefix . "planets SET " . ('b' . $id) . " = {$lvl}, {$fields} WHERE planet_id = {$planet_id}";
    dbquery($query);
    RemoveQueue($queue['task_id']);
    dbquery("DELETE FROM " . $db_prefix . "buildqueue WHERE id = " . $queue['sub_id']);
    // Добавить очки. Места пересчитывать только для крупных построек.
    if ($queue['type'] === "Build") {
        $res = BuildPrice($id, $lvl);
        $m = $res['m'];
        $k = $res['k'];
        $d = $res['d'];
        $e = $res['e'];
        $points = $m + $k + $d;
        AdjustStats($queue['owner_id'], $points, 0, 0, '+');
    } else {
        $res = BuildPrice($id, $lvl + 1);
        $m = $res['m'];
        $k = $res['k'];
        $d = $res['d'];
        $e = $res['e'];
        $points = $m + $k + $d;
        AdjustStats($queue['owner_id'], $points, 0, 0, '-');
    }
    if ($lvl > 10) {
        RecalcRanks();
    }
    if ($GlobalUser['player_id'] == $player_id) {
        InvalidateUserCache();
        $GlobalUser = LoadUser($player_id);
        // обновить данные текущего пользователя
    }
    // Запустить следующую постройку
    PropagateBuildQueue($planet_id, $queue['end']);
}
 if (!BuildMeetRequirement($GlobalUser, $aktplanet, $id)) {
     continue;
 }
 echo "<tr>";
 if ($GlobalUser['useskin']) {
     echo "<td class=l>";
     echo "<a href=index.php?page=infos&session={$session}&gid=" . $id . ">";
     echo "<img border='0' src=\"" . UserSkin() . "gebaeude/" . $id . ".gif\" align='top' width='120' height='120'></a></td>";
 }
 echo "<td class=l>";
 echo "<a href=index.php?page=infos&session={$session}&gid=" . $id . ">" . loca("NAME_{$id}") . "</a></a>";
 if ($lvl) {
     echo " (уровень " . $lvl . ")";
 }
 echo "<br>" . loca("SHORT_{$id}");
 $res = BuildPrice($id, $lvl + 1);
 $m = $res['m'];
 $k = $res['k'];
 $d = $res['d'];
 $e = $res['e'];
 echo "<br>Стоимость:";
 if ($m) {
     echo " Металл: <b>" . nicenum($m) . "</b>";
 }
 if ($k) {
     echo " Кристалл: <b>" . nicenum($k) . "</b>";
 }
 if ($d) {
     echo " Дейтерий: <b>" . nicenum($d) . "</b>";
 }
 if ($e) {
 private function __construct()
 {
     if (isset($_POST['construir'], $_GET['id'])) {
         $this->AddBuildToQueue();
     } else {
         if (isset($_POST['destruir'], $_GET['id'])) {
             $this->AddBuildToQueue(false);
         } else {
             require 'core/models/class.User.php';
             require 'core/models/implement.Menu.php';
             require 'core/models/class.Planet.php';
             require 'core/models/implement.Topnav.php';
             require 'core/buildables.php';
             require 'core/functions/GeneralFunctions.php';
             global $id_user, $id_planet;
             $lng = new Lang();
             $menu = new Menu($id_user);
             $topnav = new Topnav($id_planet, $id_user);
             $user = new User($id_user);
             $planet = new Planet($id_planet);
             foreach ($provision as $id => $item) {
                 $price = BuildPrice($item['metal'], $item['cristal'], $item['tritio'], $item['materia'], $item['price'], $planet->PlanetBuildsLeveles()[$item['name']]);
                 if ($price[0] > 0 and $price[1] > 0 and $price[2] > 0 and $price[3] > 0) {
                     $precios = 'todos';
                 } else {
                     if ($price[0] == 0 and $price[1] == 0 and $price[2] == 0 and $price[3] == 0) {
                         $precios = 'ninguno';
                     } else {
                         if ($price[0] > 0 and $price[1] == 0 and $price[2] == 0 and $price[3] == 0) {
                             $precios = 'metal';
                         } else {
                             if ($price[0] > 0 and $price[1] > 0 and $price[2] == 0 and $price[3] == 0) {
                                 $precios = 'metal_cristal';
                             } else {
                                 if ($price[0] > 0 and $price[1] > 0 and $price[2] > 0 and $price[3] == 0) {
                                     $precios = 'metal_cristal_tritio';
                                 } else {
                                     if ($price[0] > 0 and $price[1] == 0 and $price[2] == 0 and $price[3] > 0) {
                                         $precios = 'metal_materia';
                                     } else {
                                         if ($price[0] > 0 and $price[1] == 0 and $price[2] > 0 and $price[3] == 0) {
                                             $precios = 'metal_tritio';
                                         } else {
                                             if ($price[0] == 0 and $price[1] > 0 and $price[2] == 0 and $price[3] == 0) {
                                                 $precios = 'cristal';
                                             } else {
                                                 if ($price[0] == 0 and $price[1] > 0 and $price[2] == 0 and $price[3] > 0) {
                                                     $precios = 'cristal_materia';
                                                 } else {
                                                     if ($price[0] == 0 and $price[1] > 0 and $price[2] > 0 and $price[3] == 0) {
                                                         $precios = 'cristal_tritio';
                                                     } else {
                                                         if ($price[0] == 0 and $price[1] > 0 and $price[2] > 0 and $price[3] > 0) {
                                                             $precios = 'cristal_tritio_materia';
                                                         } else {
                                                             if ($price[0] == 0 and $price[1] == 0 and $price[2] > 0 and $price[3] == 0) {
                                                                 $precios = 'tritio';
                                                             } else {
                                                                 if ($price[0] == 0 and $price[1] == 0 and $price[2] > 0 and $price[3] > 0) {
                                                                     $precios = 'tritio_materia';
                                                                 } else {
                                                                     if ($price[0] == 0 and $price[1] == 0 and $price[2] == 0 and $price[3] > 0) {
                                                                         $precios = 'materia';
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
                 $requeriments = TechRequeriments($item, $planet->PlanetBuildsLeveles());
                 if ($requeriments) {
                     $build = '<input type=\'submit\' class=\'construir\' name=\'construir\' value=\'\' />';
                     if ($planet->PlanetBuildsLeveles()[$item['name']] > 0) {
                         $destroy = '<input type=\'submit\' class=\'destruir\' name=\'destruir\' value=\'\' />';
                     } else {
                         $destroy = '<input type=\'submit\' class=\'destruir_no\' name=\'destruir\' value=\'\' />';
                     }
                     $image = $item['name'];
                 } else {
                     if ($item['name'] == 'almacen_materia' or $item['name'] == 'distribuidor') {
                         $image = $item['name'];
                     } else {
                         $image = $item['name'] . '_no';
                     }
                     $build = '';
                     $destroy = '';
                 }
                 $building[] = array('id' => $id, 'name' => $item['name'], 'image' => $image, 'build' => $build, 'destroy' => $destroy, 'nivel' => $planet->PlanetBuildsLeveles()[$item['name']], 'metal' => number_format($price[0], '0', ',', '.'), 'cristal' => number_format($price[1], '0', ',', '.'), 'tritio' => number_format($price[2], '0', ',', '.'), 'materia' => number_format($price[3], '0', ',', '.'), 'tiempo_c' => FormatTimes(BuildTime($price[0], $price[1], $planet->PlanetBuildsLeveles()['nanobots'])), 'tiempo_d' => FormatTimes(BuildTime($price[0] / 2, $price[1] / 2, $planet->PlanetBuildsLeveles()['nanobots'])), 'name_lng' => $lng->{$item}['name_lng'], 'desc_lng' => $lng->{$item}['desc_lng'], 'precios' => $precios);
                 unset($precios, $price, $item, $id);
             }
             $template = new Smarty();
             $template->assign(array('abastecimiento' => $lng->m_abastecimiento, 'building' => $building));
             $template->display('buildables/provision.tpl');
         }
     }
 }