本文整理汇总了PHP中Game::newGame方法的典型用法代码示例。如果您正苦于以下问题:PHP Game::newGame方法的具体用法?PHP Game::newGame怎么用?PHP Game::newGame使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Game
的用法示例。
在下文中一共展示了Game::newGame方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: header
<?php
User::requireLoggedIn();
if (require_params("new")) {
Game::newGame($_REQUEST["new"]);
}
if (require_params("reset_dungeon")) {
$game = Game::load();
$game->delete();
header("Location: /game");
die;
}
if (require_params("reset_messages")) {
$_SESSION["user"]->json_data["read_messages"] = array();
$_SESSION["user"]->save();
header("Location: /game");
die;
}
if (true) {
$game = Game::load();
?>
<h2><?php
echo $game->name;
?>
</h2>
<a href="?reset_dungeon=true">Reset dungeon</a>
<a href="?reset_messages=true">Reset read messages</a>
<div id="game-container" class="game-tile"></div>
<script type="text/javascript">
TLOR.setup($('#game-container'), <?php
示例2: load
public static function load()
{
$username = $_SESSION["user"]->name;
if (!$GLOBALS["db"]->exists("games", array("username"), array("username" => $username))) {
Game::newGame("origin");
}
$game_array = $GLOBALS["db"]->selectAll("games", array("username" => $username))[0];
$game_unpacked = json_decode($game_array["json_data"]);
$game = new Game();
apply_arr($game_unpacked, $game);
return $game;
}
示例3: header
<?php
require_once "config.php";
header("Content-Type: application/json");
$return = array();
if (empty($_POST['title']) or empty($_POST['description'])) {
$return['status'] = 'error';
$return['message'] = 'Missing Fields';
echo json_encode($return);
exit;
}
// Add userid to post for User::newUser
if (!isset($_SESSION['userid'])) {
$return['status'] = 'error';
$return['message'] = 'Must Be Logged In To Create Games';
echo json_encode($return);
exit;
}
$_POST['userid'] = $_SESSION['userid'];
$newGame = Game::newGame($_POST);
if ($newGame['status'] == 'success') {
$return['status'] = 'success';
$return['relocate'] = "view_deck.php?deckid=" . $_POST['deckid'];
} else {
$return['status'] = $newUser['status'];
$return['message'] = $newUser['message'];
}
echo json_encode($return);