• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Player类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Player的典型用法代码示例。如果您正苦于以下问题:PHP Player类的具体用法?PHP Player怎么用?PHP Player使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Player类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: welcome

function welcome($api)
{
    $bdd = getBDD();
    $req = $bdd->prepare('UPDATE at_welcome SET jour = now(), heure = now() WHERE mac = :mac');
    $req->execute(array('mac' => $api));
    $req->closeCursor();
    $player = new Player();
    $req = $bdd->prepare('SELECT at_music.file FROM at_music JOIN at_welcome ON at_music.id = at_welcome.music WHERE at_welcome.mac = mac');
    $req->execute(array('mac' => $mac));
    $data = $req->fetch();
    $player->play($data['file']);
    $req->closeCursor();
}
开发者ID:nawrasg,项目名称:Atlantis,代码行数:13,代码来源:at_welcome.php


示例2: handle_register

 public static function handle_register()
 {
     $firstname = $_POST['firstname'];
     $username = $_POST['username'];
     $password = $_POST['password'];
     $password2 = $_POST['password2'];
     $errors = array();
     if ($firstname == null) {
         $errors[] = "Syötä nimesi.";
     }
     if ($username == null) {
         $errors[] = "Syötä uusi käyttäjätunnus.";
     }
     if (Player::username_exists($username)) {
         $errors[] = "Käyttäjätunnus on jo käytössä. Valitse toinen käyttäjätunnus.";
     }
     if ($password == null || $password2 == null) {
         $errors[] = "Syötä uusi salasana.";
     }
     if ($password != $password2) {
         $errors[] = "Annetut salasanat eivät täsmänneet.";
     }
     if ($errors != null) {
         View::make('user/register.html', array('errors' => $errors, 'username' => $username, 'firstname' => $firstname));
     } else {
         // Register user/player and login
         $player = new Player(array('firstname' => $firstname, 'username' => $username, 'password' => crypt($password)));
         $player->save();
         // POST params for signing in are the same in register.html and login.html
         self::handle_login();
     }
 }
开发者ID:rryanburton,项目名称:Tsoha-Bootstrap,代码行数:32,代码来源:user_controller.php


示例3: CreateControls

 public function CreateControls()
 {
     $this->AddCssClass('form');
     $this->SetButtonText("Save player");
     # get player to edit
     $player = $this->GetDataObject();
     if (!$player instanceof Player) {
         $player = new Player($this->GetSettings());
     }
     require_once "xhtml/forms/radio-button.class.php";
     if ($this->GetCurrentPage() == PlayerEditor::MERGE_PLAYER) {
         $this->AddControl("<p>There's another player named '" . htmlentities($player->GetName(), ENT_QUOTES, "UTF-8", false) . "' in this team. What would you like to do?</p>");
         $this->AddControl("<dl class=\"decision\"><dt>");
         $this->AddControl(new RadioButton($this->GetNamingPrefix() . "Merge", $this->GetNamingPrefix() . "MergeOptions", htmlentities("Merge with the other " . $player->GetName(), ENT_QUOTES, "UTF-8", false), 1, false, $this->IsValid()));
         $this->AddControl("</dt><dd>If they're the same person you can merge the records so there's only one " . htmlentities($player->GetName(), ENT_QUOTES, "UTF-8", false) . ". Don't choose this for a player who's got married and changed their name though.</dd>");
         $this->AddControl("<dt>");
         $this->AddControl(new RadioButton($this->GetNamingPrefix() . "Rename", $this->GetNamingPrefix() . "MergeOptions", "Choose a new name for this player", 2, false, $this->IsValid()));
         $this->AddControl("</dt><dd>If they're different people you need to pick a different name. For example, if you have two players called 'Jane Smith',\n\t\t\t\tchange one to 'Jane A Smith'.</dd></dl>");
     }
     # Container for form elements, useful for JavaScript to hide them
     $container = new XhtmlElement("div", null, "#playerEditorFields");
     $this->AddControl($container);
     # add name
     $name = new XhtmlElement("label", "Name");
     $name->AddAttribute("for", $this->GetNamingPrefix() . 'Name');
     $container->AddControl($name);
     $name_box = new TextBox($this->GetNamingPrefix() . 'Name', $player->GetName(), $this->IsValid());
     $name_box->AddAttribute('maxlength', 100);
     #$name = new FormPart('Name', $name_box);
     $container->AddControl($name_box);
 }
开发者ID:stoolball-england,项目名称:stoolball-england-website,代码行数:31,代码来源:player-editor.class.php


示例4: globalize_user_info

function globalize_user_info($private = true, $alive = true)
{
    global $username;
    global $char_id;
    $error = null;
    $char_id = self_char_id();
    // Will default to null.
    //$username = get_username(); // Will default to null.
    if ((!is_logged_in() || !$char_id) && $private) {
        $error = 'log_in';
        // A non-null set of content being in the error triggers a die at the end of the header.
    } elseif ($char_id) {
        // **************** Player information settings. *******************
        global $player, $player_id;
        // Polluting the global namespace here.  Booo.
        $player = new Player($char_id);
        // Defaults to current session user.
        $username = $player->name();
        // Set the global username.
        $player_id = $player->player_id;
        assert('isset($player_id)');
        if ($alive) {
            // *** That page requires the player to be alive to view it.
            if (!$player->health()) {
                $error = 'dead';
            } else {
                if ($player->hasStatus(FROZEN)) {
                    $error = 'frozen';
                }
            }
        }
    }
    return $error;
}
开发者ID:reillo,项目名称:ninjawars,代码行数:34,代码来源:lib_header.php


示例5: testShowHand

 /**
  * @covers Autumn\Janken\Domain\Player::showHand()
  */
 public function testShowHand()
 {
     $this->object = new Player("player 1");
     $expected = Player::STONE;
     $result = $this->object->showHand();
     $this->assertEquals($expected, $result);
 }
开发者ID:ka-autumn,项目名称:Janken,代码行数:10,代码来源:PlayerTest.php


示例6: instance

 public static function instance(Player $player, Game $game)
 {
     $strategyRepository = new AiStrategyRepository();
     $strategy = $strategyRepository->getOneById($player['ai_strategy']);
     $strategyClassName = $strategy['title'];
     $role = $player->getRoleObject();
     if ($strategyClassName == 'Passive') {
         if ($role->getIsSheriff()) {
             // 2 players alive in game
             // or only bandits against me
             // or $me->getActualLives() <= $me->getMaxLives() / 2
             $strategyClassName = 'Normal';
         } elseif ($role->getIsRenegard()) {
             // 2 players alive in game
             // $game->getSheriff()->getActualLives() <= $game->getSheriff()->getMaxLives() / 2
             // or $me->getActualLives() <= $me->getMaxLives() / 2
             $strategyClassName = 'Normal';
         } elseif ($role->getIsBandit()) {
             // $game->getSheriff()->getActualLives() <= $game->getSheriff()->getMaxLives() / 2
             // or $me->getActualLives() <= $me->getMaxLives() / 2
             $strategyClassName = 'Normal';
         } elseif ($role->getIsVice()) {
             // $game->getSheriff()->getActualLives() <= $game->getSheriff()->getMaxLives() / 2
             // or $me->getActualLives() <= $me->getMaxLives() / 2
             $strategyClassName = 'Normal';
         }
     }
     $className = $strategyClassName . $role['title'] . 'Strategy';
     return new $className($player, $game);
 }
开发者ID:Tomeno,项目名称:lulcobang,代码行数:30,代码来源:StrategyInstancer.php


示例7: testPlayer

 public function testPlayer()
 {
     $player = new Player();
     $result = $player->betRequest(json_decode($this->gameState, true));
     $this->assertTrue(is_int($result));
     $this->assertGreaterThanOrEqual(0, $result);
 }
开发者ID:IllesAprod,项目名称:poker-player-proud-cow,代码行数:7,代码来源:elsoTest.php


