示例#1
0
 protected function setup()
 {
     $roleAlias = Utils::get('identifier');
     $roleRepository = new RoleRepository(TRUE);
     $role = $roleRepository->getOneByAlias($roleAlias);
     MySmarty::assign('role', $role);
 }
示例#2
0
 protected function setup()
 {
     $roleRepository = new RoleRepository(TRUE);
     $roleRepository->addGroupBy('type');
     $roles = $roleRepository->getAll();
     MySmarty::assign('roles', $roles);
 }
示例#3
0
文件: Role.php 项目: Tomeno/lulcobang
 public function getRelatedRoles()
 {
     $roleRepository = new RoleRepository(TRUE);
     $roleRepository->addAdditionalWhere(array('column' => 'type', 'value' => $this['type'], 'xxx' => '!='));
     $roleRepository->addGroupBy('type');
     return $roleRepository->getAll();
 }
示例#4
0
 protected function run()
 {
     if ($this->check == self::OK) {
         $roleRepository = new RoleRepository();
         $characterRepository = new CharacterRepository();
         $characterCardsCount = is_numeric($this->params[0]) ? intval($this->params[0]) : 2;
         $players = $this->players;
         $roleRepository->setLimit(count($players));
         $roles = $roleRepository->getAll();
         shuffle($roles);
         $gameSets = unserialize($this->game['game_sets']);
         if ($gameSets) {
             $characters = $characterRepository->getByValidAndGameSet(1, $gameSets);
         } else {
             $characters = $characterRepository->getByValid(1);
         }
         shuffle($characters);
         $highNoonRepository = new HighNoonRepository();
         $highNoonCard = $highNoonRepository->getOneByIdAndValidAndGameSet(HighNoon::getSpecialCards(), 1, $gameSets);
         $highNoonRepository = new HighNoonRepository();
         $highNoonRepository->addAdditionalWhere(array('column' => 'id', 'value' => HighNoon::getSpecialCards(), 'xxx' => 'NOT IN'));
         $highNoonCards = $highNoonRepository->getByValidAndGameSet(1, $gameSets);
         if ($highNoonCards) {
             shuffle($highNoonCards);
             $highNoonCardIds = array();
             foreach ($highNoonCards as $card) {
                 $highNoonCardIds[] = $card['id'];
                 if (count($highNoonCardIds) == 14) {
                     break;
                 }
             }
             if ($highNoonCard) {
                 $highNoonCardIds[] = $highNoonCard['id'];
             }
             $this->game['high_noon_pile'] = serialize(array_reverse($highNoonCardIds));
         }
         $j = 0;
         foreach ($players as $player) {
             $playerPossibleCharacters = array();
             $player['role'] = $roles[$j]['id'];
             $index = $characterCardsCount * $j;
             for ($c = $index; $c < $index + $characterCardsCount; $c++) {
                 $playerPossibleCharacters[] = $characters[$c]['id'];
             }
             $player['possible_choices'] = serialize(array('possible_characters' => $playerPossibleCharacters));
             $player->save();
             $j++;
         }
         $this->game['status'] = Game::GAME_STATUS_INITIALIZED;
         $this->game = $this->game->save(TRUE);
         foreach ($this->game->getPlayers() as $player) {
             if ($player->getIsAi()) {
                 $player->play($this->game);
             }
         }
     }
 }
 public function __construct()
 {
     parent::__construct();
     $this->create_guest_account = function () {
         return UserRepository::createWithRoles(['UserID' => 1, 'Name' => 'Anonymous', 'Password' => str_random(64), 'HashMethod' => 'random'], [RoleRepository::member()]);
     };
 }
示例#6
0
 /**
  * @param bool $full
  *
  * @return User|false
  */
 public function findSingle($full = false)
 {
     $result = parent::findSingle();
     if ($result) {
         $user = new User($result);
         if ($full === true) {
             $repo = new RoleRepository($this->db);
             $user->setRoles($repo->where('user_id', '=', $user->getId())->order('name', 'ASC')->find());
             $repo = new PermissionRepository($this->db);
             $user->setPermissions($repo->where('user_id', '=', $user->getId())->order('name', 'ASC')->find());
         }
         return $user;
     } else {
         return false;
     }
 }
示例#7
0
 public function __construct($player)
 {
     parent::__construct($player);
     $userRepository = new UserRepository();
     $user = $userRepository->getOneById($player['user']);
     $this->setAdditionalField('user', $user);
     $roleRepository = new RoleRepository(TRUE);
     $role = $roleRepository->getOneById($player['role']);
     $this->setAdditionalField('role', $role);
     $characterRepository = new CharacterRepository(TRUE);
     $character = $characterRepository->getOneById($player['charakter']);
     $this->setAdditionalField('character', $character);
     $cardRepository = new CardRepository(TRUE);
     $handCardsId = unserialize($player['hand_cards']);
     $handCards = array();
     if ($handCardsId) {
         $cardRepository->addOrderBy(array('card_base_type' => 'ASC'));
         $handCards = $cardRepository->getById($handCardsId);
     }
     $this->setAdditionalField('hand_cards', $handCards);
     $cardRepository = new CardRepository(TRUE);
     $tableCardsId = unserialize($player['table_cards']);
     $tableCards = array();
     if ($tableCardsId) {
         $cardRepository->addOrderBy(array('card_base_type' => 'ASC'));
         $tableCards = $cardRepository->getById($tableCardsId);
     }
     $this->setAdditionalField('table_cards', $tableCards);
     $waitCardsId = unserialize($player['wait_cards']);
     $waitCards = array();
     if ($waitCardsId) {
         $cardRepository->addOrderBy(array('card_base_type' => 'ASC'));
         $waitCards = $cardRepository->getById($waitCardsId);
     }
     $this->setAdditionalField('wait_cards', $waitCards);
     if ($player['notices']) {
         $notices = unserialize($player['notices']);
     } else {
         $notices = array();
     }
     $this->setAdditionalField('notice_list', $notices);
 }
示例#8
0
 /**
  * Delete various.
  *
  * @param  Request  $request
  * @return Response
  */
 public function delete(Request $request)
 {
     $this->role->deleteAll($request->get('ids'));
     return redirect(route('admin.roles.index'))->with(['status' => trans('messages.deleted'), 'type-status' => 'success']);
 }
示例#9
0
 /**
  * @return Role[]
  */
 public function getRoles()
 {
     $repo = new RoleRepository($this->db);
     return $repo->order('name', 'ASC')->find(true);
 }