Esempio n. 1
0
 private function printPlayerStats($nick, $global = false)
 {
     $serverchannel = $this->Server->id . ':' . $this->Channel->id;
     if ($global) {
         $sql = "\n\t\t\t\tSELECT\n\t\t\t\t\t`nick`, SUM(`played`) AS `played`, SUM(`started`) AS `started`, SUM(`lost`) AS `lost`, SUM(`clicks`) AS `clicks`\n\t\t\t\tFROM\n\t\t\t\t\t`roulette`\n\t\t\t\tWHERE\n\t\t\t\t\t`nick` = '" . addslashes($nick) . "'\n\t\t\t";
     } else {
         $sql = "\n\t\t\t\tSELECT\n\t\t\t\t\t*\n\t\t\t\tFROM\n\t\t\t\t\t`roulette`\n\t\t\t\tWHERE\n\t\t\t\t\t`serverchannel` ='" . addslashes($serverchannel) . "'\n\t\t\t\t\tAND `nick` = '" . addslashes($nick) . "'\n\t\t\t";
     }
     $data = $this->MySQL->fetchRow($sql);
     if (!$data) {
         $this->reply($nick . ' has never played roulette.');
         return;
     }
     $this->reply(sprintf('%s has played %s, won %d and lost %d. %s started %s, pulled the trigger %s and found the chamber empty on %s.', $data['nick'], libString::plural('game', $data['played']), $data['played'] - $data['lost'], $data['lost'], $data['nick'], libString::plural('game', $data['started']), libString::plural('time', $data['clicks'] + $data['lost']), libString::plural('occasion', $data['clicks'])));
 }
Esempio n. 2
0
 private function printPlayerStats($nick)
 {
     $ranking = $this->getVar('ranking', array());
     $stats = false;
     if (preg_match('/[^0-9]/', $nick)) {
         foreach ($ranking as $index => $rank) {
             if ($rank['nick'] == $nick) {
                 $stats = $rank;
                 $stats['rank'] = $index + 1;
                 break;
             }
         }
         if ($stats === false) {
             $this->reply($nick . ' has never played dice.');
             return;
         }
     } else {
         if (isset($ranking[$nick - 1])) {
             $stats = $ranking[$nick - 1];
             $stats['rank'] = $nick;
         } else {
             $this->reply("No one is on that rank.");
             return;
         }
     }
     $text = sprintf("%s has played %s, won %d and lost %d. %s is on rank %d of %d. %s's last game was %s ago.", $stats['nick'], libString::plural('game', $stats['played']), $stats['won'], $stats['played'] - $stats['won'], $stats['nick'], $stats['rank'], sizeof($ranking), $stats['nick'], libTime::secondsToString(time() - $stats['last_played']));
     if ($stats['rank'] != 1) {
         $text .= sprintf(" %s needs to win %s to rankup.", $stats['nick'], libString::plural('more game', $ranking[$stats['rank'] - 2]['won'] - $stats['won'] + 1));
     }
     $this->reply($text);
 }