本文整理汇总了PHP中Render::player_cards方法的典型用法代码示例。如果您正苦于以下问题:PHP Render::player_cards方法的具体用法?PHP Render::player_cards怎么用?PHP Render::player_cards使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Render
的用法示例。
在下文中一共展示了Render::player_cards方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: finish_hand
public function finish_hand()
{
// find winning hand
if ($this->count_players_in_hand() == 1) {
$win_player = $this->get_last_player_standing();
$this->game_log[] = '<b>-- Hand Complete, No Showdown --</b>';
if ($this->community_cards->count() > 0) {
$this->game_log[] = 'Community Cards: ' . $this->render_community_cards();
}
$this->game_log[] = '<b>' . $win_player->name . '</b> wins $' . $this->get_pot_value() . ' (net $' . ($this->get_pot_value() - $win_player->games[$this->id]['tot_stake']) . ')';
$win_player->games[$this->id]['balance'] += $this->get_pot_value();
} else {
$this->game_log[] = '<b>*** SHOWDOWN ***</b>';
$this->game_log[] = 'Community Cards: ' . $this->render_community_cards();
$hand_pts = array();
$hand_txt = array();
foreach ($this->players as $player) {
$cards = array();
for ($i = 0; $i < 5; $i++) {
if ($i == 0 || $i == 1) {
// get player card also!
$cards[] = array('value' => $player->peek_card($i, $this->id)->get_numeric_rank(), 'suit' => $player->peek_card($i, $this->id)->get_suit());
}
// get community card
$cards[] = array('value' => $this->community_cards->cards[$i]->get_numeric_rank(), 'suit' => $this->community_cards->cards[$i]->get_suit());
}
$engine = new Engine($cards);
$hand = $engine->score($cards);
$hand_text = $engine->readable_hand($hand);
$this->game_log[] = '<b>' . $player->name . '</b> shows - ' . Render::player_cards($this, '', $player) . ' - ' . $hand_text;
$hand_pts[$player->client_id] = $hand;
$hand_txt[$player->client_id] = $hand_text;
}
asort($hand_pts);
$tmp_pts = -1;
$ways_split = 0;
$split_seats = array();
$lead_seat = NULL;
foreach ($hand_pts as $seat => $pts) {
if ($pts > $tmp_pts) {
$tmp_pts = $pts;
$split_seats[$seat] = $seat;
$split_pot = FALSE;
$lead_seat = $seat;
} elseif ($pts == $tmp_pts) {
$ways_split++;
$split_pot = TRUE;
$split_seats[$seat] = $seat;
}
}
if (!$split_pot) {
$player = $this->get_player_by_client_id($lead_seat);
$player->games[$this->id]['balance'] += $this->get_pot_value();
$this->game_log[] = '<b>' . $player->name . '</b> wins $' . $this->get_pot_value() . ' (net $' . ($this->get_pot_value() - $player->games[$this->id]['tot_stake']) . ') with ' . $hand_txt[$lead_seat];
} else {
$this->game_log[] = '<b>Split Pot</b>';
$split_amt = $this->get_pot_value() / $ways_split;
foreach ($this->players as $player) {
$player->games[$this->id]['balance'] += $split_amt;
}
$this->game_log[] = 'Each player wins $' . $split_amt;
}
}
foreach ($this->players as $player) {
if ($player->games[$this->id]['balance'] == 0) {
// END GAME!
$this->game_over = true;
} else {
$player->games[$this->id]['cur_stake'] = 0;
$player->games[$this->id]['tot_stake'] = 0;
$player->games[$this->id]['status'] = 'WAITING';
$player->cards[$this->id] = new Card_Collection();
}
}
if (!$this->game_over) {
// reset all cards
$this->deck = new Deck();
$this->deck->shuffle();
$this->community_cards = new Card_Collection();
$this->betting_round = 1;
// move dealer button
$this->dealer = $this->dealer == 1 ? 0 : 1;
}
}
示例2: render_game
public function render_game($game, $start_hand = false, $controls = true)
{
$i = 0;
foreach ($game->players as $player) {
$alt_seat = $i == 0 ? 1 : 0;
$render = array('game_id' => $game->id, 'game-' . $game->id . '-player_cards' => Render::player_cards($game, '', $player), 'game-' . $game->id . '-player_text' => Render::player_text($game, '', $player), 'game-' . $game->id . '-opponent_cards' => Render::player_cards($game, $alt_seat), 'game-' . $game->id . '-opponent_text' => Render::player_text($game, $alt_seat), 'game-' . $game->id . '-community_cards' => Render::community_cards(), 'game-' . $game->id . '-pot' => '<b>Pot: $' . $game->get_pot_value() . '</b>');
if ($game->current_turn == $i && $controls) {
$render['game-' . $game->id . '-game_controls'] = Render::game_actions($game, $player);
}
$this->send_to_one($player->client_id, 'game_render', $render);
if ($start_hand) {
// send their cards to the game log
$this->send_to_one($player->client_id, 'game_log', array('game_id' => $game->id, 'msgs' => array('<b>You were dealt:</b> ' . Render::player_cards($game, $i, $player))));
}
$i++;
}
}