本文整理汇总了PHP中Player::getFromBZID方法的典型用法代码示例。如果您正苦于以下问题:PHP Player::getFromBZID方法的具体用法?PHP Player::getFromBZID怎么用?PHP Player::getFromBZID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Player
的用法示例。
在下文中一共展示了Player::getFromBZID方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getNewUser
protected function getNewUser($username = "Sam", $role = Player::PLAYER)
{
// Try to find a valid bzid
$bzid = 300;
while (Player::getFromBZID($bzid)->isValid()) {
++$bzid;
if ($bzid > 15000) {
throw new Exception("bzid too big");
}
}
return Player::newPlayer($bzid, $username, null, "test", $role);
}
示例2: playerByBzidAction
public function playerByBzidAction(Player $me, Request $request, FlashBag $flashBag, $bzid = null)
{
if (!$me->hasPermission(Permission::VIEW_VISITOR_LOG)) {
throw new ForbiddenException();
}
if ($bzid === null) {
if (!$request->query->has('bzid')) {
throw new BadRequestException("Please provide the BZID to search for");
}
$bzid = $request->query->get('bzid');
}
$player = Player::getFromBZID($bzid);
if (!$player->isValid()) {
$flashBag->add('error', "Player with BZID {$bzid} not found");
return $this->goBack();
}
return new RedirectResponse($player->getURL());
}
示例3: loginAction
public function loginAction(Request $request, Player $me)
{
if ($me->isValid()) {
throw new ForbiddenException("You are already logged in!");
}
$query = $request->query;
$session = $request->getSession();
$token = $query->get("token");
$username = $query->get("username");
if (!$token || !$username) {
throw new BadRequestException();
}
// Don't check whether IPs match if we're on a development environment
$checkIP = !$this->isDebug();
$info = validate_token($token, $username, array(), $checkIP);
if (!isset($info)) {
throw new ForbiddenException("There was an error processing your login. Please go back and try again.");
}
$session->set("username", $info['username']);
$session->set("groups", $info['groups']);
$redirectToProfile = false;
if (!Player::playerBZIDExists($info['bzid'])) {
// If they're new, redirect to their profile page so they can add some info
$player = Player::newPlayer($info['bzid'], $info['username']);
$redirectToProfile = true;
} else {
$player = Player::getFromBZID($info['bzid']);
if ($player->isDeleted()) {
$player->setStatus('active');
}
}
$session->set("playerId", $player->getId());
$player->updateLastLogin();
$player->setUsername($info['username']);
Visit::enterVisit($player->getId(), $request->getClientIp(), gethostbyaddr($request->getClientIp()), $request->server->get('HTTP_USER_AGENT'), $request->server->get('HTTP_REFERER'));
$this->configPromoteAdmin($player);
if ($redirectToProfile) {
$profile = Service::getGenerator()->generate('profile_show');
return new RedirectResponse($profile);
} else {
return $this->goBack();
}
}
示例4: AppKernel
#!/usr/bin/env php
<?php
use BZIon\Event\ConversationAbandonEvent;
use BZIon\Event\ConversationJoinEvent;
use BZIon\Event\ConversationKickEvent;
use BZIon\Event\ConversationRenameEvent;
use BZIon\Event\Events;
use BZIon\Event\WelcomeEvent;
require_once __DIR__ . "/../bzion-load.php";
$kernel = new AppKernel("dev", true);
$kernel->boot();
$testPlayer = Player::getFromBZID(3030);
if ($testPlayer->isValid()) {
die("Please clear your current data in the database or you'll end up with duplicate entries.\n");
}
echo "Adding players...";
$alezakos = Player::newPlayer(49434, "alezakos", null, "active", Player::DEVELOPER, "", "Sample description", 84);
$allejo = Player::newPlayer(31098, "allejo", null, "active", Player::DEVELOPER, "", "I'm the one who breaks the build", 227);
$ashvala = Player::newPlayer(34353, "ashvala", null, "active", Player::DEVELOPER, "", "", 100);
$autoreport = Player::newPlayer(55976, "AutoReport", null, "test");
$blast = Player::newPlayer(180, "blast", null, "active", Player::S_ADMIN);
$kierra = Player::newPlayer(2229, "kierra", null, "active", Player::ADMIN, "", "", 174);
$mdskpr = Player::newPlayer(8312, "mdskpr");
$snake = Player::newPlayer(54497, "Snake12534");
$tw1sted = Player::newPlayer(9736, "tw1sted", null, "active", Player::DEVELOPER);
$brad = Player::newPlayer(3030, "brad", null, "active", Player::S_ADMIN, "", "I keep nagging about when this project will be done");
$constitution = Player::newPlayer(9972, "Constitution", null, "active", Player::S_ADMIN);
$themap = Player::newPlayer(57422, "the map", null, "active", Player::COP);
$oldSnake = Player::newPlayer(54498, "Snake12534");
$oldSnake->setOutdated(true);
$allPlayers = array($alezakos, $allejo, $ashvala, $autoreport, $blast, $kierra, $mdskpr, $snake, $tw1sted, $brad, $constitution, $themap);
示例5: bzidsToIdArray
/**
* Convert a comma-separated list of bzids to player IDs so we can pass
* them to Match::enterMatch()
*
* @param string $players A comma-separated list of BZIDs
* @return int[] A list of Player IDs
*/
private function bzidsToIdArray($players)
{
$players = explode(',', $players);
foreach ($players as &$player) {
$player = Player::getFromBZID($player)->getId();
}
return $players;
}
示例6: parsePlayers
/**
* Get an array of players based on a string representation
* @param string $playerString
* @return Player[]|null Returns null if there were no players recorded for this match
*/
private static function parsePlayers($playerString)
{
$players = array();
if ($playerString == null) {
return null;
}
$BZIDs = explode(",", $playerString);
foreach ($BZIDs as $bzid) {
$players[] = Player::getFromBZID($bzid);
}
return $players;
}