コード例 #1
0
 public function getContent($error = null)
 {
     $text = Neuron_Core_Text::__getInstance();
     $text->setFile('account');
     $text->setSection('premium');
     $player = Neuron_GameServer::getPlayer();
     if (!$player) {
         return '<p class="false">' . $text->get('login', 'login', 'account') . '</p>';
     }
     $openid = isset($_SESSION['neuron_openid_identity']) ? md5($_SESSION['neuron_openid_identity']) : false;
     if ($player && $player->isFound() && ($player->isEmailCertified() || $openid)) {
         $page = new Neuron_Core_Template();
         // Premium account stuff
         $page->set('premium', $text->get('premium', 'myAccount'));
         if ($player->isPremium()) {
             $page->set('premiumLast', Neuron_Core_Tools::putIntoText($text->get('premiumLast', 'myAccount'), array(date(DATETIME, $player->getPremiumEndDate()))));
             $page->set('extend2', $text->getClickTo($text->get('toPremium', 'myAccount')));
         } else {
             $page->set('notPremium1', $text->get('notPremium', 'myAccount'));
             $page->set('notPremium2', $text->getClickTo($text->get('toPremium', 'myAccount')));
         }
         $page->set('toUse', $text->getClickTo(Neuron_Core_Tools::putIntoText($text->get('toUseCredit'), array('amount' => PREMIUM_COST_CREDITS))));
         $page->set('extend_url', htmlentities($player->getCreditUseUrl(PREMIUM_COST_CREDITS)));
         $page->set('benefits', $this->getBenefits());
         if (!empty($error)) {
             $page->set('error', $text->get($error));
         }
         return $page->parse('gameserver/account/premium.tpl');
     } elseif ($player->isFound()) {
         return '<p>' . $text->get('validateEmail') . '</p>';
     }
 }
コード例 #2
0
ファイル: ClanForum.php プロジェクト: Toxicat/dolumar
 protected function getForum()
 {
     $requestData = $this->getRequestData();
     if (isset($requestData['clan'])) {
         $clan = new Dolumar_Players_Clan($requestData['clan']);
         if ($clan) {
             $login = Neuron_Core_Login::__getInstance();
             if ($login->isLogin()) {
                 $me = Neuron_GameServer::getPlayer();
                 $isMember = $clan->isMember($me);
                 $isModerator = $clan->isModerator($me);
                 //__construct ($iForumType, $iForumId, $objUser = false, $bCanSeeAll = false, $bIsModerator = false)
                 $forum = new Neuron_Forum_Forum(1, $clan->getId(), $me, $isMember, $isModerator);
             } else {
                 $forum = new Neuron_Forum_Forum(1, $clan->getId(), false, false, false);
             }
             // Fetch thze title
             $text = Neuron_Core_Text::__getInstance();
             $forum->setTitle(Neuron_Core_Tools::putIntoText($text->get('title', 'forum', 'clan'), array('clan' => Neuron_Core_Tools::output_varchar($clan->getName()))));
             return $forum;
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
コード例 #3
0
ファイル: Clan.php プロジェクト: Toxicat/dolumar
 public function getDescription($tags = true)
 {
     $this->loadData();
     if ($tags) {
         return Neuron_Core_Tools::putIntoText($this->data['c_description'], array('clan' => $this->getName(), 'members' => count($this->getMembers())));
     } else {
         return $this->data['c_description'];
     }
 }
コード例 #4
0
ファイル: OldMessages.php プロジェクト: Toxicat/dolumar
 public function getContent()
 {
     // Fetch thze model
     $login = Neuron_Core_Login::__getInstance();
     $text = Neuron_Core_Text::__getInstance();
     if ($login->isLogin()) {
         $player = Neuron_GameServer::getPlayer();
         if ($player->isBanned('messages')) {
             $end = $player->getBanDuration('messages');
             $duration = Neuron_Core_Tools::getCountdown($end);
             return '<p class="false">' . Neuron_Core_Tools::putIntoText($text->get('banned', 'messages', 'messages'), array('duration' => $duration)) . '</p>';
         } elseif (!$player->isEmailVerified()) {
             return '<p class="false">' . $text->get('validateEmail', 'main', 'account') . '</p>';
         } else {
             $objMessages = new Neuron_Structure_Messages($player);
             return $objMessages->getPageHTML($this->getInputData());
         }
     } else {
         $this->throwError($text->get('noLogin', 'main', 'main'));
     }
 }
コード例 #5
0
ファイル: Battle.php プロジェクト: Toxicat/dolumar
 private function getChooseUnits($target, $error = null)
 {
     $text = Neuron_Core_Text::__getInstance();
     $text->setFile('battle');
     $text->setSection('challenge');
     $page = new Neuron_Core_Template();
     $page->set('target', Neuron_Core_Tools::output_varchar($target->getName()));
     $page->set('action', 'attack');
     $page->set('target_id', $target->getId());
     $showForm = true;
     if ($target->getOwner()->equals($this->village->getOwner())) {
         $page->set('error', $text->get('ownVillage'));
         $showForm = false;
     }
     $page->set('showForm', $showForm);
     foreach ($this->village->getAttackSlots($target) as $k => $v) {
         $page->addListValue('slots', array('id' => $k, 'sType' => $text->get($v->getName(), 'slots', 'battle'), 'sName' => $v->getName()));
     }
     if (!empty($error)) {
         $page->set('error', $text->get($error));
     }
     $page->set('challenge', Neuron_Core_Tools::putIntoText($text->get('challenge'), array(Neuron_Core_Tools::output_varchar($target->getName()))));
     // Calculate distance
     $afstand = Dolumar_Map_Map::getDistanceBetweenVillages($this->village, $target, false);
     $page->set('distance', Neuron_Core_Tools::putIntoText($text->get('distance'), array(Neuron_Core_Tools::output_distance($afstand))));
     // Make a list of available squads
     $squads = $this->getSquads();
     foreach ($squads as $v) {
         if ($v->getUnitsAmount() > 0) {
             $page->addListValue('squads', array('sName' => Neuron_Core_Tools::output_varchar($v->getName()), 'oUnits' => $v->getUnits(), 'id' => $v->getId()));
         }
     }
     // Sort the list
     $page->sortList('units');
     if (isset($this->error)) {
         $page->set('error', $this->error);
     }
     return $page->parse('battle/chooseUnits.tpl');
 }
コード例 #6
0
 public function DoQuote($bbcode, $action, $name, $default, $params, $content)
 {
     if ($action == BBCODE_CHECK) {
         return true;
     }
     $text = Neuron_Core_Text::getInstance();
     $txtname = 'quote';
     $txtparams = array();
     if (isset($params['name'])) {
         $txtparams['name'] = htmlspecialchars(trim($params['name']));
         $txtname .= '_wrote';
         if (isset($params['date'])) {
             $date = strtotime($params['date']);
             $txtparams['date'] = date(DATETIME, $date);
             $txtname .= '_date';
         }
     } else {
         if (!is_string($default)) {
             // Do nothing
         } else {
             $txtparams['name'] = htmlspecialchars(trim($default));
             $txtname .= '_wrote';
         }
     }
     $title = Neuron_Core_Tools::putIntoText($text->get($txtname, 'textconvert', 'main', ""), $txtparams);
     $out = "\n<blockquote class=\"bbcode_quote\">\n";
     if (!empty($title)) {
         $out .= "<h4 class=\"bbcode_quote_head\">" . $title . "</h4>\n";
     }
     $out .= "<div class=\"bbcode_quote_body\">" . $content . "</div>\n</blockquote>\n";
     return $out;
 }
コード例 #7
0
ファイル: Market.php プロジェクト: Toxicat/dolumar
 private function getChooseAmount($target)
 {
     $page = new Neuron_Core_Template();
     $text = Neuron_Core_Text::getInstance();
     $tab = isset($this->aInput['tab']) ? $this->aInput['tab'] : 'resources';
     switch ($tab) {
         case 'resources':
         case 'runes':
         case 'equipment':
             break;
         default:
             $tab = 'resources';
             break;
     }
     $this->setTabUrl($page, 'resources', $target);
     $this->setTabUrl($page, 'runes', $target);
     $this->setTabUrl($page, 'equipment', $target);
     $page->set('target', $target->getId());
     $page->set('tab', $tab);
     switch ($tab) {
         case 'resources':
             $res = $this->getVillage()->resources->getResources();
             foreach ($res as $k => $v) {
                 $page->addListValue('resources', array('name' => $k, 'amount' => 0, 'available' => $v));
             }
             break;
         case 'runes':
             $runes = $this->getVillage()->resources->getRunes();
             foreach ($runes as $k => $v) {
                 $page->addListValue('runes', array('name' => $k, 'amount' => 0, 'available' => $v));
             }
             break;
         case 'equipment':
             $equipment = $this->getVillage()->equipment->getEquipment();
             $output = array();
             foreach ($equipment as $type => $vv) {
                 $output[$type] = array('name' => $text->get($type, 'types', 'equipment'), 'equipment' => array());
                 foreach ($vv as $v) {
                     $output[$type]['equipment'][] = array('id' => $v->getId(), 'name' => $v->getName(true), 'amount' => 0, 'available' => $v->getAmount(), 'formid' => 'equipment_' . $v->getId());
                 }
             }
             $page->set('equipment', $output);
             break;
     }
     $page->set('canTrade', $this->isValidTarget($target, $tab));
     $page->set('tradeerror', Neuron_Core_Tools::putIntoText($text->get($this->sError, 'market', 'buildings', $this->sError), array('percentage' => self::MAX_PERCENTAGE)));
     return $page->parse('buildings/market.phpt');
 }
コード例 #8
0
ファイル: Building.php プロジェクト: Toxicat/dolumar
 private function showUpgradeContent($error = null, $errorA = array())
 {
     $text = Neuron_Core_Text::__getInstance();
     $page = new Neuron_Core_Template();
     $input = $this->objWindow->getInputData();
     $lvl = $this->getLevel();
     if (!empty($error)) {
         if ($error == 'unfinished') {
             $errorA = array(Neuron_Core_Tools::getCountdown(max($this->data['lastUpgradeDate'], $this->data['readyDate'])));
         }
     } elseif (!$this->getVillage()->readyToBuild()) {
         $error = 'busy';
     } elseif (!$this->isFinished()) {
         $error = 'unfinished';
         $errorA = array(Neuron_Core_Tools::getCountdown(max($this->data['lastUpgradeDate'], $this->data['readyDate'])));
     }
     if (!empty($error)) {
         $txterr = Neuron_Core_Tools::putIntoText($text->get($error, 'upgradeError', 'building'), $errorA);
         $jsondata = json_encode(array('page' => 'upgrade', 'queue' => 'true', 'upgrade' => 'confirm', 'runeSelection' => isset($input['runeSelection']) ? $input['runeSelection'] : null));
         $page->set('error', $txterr);
         $page->set('errorV', $error);
         if ($error != 'done' && isset($input['upgrade'])) {
             $this->objWindow->dialog($txterr, $text->get('queueUpgrade', 'queue', 'building'), 'windowAction (this, ' . $jsondata . ');', $text->get('okay', 'main', 'main'), 'void(0);');
         }
     }
     $page->set('about', $text->get('about', 'upgrade', 'building'));
     $page->set('upgrade', $text->get('upgrade', 'upgrade', 'building'));
     $page->set('cost', $text->get('cost', 'upgrade', 'building'));
     $page->set('duration', Neuron_Core_Tools::getDurationText($this->getUpgradeTime($this->getVillage())));
     $page->set('info', $this->getUpgradeInformation());
     $page->set('upgradeAll', Neuron_Core_Tools::putIntoText($text->get('upgradeAll', 'upgrade', 'building'), array($this->getName(true))));
     $page->set('upgradeLink', Neuron_Core_Tools::putIntoText($text->get('startUpgrade', 'upgrade', 'building'), array($this->getName(true), $lvl + 1)));
     $upgrade = $this->getUpgradeCost_text($this->getVillage(), true);
     $page->set('upgradeCost', $upgrade);
     $page->set('back', $text->getClickTo($text->get('back', 'building', 'building')));
     return $page->parse('buildings/general_upgrade.tpl');
 }
コード例 #9
0
 public function processInput()
 {
     $text = Neuron_Core_Text::__getInstance();
     $text->setFile('chat');
     $text->setSection('chat');
     $login = Neuron_Core_Login::__getInstance();
     $input = $this->getRequestData();
     if (!isset($input['channel'])) {
         $this->switchChannel($this->getDefaultChannel());
     } else {
         $this->channel = intval($input['channel']);
     }
     $input = $this->getInputData();
     if ($login->isLogin()) {
         if (isset($input['message'])) {
             $message = trim($input['message']);
             if (!empty($message)) {
                 $user = Neuron_GameServer::getPlayer();
                 if (!$user->isPlaying()) {
                     $this->alert($text->get('registerfirst'));
                 } elseif (!$user->isEmailVerified()) {
                     $this->alert($text->get('validateEmail_short', 'main', 'account'));
                 } elseif ($user->isBanned('chat')) {
                     $end = $user->getBanDuration('chat');
                     $duration = Neuron_Core_Tools::getCountdown($end);
                     $this->alert(Neuron_Core_Tools::putIntoText($text->get('banned'), array('duration' => $duration)));
                 } else {
                     // Post message
                     $this->postMessage($input['message']);
                 }
             }
         }
     } else {
         $this->alert($text->get('login'));
     }
 }
コード例 #10
0
ファイル: Speedup.php プロジェクト: Toxicat/dolumar
 private function getSpeedUpBuilding($data)
 {
     $text = Neuron_Core_Text::getInstance();
     $inputData = $this->getInputData();
     $id = isset($data['building']) ? $data['building'] : null;
     $building = Dolumar_Buildings_Building::getFromId($id);
     if (!$building) {
         return '<p>Invalid input: building not found: ' . $id . '</p>';
     }
     $price = PREMIUM_SPEEDUP_BUILDINGS_PRICE;
     $unit = PREMIUM_SPEEDUP_BUILDINGS_UNIT;
     if (isset($inputData['duration'])) {
         $selected = abs(intval($inputData['duration']));
         $desc = Neuron_Core_Tools::putIntoText($text->get('confdesc_building', 'speedup', 'statusbar'), array('building' => $building->getName(), 'amount' => Neuron_Core_Tools::getDurationText($selected * $unit)));
         return $this->getConfirm($price, $unit, $selected, $desc);
     }
     $time = $building->getTimeLeft();
     return $this->getSpeedUpHTML('building', $time, $price, $unit);
 }
コード例 #11
0
ファイル: Build.php プロジェクト: Toxicat/dolumar
 public function getContent($errorInput = null, $putIntoText = array())
 {
     // Keep original value in seperate variable!
     $error = $errorInput;
     $text = Neuron_Core_Text::__getInstance();
     $login = Neuron_Core_Login::__getInstance();
     $me = Neuron_GameServer::getPlayer();
     $input = $this->getInputData();
     if ($login->isLogin() && $this->village && $this->village->isActive() && $this->village->getOwner()->getId() == $me->getId()) {
         // Make sure you are not in vacation mode.
         if ($this->village->getOwner()->inVacationMode()) {
             return '<p class="false">' . $text->get('vacationMode', 'main', 'main') . '</p>';
         }
         $page = new Neuron_Core_Template();
         $page->set('intro', $text->get('intro', 'build', 'building'));
         $page->set('construct', $text->get('construct', 'build', 'building'));
         $page->set('click', $text->get('click', 'build', 'building'));
         $selectrunewarning = addslashes($text->get('selectRune', 'build', 'building'));
         $page->set('selectRune', $selectrunewarning);
         $page->set('village', $this->village->getId());
         // Workers are working.
         if (!isset($error) && !$this->village->readyToBuild()) {
             $error = 'stillConstructing';
         }
         // Show error.
         if (isset($error)) {
             $txterr = Neuron_Core_Tools::putIntoText($text->get($error, 'buildError', 'building'), $putIntoText);
             $page->set('error', $txterr);
             $page->set('errorV', $error);
             if (isset($errorInput) && !empty($errorInput) && $errorInput != 'done') {
                 if ($error != 'done') {
                     switch ($error) {
                         case 'noRunes':
                         case 'noResources':
                         case 'stillConstructing':
                             $data = $this->getInputData();
                             $jsondata = json_encode(array('action' => 'queue', 'building' => $data['building'], 'x' => $data['x'], 'y' => $data['y'], 'rune' => $data['rune']));
                             $this->dialog($txterr, $text->get('queueBuild', 'queue', 'building'), 'windowAction (this, ' . $jsondata . ');', $text->get('okay', 'main', 'main'), 'void(0);');
                             break;
                         default:
                             $this->alert($txterr);
                             break;
                     }
                 }
             }
         }
         // Get all buildings (even those who can't be build)
         $buildings = Dolumar_Buildings_Building::getAllBuildings();
         $buildings_out = array();
         $race = $this->village->getRace();
         foreach ($buildings as $buildingV) {
             $building = Dolumar_Buildings_Building::getBuildingFromName($buildingV, $this->village->getRace());
             if ($building->canBuildBuilding($this->village)) {
                 $duration = $building->getConstructionTime($this->village);
                 $dur = Neuron_Core_Tools::getDuration($duration);
                 $size = $building->getSize();
                 $buildings_out[] = array($building->getName(), $building->getBuildingCost_Text($this->village), $building->getDescription(), $building->getSmallImage($race), $building->getBuildingId(), $dur, $building->getImage($this->village->getRace()), $size[0], $size[1], 'canBuild' => $building->checkBuildingLevels($this->village), 'upgrade' => Neuron_Core_Tools::putIntoText($text->get('upgradeFirst', 'build', 'building'), array('name' => $building->getName(true))), 'myBuildingsName' => $building->getName($this->village->buildings->getBuildingAmount($building) > 1), 'action' => new Dolumar_View_SelectBuildLocation($building->getBuildingId(), 'build', 'building_' . $building->getBuildingId(), $building->getDisplayObject($race), null, $selectrunewarning));
             }
         }
         // Order the list
         //$page->sortList ('buildings');
         usort($buildings_out, array($this, 'order_buildings'));
         $page->set('list_buildings', $buildings_out);
         return $page->parse('build.tpl');
     } else {
         return '<p class="false">' . $text->get('login', 'login', 'account') . '</p>';
     }
 }
コード例 #12
0
 public function putIntoText($txt, $params = array())
 {
     return Neuron_Core_Tools::putIntoText($txt, $params);
 }
コード例 #13
0
ファイル: Squads.php プロジェクト: Toxicat/dolumar
 private function getRemoveUnits($objSquad)
 {
     $text = Neuron_Core_Text::__getInstance();
     $text->setFile('squads');
     $text->setSection('removeUnits');
     $units = $objSquad->getUnits();
     $input = $this->getInputData();
     //return print_r ($units, true);
     $selectedUnits = array();
     $iCount = 0;
     foreach ($units as $v) {
         $key = 'unit_' . $v->getUnitId();
         if (isset($input[$key]) && (int) $input[$key] > 0) {
             $objSquad->removeUnits($v, (int) $input[$key], false);
             $iCount++;
         }
     }
     if ($iCount > 0) {
         $error = $objSquad->getError();
         if (!empty($error)) {
             $tError = $text->get($error);
         } else {
             $objSquad->reloadUnits();
             return $this->getSquadOverview($objSquad);
         }
         $units = $objSquad->getUnits();
     }
     $page = new Neuron_Core_Template();
     $page->set('title', $text->get('title'));
     $page->set('toReturn', $text->getClickTo($text->get('toReturn')));
     $page->set('noUnits', $text->get('noUnits'));
     $page->set('squadId', $objSquad->getId());
     $page->set('about', Neuron_Core_Tools::putIntoText($text->get('about'), array(Neuron_Core_Tools::output_varchar($objSquad->getName()))));
     if (isset($tError)) {
         $page->set('error', $tError);
     }
     foreach ($units as $v) {
         if ($v->getAmount() > 0 && $objSquad->getUnitType() == $v->getUnitId()) {
             $page->addListValue('units', array(Neuron_Core_Tools::output_varchar($v->getName()), $v->getAmount(), $v->getUnitId()));
         }
     }
     return $page->parse('squads/removeunits.tpl');
 }
コード例 #14
0
ファイル: Server.php プロジェクト: Toxicat/dolumar
 public function sendNewsletter($newsletter, $data)
 {
     $text = Neuron_Core_Text::getInstance();
     $credits = Neuron_GameServer_Credits::getPureCreditsObject();
     $plaintext = $text->getTemplate('newsletters/' . $newsletter, $data);
     $subject = Neuron_Core_Tools::putIntoText($text->get($newsletter, 'subjects', 'newsletters'), $data);
     // Now put it in html
     $page = new Neuron_Core_Template();
     $page->set('subject', $subject);
     $page->set('content', Neuron_Core_Tools::output_text($plaintext));
     $content = $page->parse('mailtemplate.phpt');
     //echo $page->parse ('mailtemplate.phpt');
     //exit;
     $credits->sendNewsletter($subject, $content, $plaintext, 'en');
 }
コード例 #15
0
ファイル: Army.php プロジェクト: Toxicat/dolumar
 private function prcAttack(Dolumar_Underworld_Models_Army $target = null)
 {
     $text = Neuron_Core_Text::getInstance();
     if (!isset($target)) {
         $target = Dolumar_Underworld_Mappers_ArmyMapper::getFromId($this->getInput('target'), $this->getServer()->getMap());
         if (!isset($target)) {
             $this->alert('Invalid input, target not found.');
         }
     }
     if (!$this->army->isEnemy($target)) {
         $this->alert('Invalid input: not an enemy.');
     }
     $confirmed = $this->getInput('confirmed');
     // Dialog to confirm
     if (!$confirmed == '1') {
         $this->dialog(Neuron_Core_Tools::putIntoText($text->get('attack', 'squad', 'underworld'), array($target->getDisplayName())), $text->get('dyes', 'main', 'main'), "windowAction (this, {'id':" . $this->army->getId() . ",'action':'attack','confirmed':1,'target':" . $target->getId() . "});", $text->get('dno', 'main', 'main'), 'void(0);');
     } else {
         if (!$this->army->attack($this->me, $target)) {
             $this->alert($this->army->getError());
         }
     }
 }
コード例 #16
0
ファイル: TownCenter.php プロジェクト: Toxicat/dolumar
 public function build($village, $x, $y, $owner = null, $race = null)
 {
     $db = Neuron_Core_Database::__getInstance();
     $text = Neuron_Core_Text::__getInstance();
     // We'll have to create a village
     if ($village != null) {
         $owner = $village->getOwner();
         $race = $village->getRace();
     }
     if (!empty($owner)) {
         // Add new Village
         // Load start resources
         $data = $this->getCapacity();
         //$name = $owner->getNickname () . $text->get ('village', 'main', 'main');
         $name = Neuron_Core_Tools::putIntoText($text->get('playervillage', 'main', 'main'), array('player' => $owner->getNickname()));
         // Count the existing villages
         $villages = count($owner->getVillages());
         if ($villages >= 1) {
             $name .= ' ' . ($villages + 1);
         }
         // Insert other datas.
         $data['vname'] = $name;
         $data['plid'] = $owner->getId();
         $data['race'] = $race->getId();
         $vid = $db->insert('villages', $data);
         $village = Dolumar_Players_Village::getVillage($vid);
         $building = parent::build($village, $x, $y, false);
         $owner->reloadVillages();
         return $building;
         //return array (true, $vid);
     } else {
         return false;
         return array(false, null);
     }
 }
コード例 #17
0
ファイル: Training.php プロジェクト: Toxicat/dolumar
 private function getChooseAmount($input, $unit)
 {
     $page = new Neuron_Core_Template();
     Dolumar_Units_Unit::printStatNames($page);
     $page->set('section', 'train');
     $text = Neuron_Core_Text::__getInstance();
     $text->setFile('buildings');
     $text->setSection('training');
     foreach ($this->myErrors as $v) {
         $page->addListValue('errors', array($text->get($v)));
     }
     // Title
     $page->set('train', $text->get('train'));
     // Only for premium users
     $player = $this->getVillage()->getOwner();
     if ($player->isPremium()) {
         $page->set('maxtrainable_value', Neuron_Core_Tools::putIntoText($text->get('maxtrainable'), array($this->calculateMaxTrainable($unit), $this->calculateOptimalTrainable($unit))));
     }
     $page->set('otherUnit', $text->getClickTo($text->get('toOtherUnit')));
     // Stats
     $stats = $unit->getStats();
     $page->set('unit', $unit->getName());
     $page->set('stats', $stats);
     $page->set('trainingCost', $text->get('trainingCost'));
     $page->set('trainingCost_value', $unit->getTrainingCost_text());
     $page->set('consCost', $text->get('consCost'));
     $page->set('consCost_value', $unit->getConsumption_text());
     $page->set('trainUnits', $text->get('trainUnits'));
     $page->set('trainSubmit', $text->get('trainSubmits'));
     $page->set('amount', $text->get('amount'));
     $page->set('unit_value', $input['unit']);
     return $page->parse('buildings/training.tpl');
 }
コード例 #18
0
 public function getTemplate($file, $fields = array())
 {
     return Neuron_Core_Tools::putIntoText($this->getFile($file), $fields);
 }
コード例 #19
0
ファイル: PlayerProfile.php プロジェクト: Toxicat/dolumar
 public function getVillageProfile($objVillage)
 {
     if (!$objVillage || !$objVillage->isFound()) {
         return '<p>Village not found.</p>';
         return null;
     }
     $text = Neuron_Core_Text::__getInstance();
     $text->setFile('village');
     $text->setSection('profile');
     $townCenter = $objVillage->buildings->getTownCenter();
     if ($townCenter) {
         $l = $townCenter->getLocation();
     } else {
         $l = array('?', '?');
     }
     $page = new Neuron_Core_Template();
     $page->set('village', Neuron_Core_Tools::output_varchar($objVillage->getName()));
     $page->set('location', $text->get('location'));
     $page->set('villageProfile', $text->get('villageProfile'));
     $page->set('location_value', '[' . $l[0] . ',' . $l[1] . ']');
     $page->set('locX', $l[0]);
     $page->set('locY', $l[1]);
     // Owner
     $owner = $objVillage->getOwner();
     $page->set('owner', $text->get('owner'));
     $page->set('owner_value', Neuron_Core_Tools::output_varchar($owner->getNickname()));
     $page->set('pid', $owner->getId());
     // Ranking
     $rank = $objVillage->getRank();
     $page->set('rank', $text->get('rank'));
     $page->set('rank_value', Neuron_Core_Tools::putIntoText($text->get('ranking'), array($rank[0], $rank[1])));
     // Race
     $race = $objVillage->getRace();
     $page->set('race', $text->get('race'));
     $page->set('race_value', Neuron_Core_Tools::output_varchar($race->getRaceName()));
     $page->set('score', $objVillage->getNetworth());
     $me = Neuron_GameServer::getPlayer();
     if ($me && $objVillage->isActive()) {
         foreach ($me->getVillages() as $v) {
             if (!$v->equals($objVillage)) {
                 // Register the visit
                 $v->visits->registerVisit($objVillage);
                 $page->addListValue('challenges', array(Neuron_Core_Tools::putIntoText($text->get('challenge'), array(Neuron_Core_Tools::output_varchar($v->getName()))), htmlentities(json_encode(array('vid' => $v->getId(), 'target' => $objVillage->getId())))));
                 $distance = Dolumar_Map_Map::getDistanceBetweenVillages($v, $objVillage);
                 $page->addListValue('distances', array('id' => $v->getId(), 'name' => Neuron_Core_Tools::output_varchar($v->getName()), 'distance' => Neuron_Core_Tools::output_distance($distance, false, false)));
             }
         }
     } elseif (!$objVillage->isActive()) {
         $page->set('notActive', $text->get('notActive'));
     }
     // Set honour
     $page->set('honour_value', $objVillage->honour->getHonour());
     return $page->parse('villageProfile.tpl');
 }
コード例 #20
0
 public function getEmailCertification()
 {
     $me = Neuron_GameServer::getPlayer();
     $text = Neuron_Core_Text::__getInstance();
     $text->setFile('account');
     $text->setSection('choosemail');
     $page = new Neuron_Core_Template();
     $page->set('welcome', Neuron_Core_Tools::putIntoText($text->get('welcome'), array(Neuron_Core_Tools::output_varchar($me->getNickname()))));
     $page->set('return', $text->getClickTo($text->get('toReturn')));
     $input = $this->getInputData();
     // Set e-mail (certification required)
     if (isset($input['email'])) {
         if (!$me->setEmail($input['email'])) {
             $page->set('error', $text->get($me->getError()));
         }
     }
     if ($me->isEmailSet()) {
         if (isset($input['action']) && $input['action'] == 'resend') {
             $me->sendCertificationMail();
             return '<p>Your verification email is sent.</p>';
         }
         $page->set('section', 'notcertified');
         $page->set('email_title', $text->get('email_title'));
         $page->set('email_about', $text->get('certification'));
         $page->set('cert_again', $text->getClickTo($text->get('toCertAgain')));
         return $page->parse('gameserver/account/myAccount_email.tpl');
     } else {
         $page->set('section', 'choosemail');
         $page->set('email_title', $text->get('email_title'));
         $page->set('email', $text->get('email'));
         $page->set('submit', $text->get('submit'));
         $page->set('about', $text->get('about'));
         return $page->parse('gameserver/account/myAccount_email.tpl');
     }
 }
コード例 #21
0
ファイル: Logs.php プロジェクト: Toxicat/dolumar
 public function getLogText($log, $showUrl = true, $html = true)
 {
     $text = Neuron_Core_Text::__getInstance();
     // Secondly: old data (but they do have nice names...)
     $data = array();
     foreach ($log as $k => $v) {
         $data[$k] = $v;
     }
     // Define an url for certain actions
     $sUrl = null;
     switch ($log['action']) {
         case 'sendMsg':
         case 'receiveMsg':
             $sUrl = "openWindow('messages');";
             break;
     }
     if (!isset($log['village'])) {
         return 'invalid log';
     }
     if (isset($log['data']) && is_array($log['data'])) {
         foreach ($log['data'] as $v) {
             if ($v instanceof Neuron_GameServer_Interfaces_Logable) {
                 if (isset($sUrl) || $html == false) {
                     $data[] = Neuron_Core_Tools::output_varchar($v->getName());
                 } else {
                     $data[] = $v->getDisplayName();
                 }
             } elseif (is_string($v) || is_int($v) || is_float($v)) {
                 $data[] = $v;
             } else {
                 $data[] = 'invalid data';
             }
         }
     }
     $mylog = isset($this->myvillages[$log['village']]) ? 'mylogs' : 'hislogs';
     $village = Dolumar_Players_Village::getVillage($log['village']);
     $data['village'] = $village->getName();
     $data['player'] = $village->getOwner()->getDisplayName();
     $datafields = array();
     foreach ($data as $k => $v) {
         if (!is_array($v)) {
             $datafields[$k] = $v;
         }
     }
     $txt = Neuron_Core_Tools::putIntoText($text->get($log['action'], $mylog, 'logs', $text->get($log['action'], 'mylogs', 'logs')), $datafields);
     if (isset($sUrl) && $showUrl) {
         return '<a href="javascript:void(0);" onclick="' . $sUrl . '">' . $txt . '</a>';
     } else {
         return $txt;
     }
 }
コード例 #22
0
     break;
 case 'ranking':
     // Ranking is handling its own output.
     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.';
コード例 #23
0
 public function processInput()
 {
     $login = Neuron_Core_Login::getInstance();
     $text = Neuron_Core_Text::getInstance();
     $input = $this->getInputData();
     if ($login->isLogin()) {
         if (isset($input['message'])) {
             $message = trim($input['message']);
             if (!empty($message)) {
                 $user = Neuron_GameServer::getPlayer();
                 if (!$user->isPlaying()) {
                     $this->alert($text->get('registerfirst'));
                 } elseif (!$user->isEmailVerified()) {
                     $this->alert($text->get('validateEmail_short', 'main', 'account'));
                 } elseif ($user->isBanned('chat')) {
                     $end = $user->getBanDuration('chat');
                     $duration = Neuron_Core_Tools::getCountdown($end);
                     $this->alert(Neuron_Core_Tools::putIntoText($text->get('banned'), array('duration' => $duration)));
                 } else {
                     // Post message
                     $this->postMessage($input['message']);
                 }
             }
         }
     }
     // Check for input: load older messages
     if (isset($input['loadprevious'])) {
         $before = $input['loadprevious'];
         if ($html = $this->getOlderMessages($before)) {
             $this->addHtmlToElement('messagecontainer', $html, 'top');
         } else {
             $this->addHtmlToElement('messagecontainer', '<div></div>', 'top');
         }
     }
     // If not using blocking, we can "safely" process it right now
     if (!self::USE_BLOCKING) {
         $this->getRefresh();
     }
 }
コード例 #24
0
ファイル: Cold.php プロジェクト: Toxicat/dolumar
 public function getBattleLog($report, $unit, $probability, $data, $html = true)
 {
     $data[0] = isset($data[0]) ? $data[0] : null;
     $text = Neuron_Core_Text::__getInstance();
     return Neuron_Core_Tools::putIntoText($text->get('onSuccess', $this->getClassName(), 'effects'), array('bonus' => $this->getBonusFromLevel(), 'target' => $report->getUnitData($data[0]), 'unit' => $unit->getName(), 'probability' => $probability, 'level' => $this->getLevel(), 'spell' => $html ? $this->getDisplayName() : $this->getName()));
 }
コード例 #25
0
ファイル: Equipment.php プロジェクト: Toxicat/dolumar
 public function getName($multiple = false)
 {
     $text = Neuron_Core_Text::__getInstance();
     $singular = $text->get($this->getItemName(), 'equipment', 'equipment', $this->getItemName());
     if ($multiple) {
         $txt = $text->get($this->getItemName(), 'equipments', 'equipment', $singular);
     } else {
         $txt = $singular;
     }
     $level = $this->getLevel();
     // One or more?
     $wtext = $text->get('level' . $level, 'quality', 'equipment', false);
     if ($multiple) {
         $wtext = $text->get('level' . $level, 'qualities', 'equipment', $wtext);
     }
     // Types
     $type = $this->getItemType();
     $wtext = $text->get('level' . $level, $type . '-quality', 'equipment', $wtext);
     if ($multiple) {
         $wtext = $text->get('level' . $level, $type . '-qualities', 'equipment', $wtext);
     }
     if ($wtext) {
         $wtext = Neuron_Core_Tools::putIntoText($wtext, array('equipment' => $txt));
     } else {
         $wtext = $txt . ' ' . $level;
     }
     return $wtext;
 }
コード例 #26
0
ファイル: Crafting.php プロジェクト: Toxicat/dolumar
 private function getCost($item)
 {
     $text = Neuron_Core_Text::getInstance();
     return Neuron_Core_Tools::putIntoText($text->get('cost', 'crafting', 'buildings'), array($item->getName(), $item->getCraftCost_text($this->getVillage())));
 }
コード例 #27
0
 public function date_long($stamp)
 {
     $text = Neuron_Core_Text::__getInstance();
     $dag = $text->get('day' . (date('w', $stamp) + 1), 'days', 'main');
     $maand = $text->get('mon' . date('m', $stamp), 'months', 'main');
     return Neuron_Core_Tools::putIntoText($text->get('longDateFormat', 'dateFormat', 'main'), array($dag, date('d', $stamp), $maand, date('Y', $stamp)));
 }
コード例 #28
0
ファイル: Magic.php プロジェクト: Toxicat/dolumar
 protected function getConfirmCast($objUnit, $objSpell, $objTarget, $inputData = null)
 {
     $text = Neuron_Core_Text::__getInstance();
     $page = new Neuron_Core_Template();
     $page->setTextSection('confirm', $this->sTextFile);
     if (isset($objTarget)) {
         $page->set('target', Neuron_Core_Tools::output_varchar($objTarget->getName()));
     }
     $page->set('spell', Neuron_Core_Tools::output_varchar($objSpell->getName()));
     $page->set('cost', Neuron_Core_Tools::resourceToText($objSpell->getCost($objUnit, $objTarget)));
     $page->set('about', Neuron_Core_Tools::output_varchar($objSpell->getDescription()));
     $page->set('duration', $objSpell->getType_text());
     $page->set('difficulty', $objSpell->getDifficulty());
     $page->set('probability', $this->getProbability($objUnit, $objSpell, $objTarget));
     $page->set('toCast', Neuron_Core_Tools::putIntoText($text->get('toCast', 'confirm', $this->sTextFile), array('spell' => Neuron_Core_Tools::output_varchar($objSpell->getName()))));
     // Set hidden values
     $page->set('inputData', $inputData);
     return $page->parse('magic/confirm.phpt');
 }
コード例 #29
0
ファイル: MeteorRain.php プロジェクト: Toxicat/dolumar
 public function getBattleLog($report, $unit, $probability, $data, $html = true)
 {
     $text = Neuron_Core_Text::__getInstance();
     return Neuron_Core_Tools::putIntoText($text->get('onSuccess', $this->getClassName(), 'effects'), array('squads' => $data[0], 'casualties' => $data[1], 'unit' => $unit->getName(), 'probability' => $probability, 'level' => $this->getLevel(), 'spell' => $html ? $this->getDisplayName() : $this->getName()));
 }
コード例 #30
0
ファイル: Report.php プロジェクト: Toxicat/dolumar
 public function getFightReport($now = NOW, $logid = null, $showAll = false)
 {
     $text = Neuron_Core_Text::__getInstance();
     $this->loadData();
     $data = $this->data['battleLog'];
     // Check how much "report" can be seen
     $fightStart = $this->data['fightDate'];
     $out = array();
     $data = explode(';', $data);
     array_pop($data);
     $lastAction = null;
     $out[] = Neuron_Core_Tools::putIntoText($text->getRandomLine('introtext', 'battlereport', $this->id), array('attacker' => $this->getAttacker()->getName(), 'defender' => $this->getDefender()->getName()));
     $isDone = $showAll || $this->isDone();
     $slots = json_decode($this->data['slots'], true);
     if (isset($slots['attacking']) && isset($slots['defending'])) {
         // Create thze battle report
         $attacking = $this->parseUnitSlots($slots['attacking']);
         $defending = $this->parseUnitSlots($slots['defending']);
         $this->oBattlefield = new Dolumar_Battle_Battlefield($attacking, $defending);
     } else {
         $this->oBattlefield = new Dolumar_Battle_Battlefield(null, null);
     }
     $i = 0;
     foreach ($data as $v) {
         $facts = explode('|', $v);
         $orgfacts = $facts;
         if (count($facts) > 3) {
             // Fetch the date from the data
             $iDate = array_shift($facts);
             // Jump out of the loop if date is in the future
             if (!$isDone && $iDate + $fightStart > time()) {
                 break;
             }
             $iAction = intval(array_shift($facts));
             $iRandom = array_shift($facts);
             // $iTeam: attacker = 1, defender = 2.
             $iTeam = array_shift($facts);
             $isAttacker = $iTeam == 1;
             $date = Neuron_Core_Tools::getDuration($iDate);
             // Check for "empty" status report
             if ($lastAction === 0 && $iAction === 0) {
                 array_pop($out);
             }
             $lastAction = $iAction;
             // Check if we should push this log to the battlefield
             if ($logid != null && $logid == $i) {
                 $selected = true;
                 $usefield = true;
             } else {
                 $selected = false;
                 $usefield = $logid === null || $logid > $i;
             }
             switch ($iAction) {
                 // Status
                 case 0:
                     //$out[] = null;
                     $out[] = $text->getRandomLine('status_' . $facts[0], 'battlereport', $iRandom);
                     if ($usefield) {
                         $this->oBattlefield->nextround();
                     }
                     break;
                     // Move
                 // Move
                 case 1:
                     $unit = $this->getUnitData($facts[0]);
                     $out[] = Neuron_Core_Tools::putIntoText($text->getRandomLine('move', 'battlereport', $iRandom, $unit), array('unit' => (string) $unit, 'from' => $facts[1], 'to' => $facts[2]));
                     if ($usefield) {
                         $this->oBattlefield->move($isAttacker, $facts[1], $facts[2], $unit);
                     }
                     break;
                     // Stunned
                 // Stunned
                 case 2:
                     $unit = $this->getUnitData($facts[0]);
                     $slot = $this->getUnitSlot($facts[0]);
                     $out[] = Neuron_Core_Tools::putIntoText($text->getRandomLine('stunned', 'battlereport', $iRandom), array('unit' => (string) $unit));
                     if ($usefield) {
                         $this->oBattlefield->stunned(!$isAttacker, $slot, $unit);
                     }
                     break;
                     // Magic
                 // Magic
                 case 5:
                     /* 112|5|68|1|1:1|3|4:3:7::0:50|8 */
                     // unit | effect | probability
                     $unitData = explode(':', array_shift($facts));
                     $unit = Dolumar_SpecialUnits_SpecialUnits::getFromId($unitData[0]);
                     if ($unit) {
                         $unit->setLevel($unitData[1]);
                         $unit->setVillage($this->getAttacker());
                         $effectId = array_shift($facts);
                         $effect = Dolumar_Effects_Effect::getFromId($effectId);
                         $probability = array_shift($facts);
                         if ($effect && $effect instanceof Dolumar_Effects_Battle) {
                             $out[] = $effect->getBattleLog($this, $unit, $probability, $facts);
                             if ($usefield) {
                                 $this->oBattlefield->specialunit_action($isAttacker, $unit, $effect, true);
                             }
                         } else {
                             $out[] = 'Unidentified battle effect: ' . $effectId;
                         }
                     } else {
                         $out[] = 'Unidentified battle effect user: '******':', array_shift($facts));
                     $unit = Dolumar_SpecialUnits_SpecialUnits::getFromId($unitData[0]);
                     $unit->setLevel($unitData[1]);
                     $unit->setVillage($this->getAttacker());
                     $effectId = array_shift($facts);
                     $effect = Dolumar_Effects_Effect::getFromId($effectId);
                     $probability = array_shift($facts);
                     if ($effect && $effect instanceof Dolumar_Effects_Battle) {
                         $out[] = $effect->getFailedLog($this, $unit, $probability, $facts);
                         if ($usefield) {
                             $this->oBattlefield->specialunit_action($isAttacker, $unit, $effect, false);
                         }
                     }
                     break;
                     // Dead special units
                 // Dead special units
                 case 7:
                     /* 158|6|59|1|1:1|3 */
                     $unitData = explode(':', array_shift($facts));
                     $unit = Dolumar_SpecialUnits_SpecialUnits::getFromId($unitData[0]);
                     $unit->setLevel($unitData[1]);
                     $unit->setVillage($this->getAttacker());
                     $out[] = Neuron_Core_Tools::putIntoText($text->getRandomLine('specialunitdied', 'battlereport', $iRandom), array('unit' => $unit->getName(), 'level' => $unit->getLevel()));
                     if ($usefield) {
                         $this->oBattlefield->specialunit_dead($isAttacker, $effect, false);
                     }
                     break;
                     // whiped units
                 // whiped units
                 case 8:
                     $unit = $this->getUnitData($facts[0]);
                     $out[] = Neuron_Core_Tools::putIntoText($text->getRandomLine('whipe', 'battlereport', $iRandom), array('unit' => (string) $unit, 'date' => $date));
                     if ($usefield) {
                         $this->oBattlefield->whipe($isAttacker, $this->getUnitSlot($facts[0]), $unit);
                     }
                     break;
                 case 9:
                     $unit = $this->getUnitData($facts[0]);
                     $out[] = Neuron_Core_Tools::putIntoText($text->getRandomLine('flee', 'battlereport', $iRandom), array('unit' => (string) $unit, 'date' => $date));
                     if ($usefield) {
                         $this->oBattlefield->flee($isAttacker, $this->getUnitSlot($facts[0]), $unit);
                     }
                     break;
                     // Damage
                 // Damage
                 case 10:
                 case 11:
                 case 12:
                     switch ($iAction) {
                         case 11:
                             $damage = 'melee';
                             break;
                         case 12:
                             $damage = 'shooting';
                             break;
                         default:
                             $damage = 'error';
                             break;
                     }
                     $attacker = $this->getUnitData($facts[0]);
                     $defender = $this->getUnitData($facts[1]);
                     $out[] = Neuron_Core_Tools::putIntoText($text->getRandomLine('casualties_' . $damage, 'battlereport', $iRandom), array('attacker' => (string) $attacker, 'defender' => (string) $defender, 'amount' => $facts[2], 'date' => $date, 'frontage' => $this->getUnitFrontage($facts[0])));
                     if ($usefield) {
                         $this->oBattlefield->damage($isAttacker, $this->getUnitSlot($facts[0]), $this->getUnitSlot($facts[1]), $facts[2], $attacker, $defender);
                     }
                     break;
                     // Default
                 // Default
                 default:
                     $out[] = $date . ' Unknown log: ' . $iAction;
                     break;
             }
             $i = count($out);
         }
     }
     if (!$isDone) {
         $out[] = '...';
     }
     return $out;
 }