Ejemplo n.º 1
0
 public function hasClan(Dolumar_Players_Clan $clan)
 {
     foreach ($this->clans as $v) {
         if ($clan->equals($v)) {
             return true;
         }
     }
     return false;
 }
Ejemplo n.º 2
0
 private function getClan()
 {
     $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();
             } else {
                 return null;
             }
             if ($clan->isMember($me)) {
                 return $clan;
             }
         }
     }
     return null;
 }
Ejemplo n.º 3
0
 public static function getClanportals(Dolumar_Players_Clan $clan)
 {
     $db = Neuron_DB_Database::getInstance();
     $villages = array();
     foreach ($clan->getMembers() as $player) {
         foreach ($player->getVillages() as $v) {
             $villages[] = $v->getId();
         }
     }
     $list = "(" . implode($villages, ",") . ")";
     $data = $db->query("\n\t\t\tSELECT\n\t\t\t\t*\n\t\t\tFROM\n\t\t\t\tmap_portals\n\t\t\tWHERE\n\t\t\t\tp_caster_v_id IN {$list} OR\n\t\t\t\tp_target_b_id IN {$list}\n\t\t");
     $out = array();
     foreach ($chk as $v) {
         $in = new self($v['p_id']);
         $in->setData($v[0]);
         $out[] = $in;
     }
     return $out;
 }
Ejemplo n.º 4
0
 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;
     }
 }
Ejemplo n.º 5
0
 protected function getPlayerInitialization($registrationTracker = false)
 {
     // Check if we can actually register
     $server = Neuron_GameServer::getServer();
     if (!$server->canRegister()) {
         return '<p>This server has gone into "endgame" mode. You can not register here anymore. But stay tuned, a new game will start soon.</p>';
     }
     $data = $this->getInputData();
     $me = Neuron_GameServer::getPlayer();
     if (isset($data['race'])) {
         // Check for clans
         $clan = isset($data['clan']) ? intval($data['clan']) : 0;
         $location = isset($data['location']) ? $data['location'] : null;
         $objClan = false;
         if ($clan > 0) {
             $objClan = new Dolumar_Players_Clan($clan);
             if ($objClan->isFound()) {
                 // Check for password
                 if ($objClan->isPasswordProtected()) {
                     // Break out of the function if the password is not correct.
                     if (!isset($data['password']) || !$objClan->checkPassword($data['password'])) {
                         return $this->requestClanPassword($data['race'], $objClan);
                     }
                 }
                 $members = $objClan->getMembers();
                 if (count($members) > 0) {
                     $member = $members[rand(0, count($members) - 1)];
                     // Fetch towncenter
                     $village = $member->getMainVillage();
                     if ($village) {
                         // Overwrite location with the location of this towncenter.
                         $location = $village->buildings->getTownCenterLocation();
                     } else {
                         $location = array(0, 0);
                     }
                 } else {
                     $location = array(0, 0);
                 }
             }
         }
         if ($me->initializeAccount($data['race'], $location, $objClan)) {
             // Scroll to the right location
             $me = Neuron_GameServer::getPlayer();
             $home = $me->getHomeLocation();
             $this->mapJump($home[0], $home[1]);
             // Reload area
             $this->reloadLocation($home[0], $home[1]);
             reloadEverything();
             return $this->getContent(false);
         } else {
             //return $this->getPlayerInitialization ();
         }
     }
     $text = Neuron_Core_Text::__getInstance();
     $text->setFile('account');
     $text->setSection('selectRace');
     $data = $this->getInputData();
     // Show form
     $page = new Neuron_Core_Template();
     $error = Neuron_GameServer::getPlayer()->getError();
     if (!empty($error)) {
         $page->set('error', $text->get($error, 'errors', 'account', $error));
     }
     // Loop trough races
     foreach (Dolumar_Races_Race::getRaces() as $k => $v) {
         $race = Dolumar_Races_Race::getFromId($k);
         if ($race->canPlayerSelect(Neuron_GameServer::getPlayer())) {
             $page->addListValue('races', array($text->get($v, 'races', 'races', $v), $text->get($v, 'desc', 'races', 'null'), $k));
         }
     }
     $page->sortList('races');
     // Some text values
     $page->set('submit', $text->get('submit'));
     $page->set('select', $text->get('select'));
     $page->set('location', $text->get('location'));
     if ($registrationTracker === true) {
         $tracker = Neuron_GameServer::getPlayer()->getTrackerUrl('registration');
         $page->set('tracker_url', htmlentities($tracker));
     }
     // Locations
     $page->addListValue('directions', array($text->get('r', 'directions', 'main'), 'r'));
     $page->addListValue('directions', array($text->get('n', 'directions', 'main'), 'n'));
     $page->addListValue('directions', array($text->get('ne', 'directions', 'main'), 'ne'));
     $page->addListValue('directions', array($text->get('e', 'directions', 'main'), 'e'));
     $page->addListValue('directions', array($text->get('es', 'directions', 'main'), 'es'));
     $page->addListValue('directions', array($text->get('s', 'directions', 'main'), 's'));
     $page->addListValue('directions', array($text->get('sw', 'directions', 'main'), 'sw'));
     $page->addListValue('directions', array($text->get('w', 'directions', 'main'), 'w'));
     $page->addListValue('directions', array($text->get('wn', 'directions', 'main'), 'wn'));
     // Fetch a list of all clans
     $db = Neuron_Core_Database::__getInstance();
     $clans = $db->select('clans', array('*'));
     // Add a list of all clans ;-)
     foreach ($clans as $v) {
         $clan = new Dolumar_Players_Clan($v['c_id'], $v);
         $page->addListValue('clans', array('id' => $clan->getId(), 'name' => Neuron_Core_Tools::output_varchar($clan->getName()), 'isLocked' => $clan->isPasswordProtected(), 'isFull' => $clan->isFull()));
     }
     return $page->parse('account/selectRace.phpt');
 }
Ejemplo n.º 6
0
 private function getWinner()
 {
     $server = Neuron_GameServer::getServer();
     $winner = $server->getData('winner');
     if ($winner) {
         return Dolumar_Players_Clan::getFromId($winner);
     }
     return null;
 }
Ejemplo n.º 7
0
 public static function getSides(Dolumar_Underworld_Models_Mission $mission)
 {
     $tmp = array();
     /*
     // First, load the sides from the mission
     $sides = $mission->getMap ()->getSideIds ();
     
     foreach ($sides as $v)
     {
     	$tmp[$v] = new Dolumar_Underworld_Models_Side ($v);
     }
     */
     // Now load all the clans
     $db = Neuron_DB_Database::getInstance();
     $data = $db->query("\n\t\t\tSELECT\n\t\t\t\t*\n\t\t\tFROM\n\t\t\t\tunderworld_missions_clans\n\t\t\tWHERE\n\t\t\t\tum_id = {$mission->getId()}\n\t\t");
     foreach ($data as $v) {
         if (!isset($tmp[$v['umc_side']])) {
             $tmp[$v['umc_side']] = new Dolumar_Underworld_Models_Side($v['umc_side']);
         }
         $clan = Dolumar_Players_Clan::getFromId($v['c_id']);
         $tmp[$v['umc_side']]->addClan($clan);
     }
     return array_values($tmp);
 }
Ejemplo n.º 8
0
 /**
  * Determine if it's time to take a step forwards
  */
 public function updateStatus()
 {
     $state = $this->getData('gamestate');
     if (!$state) {
         $this->setData('gamestate', self::GAMESTATE_PLAYING);
         return;
     }
     switch ($state) {
         case self::GAMESTATE_PLAYING:
             // If the server has been running for xxx months, go to next step
             $duration = GAME_RUNNING_DURATION;
             $start = $this->getStartDate();
             $timepassed = time() - $start;
             if ($timepassed > $duration) {
                 // Initiate end game
                 $this->setData('gamestate', self::GAMESTATE_ENDGAME_STARTED);
                 // And notify all players
                 Neuron_GameServer_Player_Guide::addPublicMessage('end_scroll', array(), 'guide', 'scared');
             }
             break;
         case self::GAMESTATE_ENDGAME_FINISHED:
             $this->setData('end_date', time());
             $this->setData('gamestate', self::GAMESTATE_WAITINGFORRESET);
             $server = Neuron_GameServer::getServer();
             $out = array();
             $out['winner'] = '';
             $out['members'] = '';
             $out['ranking'] = '';
             $out['members'] = '';
             $out['villages'] = '';
             $out['clans'] = '';
             $out['players'] = '';
             $winner = $server->getData('winner');
             if ($winner) {
                 $clan = Dolumar_Players_Clan::getFromId($winner);
                 if ($clan) {
                     $out['winner'] = Neuron_Core_Tools::output_varchar($clan->getName());
                     foreach ($clan->getMembers() as $v) {
                         $out['members'] .= "- " . Neuron_Core_Tools::output_varchar($v->getName()) . "\n";
                     }
                 }
             }
             // Ranking
             $players = Dolumar_Players_Ranking::getPlayerRanking(0, 5);
             $i = 0;
             foreach ($players as $v) {
                 $i++;
                 $out['players'] .= $i . ". " . $v->getName() . ' (' . $v->getScore() . ')' . "\n";
             }
             $villages = Dolumar_Players_Ranking::getRanking(0, 5);
             $i = 0;
             foreach ($villages as $v) {
                 $i++;
                 $out['villages'] .= $i . ". " . $v->getName() . ' (' . $v->getNetworth() . ')' . "\n";
             }
             $ranking = Dolumar_Players_Ranking::getClanRanking(0, 5);
             $i = 0;
             foreach ($ranking as $v) {
                 $i++;
                 $out['clans'] .= $i . ". " . $v->getName() . ' (' . $v->getNetworth() . ')' . "\n";
             }
             $out['servername'] = $this->getServerName();
             $out['serverurl'] = ABSOLUTE_URL;
             // Send out the bloody newsletter
             if (!defined('IS_TESTSERVER') || !IS_TESTSERVER) {
                 $this->sendNewsletter('serverreset', $out);
             }
             break;
         case self::GAMESTATE_WAITINGFORRESET:
             if ($this->getData('end_date') <= NOW - 60 * 60 * 23) {
                 $this->reset();
             }
             break;
     }
 }
Ejemplo n.º 9
0
 private function makeClan($name)
 {
     $profile = Neuron_GameServer::getPlayer();
     if ($profile) {
         $db = Neuron_Core_Database::__getInstance();
         // Check for a clan with the same name
         $chk = $db->select('clans', array('c_id'), "c_name = '" . $db->escape($name) . "'");
         if (count($chk) > 0) {
             $this->addError('name_duplicate');
             return false;
         } else {
             $id = $db->insert('clans', array('c_name' => $name));
             // Add yourself
             /*
             $db->insert
             (
             	'clan_members',
             	array
             	(
             		'plid' => $profile->getId (),
             		'c_id' => $id,
             		'c_status' => 'leader'
             	)
             );
             */
             $clan = Dolumar_Players_Clan::getFromId($id);
             $clan->doJoinClan($profile, 'leader');
             return true;
         }
     }
 }
Ejemplo n.º 10
0
 public function getJoinSide(Dolumar_Players_Clan $clan)
 {
     $side = new Dolumar_Underworld_Models_Side($clan->getId());
     return $side;
 }
Ejemplo n.º 11
0
 private static function addClan(Dolumar_Underworld_Models_Mission $mission, Dolumar_Players_Clan $clan, Dolumar_Underworld_Models_Side $side)
 {
     $db = Neuron_DB_Database::getInstance();
     $missionId = self::getMissionId($mission);
     $chk = $db->query("\n\t\t\tSELECT\n\t\t\t\tus_id\n\t\t\tFROM\n\t\t\t\tunderworld_log_clans\n\t\t\tWHERE\n\t\t\t\tum_id = '{$missionId}' AND\n\t\t\t\tus_clan = '{$clan->getId()}'\n\t\t");
     if (count($chk) === 0) {
         $chk = $db->query("\n\t\t\t\tINSERT INTO\n\t\t\t\t\tunderworld_log_clans\n\t\t\t\tSET\n\t\t\t\t\tum_id = '{$missionId}',\n\t\t\t\t\tus_clan = '{$clan->getId()}',\n\t\t\t\t\tus_side = '{$clan->getId()}'\n\t\t\t");
     }
 }