本文整理汇总了PHP中Game::isIn方法的典型用法代码示例。如果您正苦于以下问题:PHP Game::isIn方法的具体用法?PHP Game::isIn怎么用?PHP Game::isIn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Game
的用法示例。
在下文中一共展示了Game::isIn方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: 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();
}
}
示例3: getView
public function getView($params, $synchrone)
{
try {
$game = new Game($params['game']);
if (!$game->isIn(F::i('Session')->getMid())) {
throw new Exception('You are not part of this Game');
}
} catch (Exception $e) {
// Get Out!
die('Oust !');
}
$game->reject(F::i('Session')->getMid());
Tools::redirect('?action=current_games');
}
示例4: getView
public function getView($params, $synchrone)
{
try {
if (!isset($params['game'])) {
throw new Exception('No Game given');
}
$game = new Game($params['game']);
if ($game->g_step == 0) {
throw new ModelException('Game not launched');
}
if (!$game->isIn(F::i('Session')->getMid())) {
throw new ModelException('You can\'t play : you are not in the game !');
}
$sql = array();
// Check all the actions
$params['act'] = isset($params['act']) ? $params['act'] : array();
for ($i = 0; $i < count($params['act']); $i++) {
list($from, $to, $strength, $priority) = explode(';', $params['act'][$i]);
if ($strength <= 0) {
throw new ModelException('Strength positive !');
}
if (!in_array($priority, $GLOBALS['priorities'])) {
throw new ModelException('Priority Unavailble !');
}
// Check actions
$result = F::i(_DBMS_SYS)->query('SELECT c1.cou_id AS cou_id1, c1.cou_name AS cou_from, c2.cou_id AS cou_id2, c2.cou_name AS cou_to FROM !prefix_adjacent a LEFT JOIN !prefix_countries c1 ON a.cou_id1 = c1.cou_id LEFT JOIN !prefix_countries c2 ON a.cou_id2 = c2.cou_id WHERE (c1.cou_name = ? AND c2.cou_name = ?) OR (c1.cou_name = ? AND c2.cou_name = ?)', array($from, $to, $to, $from));
if ($result->getNumRows() != 0) {
$obj = $result->getObject();
// Check capacity...
// TODO
$from_id = $obj->cou_from == $from ? $obj->cou_id1 : $obj->cou_id2;
$to_id = $obj->cou_to == $to ? $obj->cou_id2 : $obj->cou_id1;
$sql[] = array('INSERT INTO !prefix_actions (g_id, cou_from, cou_to, a_strength, a_priority) VALUES (?, ?, ?, ?, ?)', array($game->g_id, $from_id, $to_id, $strength, $priority));
}
}
// Confirm the player
F::i(_DBMS_SYS)->exec('UPDATE !prefix_players SET p_ready=1 WHERE m_id=? AND g_id=?', array(F::i('Session')->getMid(), $game->g_id));
// Insert Actions
F::i(_DBMS_SYS)->mexec($sql);
} catch (ModelException $e) {
// Get Out!
die('Oust ! : ' . $e->getMessage());
}
}
示例5: getView
public function getView($params, $synchrone)
{
try {
if (!isset($params['game'])) {
throw new Exception('No Game given');
}
$game = new Game($params['game']);
if (!$game->isIn(F::i('Session')->getMid())) {
throw new Exception('Not In');
}
if (!isset($params['step']) || empty($params['step'])) {
throw new Exception('Need step');
}
$view = View::setFile('confirm', View::JSON_FILE);
if ($params['step'] == $game->g_step + 1) {
// If all players ready
$result = F::i(_DBMS_SYS)->query('SELECT m_id FROM !prefix_players WHERE g_id=? AND p_ready=0', array($game->g_id));
if ($result->getNumRows() == 0) {
// If somebody is solving the game
// Dangerous Part so ask the database to have the LAST info
$result = F::i(_DBMS_SYS)->query('SELECT g_resolving FROM !prefix_games WHERE g_id=?', array($game->g_id));
if ($result->getObject()->g_resolving == 0) {
// Let's Solve !
F::i(_DBMS_SYS)->mexec(array(array('UPDATE !prefix_games SET g_resolving=1 WHERE g_id=?', array($game->g_id)), array('CALL PROC_SOLVE_ATTACKS(?)', array($game->g_id)), array('UPDATE !prefix_players SET p_ready=0 WHERE g_id=?', array($game->g_id)), array('UPDATE !prefix_games SET g_step=g_step+1 WHERE g_id=?', array($game->g_id)), array('UPDATE !prefix_games SET g_resolving=0 WHERE g_id=?', array($game->g_id))));
}
$view->setValue('confirm', 1);
} else {
$view->setValue('confirm', 0);
}
} else {
if ($params['step'] == $game->g_step) {
$view->setValue('confirm', 1);
} else {
throw new Exception('Not a valid step');
}
}
} catch (Exception $e) {
// Get Out!
die('Oust ! : ' . $e->getMessage());
}
return $view->getContent();
}
示例6: getView
public function getView($params, $synchrone)
{
$search_form = new Form($this->search_fields, $params);
$access_form = new Form($this->access_fields, $params);
$title = '';
$insert = TRUE;
try {
if (!isset($params['game'])) {
throw new Exception('No Game given');
}
$game = new Game($params['game']);
if ($game->isIn(F::i('Session')->getMid())) {
throw new Exception('Already In');
}
} catch (Exception $e) {
$insert = FALSE;
}
if ($insert) {
if ($game->g_access_key == 'NULL' || $access_form->isSubmitting() && Tools::isEmpty($access_form->getErrors()) && $game->g_access_key == Tools::saltHash($params['access_key'])) {
$game->insert(F::i('Session')->getMid());
Tools::redirect('?action=wait_game&game=' . $game->g_id);
} else {
// CHECK
if ($access_form->isSubmitting()) {
// Error
die('bad access key');
} else {
$view = View::setFile('formular', View::HTML_FILE);
$errors = $access_form->getErrors();
// Errors in the filling
if (!empty($errors)) {
$view->setSwitch('form_errors', TRUE);
foreach ($errors as $field => $error) {
$view->setGroupValues('form_errors', array('error' => F::i('Lang')->getKey('error_' . $field . '_' . $error)));
}
}
$view->setValue('form', $access_form->getHTML(F::i('Lang')->getKey('access_key'), '#', 'POST', 'tabbed_form'));
}
}
} else {
$sql = 'SELECT g.g_id, g_name, TIMESTAMPDIFF(HOUR, g_start, NOW()) AS lifetime, COUNT(*) AS g_total_players, m_login AS g_owner
FROM !prefix_members m, !prefix_games AS g, !prefix_players AS p
WHERE g.m_id = m.m_id
AND p.g_id = g.g_id
AND g.g_id NOT IN (
SELECT g_id FROM !prefix_players WHERE m_id = ?
)';
$array = array(F::i('Session')->getMid());
// If search is defined, add condition
if (isset($params['search'])) {
$sql .= ' AND g_name LIKE ?';
$array[] = '%' . $params['search'] . '%';
}
$sql .= ' GROUP BY g.g_id ORDER BY g_start DESC';
// Get all the games
$result = F::i(_DBMS_SYS)->query($sql, $array);
$view = View::setFile('list_games', View::HTML_FILE);
$view->setValue('form', $search_form->getHTML('', '#', 'POST', 'inline'));
if ($result->getNumRows() == 0) {
$view->setSwitch('no_games', TRUE);
}
for ($i = 0; $i < $result->getNumRows(); $i++) {
$obj = $result->getObject();
$view->setGroupValues('games', array('link' => '?action=join_game&game=' . $obj->g_id, 'name' => stripslashes($obj->g_name), 'total_players' => $obj->g_total_players, 'owner' => $obj->g_owner, 'lifetime' => $obj->lifetime));
}
$title = F::i('Lang')->getKey('title_join_game');
}
return parent::setBody($view);
}