Example #1
0
 public static function getGlobalRanking(\PDO $db, \GroupBot\Types\User $user)
 {
     $leaderboard = Query::getUsersByMoneyAndLevel($db, NULL, true, false);
     foreach ($leaderboard as $key => $usr) {
         if ($usr->user_id == $user->user_id) {
             return $key + 1;
         }
     }
     return false;
 }
Example #2
0
 private function poorbonuses()
 {
     $total_coin = $this->Transact->CoinSQL->getTotalCoinExisting(false);
     $total_users = $this->UserSQL->GetTotalNumberOfUsers(false);
     $average_coin = $total_coin / $total_users;
     $Users = Query::getUsersByMoneyAndLevel($this->db, NULL, false, false);
     $Users = $this->filterUsersByLastActivity($Users);
     /** @var User[] $PoorestUsers */
     $PoorestUsers = array();
     foreach ($Users as $User) {
         if ($User->getBalance(true) < $average_coin) {
             $PoorestUsers[] = $User;
         }
     }
     $bank = $this->UserSQL->getUserFromId(COIN_BANK_ID);
     $to_give = $bank->getBalance(true) * COIN_POOR_BONUS / count($PoorestUsers);
     $this->Transact->removeMoney($bank, $bank->getBalance(true) * COIN_POOR_BONUS);
     foreach ($PoorestUsers as $User) {
         $this->Transact->addMoney($User, $to_give);
         $User->save($this->db);
     }
     $this->Transact->maintainFixedLevel($bank);
     $bank->save($this->db);
     Telegram::customShitpostingMessage(emoji(0x1f4e2) . " Oh happy day! " . round($bank->getBalance() * COIN_POOR_BONUS, 2) . " of " . COIN_TAXATION_BODY . "'s wealth has been spread amongst the poorest members of the community.");
     return true;
 }