Example #1
0
 public function main()
 {
     $Level = new Level();
     $user = $this->Message->User;
     $greetings = array("Arise", "Congratulations");
     if ($Level->buyLevel($user, $this->db)) {
         $out = emoji(0x1f4ef) . " " . $greetings[mt_rand(0, count($greetings) - 1)] . " *" . $user->getName() . "*, you are now a *Level " . $user->level . " " . $user->getTitle() . "*!" . "\nYou may rise to Level " . ($user->level + 1) . " for a price of " . $Level->getLevelPrice($user->level + 1) . " Coin.";
     } else {
         $out = emoji(0x1f44e) . " Sorry, you need " . $Level->getLevelPrice($user->level + 1) . " Coin to rise to Level " . ($user->level + 1) . ".";
     }
     Telegram::talk($this->Message->Chat->id, $out);
 }
Example #2
0
 public function t_stats()
 {
     $log = new Logging($this->Message);
     $Coin = new Coin();
     $BlackjackSQL = new SQL();
     $CasinowarSQL = new \GroupBot\Brains\Casinowar\SQL();
     $Level = new Level();
     if ($this->isParam()) {
         $user_id = $log->checkIfUserIsLogged($this->getParam());
         if (!$user_id) {
             Telegram::talk($this->Message->Chat->id, "can't find that user, brah");
             return false;
         }
     } else {
         $user_id = $this->Message->User->id;
     }
     $log = $log->getAllUserLogsForChat($user_id);
     $bj_stats = $BlackjackSQL->select_player_stats($user_id);
     $cw_stats = $CasinowarSQL->select_player_stats($user_id);
     $level = $Level->SQL->get_level($user_id);
     $level_title = $Level->getTitle($level);
     $CoinUser = $Coin->SQL->GetUserById($user_id);
     $date = 0;
     foreach ($log->LogsCommand as $cmd) {
         if (strtotime($cmd->last_used) > $date) {
             $last_cmd = $cmd;
             $date = strtotime($cmd->last_used);
         }
     }
     if (!isset($last_cmd)) {
         return false;
     }
     $out = emoji(0x1f4c8) . "*" . $this->Message->Chat->title . "* stats for " . "\n*" . $log->User->first_name . " " . $log->User->last_name . "*, the Level *{$level}* {$level_title}" . "\n`   `•` " . $log->posts_today . "` message" . $this->plural_grammar($log->posts_today) . " sent today" . "\n`   `•` " . $log->posts . "` message" . $this->plural_grammar($log->posts) . " sent ever" . "\n`   `•` " . round(86400 * $log->posts / (strtotime("now") - strtotime("2015-11-19 11:00:00")), 0) . "` messages sent per day, on average" . "\nLast message `(" . date('D jS g:iA', strtotime($log->lastpost_date)) . ")`:" . "\n`   `_" . $log->lastpost . "_" . "\nLast command: `" . $last_cmd->command . "`" . "\n`   `•` " . $last_cmd->uses_today . "` use" . $this->plural_grammar($last_cmd->uses_today) . " today" . "\n`   `•` " . $last_cmd->uses . "` use" . $this->plural_grammar($last_cmd->uses_today) . " ever";
     $last_coin_activity = isset($CoinUser->last_activity) ? date('D jS g:iA', strtotime($CoinUser->last_activity)) : "not recorded";
     $out .= "\n\n" . emoji(0x1f4b2) . "*" . COIN_CURRENCY_NAME . "* stats:" . "\n`   `•` " . $CoinUser->getBalance() . "`" . emoji(0x1f4b0) . " in the bank" . "\n`   `•` " . $Coin->SQL->GetNumberOfTransactionsByUser($CoinUser) . "` outgoing transactions ever" . "\n`   `•`  `Last activity: `" . $last_coin_activity . "`";
     if ($bj_stats) {
         $bj_balance = $bj_stats->coin_won - $bj_stats->coin_lost;
         $out .= "\n\n" . emoji(0x1f0cf) . "*Blackjack* stats:" . "\n`   `•` " . $bj_stats->games_played . "` games ever with `" . $bj_stats->wins . ":" . $bj_stats->losses . ":" . $bj_stats->draws . "` _(W:L:D)_" . "\n`   `•` " . $bj_stats->hits . "` hits, `" . $bj_stats->stands . "` stands, `" . $bj_stats->surrenders . "` surrenders" . "\n`   `•` " . $bj_stats->splits . "` splits, `" . $bj_stats->doubledowns . "` doubledowns, `" . $bj_stats->blackjacks . "` blackjacks" . "\n`   `•` " . round($bj_stats->total_coin_bet, 2) . "`" . emoji(0x1f4b0) . " bet ever, currently " . ($bj_balance == 0 ? "breaking even at `" : ($bj_balance > 0 ? "up `" : "down `")) . round($bj_balance, 2) . "`" . emoji(0x1f4b0);
     }
     if ($cw_stats) {
         $cw_balance = $cw_stats->coin_won - $cw_stats->coin_lost;
         $out .= "\n\n" . emoji(0x1f0cf) . "*Casino war* stats:" . "\n`   `•` " . $cw_stats->games_played . "` games ever with `" . $cw_stats->wins . ":" . $cw_stats->losses . "` _(W:L)_" . "\n`   `•` " . $cw_stats->wars . "` wars and `" . $cw_stats->surrenders . "` surrenders." . "\n`   `•` " . round($cw_stats->total_coin_bet, 2) . "`" . emoji(0x1f4b0) . " bet ever, currently " . ($cw_balance == 0 ? "breaking even at `" : ($cw_balance > 0 ? "up `" : "down `")) . round($cw_balance, 2) . "`" . emoji(0x1f4b0);
     }
     Telegram::talk($this->Message->Chat->id, $out);
     return true;
 }
Example #3
0
 public function addIncome(User $user)
 {
     if ($user->received_income_today) {
         return false;
     }
     $user->received_income_today = true;
     return $this->Transact->transactFromBank(new BankTransaction($user, Level::getDailyAllowance($user->level), new TransactionType(TransactionType::DailyIncome)));
 }
Example #4
0
 public static function buyLevel(User $user, \PDO $db)
 {
     $price = Level::getLevelPrice($user->level + 1);
     if ($user->getBalance() >= $price) {
         $Transact = new Transact($db);
         if ($Transact->transactToBank(new BankTransaction($user, $price, new TransactionType(TransactionType::LevelPurchase)))) {
             $user->level++;
             $user->save($db);
             return true;
         }
     }
     return false;
 }
Example #5
0
 public function main()
 {
     $Events = new Events($this->db);
     if ($Events->addIncome($this->Message->User)) {
         Telegram::talk($this->Message->Chat->id, emoji(0x1f4b8) . " " . $this->Message->User->getNameLevelAndTitle() . ", you received your daily allowance of `" . Level::getDailyAllowance($this->Message->User->level) . "` coin. You now have `" . $this->Message->User->getBalance() . "` coin.");
     } else {
         $now = new \DateTime();
         $future_date = new \DateTime('tomorrow');
         $interval = $future_date->diff($now);
         $time = $interval->format("*%h hours* and *%i minutes*");
         $out = emoji(0x1f4e2) . " " . $this->Message->User->getNameLevelAndTitle() . "..." . "\n\n" . emoji(0x1f44e) . " You must wait {$time} until you can add to your collection of `" . $this->Message->User->getBalance() . "` coin.";
         //$out = emoji(0x1F44E) . " You've already received your allowance today!"
         //     . "\nThere's still $time to go until tomorrow";
         Telegram::talk($this->Message->Chat->id, $out);
     }
 }