本文整理汇总了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();
}
示例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();
}
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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.');
}
}
示例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());
}
示例10: attack
public function attack(Player $player)
{
$damage = $this->getDamage() - $player->getArmor();
if ($damage < 1) {
$damage = 1;
}
$player->decreaseHitpoints($damage);
}
示例11: distributeCards
public function distributeCards(Player $player)
{
$cards = $player->getCards();
if ($player->isHuman()) {
$this->playerCards = $cards;
} else {
$this->bankCards = $cards;
}
}
示例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());
}
示例13: play
public function play()
{
$player = new Player();
$result = array();
foreach (range(1, 20) as $number) {
$result[] = $player->fizzBuzz($number);
}
return $result;
}
示例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;
}
示例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);
}