本文整理汇总了PHP中Game类的典型用法代码示例。如果您正苦于以下问题:PHP Game类的具体用法?PHP Game怎么用?PHP Game使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Game类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: index
/**
* PAGE: index
* This method handles what happens when you move to http://yourproject/home/index (which is the default page btw)
*/
public function index()
{
$redirected = false;
//check if there is an error
if ($_GET['error'] != '') {
//load error page!
die("<h1>Whoops, something went wrong, you can refresh to see if it fixes it otherwise check back later.</h1>");
}
if (isset($_GET['appSource'])) {
$redirected = true;
$appSource = (int) $_GET['appSource'];
}
if (!$redirected) {
if (isset($_GET['id']) && $_GET['id'] != "") {
$extraParameters['id'] = $_GET['id'];
}
if (isset($_GET['fbSource'])) {
$extraParameters['appSource'] = $_GET['appSource'];
}
if (isset($_GET['traffic_source']) && $_GET['traffic_source'] != '') {
$extraParameters['traffic_source'] = $_GET['traffic_source'];
}
}
$signedRequest = null;
if (isset($_POST['signed_request'])) {
$signedRequest = self::parseSignedRequest($_POST['signed_request']);
}
Log::add('Signed request: ' . $signedRequest);
//check if user_id
if ($signedRequest === null) {
//we need to get one!
$url = Config::get('facebook.appurl') . "?" . http_build_query($_GET);
header("location: " . $url);
exit;
}
if (!isset($signedRequest['user_id']) || $signedRequest['user_id'] == '') {
$redirectUrl = self::buildUrl($extraParameters);
$oAuthUrl = "https://www.facebook.com/dialog/oauth?";
$oAuthUrl .= http_build_query(array_filter(array('client_id' => Config::Get('facebook.appid'), 'redirect_uri' => self::buildUrl($extraParameters), 'scope' => 'user_friends,email')));
die("<script>top.location.href = '" . $oAuthUrl . "';</script>");
}
$fbCurlReq = new Curl();
$fbCurlReq->setOpt(CURLOPT_SSL_VERIFYPEER, false);
$fbCurlReq->get('https://graph.facebook.com/me?access_token=' . $signedRequest['oauth_token']);
if ($fbCurlReq->error) {
Log::add('Error fb user profile ' . $fbCurlReq->error_code . ': ' . $fbCurlReq->error_message);
} else {
$dataArray = $fbCurlReq->response;
}
Log::add('dataArray = ' . print_r($dataArray, true));
//check too see if this is a post :)
$game = new Game();
$game->loadGame((array) $dataArray, 'facebook', $extraParameters);
}
开发者ID:sherdog,项目名称:wnd,代码行数:58,代码来源:home.php
示例2: executeCreate
public function executeCreate(sfWebRequest $request)
{
$user = UserPeer::retrieveByPk($request->getParameter('username'));
if (!$user) {
$arr = array();
$arr["result"] = false;
$arr["message"] = "Invalid username";
$this->renderText(json_encode($arr));
return sfView::NONE;
}
$game = new Game();
$game->setIsPublic($request->getParameter('public', 0));
$game->setStartTime(time());
$game->setIsActive(true);
$game->setLatitude($request->getParameter('latitude'));
$game->setLongitude($request->getParameter('longitude'));
$game->save();
$gameMember = new GameMember();
$gameMember->setUserId($user->getId());
$gameMember->setGameId($game->getId());
$gameMember->setIsActive(true);
$gameMember->save();
$user->setCurrentGameId($game->getId());
$this->updateUserLocation($user, $request);
$arr = array();
$arr["result"] = true;
$arr["message"] = "Game created, game number is " . $game->getId() . ". When others join, you will be assigned a target";
$this->renderText(json_encode($arr));
return sfView::NONE;
}
开发者ID:adatta02,项目名称:comp194ma,代码行数:30,代码来源:actions.class.php
示例3: getListJuegoDetalleFactura
function getListJuegoDetalleFactura($condicion = null, $parametros = array())
{
if ($condicion === null) {
$condicion = "";
} else {
$condicion = "where {$condicion}";
}
$sql = "select ju.*, de.*, fa.*, cl.* from detalle de \r\n left join juego ju on ju.id_juego = de.id_juego \r\n left join factura fa on fa.num_factura = de.num_factura \r\n left join cliente cl on fa.id_cliente = cl.id_cliente \r\n {$condicion} ORDER BY cl.email, fa.fecha desc ";
$this->bd->send($sql, $parametros);
$r = array();
$contador = 0;
while ($fila = $this->bd->getRow()) {
$juego = new Game();
$juego->set($fila);
$detalle = new Detalle();
$detalle->set($fila, 8);
$factura = new Factura();
$factura->set($fila, 13);
$cliente = new User();
$cliente->set($fila, 16);
$r[$contador]["juego"] = $juego;
$r[$contador]["factura"] = $factura;
$r[$contador]["detalle"] = $detalle;
$r[$contador]["cliente"] = $cliente;
$contador++;
}
return $r;
}
开发者ID:jjorgosogarcia,项目名称:videojuegosPhp,代码行数:28,代码来源:ManageRelationsJ.php
示例4: updateAction
public function updateAction()
{
$Game = new Game();
$data = array('title' => $this->_request->title, 'description' => $this->_request->description, 'price' => $this->_request->price, 'no_times_played' => $this->_request->no_times_played, 'purchase_date' => $this->_request->purchase_date);
$Game->update($data, "id = " . $this->_request->id);
$this->_redirect('main/index');
}
开发者ID:biscuiteater,项目名称:gamebox,代码行数:7,代码来源:GamesController.php
示例5: addGameRow
public function addGameRow(Game $oGame, $includeField = true)
{
$oGame = Game::getByNefubId($oGame->nefub_id);
$field = $oGame->field ? $oGame->field : 1;
$gameType = $oGame->getCompetition()->getGender()->name . ' ' . $oGame->getCompetition()->getGenre()->name;
$team1 = utf8_decode($oGame->getTeam1()->name);
$team2 = utf8_decode($oGame->getTeam2()->name);
if ($oGame->getFirstReferee()) {
$oGame = new Game($oGame->getId());
$oReferee = $oGame->getFirstReferee();
$referee = utf8_decode($oReferee->getName());
if (!$oReferee->getPerson()) {
$referee .= ' (' . $oReferee->getTeam()->getCompetition()->getGender()->name;
$referee .= ' ' . $oReferee->getTeam()->getCompetition()->getGenre()->name . ')';
}
} else {
$referee = 'Onbekend';
}
$text = $oGame->getFormattedTime();
$text .= "\t";
$text .= $team1;
$text .= "\t";
$text .= $team2;
$text .= "\n";
$text .= $gameType;
if ($includeField) {
$text .= $field;
}
$this->section->addText($text, array('name' => 'Arial', 'size' => 10, 'bold' => false));
}
开发者ID:rjpijpker,项目名称:nefub-mobile,代码行数:30,代码来源:ScheduleDocx.php
示例6: create
public static function create($m_id, $g_name, $access_key)
{
F::i(_DBMS_SYS)->exec('INSERT INTO !prefix_games (g_id, m_id, g_name, g_access_key) VALUES (NULL, ?, ?, ?)', array($m_id, $g_name, $access_key));
$game = new Game(F::i(_DBMS_SYS)->getInsertId());
$game->insert($m_id);
return $game;
}
开发者ID:Korko,项目名称:RiskOnline,代码行数:7,代码来源:Game.php
示例7: indexAction
public function indexAction()
{
// ok lets show all their games here
$Game = new Game();
$games = $Game->findAll($this->sessionUserId);
$this->view->games = $games;
}
开发者ID:biscuiteater,项目名称:gamebox,代码行数:7,代码来源:MainController.php
示例8: __invoke
public function __invoke()
{
$hitPoints = 103;
$damagePoints = 9;
$armourPoints = 2;
$boss = new Boss($hitPoints, $damagePoints, $armourPoints);
$game = new Game(new TurnTaker());
$weapons = $this->getWeaponCollection();
$armours = $this->getArmourCollection();
$rings = $this->getRingCollection();
$lowestCost = null;
foreach ($weapons as $w => $weapon) {
foreach ($armours as $a => $armour) {
$permutations = $this->getRingPermutations(array_keys($rings));
foreach ($permutations as $permutation) {
$boss->resurrect($hitPoints);
$r1 = $permutation[0];
$r2 = $permutation[1];
$player = new Player($weapon, $armour, $rings[$r1], $rings[$r2], 100);
/**
* @var $winner PlayerInterface
*/
$winner = $game->play($player, $boss);
if (!$winner->isBoss()) {
$cost = $weapon->getCost() + $armour->getCost() + $rings[$r1]->getCost() + $rings[$r2]->getCost();
if (!$lowestCost || $cost < $lowestCost) {
$lowestCost = $cost;
}
}
}
}
}
$this->write("Lowest amount of gold to win: " . $lowestCost);
}
开发者ID:garethellis36,项目名称:advent-of-code-2015,代码行数:34,代码来源:Puzzle1.php
示例9: getView
public function getView($params, $synchrone)
{
try {
$game = new Game($params['game']);
if ($game->g_step > 0) {
throw new Exception('Game already launched');
}
if (!$game->isIn(F::i('Session')->getMid())) {
throw new Exception('You are not in this game');
}
} catch (Exception $e) {
// Get Out!
die('Oust ! : ' . $e);
}
if ($synchrone) {
$view = View::setFile('wait_game', View::HTML_FILE);
$view->setValue('u_js', '?action=wait_game&game=' . $game->g_id);
$view->setValue('u_leave', '?action=leave_game&game=' . $game->g_id);
$view->setValue('game', stripslashes($game->g_name));
if ($game->m_id == F::i('Session')->getMid()) {
$view->setSwitch('creator', TRUE);
$view->setValue('u_launch', '?action=launch_game&game=' . $game->g_id);
}
return parent::setBody($view, F::i('Lang')->getKey('title_wait_game'));
} else {
$view = View::setFile('wait_game', View::JSON_FILE);
$players = $game->getPlayers();
for ($i = 0; $i < count($players); $i++) {
$view->setGroupValues('players', array('name' => $players[$i]->m_login, 'color' => $players[$i]->col_code, 'col_name' => $players[$i]->col_name));
}
return $view->getContent();
}
}
开发者ID:Korko,项目名称:RiskOnline,代码行数:33,代码来源:wait_game.php
示例10: load
public function load()
{
//1055918
$this->clear();
$game = new Game();
$game->setGametrackerId(1055918);
$homeTeam = new GameTeam();
$team = $this->CI->_team->findOneBySlug('miami-fl');
$homeTeam->setTeam($team);
$homeTeam->setScore(4);
$homeTeam->setSide('home');
$homeLineup = new Lineup();
// <player name="Alfredo Rodriguez" shortname="Rodriguez, A" code="" uni="2" gp="1" gs="1" spot="1" pos="ss" atpos="ss" bats="R" throws="R" class="SR" bioid="395839" bioxml="http://grfx.cstv.com/bios/00/39/58/395839.xml">
$player = $this->CI->_player->findOneBySlug('alfredo-rodriguez');
$batter = new GameBatter();
$batter->setPlayer($player);
$batter->setNumber(2);
$batter->setOrder(1);
$batter->setPosition('SS');
$batter->setAtBats(3);
$batter->setRuns(0);
$batter->setRunsBattedIn(1);
$batter->setWalks(1);
$batter->setHitByPitch(1);
$batter->setGroundBalls(1);
$batter->setFlyBalls(2);
$batter->save();
$homeLineup->addPlayer($batter);
$homeTeam->setLineup($homeLineup);
$game->setHome($homeTeam);
print_r($game->getHome()->getLineup()->getPlayers());
die;
$division->save();
print_r(sprintf("Created Division: %s (%s)\n", $division->getName(), $division->getId()));
}
开发者ID:bigjoevtrj,项目名称:codeigniter-bootstrap,代码行数:35,代码来源:game.php
示例11: getView
public function getView($params, $synchrone)
{
try {
$game = new Game($params['game']);
if (!$game->isIn(F::i('Session')->getMid())) {
throw new Exception('Not In');
}
} catch (Exception $e) {
// Get Out!
die('Oust !');
}
$view = View::setFile('map', View::HTML_FILE);
/**
* Links
*/
$result = F::i(_DBMS_SYS)->query('SELECT cou1.cou_name AS cou1, cou2.cou_name AS cou2 FROM !prefix_adjacent a, !prefix_countries cou1, !prefix_countries cou2 WHERE a.cou_id1 = cou1.cou_id AND a.cou_id2 = cou2.cou_id');
while (($obj = $result->getObject()) != NULL) {
$view->setGroupValues('adjacents', array('from' => $obj->cou1, 'to' => $obj->cou2));
}
$view->setValue('game', $game->g_id);
$view->setValue('mode', isset($params['mode']) ? $params['mode'] : 'owner');
$view->setValue('confirmed', $game->getPlayer(F::i('Session')->getMid())->p_ready);
$view->setValue('step', $game->g_step);
$view->setValue('m_id', F::i('Session')->getMid());
return parent::setBody($view, '', TRUE);
}
开发者ID:Korko,项目名称:RiskOnline,代码行数:26,代码来源:play.php
示例12: display
function display($id)
{
$game = new Game();
$game->setId($id);
$game = Query::getOne($game);
return $game;
}
开发者ID:jocodev1,项目名称:colliermvc,代码行数:7,代码来源:GameController.php
示例13: getView
public function getView($params, $synchrone)
{
try {
$game = new Game($params['game']);
if ($game->g_step > 0) {
throw new Exception('Game already launched');
}
if ($game->m_id != F::i('Session')->getMid()) {
throw new Exception('You are not the owner of this game !');
}
if ($game->getNumPlayers() == 1) {
throw new Exception('Cannot launch a game with a single player');
}
} catch (Exception $e) {
// Get Out!
die('Oust !');
}
// Give countries to players
/*
* 42 countries
* /2 => 21
* /3 => 14
* /4 => 10.5 (10 + 2)
* /5 => 8.4 (8 + 2)
* /6 => 7
* /7 => 6
* /8 => 5.25 (5 + 2)
* /9 => 4.67 (4 + 6)
* /10 => 4.2 (4 + 2)
*/
$players = $game->getPlayers();
$count_players = count($players);
$result = F::i(_DBMS_SYS)->query('SELECT cou_id FROM !prefix_countries');
$countries = array();
while (($obj = $result->getObject()) != NULL) {
$countries[] = $obj->cou_id;
}
$count_countries = count($countries);
$countries_per_player = intval($count_countries / $count_players);
shuffle($countries);
$lands = array_chunk($countries, $countries_per_player);
// What to do with the last countries ? Give...
$remaining = array();
if (count($lands) > $count_players) {
$remaining = $lands[$count_players];
}
shuffle($players);
for ($i = 0; $i < count($remaining); $i++) {
$lands[$i][] = $remaining[$i];
}
// Save and Go to step 1
for ($i = 0; $i < $count_players; $i++) {
for ($j = 0; $j < count($lands[$i]); $j++) {
F::i(_DBMS_SYS)->exec('INSERT INTO !prefix_lands (g_id, cou_id, m_id) VALUES (?, ?, ?)', array($params['game'], $lands[$i][$j], $players[$i]->m_id));
}
}
$game->nextStep();
Tools::redirect('?action=play&game=' . $params['game']);
}
开发者ID:Korko,项目名称:RiskOnline,代码行数:59,代码来源:launch_game.php
示例14: testSetCLock
public function testSetCLock()
{
$game = new Game();
$clock = $this->getClockMock();
$game->setClock($clock);
$this->assertSame($clock, $game->getClock());
$this->assertTrue($game->hasClock());
}
开发者ID:hotfics,项目名称:lichess-old,代码行数:8,代码来源:GameTest.php
示例15: beforeSave
public function beforeSave()
{
if (preg_match('/^ん$/u', mb_substr($this->data['Word']['pronunciation'], -1, 1, 'UTF-8')) === 1) {
App::import('Model', 'Game');
$game = new Game();
$game->save(array('id' => $this->data['Word']['game_id'], 'is_active' => false), false, array('is_active'));
}
return parent::beforeSave();
}
开发者ID:ndyuya,项目名称:word-chain-game,代码行数:9,代码来源:Word.php
示例16: reload
public function reload()
{
if ($this->isLoaded()) {
$this->SQL->delete_game($this->Game->chat_id);
}
$this->Game = new Game();
$this->Game->construct($this->chat_id, mt_rand(0, 5), 0);
return $this->SQL->insert_game($this->Game);
}
开发者ID:squaredcircle,项目名称:GroupBot,代码行数:9,代码来源:RussianRoulette.php
示例17: byGame
public function byGame()
{
$CRs = new CR($this->db);
$this->f3->set('list', $CRs->byGame($this->f3->get('PARAMS.id')));
$Game = new Game($this->db);
$this->f3->set('game', $myGame = $Game->load(array('id=?', $this->f3->get('PARAMS.id'))));
$this->f3->set('site_title', 'CRs de ' . $myGame['name'] . ' | CROTYpedia');
$this->f3->set('view', 'cr/index.htm');
}
开发者ID:XaaT,项目名称:ttb,代码行数:9,代码来源:CRController.php
示例18: displayTopPlayers
public function displayTopPlayers()
{
echo "\n\t\t\t<span>\n\t\t\t<b>·</b> <a href='" . MAIN_ROOT . "top-players/recruiters.php'>Recruiters</a>\n\t\t\t</span><br>\n\t\t\t";
$hpGameObj = new Game($this->MySQL);
$arrGames = $hpGameObj->getGameList();
foreach ($arrGames as $gameID) {
$hpGameObj->select($gameID);
echo "\n\t\t\t\t<span>\n\t\t\t\t<b>·</b> <a href='" . MAIN_ROOT . "top-players/game.php?gID=" . $gameID . "'>" . $hpGameObj->get_info_filtered("name") . "</a>\n\t\t\t\t</span><br>\n\t\t\t\t";
}
}
开发者ID:bluethrust,项目名称:clanscriptsv4,代码行数:10,代码来源:roboredmenu.php
示例19: actionAnswer
function actionAnswer()
{
$game = new Game();
if (isset($_POST['answer']) && !empty($_POST['answer'])) {
$answer = Functions::Encode($_POST['answer']);
$answer_id = Functions::Encode($_POST['answer_id']);
$model = $game->verifyAnswer($answer_id, $answer);
print $model;
}
}
开发者ID:KGB-Steam,项目名称:test,代码行数:10,代码来源:GameController.php
示例20: randomGame
public function randomGame()
{
$id = $this->db->getValue("select id from chess_game where database_id=? order by rand()", $this->getId());
if (isset($id)) {
$game = new Game($id);
return $game->read();
} else {
throw new LudoDBObjectNotFoundException("No games found in selected database(" . $this->getId() . ")");
}
}
开发者ID:manishkhanchandani,项目名称:mkgxy,代码行数:10,代码来源:Database.php
注:本文中的Game类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论