Exemplo n.º 1
0
 public function quest_end($config, $player)
 {
     $quest = (int) $quest;
     if ($player->in_quest != 0) {
         $quest = get_row("select * , unix_timestamp() as tnow from quests where q_id = " . $player->in_quest);
         if ($quest->tnow >= $player->in_quest_time) {
             $text = '';
             if ($quest->q_exp > 0) {
                 $exp = floor($quest->q_exp * ($player->lvl + 1) * 1.77);
                 call("update users set in_quest = 0,in_quest_time = 0, exp = exp + " . $exp . " where usr_id = " . $player->usr_id);
                 call("update users set skills = skills + 1, exp = exp - exp_lvl, exp_lvl = exp_lvl * 1.45, lvl = lvl + 1 where exp >= exp_lvl and usr_id = " . $player->usr_id);
                 $text .= 'Twój heros zdobył ' . $exp . ' doświadczenia<br/>';
             }
             if ($quest->q_res > 0) {
                 $res = floor($quest->q_res * ($player->lvl + 1) * 1.77);
                 call("update users set in_quest = 0,in_quest_time = 0 where usr_id = " . $player->usr_id);
                 require_once 'functions/TownMgr.php';
                 $TownMgr = new TownMgr();
                 $TownMgr->change_resources($config, $player->actual_town, $res, $res, $res, 0);
                 $text .= 'Twój heros zdobył ' . $res . ' każdego z surowców<br/>';
             }
             require_once 'functions/MsgMgr.php';
             $MsgMgr = new MsgMgr();
             $MsgMgr->raport($config, $player->usr_id, $text);
         }
     }
 }
Exemplo n.º 2
0
 public function caravan_send($config, $player, $town, $wood, $stone, $iron)
 {
     $town = textV($town);
     $wood = (int) $wood;
     $stone = (int) $stone;
     $iron = (int) $iron;
     if ($wood + $stone + $iron < 1) {
         $msg = 'wyślij minimum 1 sztukę jakiegoś surowca';
     } elseif ($player->clan_id == 0) {
         $msg = 'nie jesteś w klanie, karawany można wysyłać tylko do sojuszników w swoim klanie';
     } elseif ($player->town->t_wood < $wood || $player->town->t_stone < $stone || $player->town->t_iron < $iron) {
         $msg = 'nie posiadasz tyle surowców';
     } else {
         $can = get_row($q = "select clan_id, t_id from users inner join towns on t_usr_id = usr_id where t_name = '" . $town . "' limit 1");
         if (empty($can)) {
             $msg = 'takie miasto nie istnieje';
         } elseif ($can->clan_id != $player->clan_id) {
             $msg = 'te miasto nie jest w tym samym klanie co ty';
         } else {
             $event_check = get_one("select count(*) from events where (e_type = 20 or e_type = 21) and e_done = 0 and e_t_id = " . $player->actual_town);
             if ($event_check > 9) {
                 $msg = 'masz już maksymalną ilość karawan w podróży';
             } else {
                 $market_lvl = get_one("select go_lvl from game_objects where go_type = 1 and go_subtype = 6 and go_t_id = " . $player->actual_town);
                 if (empty($market_lvl)) {
                     $msg = 'nie posiadasz rynku, jak chcesz wysłać karawanę??';
                 } elseif ($market_lvl <= $event_check) {
                     $msg = 'masz już maksymalną ilość karawan w podróży';
                 } else {
                     $y = get_row("select * from map where m_t_id =" . $can->t_id);
                     $x = get_row("select * from map where m_t_id =" . $player->actual_town);
                     if ($x->m_x != $y->m_x && $x->m_y == $y->m_y) {
                         $range = abs($y->m_x - $x->m_x) * 300;
                     } elseif ($x->m_x == $y->m_x && $x->m_y != $y->m_y) {
                         $range = abs($y->m_y - $x->m_y) * 300;
                     } else {
                         $range = floor(sqrt(pow(abs($y->m_x - $x->m_x), 2) + pow(abs($y->m_y - $x->m_y), 2))) * 300;
                     }
                     call("insert into caravan(ca_from, ca_to, ca_wood, ca_stone, ca_iron)\n\t\t\t\t\t\t\tvalue(" . $player->actual_town . "," . $can->t_id . "," . $wood . "," . $stone . "," . $iron . ")");
                     $ca = get_row("select last_insert_id() as ca, unix_timestamp() as estart");
                     require_once 'functions/TownMgr.php';
                     $TownMgr = new TownMgr();
                     $TownMgr->change_resources($config, $player->actual_town, -$wood, -$stone, -$iron, 0);
                     require_once 'functions/EventsMgr.php';
                     $EventMgr = new EventsMgr();
                     $EventMgr->event_add($config, $player->actual_town, 20, $can->t_id, $ca->ca, 0, $ca->estart, $ca->estart + $range, 0);
                     $msg = 'wysłano karawanę do miasta ' . $town;
                 }
             }
         }
     }
     return $msg;
 }
Exemplo n.º 3
0
 public function colectors_dismis($config, $town, $id)
 {
     $data = get_row("select * from colectors where co_id = {$id}");
     call("update game_objects set go_lvl = go_lvl + " . $data->co_counts . " where go_type = 3 and go_subtype = 8 and go_t_id =" . $town);
     require_once 'functions/TownMgr.php';
     $towns = new TownMgr();
     $towns->change_resources($config, $town, $data->co_wood, $data->co_stone, $data->co_iron, 0);
     require_once 'functions/MsgMgr.php';
     $MsgMgr = new MsgMgr();
     $user = get_one("select t_usr_id from towns where t_id = " . $town);
     $MsgMgr->raport($config, $user, 'Zbieracze powrócili do miasta i przynieśli ze sobą ' . $data->co_wood . ' drewna, ' . $data->co_stone . ' gliny i ' . $data->co_iron . ' żelaza');
 }
Exemplo n.º 4
0
function getTown($config, $player)
{
    if ($player->actual_town > 0) {
        $player_data = get_row("select * from towns where t_id =" . $player->actual_town);
    } else {
        require 'functions/TownMgr.php';
        $town = new TownMgr();
        $town->new_town($config, $player);
    }
    return $player_data;
}
Exemplo n.º 5
0
<?php

isUser($config);
$player = getUser($config);
$player->town = getTown($config, $player);
require_once 'functions/MainMgr.php';
$main = new MainMgr();
$main->town_main($config, $player);
require_once 'functions/TownMgr.php';
$town = new TownMgr();
$town->inc_resources($config, $player->actual_town);
require_once 'functions/HeroMgr.php';
$Hero = new HeroMgr();
$Hero->quest_end($config, $player);
require 'header.php';
require $page;
require 'footer.php';
Exemplo n.º 6
0
<?php

if (!empty($_GET['set_town'])) {
    require_once 'functions/TownMgr.php';
    $TownMgr = new TownMgr();
    $TownMgr->set_town($config, $player, $_GET['set_town']);
    reload($config, 'town', '');
}
?>
<DIV class="pageSubnav" id="overviewNav">
 <UL class="menu">
    <LI class="vipItem" title="VIP Option"><A href="index.php?action=town">Podgląd miasta</A></LI>
 </UL>
    <H2>Przyrost na godzinę</H2>
    <DIV class="box">
        <DIV id="resTimes">
			<DIV class="timeItem" id="timeWood">
                <SMALL>Drewno</SMALL><?php 
echo $player->town->t_wood;
?>
<small>+<?php 
echo $player->town->t_wood_inc;
?>
</small>
				
            </DIV>
            <DIV class="timeItem" id="timeIron">
                <SMALL>Glina</SMALL><?php 
echo $player->town->t_stone;
?>
<small>+<?php 
Exemplo n.º 7
0
 public function build_stop($config, $event, $player)
 {
     $event = (int) $event;
     $error = 1;
     //sprawdź czy w ogóle takie zdarzenie w kolejce istnieje
     $event_check = get_row($q = "select e_type, e_subtype, e_count from events where e_id = " . $event . " and e_done = 0 and e_t_id = " . $player->actual_town . " limit 1");
     if (empty($event_check)) {
         //nie ma takiego zdarzenia
         $error = 2;
     } else {
         //pobierz dane obiektu
         $object = get_row("\n\t\t\t\tselect * from game_objects_param \n\t\t\t\tleft join game_objects \n\t\t\t\ton go_t_id = " . $player->actual_town . "\n\t\t\t\tand go_gop_id = gop_id\n\t\t\t\twhere gop_type = " . $event_check->e_type . " and gop_subtype = " . $event_check->e_subtype . "\n\t\t\t\tlimit 1\n\t\t\t");
         //jeżeli obiektu nie ma na liście obiektów wybudowanych, to bierz pod uwagę parametry startowe
         if (empty($object->go_id)) {
             if (empty($object->gop_id)) {
                 //jeżeli w ogóle nie ma takiego obiektu ustaw error = 2
                 $error = 2;
             } else {
                 //pobierz koszt z parametrów startowych i przemnóż przez ilość budowanych obiektów
                 $object->go_wood = $object->gop_wood * $event_check->e_count;
                 $object->go_stone = $object->gop_stone * $event_check->e_count;
                 $object->go_iron = $object->gop_iron * $event_check->e_count;
                 $object->go_pop = $object->gop_pop * $event_check->e_count;
             }
         } else {
             //przemnóż przez ilość budowanych obiektów
             $object->go_wood = $object->go_wood * $event_check->e_count;
             $object->go_stone = $object->go_stone * $event_check->e_count;
             $object->go_iron = $object->go_iron * $event_check->e_count;
             $object->go_pop = $object->go_pop * $event_check->e_count;
         }
         //nie wywaliło error = 2
         if ($error == 1) {
             //przerwij budowanie
             require_once 'functions/EventsMgr.php';
             $eventend = new EventsMgr();
             $eventend->event_stop($config, $event, $player->actual_town);
             //zwróć surowce
             require_once 'functions/TownMgr.php';
             $town = new TownMgr();
             $town->change_resources($config, $player->actual_town, floor($object->go_wood * 0.9), floor($object->go_stone * 0.9), floor($object->go_iron * 0.9), -$object->go_pop);
             $error = 0;
         }
     }
     return $error;
 }
Exemplo n.º 8
0
    $error = $build->build_stop($config, $_GET['techstop'], $player);
    $param['type'] = 7;
    reload($config, 'build', $param);
}
if (!empty($_GET['type']) && !empty($_GET['subtype']) && !empty($_GET['unitstop'])) {
    require_once 'functions/BuildMgr.php';
    $build = new BuildMgr();
    $error = $build->build_stop($config, $_GET['unitstop'], $player);
    $param['type'] = 5;
    reload($config, 'build', $param);
}
if (!empty($_POST['type']) && !empty($_POST['vtype']) && !empty($_POST['counts'])) {
    $is_market = get_one("select go_id from game_objects where go_t_id = " . $player->actual_town . " and go_type =1 and go_subtype = 6 limit 1");
    if (!empty($is_market)) {
        require_once 'functions/TownMgr.php';
        $town = new TownMgr();
        $error = $town->town_market($config, $player, $_POST['type'][0], $_POST['vtype'][0], $_POST['counts']);
        $player->town = getTown($config, $player);
    }
}
if (!empty($_GET['caravan_back'])) {
    require_once 'functions/MarketMgr.php';
    $MarketMgr = new MarketMgr();
    $error = $MarketMgr->caravan_back($config, $player->actual_town, $_GET['caravan_back']);
}
if (!empty($_POST['town'])) {
    if (empty($_POST['wood'])) {
        $_POST['wood'] = 0;
    }
    if (empty($_POST['stone'])) {
        $_POST['stone'] = 0;