Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if($data['i'] == 20010 && isset($data['d']) && $data['u'] != 404) {
- try {
- if($data['t'] == "") {
- if(isset($this->boards[$data['u']]))
- unset($this->boards[$data['u']]);// = new Connect4();
- return;
- }
- if((isset($this->boards[$data['u']]) && (strlen($data['t']) == 0 || strlen($data['t'] == 1))) || !isset($this->boards[$data['u']])) $this->boards[$data['u']] = new Connect4();
- $last = substr($data['t'], -1);
- if(is_numeric($last)) {
- return $this->sendPC($data['u'], "The fuck you doin?");
- }
- $move = $this->boards[$data['u']]->set(ord($last) - 65);
- //var_dump($move);
- if($move == 1000) {
- $this->sendPC($data['u'], "You have won.");
- unset($this->boards[$data['u']]);
- return;
- } else if ($move == 50) {
- $this->sendPC($data['u'], "You caused the game to become a draw.");
- unset($this->boards[$data['u']]);
- return;
- } else if ($move[0] == 51) {
- $this->sendPC($data['u'], "I caused the game to become a draw.");
- unset($this->boards[$data['u']]);
- } else if ($move == -1000 || $move[0] == -1000) {
- $this->sendPC($data['u'], "You have lost.");
- unset($this->boards[$data['u']]);
- } else if ($move == 666) {
- //$this->sendPC($data['u'], "Tsk tsk tsk... No cheating.");
- $this->socket->send($this->buildPacket('x', array(
- 'i' => 20010,
- 'u' => $data['d'],
- 'd' => $data['u'],
- 't' => substr($data['t'], 0, -1),
- )));
- return;
- } else if(strlen($data['t']) >= 42) {
- $this->sendPC($data['u'], "The game has ended in a draw because the board is full.");
- unset($this->boards[$data['u']]);
- return;
- }
- if(is_array($move)) {
- $move = $move[1];
- }
- $move = chr($move + 65);
- $this->socket->send($this->buildPacket('x', array(
- 'i' => 20010,
- 'u' => $data['d'],
- 'd' => $data['u'],
- 't' => $data['t'] . $move,
- )));
- } catch (Exception $e) {
- print $e->getMessage()."\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement