Ejemplo n.º 1
0
 public function execute($a = null, $b = null, $c = null)
 {
     $buildings = $this->getTarget()->buildings->getBuildings();
     shuffle($buildings);
     $level = $this->getLevel();
     foreach ($buildings as $v) {
         if ($v->getLevel() <= $level) {
             $v->doDestructBuilding(false, NOW, false);
             Dolumar_Players_Logs::getInstance()->addDestroyBuildingLog($this->getVillage(), $this->getTarget(), $v);
             return true;
         }
     }
     return false;
 }
Ejemplo n.º 2
0
 public function openPortal($village)
 {
     if ($village->equals($this->village)) {
         throw new Neuron_Core_Error('Can\'t open portal to own village.');
     }
     $race = $village->getRace();
     $building = Dolumar_Buildings_Portal::getBuilding(60, $race);
     $date = NOW + self::PORTAL_LIFESPAN_HOURES * 60 * 60 / GAME_SPEED_EFFECTS;
     $loc1 = $this->openPortalNearVillage($this->village, $building, $date);
     $loc2 = $this->openPortalNearVillage($village, $building, $date);
     $db = Neuron_DB_Database::getInstance();
     $db->query("\n\t\t\tINSERT INTO\n\t\t\t\tmap_portals\n\t\t\tSET\n\t\t\t\tp_caster_v_id = {$this->village->getId()},\n\t\t\t\tp_target_v_id = {$village->getId()},\n\t\t\t\tp_caster_x = {$loc1[0]},\n\t\t\t\tp_caster_y = {$loc1[1]},\n\t\t\t\tp_target_x = {$loc2[0]},\n\t\t\t\tp_target_y = {$loc2[1]},\n\t\t\t\tp_caster_b_id = {$loc1[2]},\n\t\t\t\tp_target_b_id = {$loc2[2]},\n\t\t\t\tp_endDate = FROM_UNIXTIME({$date})\n\t\t");
     $logs = Dolumar_Players_Logs::getInstance();
     $logs->addOpenPortalLog($this->village, $village, $date);
 }
Ejemplo n.º 3
0
 public function getContent()
 {
     if (!$this->objVillage) {
         $text = Neuron_Core_Text::__getInstance();
         return '<p class="false">' . $text->get('login', 'login', 'account') . '</p>';
     }
     $input = $this->getInputData();
     // Get logs from this village
     $objLogs = Dolumar_Players_Logs::__getInstance();
     $iPage = isset($input['page']) ? $input['page'] : 0;
     $page = new Neuron_Core_Template();
     // Split in pages
     $limit = Neuron_Core_Tools::splitInPages($page, $objLogs->countLogs($this->objVillage), $iPage, 10);
     $objLogs->addMyVillage($this->objVillage);
     $logs = $objLogs->getLogs($this->objVillage, $limit['start'], $limit['perpage'], 'DESC');
     return $this->getLogHTML($page, $objLogs, $logs);
 }
Ejemplo n.º 4
0
 public function getBody()
 {
     $player = Neuron_GameServer::getPlayer();
     if (!$player->isModerator()) {
         return '<p>You don\'t have the rights to access the player logs.</p>';
     }
     $page = new Neuron_Core_Template();
     // Let's find the players
     $input = Neuron_Core_Tools::getInput('_GET', 'players', 'varchar');
     $playerids = explode('|', $input);
     $players = array();
     $villages = array();
     $ids = array();
     $i = 0;
     foreach ($playerids as $v) {
         $player = Neuron_GameServer::getPlayer($v);
         if ($player) {
             $players[] = $player;
             $villages = array_merge($villages, $player->getVillages());
             $ids[$player->getId()] = $i;
             $page->addListValue('players', array('key' => $i, 'id' => $player->getId(), 'name' => $player->getName(), 'url' => $this->getUrl('user', array('id' => $player->getId()))));
             $i++;
         }
     }
     $pageid = max(0, intval(Neuron_Core_Tools::getInput('_GET', 'page', 'int', 1)) - 1);
     $objLogs = Dolumar_Players_Logs::getInstance();
     $logs = $objLogs->getLogs($villages, $pageid * 250, 250, 'DESC');
     foreach ($logs as $v) {
         $player = Dolumar_Players_Village::getFromId($v['village'])->getOwner();
         // Check if this is an important log.
         $bImportant = $this->isImportantLog($players, $v);
         $page->addListValue('logs', array('action' => $objLogs->getLogText($v, false), 'date' => date(DATETIME, $v['timestamp']), 'player' => $player->getName(), 'url' => $this->getUrl('user', array('id' => $player->getId())), 'key' => $ids[$player->getId()], 'important' => $bImportant ? 'important' : null));
     }
     $page->set('page', $pageid + 1);
     if (count($logs) == 250) {
         $page->set('nextpage', $this->getUrl('gamelogs', array('players' => $input, 'page' => $pageid + 2)));
     }
     if ($pageid > 0) {
         $page->set('previouspage', $this->getUrl('gamelogs', array('players' => $input, 'page' => $pageid)));
     }
     return $page->parse('pages/admin/gamelogs.phpt');
 }
Ejemplo n.º 5
0
 public function getBody()
 {
     $timeframe = Neuron_Core_Tools::getInput('_GET', 'timeframe', 'int', 60 * 60 * 48);
     $page = new Neuron_Core_Template();
     $page->set('timeframe', $timeframe);
     $objLogs = Dolumar_Players_Logs::getInstance();
     $objLogs->setTimeInterval(NOW - $timeframe, NOW);
     $pageid = Neuron_Core_Tools::getInput('_GET', 'page', 'int', 1);
     $limit = Neuron_Core_Tools::splitInPages($page, $objLogs->getSuspiciousLogsCounter(), $pageid, self::SUSPICIOUS_TRANSACTIONS_PERPAGE, 7, array('timeframe' => $timeframe), 'multis');
     //print_r ($limit);
     //$logs = $objLogs->getSuspiciousLogs ();
     $logs = $objLogs->getSuspiciousLogs($limit['start'], $limit['perpage'], 'DESC');
     foreach ($logs as $v) {
         $player = Dolumar_Players_Village::getFromId($v['village'])->getOwner();
         $page->addListValue('logs', array('action' => $objLogs->getLogText($v, false), 'date' => date(DATETIME, $v['timestamp']), 'player' => $player->getDisplayName()));
     }
     // Output the shizzle
     $html = $page->parse('dolumar/pages/admin/multis/dangeroustransactions.phpt');
     $html .= parent::getBody();
     return $html;
 }
Ejemplo n.º 6
0
 private function getBattleOverview()
 {
     //$db = Neuron_Core_Database::__getInstance ();
     $text = Neuron_Core_Text::__getInstance();
     $text->setSection('overview');
     $text->setFile('battle');
     $input = $this->getInputData();
     // Get logs from this village
     $objLogs = Dolumar_Players_Logs::getInstance();
     $objLogs->addShowOnly('attack');
     $objLogs->addShowOnly('defend');
     $iPage = isset($input['page']) ? $input['page'] : 0;
     $page = new Neuron_Core_Template();
     // Split in pages
     $limit = Neuron_Core_Tools::splitInPages($page, $objLogs->countLogs($this->village), $iPage, 10);
     $objLogs->addMyVillage($this->village);
     $logs = $objLogs->getLogs($this->village, $limit['start'], $limit['perpage'], 'DESC');
     $loghtml = $this->getLogHTML($page, $objLogs, $logs);
     $output = new Neuron_Core_Template();
     $output->set('vid', $this->village->getId());
     $output->set('title', $text->get('overview'));
     $output->set('loghtml', $loghtml);
     return $output->parse('battle/overview.tpl');
 }
