function printPlayers() { $k = 1; $p = new pokerHoldemPlayer(); $p->getPlayer(1, 1, "player A"); $this->hand_players[$k++] = $p; $p = new pokerHoldemPlayer(); $p->getPlayer(1, 2, "player B"); $this->hand_players[$k++] = $p; $p = new pokerHoldemPlayer(); $p->getPlayer(1, 3, "player C"); $this->hand_players[$k++] = $p; $k = 2; $t = $this->hand_players[$k]; echo $t->hand_id . " TN :" . $t->nick_name . "<br>"; $t->nick_name .= "Its NEW NOW"; $t->savePlayer(); echo $this->hand_players[$k]->hand_id . " N :" . $this->hand_players[$k]->nick_name . "<br>"; $k = 3; echo $this->hand_players[$k]->hand_id . " N :" . $this->hand_players[$k]->nick_name . "<br>"; echo "<pre>" . print_r($this->hand_players) . "</pre>"; }
function sitOnTable() { global $db; if (!isset($this->hand_players[$this->request['request_position']])) { $hp_id = 0; $sql = " SELECT * FROM holdem_hand_palyer WHERE player_id='" . $this->request['request_player_id'] . "' "; $pro = $db->mysqlFetchRow($sql); if ($pro) { if (intval($pro['table_id']) == 0) { $hp_id = $pro['id']; } else { $this->setLastError("You are already playing on some table"); return; } } $sql = " SELECT SUM(points) pts FROM points WHERE mid='" . $this->request['request_player_id'] . "' "; $ro = $db->mysqlFetchRow($sql); if (intval($ro['pts']) < $this->initial_stake) { $this->setLastError("You do not have sufficient balance to play on this table"); return; } $sql = " SELECT * FROM members WHERE id='" . $this->request['request_player_id'] . "' "; $ro = $db->mysqlFetchRow($sql); if (!$ro) { $this->setLastError("User not found. Please login and try again"); return; } $p = new pokerHoldemPlayer($this->request['table_id'], $this->request['request_player_id']); $p->id = $hp_id; $p->current_state = P_STATE_NEW; $p->table_position = $this->request['request_position']; $p->nick_name = $this->request['nick_name']; $p->table_stack = $this->request['table_stack']; if (intval($p->table_stack) == 0) { $p->table_stack = $this->initial_stake; } if ($p->nick_name == "") { $p->nick_name = $ro['First_Name']; } $p->last_request_time = time(); $p->savePlayer(); $this->hand_players[$this->request['request_position']] = $p; $mp = array(); $mp['mid'] = $p->player_id; $mp['edate'] = date("YmdHis"); $mp['points'] = 0 - $p->table_stack; $mp['game'] = "T"; $db->mysqlAddUpdateRow('points ', $mp); } else { $p = $this->hand_players[$this->request['request_position']]; if ($this->request['request_player_id'] == $p->player_id && $p->current_state == P_STATE_SITTING_OUT) { $p->current_state = P_STATE_NEW; $p->savePlayer(); } } }