Exemplo n.º 1
0
 /**
  * Creates a new clan with the current user as the leader
  *
  * @return Array The viewspec
  * @note
  * Player must be high enough level to create a clan
  *
  * @see CLAN_CREATOR_MIN_LEVEL
  */
 public function create()
 {
     $player = new Player(self_char_id());
     if ($player->level >= self::CLAN_CREATOR_MIN_LEVEL) {
         $default_clan_name = 'Clan ' . $player->name();
         while (!Clan::isUniqueClanName($default_clan_name)) {
             $default_clan_name = $default_clan_name . rand(1, 999);
         }
         $clan = Clan::createClan($player->id(), $default_clan_name);
         $parts = ['action_message' => 'Your clan was created with the default name: ' . $clan->getName() . '. Change it below.', 'title' => 'Clan ' . $clan->getName(), 'clan' => $clan, 'pageParts' => ['edit']];
     } else {
         $parts = ['error' => 'You do not have enough renown to create a clan. You must be at least level ' . self::CLAN_CREATOR_MIN_LEVEL . '.', 'title' => 'You cannot create a clan yet', 'clans' => ClanFactory::clansRanked(), 'pageParts' => ['list']];
     }
     return $this->render($parts);
 }