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); }
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;
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); }
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; }
public function execute() { $db = Neuron_Core_Database::__getInstance(); $this->loadData(); // Check if there are survivors $doesGoHome = true; // Check for delay! $chk = $db->select('battle', array('MAX(endFightDate) AS maxEndFightDate,COUNT(battleId) AS amPendingBattles'), "arriveDate < " . $this->data['arriveDate'] . " AND targetId = " . $this->data['targetId']); if ($chk[0]['maxEndFightDate'] > $this->data['fightDate']) { // Delay this battle! $this->delayFightDate($chk[0]['maxEndFightDate'], $chk[0]['amPendingBattles']); return false; } else { // Update honouer $this->updateHonour($this->attackingVillage, $this->defendingVillage); // Defending village $this->defendingVillage->clearEffects(); $this->defendingVillage->addEffect(new Dolumar_Effects_Boost_TowerBonus($this->getDefendBonus() / 100)); $profiler = Neuron_Profiler_Profiler::__getInstance(); $profiler->start('Fighting battle ' . $this->data['battleId']); $battle = $this->data; if ($battle['attackType'] == 'attack') { // Load the attack slots //$slots = $this->attackingVillage->getAttackSlots ($this->defendingVillage); $slots = $this->defendingVillage->getDefenseSlots($battle['iBattleSlots']); // Load attacking troops $squads = $db->select('battle_squads', array('*'), "bs_bid = {$battle['battleId']}"); $attacking = array(); foreach ($squads as $v) { $squad = $this->getSquad($v['bs_squadId']); $unit = $squad->getUnit($v['bs_unitId']); if ($unit && isset($slots[$v['bs_slot']])) { $attacking[$v['bs_slot']] = $unit; $attacking[$v['bs_slot']]->setBattleSlot($slots[$v['bs_slot']]); } } // Load defending units $defending = $this->defendingVillage->getDefendingUnits($this->data['fightDate'], $battle['iBattleSlots']); // Let's do the fight $fight = new Dolumar_Battle_Fight($this->attackingVillage, $this->defendingVillage, $attacking, $defending, $slots, $this->getSpecialUnits(), $this->objLogger); $fightLog = $this->killAndLog($fight); $resultLog = json_encode($this->takeAndDestroy($fight)); $this->logId = $db->insert('battle_report', array('fightDate' => $battle['fightDate'], 'fightDuration' => $this->objLogger->getDuration(), 'battleId' => $battle['battleId'], 'fromId' => $this->attackingVillage->getId(), 'targetId' => $this->defendingVillage->getId(), 'fightLog' => $fightLog, 'resultLog' => $resultLog, 'battleLog' => $this->objLogger->getFightLog(), 'squads' => $this->objLogger->getSquads(), 'slots' => $this->objLogger->getInitialSlots($battle['iBattleSlots']), 'victory' => $fight->getResult(), 'specialUnits' => $this->objLogger->getSpecialUnits(), 'execDate' => 'NOW()')); if ($this->objLogger->getAttackingArmy()->getKilledPercentage() >= 100) { $doesGoHome = false; } //mail ('*****@*****.**', 'Battle test', $fightLog); // Add log $objLogs = Dolumar_Players_Logs::__getInstance(); $objLogs->addBattleReport($this); $fight->__destruct(); unset($fight); } $duration = $this->objLogger->getDuration(); // Update local data $this->data['isFought'] = 1; $this->data['endFightDate'] = $this->data['fightDate'] + $duration; // Check if there are survivors if ($doesGoHome) { $this->data['endDate'] = $this->data['endFightDate'] + $this->data['goHomeDuration']; } else { $this->data['endDate'] = $this->data['endFightDate'] + 1; } $this->data['bLogId'] = $this->logId; // Update mysql $db->update('battle', array('isFought' => 1, 'endDate' => $this->data['endDate'], 'endFightDate' => $this->data['endFightDate'], 'bLogId' => $this->logId), "battleId = '{$battle['battleId']}'"); // Reload units $this->attackingVillage->reloadUnits(); $this->defendingVillage->reloadUnits(); $this->defendingVillage->recalculateNetworth(); $this->defendingVillage->onBattleFought($this); $this->attackingVillage->onBattleFought($this); $profiler->stop(); } }
public function giveReferralBonus($objUser) { $village = $this->getMainVillage(); if ($village) { $runes = Neuron_Core_Tools::getRandomRuneOptions(); shuffle($runes); $randomRune = $runes[0]; $runes = array(); $runes[$randomRune] = 1; $village->resources->giveRunes($runes); // Make it a log $objLogs = Dolumar_Players_Logs::__getInstance(); $objLogs->addReferreeBonusLog($village, $objUser, $runes); } }
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); }
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; }
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(); }
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); } }