示例8: post_register

 function post_register()
 {
     // set validation rules for new user content.
     $rules = array('name' => 'required|min:3|max:75', 'email' => 'required|unique:users|email', 'password' => 'required|min:5|max:64');
     $v = Validator::make(Input::all(), $rules);
     if ($v->fails()) {
         return Redirect::to('user/new')->with_input('except', array('password'))->with_errors($v);
     }
     $nameArr = explode(' ', Input::get('name'), 2);
     $player = new Player();
     $player->first_name = $nameArr[0];
     $player->last_name = isset($nameArr[1]) ? $nameArr[1] : '';
     $player->save();
     if ($player->save()) {
         $user = new User();
         $user->password = Hash::make(Input::get('password'));
         $user->email = Input::get('email');
         $user->player_id = $player->id;
         if ($user->save()) {
             // log the user in the session
             Auth::login($user->id);
             return Redirect::to('user')->with('welcomeMsg', true);
         } else {
             // oh shit. roll back the player and return an error
             $player->delete();
             return Redirect::to('user/new')->with_input('except', array('password'))->with('error', 'Nah fool... something went real wrong.');
         }
     } else {
         return Redirect::to('user/new')->with_input('except', array('password'))->with('error', 'This user could not be created.');
     }
 }
开发者ID:kleitz,项目名称:brackets,代码行数:31,代码来源:home.php


示例9: testStack

 public function testStack()
 {
     $player = new Player('white');
     $stack = $player->getStack();
     $this->assertEquals(0, $player->getStack()->getVersion());
     $stack->addEvent(array('type' => 'test'));
     $this->assertEquals(1, $player->getStack()->getVersion());
 }
开发者ID:hafeez3000,项目名称:lichess,代码行数:8,代码来源:PlayerTest.php


示例10: attack

 public function attack(Player $player)
 {
     $damage = $this->getDamage() - $player->getArmor();
     if ($damage < 1) {
         $damage = 1;
     }
     $player->decreaseHitpoints($damage);
 }
开发者ID:hmazter,项目名称:advent-of-code-solutions,代码行数:8,代码来源:Boss.php


示例11: distributeCards

 public function distributeCards(Player $player)
 {
     $cards = $player->getCards();
     if ($player->isHuman()) {
         $this->playerCards = $cards;
     } else {
         $this->bankCards = $cards;
     }
 }
开发者ID:puterakahfi,项目名称:cqrs-php-sandbox,代码行数:9,代码来源:GameView.php


示例12: testLifeCannotExceedMaxValue

 public function testLifeCannotExceedMaxValue()
 {
     $player = new Player('John Doe');
     $player->gainLife(51);
     $this->assertEquals(Player::MAX_LIFE, $player->getLife());
     $player = new Player('John Doe');
     $player->setLife(151);
     $this->assertEquals(Player::MAX_LIFE, $player->getLife());
 }
开发者ID:rogeriopvl,项目名称:dri_codesessions_tdd,代码行数:9,代码来源:TestPlayer.php


示例13: play

 public function play()
 {
     $player = new Player();
     $result = array();
     foreach (range(1, 20) as $number) {
         $result[] = $player->fizzBuzz($number);
     }
     return $result;
 }
开发者ID:roblevintennis,项目名称:dotfiles,代码行数:9,代码来源:FizzBuzz.php


示例14: purgeOldQueueData

 /**
  * Purge Old Queue Data
  *
  * Removes an item marked as playing if it's been
  * more than 15 minutes since it was played.
  *
  * @param array $queue
  * @return array Modified queue
  */
 public function purgeOldQueueData($queue)
 {
     if ($queue[0]['status'] == 'playing' && date('YmdHi', strtotime($queue[0]['ts_played'])) < date('YmdHi') - 15) {
         $player = new Player();
         $player->markSongPlayed($queue[0]['id']);
         array_shift($queue);
     }
     return $queue;
 }
开发者ID:nbar1,项目名称:gs,代码行数:18,代码来源:Queue.php


示例15: showAction

 public function showAction(Server $server, Player $me, Request $request)
 {
     if ($server->staleInfo()) {
         $server->forceUpdate();
     }
     if ($request->get('forced') && $me->canEdit($server)) {
         $server->forceUpdate();
     }
     return array("server" => $server);
 }
