当前位置: 首页>>代码示例>>PHP>>正文


PHP Player类代码示例

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


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


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