当前位置: 首页>>代码示例>>PHP>>正文


PHP Game::join方法代码示例

本文整理汇总了PHP中Game::join方法的典型用法代码示例。如果您正苦于以下问题:PHP Game::join方法的具体用法?PHP Game::join怎么用?PHP Game::join使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Game的用法示例。


在下文中一共展示了Game::join方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: create_game

 private function create_game($table = 0, $creator = null, $joiner = null)
 {
     $data = new stdClass();
     $data->name = $this->format . ' ' . addslashes($this->name);
     $data->name .= ' : Round ' . $this->round . ' Table ' . $table;
     $data->creator_nick = $creator->nick;
     $data->creator_id = $creator->player_id;
     $data->creator_avatar = $creator->avatar;
     $data->creator_deck = $creator->get_deck()->summarize();
     if ($joiner != null) {
         $data->joiner_nick = $joiner->nick;
         $data->joiner_id = $joiner->player_id;
         $data->joiner_avatar = $joiner->avatar;
         $data->joiner_deck = $joiner->get_deck()->summarize();
         $data->status = 3;
     } else {
         $data->status = 7;
         $data->creator_score = 2;
         $data->joiner_nick = 'BYE';
         $data->joiner_id = '';
         $data->joiner_avatar = '';
         $data->joiner_deck = '';
     }
     $data->tournament = $this->id;
     $data->round = $this->round;
     $game = new Game($data, 'tournament', $this);
     $game->join($data);
     return $game;
 }
开发者ID:OlivierLamiraux,项目名称:mtgas,代码行数:29,代码来源:ws_tournament.php

示例2: recieve

 public function recieve(WebSocketTransportInterface $user, $data)
 {
     switch ($data->type) {
         // Shout
         case 'shout':
             global $db;
             $nick = $db->escape($user->nick);
             $message = $db->escape($data->message);
             $db->query("INSERT\n\t\t\t\t\tINTO `shout` (`sender_id`, `sender_nick`, `message`)\n\t\t\t\t\tVALUES ('{$user->player_id}', '{$nick}', '{$message}')");
             $data->player_id = $user->player_id;
             $data->player_nick = $user->nick;
             $data->time = now();
             $this->shouts[] = $data;
             if (count($this->shouts) > $this->nbshouts) {
                 array_shift($this->shouts);
             }
             $this->broadcast(json_encode($data));
             break;
         case 'blur':
             $user->inactive = true;
             $this->broadcast(json_encode($this->list_users()));
             break;
         case 'focus':
             $user->inactive = false;
             $this->broadcast(json_encode($this->list_users()));
             break;
         case 'keypress':
             $user->typing = true;
             $this->broadcast(json_encode($this->list_users()));
             break;
         case 'keyup':
             $user->typing = false;
             $this->broadcast(json_encode($this->list_users()));
             break;
             // Duels
         // Duels
         case 'pendingduel':
             $data->creator_id = $user->player_id;
             $duel = new Game($data);
             $this->observer->pending_duels[] = $duel;
             $this->broadcast(json_encode($duel));
             break;
         case 'joineduel':
             $duel_index = $this->observer->pending_duel($data->id);
             if ($duel_index === false) {
                 $this->say('Pending duel ' . $data->id . ' not found');
                 break;
             }
             $splduels = array_splice($this->observer->pending_duels, $duel_index, 1);
             $duel = $splduels[0];
             if ($duel->creator_id == $user->player_id) {
                 $this->broadcast('{"type": "duelcancel", "id": "' . $data->id . '"}');
             } else {
                 $data->joiner_id = $user->player_id;
                 $duel = $duel->join($data);
                 $duel->type = 'joineduel';
                 // Send first one time to both players
                 $duel->redirect = true;
                 $json = json_encode($duel);
                 $this->send_first($json, $duel->creator_id);
                 $this->send_first($json, $duel->joiner_id);
                 // Then broadcast to inform other users game was joined
                 $duel->redirect = false;
                 $this->broadcast(json_encode($duel));
                 $this->observer->joined_duels[] = $duel;
             }
             break;
         case 'goldfish':
             $data->type = 'joineduel';
             $data->name = 'Goldfish';
             $data->creator_id = $user->player_id;
             $data->joiner_id = $user->player_id;
             $duel = new Game($data);
             $duel->join($data);
             $duel->redirect = true;
             $user->sendString(json_encode($duel));
             $duel->redirect = false;
             $this->observer->joined_duels[] = $duel;
             break;
             // Tournament
         // Tournament
         case 'pending_tournament':
             foreach ($this->observer->pending_tournaments as $tournament) {
                 if ($tournament->registered($user) !== false) {
                     $tournament->unregister($user);
                 }
             }
             $data->type = 'pending_tournament';
             $tournament = Tournament::create($data, $user);
             if (is_string($tournament)) {
                 $user->sendString('{"type": "msg", "msg": "' . $tournament . '"}');
             } else {
                 $tournament->type = $data->type;
                 $this->observer->pending_tournaments[] = $tournament;
                 $data->player_id = $user->player_id;
                 $tournament->register($data, $user);
             }
             break;
         case 'tournament_register':
             $data->player_id = $user->player_id;
//.........这里部分代码省略.........
开发者ID:OlivierLamiraux,项目名称:mtgas,代码行数:101,代码来源:ws_index_handler.php

示例3: catch

    }
} catch (MyException $e) {
    if (!defined('DEBUG') || !DEBUG) {
        Flash::store('Error Accessing Game !');
    } else {
        call('ERROR ACCESSING GAME');
    }
}
if (isset($_POST['join'])) {
    // make sure this user is not full
    if ($GLOBALS['Player']->max_games && $GLOBALS['Player']->max_games <= $GLOBALS['Player']->current_games) {
        Flash::store('You have reached your maximum allowed games !');
    }
    test_token();
    try {
        $Game->join();
        Flash::store('Game Joined Successfully');
    } catch (MyException $e) {
        if (214 == $e->getCode()) {
            Flash::store('That color is already in use, try again', true);
        } else {
            Flash::store('Game Join FAILED !');
        }
    }
}
if (isset($_POST['invite'])) {
    test_token();
    try {
        $player_ids = $Game->invite();
        // send the messages
        $message = 'You have been invited to join the game "' . htmlentities($Game->name, ENT_QUOTES, 'UTF-8', false) . '".' . "\n\n" . 'If you wish to play in this game, please join it from the home page.';
开发者ID:studywithyou,项目名称:webrisk,代码行数:31,代码来源:join.php


注:本文中的Game::join方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。