开发者ID:kleitz,项目名称:bzion,代码行数:10,代码来源:ServerController.php


示例16: testGetters

 /**
  * Test getters
  */
 public function testGetters()
 {
     $connection = $this->getMock('Ratchet\\ConnectionInterface');
     $type = Player::TYPE_WEREWOLF;
     $nickname = "Villager 1";
     $player = new Player($connection, $type, $nickname);
     $this->assertEquals($connection, $player->getConnection());
     $this->assertEquals($type, $player->getType());
     $this->assertEquals($nickname, $player->getNickname());
 }
开发者ID:martinph,项目名称:werewolf,代码行数:13,代码来源:PlayerTest.php


示例17: shouldNotGrantAccessWhenAccessIsAlreadyGiven

 /**
  * @test
  */
 public function shouldNotGrantAccessWhenAccessIsAlreadyGiven()
 {
     // given
     $pl = new Player();
     // when
     $pl->grantAccessTo(ChessRoles::LOGIN);
     $pl->grantAccessTo(ChessRoles::LOGIN);
     // then
     $this->assertEquals(ChessRoles::LOGIN, $pl->getUserAccess());
 }
开发者ID:manishkhanchandani,项目名称:mkgxy,代码行数:13,代码来源:PlayerTest.php


示例18: testMessageHasARobustSender

 public function testMessageHasARobustSender()
 {
     $rec = new Player($this->char_id);
     Message::create(['send_from' => $rec->id(), 'send_to' => $this->char_id_2, 'message' => 'Random phpunit test message of some content', 'type' => 0]);
     $messages = Message::findByReceiver(new Player($this->char_id_2), $type = 0, $limit = 1000, $offset = 0);
     $this->assertGreaterThan(0, count($messages), 'Collection has no results found');
     $first_message = $messages->first();
     $this->assertTrue($first_message instanceof Message, 'First message not a valid message model');
     $this->assertNotEmpty($first_message->sender);
     $this->assertGreaterThan(0, strlen($first_message->sender));
 }
开发者ID:reillo,项目名称:ninjawars,代码行数:11,代码来源:MessageTest.php


示例19: testAttackLegalCantAttackSelfEvenIfUsingSelfIdVsSelfUsername

 public function testAttackLegalCantAttackSelfEvenIfUsingSelfIdVsSelfUsername()
 {
     $this->setExpectedException('InvalidArgumentException');
     $char_id = TestAccountCreateAndDestroy::create_testing_account();
     $this->oldify_character_last_attack($char_id);
     $player = new Player($char_id);
     $info = $player->dataWithClan();
     $this->assertTrue((bool) $info['uname'], 'Character uname not found to check attacklegal with');
     $legal = new AttackLegal($player, $info['uname'], ['required_turns' => 1, 'ignores_stealth' => true]);
     $this->assertFalse($legal->check(false));
 }
开发者ID:NinjaWars,项目名称:ninjawars,代码行数:11,代码来源:combat_test.php


示例20: testCantAttackIfExcessiveAmountOfTurnsIsRequired

 public function testCantAttackIfExcessiveAmountOfTurnsIsRequired()
 {
     $confirm = true;
     $char_id = TestAccountCreateAndDestroy::create_testing_account($confirm);
     $this->oldify_character_last_attack($char_id);
     $char_2_id = TestAccountCreateAndDestroy::create_alternate_testing_account($confirm);
     $this->oldify_character_last_attack($char_2_id);
     $char = new Player($char_2_id);
     $legal = new AttackLegal($char_id, $char->name(), ['required_turns' => 4000000000.0, 'ignores_stealth' => true]);
     $this->assertFalse($legal->check($update_timer = false));
 }
开发者ID:reillo,项目名称:ninjawars,代码行数:11,代码来源:combat_test.php



注:本文中的Player类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP PlayerUtil类代码示例发布时间:2022-05-23
下一篇:
PHP Planning类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap