本文整理汇总了PHP中game类的典型用法代码示例。如果您正苦于以下问题:PHP game类的具体用法?PHP game怎么用?PHP game使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了game类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: index
function index(){
if (!$this->sub){
return array(
'name'=>'微游戏',
'subkeywords'=>1,
'sublinks'=>1,
);
}else {
$game=new game();
$items=M('Games')->where(array('token'=>$this->token))->select();
$arr=array(
'name'=>'微游戏',
'subkeywords'=>array(
),
'sublinks'=>array(
),
);
if ($items){
foreach ($items as $v){
$link=$game->getLink($v,'{wechat_id}');
$arr['subkeywords'][$v['id']]=array('name'=>$v['title'],'keyword'=>$v['keyword']);
$arr['sublinks'][$v['id']]=array('name'=>$v['title'],'link'=>$link);
}
}
return $arr;
}
}
开发者ID:kevicki,项目名称:pig,代码行数:28,代码来源:FunctionLibrary_game.class.php
示例2: process
public function process()
{
$user = user::getInstance();
$db = db::getInstance();
include './models/game.class.php';
include './models/grid.class.php';
// récupérer le gameid
$this->gameid = isset($_REQUEST['gameid']) ? intval($_REQUEST['gameid']) : false;
if ($this->gameid === false) {
trigger_error('Game not found', E_USER_ERROR);
}
// lecture de l'objet game
$game = new game();
$game->read($this->gameid);
// création d'une nouvelle grille
$gridtype = GRIDTYPE_ALLWORDS;
$grid = new grid();
$gridid = $grid->create($gridtype);
// ajout de la grille au game
$game->assign_grid($gridid);
$game->start_grid($gridid);
// enrichissement du retour json
$res = $grid->get();
$res->gameid = $this->gameid;
$res->gametype = GAMETYPE_PRACTICE_ALLWORDS;
header('Content-Type: application/json');
echo json_encode($res);
die;
}
开发者ID:ryu38000,项目名称:Magic-Word-game,代码行数:29,代码来源:game.launch.practice.allwords.class.php
示例3: index
public function index()
{
$thisItem = $this->item;
$game = new game();
$link = $game->getLink($thisItem, $this->wechat_id);
return array(array(array($thisItem['title'], $thisItem['intro'], $thisItem['picurl'], $link)), 'news');
}
开发者ID:node-rookie,项目名称:bdg,代码行数:7,代码来源:GameReply.class.php
示例4: myDynamic
public function myDynamic()
{
$vhost = 'http://www.meihua.com';
$wxinfo = M('Wxuser')->where(array('uid' => intval(session('uid')), 'token' => $this->token))->find();
$PData = array('uname' => $this->token, 'domain' => $_SERVER['HTTP_HOST'], 'email' => $wxinfo['qq'], 'gzh' => $wxinfo['wxid'], 'gzhname' => $wxinfo['wxname']);
$key = 'Y@2T&9i3l#m8u';
$tmp = array();
foreach ($PData as $kk => $vv) {
$tmp[] = md5($kk . trim($vv) . $key);
}
$game = new game();
$key = base64_encode(implode('_', $tmp));
$PData['key'] = $key;
$request_url = $vhost . '/index.php?m=Index&c=login&a=verifyUser';
$tmpdata = $game->api_notice_increment($request_url, $PData, 'POST');
if ($tmpdata == '') {
$tmpdata = $game->api_notice_increment($request_url, $PData, 'POST');
}
$type = $this->_get('type', 'trim');
unset($_GET['token']);
$iframeUrl = $vhost . '/index.php?m=Index&c=login&a=loginNoPwd&logkey=' . $tmpdata . '&' . http_build_query($_GET);
$this->assign('iframeUrl', $iframeUrl);
$this->display();
}
开发者ID:kevicki,项目名称:pig,代码行数:28,代码来源:CustomTmplsAction.class.php
示例5: link
public function link()
{
$id = $this->_get("id");
$wecha_id = $this->wecha_id;
$siteUrl = $this->_get("siteurl");
$item = M("Games")->where(array("id" => $id))->find();
if ($item) {
$game = new game();
$url = $game->getLink($item, $wecha_id, $siteUrl);
header("Location:" . $url);
}
}
开发者ID:kevicki,项目名称:pig,代码行数:13,代码来源:GameAction.class.php
示例6: process
public function process()
{
$db = db::getInstance();
$user = user::getInstance();
include './models/game.class.php';
// récupérer le gameid si il existe
$game = false;
$this->gameid = isset($_REQUEST['gameid']) ? intval($_REQUEST['gameid']) : false;
if ($this->gameid !== false) {
$game = new game();
if (!$game->read($this->gameid)) {
$this->gameid = false;
trigger_error('Game not found!', E_USER_ERROR);
}
if (!isset($game->userids[$user->id])) {
$this->gameid = false;
trigger_error('Not your game!', E_USER_ERROR);
}
}
/*// fermer toute grille en cours pour cet utilisateur
$sql = 'UPDATE gamesstatus
SET gridstatus = ' . intval(GRIDSTATUS_FINISHED) . '
WHERE userid = ' . intval($user->id) . '
AND gridstatus = ' . intval(GRIDSTATUS_STARTED);
$db->query($sql);*/
// déterminer le type de partie à partir du mode
$gametype = false;
switch ($this->mode) {
case 'game.launch.practice.allwords':
$gametype = GAMETYPE_PRACTICE_ALLWORDS;
break;
case 'game.launch.practice.longest':
$gametype = GAMETYPE_PRACTICE_LONGEST;
break;
case 'game.launch.practice.constraints':
$gametype = GAMETYPE_PRACTICE_CONSTRAINTS;
break;
case 'game.launch.practice.full':
$gametype = GAMETYPE_PRACTICE_FULL;
break;
}
// créer une nouvelle partie
if (!$this->gameid) {
$userids = array($user->id);
$game = new game();
$this->gameid = $game->create($userids, $gametype, $user->get_lang());
}
return $this->display();
}
开发者ID:ryu38000,项目名称:Magic-Word-game,代码行数:49,代码来源:game.launch.practice.main.class.php
示例7: send_email
/** Send en bestemt artikkel på e-post */
protected function send_email($row)
{
$this->email->text('Hei,
Siden du ikke lengre er med i avisfirmaet "' . $row['ff_name'] . '" har din artikkel blitt slettet fordi den ikke tilhørte noen utgivelse. I tilfelle du kanskje ønsker å beholde teksten fra artikkelen, sender vi den på e-post.
Avisfirma: ' . $row['ff_name'] . ' <' . ess::$s['path'] . '/ff/?ff_id=' . $row['ff_id'] . '>
Tittel: ' . $row['ffna_title'] . '
Opprettet: ' . ess::$b->date->get($row['ffna_created_time'])->format(date::FORMAT_SEC) . ($row['ffna_updated_time'] ? '
Sist oppdatert: ' . ess::$b->date->get($row['ffna_updated_time'])->format(date::FORMAT_SEC) : '') . ($row['ffna_published'] ? '
Publisert: ' . ess::$b->date->get($row['ffna_published_time'])->format(date::FORMAT_SEC) : '') . '
Pris: ' . game::format_cash($row['ffna_price']) . '
Innhold:
-- START --
' . $row['ffna_text'] . '
-- SLUTT --
--
Kofradia.no
Denne e-posten er sendt til ' . $row['u_email'] . ' som ' . ($row['up_access_level'] == 0 ? 'tidligere tilhørte' : 'tilhører') . ' ' . $row['up_name'] . '
' . ess::$s['path']);
$this->email->format();
mailer::add_emails($this->email, $row['u_email'], "Din tidligere artikkel: {$row['ffna_title']} - Kofradia", true);
putlog("CREWCHAN", "AVISARTIKKEL SLETTET: E-post planlagt for utsendelse. %c4Mailer scriptet må kjøres!");
}
开发者ID:Kuzat,项目名称:kofradia,代码行数:29,代码来源:class.avis_slett_artikler.php
示例8: process
public function process()
{
$db = db::getInstance();
$user = user::getInstance();
include './models/game.class.php';
include './models/grid.class.php';
// récupérer le gameid
$this->gameid = isset($_REQUEST['gameid']) ? intval($_REQUEST['gameid']) : false;
if ($this->gameid === false) {
trigger_error('Game not found', E_USER_ERROR);
}
// lecture de l'objet game
$game = new game();
$game->read($this->gameid);
// lire les grilles terminées pour trouver le prochain type de grille
$sql = 'SELECT COUNT(gridid) AS count_gridid
FROM gamesstatus
WHERE gameid = ' . intval($this->gameid) . '
AND userid = ' . intval($user->id) . '
AND gridstatus = ' . intval(GRIDSTATUS_FINISHED);
$result = $db->query($sql);
$grid_count = ($row = $result->fetch_assoc()) ? intval($row['count_gridid']) : 0;
// déterminer le prochain type de grille
switch ($grid_count) {
case 0:
$gridtype = GRIDTYPE_ALLWORDS;
break;
case 1:
$gridtype = GRIDTYPE_LONGEST;
break;
case 2:
$gridtype = GRIDTYPE_CONSTRAINTS;
break;
}
// création d'une nouvelle grille
$grid = new grid();
$gridid = $grid->create($gridtype);
// ajout de la grille au game
$game->assign_grid($gridid);
$game->start_grid($gridid);
$res = $grid->get();
$res->gameid = $this->gameid;
$res->gametype = GAMETYPE_PRACTICE_FULL;
header('Content-Type: application/json');
echo json_encode($res);
die;
}
开发者ID:ryu38000,项目名称:Magic-Word-game,代码行数:47,代码来源:game.launch.practice.full.class.php
示例9: test
public function test()
{
$username = "howdy";
$password = "123456";
$email = "[email protected]";
$username2 = "bla2";
$password2 = "pass2";
$email2 = "[email protected]";
user::create_new_user($username, $password, $email);
$this->assertEquals(1, user::getNumberOfUsers(), "number of users is not correct after adding a new user");
user::create_new_user($username2, $password2, $email2);
$this->assertEquals(2, user::getNumberOfUsers(), "number of users is not correct after adding a new user");
$user1ID = user::getUserByUsername($username)['id'];
$user2ID = user::getUserByUsername($username2)['id'];
$game_size = 6;
$this->assertTrue(game::add_new_game($user1ID, $game_size, $user1ID, $user2ID), "failed to add a new game");
$game_id1 = game::$last_inserted_id;
$this->assertTrue(game::add_new_game($user2ID, $game_size, $user2ID, $user1ID), "failed to add a new game");
$game_id2 = game::$last_inserted_id;
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
//message::get_all_messages_for_game_id($game_id)
//message::add_new_message($game_id,$user_id,$message)
$message = "helllo";
$this->assertNull(message::get_all_messages_for_game_id($game_id1), "null should be returned because no messages added for the given game_id [get_all_messages_for_game_id()]");
$this->assertNull(message::get_all_messages_for_game_id("rr"), "null should be returned because an invalid game_id was passed [get_all_messages_for_game_id()]");
$this->assertFalse(message::add_new_message("hhh", $user1ID, $message), "false should be reutnred because an invalid game_id was passed [add_new_message()]");
$this->assertFalse(message::add_new_message($game_id1, "blla", $message), "false should be reutnred because an invalid user_id was passed [add_new_message()]");
$this->assertTrue(message::add_new_message($game_id1, $user1ID, $message), "falied to add new message [add_new_message()]");
$this->assertEquals(1, count(message::get_all_messages_for_game_id($game_id1)), "expecting to get an array with one message [get_all_messages_for_game_id()]");
$messages = message::get_all_messages_for_game_id($game_id1);
$this->assertEquals($message, $messages[0]['message_text'], "[add_new_message()]");
$this->assertEquals($game_id1, $messages[0]['gameID'], "[add_new_message()]");
$this->assertEquals($user1ID, $messages[0]['userID'], "[add_new_message()]");
$this->assertTrue(message::add_new_message($game_id2, $user1ID, "yolooo"), "falied to add new message [add_new_message()]");
$message2 = "where are you";
$this->assertTrue(message::add_new_message($game_id1, $user2ID, $message2), "falied to add new message [add_new_message()]");
$this->assertEquals(2, count(message::get_all_messages_for_game_id($game_id1)), "expecting to get an array with two messages [get_all_messages_for_game_id()]");
//message::get_message_count($game_id)
$this->assertEquals(2, message::get_message_count($game_id1), "[message::get_message_count()]");
$this->assertEquals(-1, message::get_message_count("asdasdasd"), "providing an invalid game_id so it should be rejected[message::get_message_count()]");
message::clear_table();
$this->assertEquals(0, message::get_message_count($game_id1), "[message::get_message_count()]");
$this->assertTrue(message::add_new_message($game_id1, $user1ID, $message), "falied to add new message [add_new_message()]");
$this->assertTrue(message::add_new_message($game_id1, $user2ID, $message2), "falied to add new message [add_new_message()]");
$this->assertTrue(message::add_new_message($game_id2, $user1ID, "yolooo"), "falied to add new message [add_new_message()]");
$this->assertEquals(1, message::get_message_count($game_id2), "[message::get_message_count()]");
$messages = message::get_all_messages_for_game_id($game_id1);
//message::get_all_messages_after_given_date($game_id,$date)
$this->assertNull(message::get_all_messages_after_given_date(0, 0), "get_all_messages_after_given_date()");
$this->assertNull(message::get_all_messages_after_given_date($messages[1]['gameID'], $messages[1]['date']), "get_all_messages_after_given_date()");
$this->assertEquals(1, count(message::get_all_messages_after_given_date($messages[0]['gameID'], $messages[0]['date'])), "get_all_messages_after_given_date()");
$this->assertEquals(2, count(message::get_all_messages_after_given_date($messages[0]['gameID'], $messages[0]['date'] - 0.1)), "get_all_messages_after_given_date()");
//message::delete_message($message_id)
$this->assertFalse(message::delete_message("dddd"), "[delete_message()]");
$this->assertTrue(message::delete_message($messages[0]['id']), "[delete_message()]");
$this->assertEquals(1, count(message::get_all_messages_after_given_date($messages[0]['gameID'], $messages[0]['date'] - 0.1)), "get_all_messages_after_given_date()");
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
}
开发者ID:uunuu,项目名称:dot_boxes,代码行数:58,代码来源:table_messageTest.php
示例10: hangman
/**
* Purpose: default constructor
* Preconditions: none
* Postconditions: parent object started
**/
function hangman()
{
/**
* instantiate the parent game class so this class
* inherits all of the game class's attributes
* and methods
**/
game::start();
}
开发者ID:MetalMor,项目名称:ExM7UF1,代码行数:14,代码来源:class.hangman.php
示例11: action_bestranker
/**
* Hent beste ranker siste 24 timer
*/
public function action_bestranker()
{
$stats = new \Kofradia\Users\Stats();
$players = $stats->getBestRankers();
if (count($players) == 0) {
return \Kofradia\View::forgeTwig('users/login/helpers/best_ranker', array("player" => null));
}
$player = reset($players);
return \Kofradia\View::forgeTwig('users/login/helpers/best_ranker', array("player" => $player, "img" => \player::get_profile_image_static($player['up_profile_image_url']), "rank" => new \Kofradia\Game\Player\Rank($player['up_points'], $player['upr_rank_pos'], $player['up_access_level']), "profile_link" => \game::profile_link($player['up_id'], $player['up_name'], $player['up_access_level'])));
}
开发者ID:Kuzat,项目名称:kofradia,代码行数:13,代码来源:Helpers.php
示例12: reload
/**
* Load settings and save to cache
*/
public static function reload()
{
$result = \Kofradia\DB::get()->query("SELECT id, name, value FROM settings");
\game::$settings = array();
while ($row = $result->fetch()) {
\game::$settings[$row['name']] = array("id" => $row['id'], "value" => $row['value']);
}
// keep for 1 hour
\cache::store("settings", \game::$settings, 3600);
}
开发者ID:Kuzat,项目名称:kofradia,代码行数:13,代码来源:Settings.php
示例13: counterFilter
public function counterFilter($time, $redirect_to)
{
$rel = (string) $time;
if ($redirect_to) {
if ($redirect_to === true) {
$rel .= ",refresh";
} else {
$rel .= "," . htmlspecialchars($redirect_to);
}
}
return '<span class="counter" rel="' . $rel . '">' . \game::timespan($time, \game::TIME_FULL, 5) . '</span>';
}
开发者ID:Kuzat,项目名称:kofradia,代码行数:12,代码来源:Counter.php
示例14: add_new_move
public static function add_new_move($game_id, $x, $y, $edgePosition, $player_id)
{
$date = microtime(true);
//TEST:
//game_id is valid
//player_id is valid
//consistent $x and $y coordinates with the game size
//valid edgePosition (it has to be one of the values: 1 (NORTH), 2 (SOUTH), 3 (EAST) , 4 (WEST) )
//secure the input
if (safe_input::is_number($game_id) && safe_input::is_number($x) && safe_input::is_number($y) && safe_input::is_number($edgePosition) && safe_input::is_number($player_id)) {
//validate game_id
$game_info = game::getGameById($game_id);
if ($game_info == false) {
return false;
//no game exists with the given id
}
$other_player_id = -1;
//check if player_id is a player in the game
if ($player_id == $game_info['player1ID']) {
$other_player_id = $game_info['player2ID'];
} elseif ($player_id == $game_info['player2ID']) {
$other_player_id = $game_info['player1ID'];
} else {
return false;
//ERROR!! (player tring to play is not part of the game
}
//check if it is the player's turn
if ($player_id != $game_info['currentTurnPlayerID']) {
return false;
//it is not the player's turn!
}
//check coordinates consistency
if ($x > $game_info['size'] || $y > $game_info['size'] || $x < 1 || $y < 1) {
return false;
//invalid move coordinates
}
//check edigePosition
if ($edgePosition != 1 && $edgePosition != 2 && $edgePosition != 3 && $edgePosition != 4) {
return false;
//invalid edgePosition value!
}
//add the move
$db = new database();
$query[] = "INSERT INTO `move` (`gameID`, `date`, `x`, `y`, `edgePosition`, `playerID`) VALUES ( '{$game_id}', '{$date}', '{$x}', '{$y}', '{$edgePosition}' , '{$player_id}');";
$query[] = "UPDATE `game` SET `currentTurnPlayerID` = '{$other_player_id}' , `lastActivityDate` = '{$date}' WHERE `id` = '{$game_id}'";
$res = $db->execute_transaction($query);
return $res;
} else {
return false;
//ERROR!!!! (invalid input!!)
}
}
开发者ID:uunuu,项目名称:dot_boxes,代码行数:52,代码来源:table_move.php
示例15: show_link
function show_link()
{
$ret = array();
for ($i = 0; $i < func_num_args(); $i++) {
$arg = func_get_arg($i);
if (!$this->exists($arg)) {
trigger_error("Fant ikke elementet med ID {$arg}!", E_USER_ERROR);
}
$type = $this->types[$this->elms[$arg]['type']];
// aktiv?
$active = $this->active == $arg ? 1 : 0;
$ret[] = '<a href="' . htmlspecialchars(game::address($this->address, $_GET, array($this->sort_name), array($this->sort_name => $arg))) . '" class="op50"><img src="' . $type[$active] . '" alt="' . htmlspecialchars($this->elms[$arg]['title']) . '" /></a>';
#if ($active == 1) return end($ret);
}
return implode("", $ret);
}
开发者ID:Kuzat,项目名称:kofradia,代码行数:16,代码来源:class.sorts.php
示例16: get_text
protected function get_text($name, $sub, $data)
{
switch ($name) {
case "rank":
case "rank_kill":
return ucfirst(game::$ranks['items_number'][$sub]['name']);
case "familie":
return 'Broderskap';
case "familie_rank":
return game::format_num($data['ff_points_sum']) . ' poeng';
case "ff_owner":
return ucfirst(ff::$types[$sub]['typename']);
case "cash_num":
return hall_of_fame::get_cash_pos($sub);
}
}
开发者ID:Kuzat,项目名称:kofradia,代码行数:16,代码来源:hall_of_fame.php
示例17: format_size
function format_size($bytes)
{
// GB
if ($bytes >= 1073741824) {
return game::format_number(round($bytes / 1073741824, 3), 3) . " GB";
}
// MB
if ($bytes >= 1048576) {
return game::format_number(round($bytes / 1048576, 2), 2) . " MB";
}
// KB
if ($bytes >= 1024) {
return game::format_number(round($bytes / 1024, 2), 2) . " KB";
}
// bytes
return $bytes . " bytes";
}
开发者ID:Kuzat,项目名称:kofradia,代码行数:17,代码来源:statistikk.php
示例18: visliste
function visliste($name, $where)
{
global $_base;
$result = \Kofradia\DB::get()->query("SELECT up_id, up_name, up_access_level, up_last_online FROM users_players WHERE {$where} ORDER BY up_name");
// hopp over hvis det ikke finnes noen
if ($result->rowCount() == 0) {
return;
}
echo '
<h2 class="bg1">' . $name . '<span class="left2"></span><span class="right2"></span></h2>
<div class="bg1">
<dl class="dd_right">';
while ($row = $result->fetch()) {
echo '
<dt>' . game::profile_link($row['up_id'], $row['up_name'], $row['up_access_level']) . '</dt>
<dd>' . game::timespan($row['up_last_online'], game::TIME_ABS | game::TIME_NOBOLD) . '</dd>';
}
echo '
</dl>
</div>';
}
开发者ID:Kuzat,项目名称:kofradia,代码行数:21,代码来源:crewet.php
示例19:
<?php
include_once './include/table_user.php';
include_once './include/table_game.php';
include_once './include/table_message.php';
include_once './include/table_log.php';
include_once './include/table_pending_game.php';
include_once './include/table_session.php';
include_once './include/table_move.php';
//drop the tables:
$successful = True;
$successful = move::drop_table() && $successful;
$successful = session::drop_table() && $successful;
$successful = pending_game::drop_table() && $successful;
$successful = log::drop_table() && $successful;
$successful = message::drop_table() && $successful;
$successful = game::drop_table() && $successful;
$successful = user::drop_table() && $successful;
if (!$successful) {
echo "Failed to delete tables";
} else {
echo "OK";
}
开发者ID:uunuu,项目名称:dot_boxes,代码行数:23,代码来源:uninstall.php
示例20: sql
include 'include/text_races.php';
include 'include/text_planets.php';
include 'include/ship_data.php';
include 'include/race_data.php';
include 'include/sql.php';
include 'include/functions.php';
// #############################################################################
// SQL-Object for Database connection
$db = new sql($config['server'] . ":" . $config['port'], $config['game_database'], $config['user'], $config['password']);
// create sql-object for db-connection
if (isset($_GET['sql_debug'])) {
$db->debug = true;
}
// #############################################################################
// Game-Object
$game = new game();
// #############################################################################
// Config load and evaluate
$game->load_config();
$ACTUAL_TICK = $NEXT_TICK = 0;
$ACTUAL_TICK = $game->config['tick_id'];
$NEXT_TICK = $game->config['tick_time'] - $game->TIME;
$LAST_TICK_TIME = $game->config['tick_time'] - 5 * 60;
// #############################################################################
// Session-System
include 'include/session.php';
if ($game->config['game_stopped'] == 1 && $game->player['user_auth_level'] != STGC_DEVELOPER) {
message(GENERAL, $game->config['stop_message']);
}
$game->init_player();
if (isset($_POST['user_notepad'])) {
开发者ID:startrekfinalfrontier,项目名称:UI,代码行数:31,代码来源:submit_notepad.php
注:本文中的game类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论