Ejemplo n.º 7
0
 protected function doCastSpell($objUnit, $objSpell, $objTarget, $visible = true)
 {
     // Just feed the random number generator, just to be sure.
     mt_srand();
     $page = new Neuron_Core_Template();
     $text = Neuron_Core_Text::getInstance();
     $page->setTextSection('result', $this->sTextFile);
     // Now let's start the checking
     $cost = $objSpell->getCost($objUnit, $objTarget);
     if ($this->village->resources->takeResourcesAndRunes($cost)) {
         $dif = $this->getProbability($objUnit, $objSpell, $objTarget);
         $rand = mt_rand(0, 100);
         $objSpell->setVillage($this->village);
         $objSpell->setTarget($objTarget);
         $objSpell->prepare();
         // Some spells are not castable for some reason.
         if (!$objSpell->isCastable()) {
             $page->set('success', false);
             $page->set('message', $text->get($objSpell->getError(), 'errors', $this->sTextFile));
         } else {
             if ($rand < $dif) {
                 $objSpell->execute($visible);
                 reloadStatusCounters();
                 $page->set('success', true);
                 $page->set('message', $objSpell->getSuccessMessage());
                 // Call the trigger!
                 $objUnit->onSuccess();
                 // Update request data (to return to overview)
                 //$this->updateRequestData (array ('building' => $'village' => $this->village->getId ()));
                 $page->set('extra', $objSpell->getExtraContent());
                 $success = true;
             } else {
                 $page->set('success', false);
                 $page->set('message', $objSpell->getFailedMessage());
                 // Call the trigger!
                 $objUnit->onFail();
                 if ($objUnit->isAlive()) {
                     $page->set('retry', true);
                     $page->set('inputData', $this->getInputData());
                 }
                 $success = false;
             }
             $toTarget = $success || !$visible;
             if (!$success) {
                 $visible = true;
             }
             $objTarget = $objSpell->getTarget();
             $log = Dolumar_Players_Logs::getInstance();
             $log->addEffectLog($objTarget, $objSpell, $this->village, $success, $visible, $toTarget, $this->sTextFile);
             reloadEverything();
         }
     } else {
         $page->set('success', false);
         $page->set('error', 'err_resources');
     }
     return $page->parse('magic/result.phpt');
 }
Ejemplo n.º 8
0
 private function canMoveVillage(Dolumar_Players_Village $village)
 {
     // Fetch logs
     $objLogs = Dolumar_Players_Logs::getInstance();
     $objLogs->clearFilters();
     $objLogs->addShowOnly('premium_movevillage');
     $objLogs->setTimeInterval(time() - 60 * 60 * self::MIN_MOVEVILLAGE_INTERVAL_DAYS);
     $logs = $objLogs->getLogs($village, 0, 5, 'DESC');
     if (count($logs) > 0) {
         return false;
     }
     return true;
 }
Ejemplo n.º 9
0
 public function trainUnits($unit, $amount, $building)
 {
     $db = Neuron_Core_Database::__getInstance();
     $duration = floor($unit->getTrainingDuration($this) * $amount);
     $db->insert('villages_units', array('vid' => $this->getId(), 'unitId' => $unit->getUnitId(), 'buildingId' => $building->getBuildingId(), 'bid' => $building->getId(), 'amount' => $amount, 'village' => $this->getId(), 'startTraining' => time(), 'endTraining' => time() + $duration));
     // Log
     $objLogs = Dolumar_Players_Logs::__getInstance();
     $objLogs->addUnitTrained($this, $unit, $amount);
     reloadStatusCounters();
 }
Ejemplo n.º 10
0
 public function increaseBuildingLevel($building, $setToMax = false)
 {
     $this->loadBuildingLevels();
     $db = Neuron_Core_Database::__getInstance();
     $id = $building->getBuildingId();
     if ($setToMax) {
         $u = $db->update('villages_blevel', array('lvl' => $setToMax), "vid = '" . $this->objMember->getId() . "' AND bid = '{$id}' AND lvl < '" . $setToMax . "'");
     } else {
         $u = $db->update('villages_blevel', array('lvl' => '++'), "vid = '" . $this->objMember->getId() . "' AND bid = '{$id}'");
     }
     if ($u == 0) {
         $chk = $db->select('villages_blevel', array('lvl'), "vid = '" . $this->objMember->getId() . "' AND bid = '{$id}'");
         if (count($chk) == 0) {
             $db->insert('villages_blevel', array('vid' => $this->objMember->getId(), 'bid' => $id, 'lvl' => 1));
         }
     }
     if (isset($this->buildingLevels[$id])) {
         $this->buildingLevels[$id]++;
     }
     $this->objMember->recalculateNetworth();
     // Add log
     $objLogs = Dolumar_Players_Logs::__getInstance();
     $objLogs->addUpgradeBuilding($this->objMember, $building);
 }
Ejemplo n.º 11
0
 public function invitationGiftSender($data, Neuron_GameServer_Player $to)
 {
     $village = $this->getMainVillage();
     if ($village) {
         $data = array();
         $data['to'] = $to;
         Dolumar_Players_Logs::getInstance()->addLog($village, 'invitegift_received', $data, true);
     }
 }
Ejemplo n.º 12
0
 public function fillAll()
 {
     $capacity = $this->getCapacity();
     $resources = $this->getResources();
     $toAdd = array();
     foreach ($resources as $v => $n) {
         $toAdd[$v] = $capacity[$v] - $resources[$v];
         if ($toAdd[$v] < 0) {
             $toAdd[$v] = 0;
         }
     }
     $this->giveResources($toAdd);
     $objLogs = Dolumar_Players_Logs::__getInstance();
     $objLogs->addPremiumResourcesBoughtLog($this->objMember, $toAdd);
 }
Ejemplo n.º 13
0
 public function transferEquipment(Dolumar_Players_Village $objTarget, Dolumar_Players_Equipment $objEquipment, $amount, $delay = 0)
 {
     if ($this->removeEquipment($objEquipment, $amount)) {
         if ($objTarget->equipment->addEquipment($objEquipment, $amount, $delay, $this->objProfile)) {
             $objLogs = Dolumar_Players_Logs::__getInstance();
             $objLogs->addEquipmentTransferLog($this->objProfile, $objTarget, $objEquipment, $amount);
             return true;
         }
     }
     $this->error = 'dont_have_equipment';
     return false;
 }
Ejemplo n.º 14
0
 public function trainTechnology($technology)
 {
     $db = Neuron_Core_Database::__getInstance();
     // Fetch technology id
     $techIds = $db->select('technology', array('techId'), "techName = '" . $db->escape($technology->getString()) . "'");
     if (count($techIds) == 0) {
         $techId = $db->insert('technology', array('techName' => $technology->getString()));
     } else {
         $techId = $techIds[0]['techId'];
     }
     $db->insert('villages_tech', array('vid' => $this->objProfile->getId(), 'techId' => $techId, 'startDate' => time(), 'endDate' => time() + $technology->getDuration()));
     $objLogs = Dolumar_Players_Logs::__getInstance();
     $objLogs->addResearchDone($this->objProfile, $technology);
     reloadStatusCounters();
     return true;
 }
Ejemplo n.º 15
0
 private static function getObjectsFromLog($data)
 {
     return Dolumar_Players_Logs::getObjectsFromLog($data);
 }
Ejemplo n.º 16
0
 public function leaveClan($user, $action = 'leave')
 {
     $db = Neuron_DB_Database::__getInstance();
     $db->query("\n\t\t\tUPDATE\n\t\t\t\tclan_members\n\t\t\tSET\n\t\t\t\tcm_active = 0\n\t\t\tWHERE\n\t\t\t\tc_id = " . $this->getId() . " AND \n\t\t\t\tplid = " . $user->getId() . "\n\t\t");
     $logs = Dolumar_Players_Logs::getInstance();
     $logs->addLeaveClanLog($user, $this, $action);
     $this->recalculateFullness();
     // Also destroy all clan buildings
     foreach ($user->getVillages() as $v) {
         foreach ($v->buildings->getBuildings() as $vv) {
             $vv->onClanLeave();
         }
     }
 }
Ejemplo n.º 17
0
 public function withdraw()
 {
     if ($this->canWithdraw()) {
         // Logs
         $logs = Dolumar_Players_Logs::getInstance();
         $logs->addWithdrawBattle($this);
         $db = Neuron_Core_Database::__getInstance();
         //$battle = $this->getData ();
         // Calculate the "return home" time
         $duration = NOW - $this->getStartDate();
         // Double return time
         $duration = $duration * 2;
         //die ('duration: '. $duration);
         // Update mysql
         $db->update('battle', array('isFought' => 1, 'arriveDate' => NOW - 1, 'endDate' => NOW + $duration, 'fightDate' => NOW - 1, 'endFightDate' => NOW - 1, 'bLogId' => 0), "battleId = '{$this->getId()}'");
         $this->reloadData();
         // Removal
         //$this->doRemoveBattle ();
     }
 }
Ejemplo n.º 18
0
     include 'ranking.php';
     exit;
     break;
 case 'rss':
     $text = Neuron_Core_Text::__getInstance();
     $output_type = 'xml';
     $xml_name = 'rss';
     $xml_version = '2.0';
     // Check for login
     if ($login->isLogin()) {
         $myself = Neuron_GameServer::getPlayer();
         $output['content']['channel'] = array();
         $output['content']['title'] = Neuron_Core_Tools::putIntoText($text->get('rss_title', 'main', 'main'), array('username' => Neuron_Core_Tools::output_varchar($myself->getName())));
         $output['content']['link'] = ABSOLUTE_URL;
         $output['content']['description'] = 'Player logs';
         $objLogs = Dolumar_Players_Logs::__getInstance();
         // Only village
         //$village = $myself->getMainVillage ();
         //if ($village) {
         foreach ($objLogs->getLogs($myself, 0, 50, 'DESC', false) as $v) {
             // <pubDate>Sun, 19 May 2002 15:21:36 GMT</pubDate>
             $output['content']['items'][] = array('title' => $objLogs->getLogText($v, false, false), 'link' => ABSOLUTE_URL, 'description' => null, 'pubDate' => gmdate('r', $v['unixtime']));
         }
         //}
     } else {
         header('WWW-Authenticate: Basic realm="Profile Logs"');
         header('HTTP/1.0 401 Unauthorized');
         echo 'Please login to access your profile logs.';
         exit;
     }
     break;
Ejemplo n.º 19
0
 private function getFreshData()
 {
     // FIRST! Update the content.
     $this->updateContent();
     // Check the latest logs for notifications
     $me = Neuron_GameServer::getPlayer();
     if ($me) {
         $objLogs = Dolumar_Players_Logs::__getInstance();
         // Data
         $data = $this->getRequestData();
         $lastLogId = isset($data['lastLog']) ? $data['lastLog'] : $objLogs->getLastLogId();
         $logs = array();
         $villages = $me->getVillages();
         foreach ($villages as $v) {
             $logs = array_merge($logs, $objLogs->getLastLogs($v, $lastLogId, true));
         }
         // Update the last data
         if (count($logs) > 0) {
             // You can only show one log, so let's show the first one.
             $this->showNewsflash($objLogs->getLogText($logs[0]));
             // Check for reload actions
             foreach ($logs as $v) {
                 switch ($v['action']) {
                     case 'premium_movevillage':
                     case 'premium_movebuilding':
                     case 'premium_bonusbuild':
                         $this->reloadMap();
                         break;
                 }
             }
         }
         // Update the data
         $data['lastLog'] = $objLogs->getLastLogId();
         $this->updateRequestData($data);
     }
 }