Ejemplo n.º 1
0
 /**
  * @param UserVote[] $votes
  * @return UserVote[]
  */
 private function map_users($votes)
 {
     $DbUser = new User($this->db);
     foreach ($votes as $vote) {
         $vote->voter = $DbUser->getUserFromId($vote->voter);
         $vote->voted_for = $DbUser->getUserFromId($vote->voted_for);
     }
     return $votes;
 }
Ejemplo n.º 2
0
 private function getBank(Transaction $transaction)
 {
     if ($transaction->user_sending->user_id == COIN_BANK_ID) {
         return $transaction->user_sending;
     } elseif ($transaction->user_receiving->user_id == COIN_BANK_ID) {
         return $transaction->user_receiving;
     }
     return $this->UserSQL->getUserFromId(COIN_BANK_ID);
 }
Ejemplo n.º 3
0
 private function collectPeriodicTax()
 {
     $bank = $this->UserSQL->getUserFromId(COIN_BANK_ID);
     $this->Transact->CoinSQL->CollectPeriodicTax();
     $to_collect = COIN_PERIODIC_TAX * $this->Transact->CoinSQL->getTotalCoinExisting(false);
     $bank->balance = $bank->getBalance(true) + $to_collect;
     $this->Transact->CoinSQL->AddTransactionLog(new Transaction(NULL, $bank, $to_collect, new TransactionType(TransactionType::AllTax)));
     $this->Transact->maintainFixedLevel($bank);
     $bank->save($this->db);
     Telegram::customShitpostingMessage(emoji(0x1f4e2) . " " . COIN_TAXATION_BODY . " just collected " . round($to_collect, 2) . " " . COIN_CURRENCY_NAME . " in tax.");
     return true;
 }
Ejemplo n.º 4
0
 public function sendReminders()
 {
     $reminders = $this->SQL->select_reminders();
     $UserDb = new User($this->db);
     /** @var Reminder $reminder */
     foreach ($reminders as $reminder) {
         $date_due = Carbon::parse($reminder->date_due);
         $date_created = Carbon::parse($reminder->date_created);
         if ($date_due->lte(Carbon::now())) {
             $user = $UserDb->getUserFromId($reminder->user_id);
             $out = emoji(0x23f0) . " *" . $user->getName() . "*, your reminder from *" . $date_created->diffForHumans(Carbon::now(), true) . "* ago:" . "\n" . "\n`" . $reminder->content . "`";
             Telegram::talkForced($reminder->chat_id, $out);
             $this->SQL->delete_reminder($reminder);
         }
     }
 }
Ejemplo n.º 5
0
 /**
  * @param $game_id
  * @return Player|bool
  */
 public function select_players($game_id)
 {
     $sql = 'SELECT * FROM bj_players WHERE game_id = :game_id ORDER BY player_no ASC';
     $query = $this->db->prepare($sql);
     $query->bindValue(':game_id', $game_id);
     $query->execute();
     if ($query->rowCount()) {
         $Players = $query->fetchAll(\PDO::FETCH_CLASS, 'GroupBot\\Brains\\Blackjack\\Types\\Player');
         usort($Players, function ($a, $b) {
             if ($a->player_no == $b->player_no) {
                 return 0;
             }
             return $a->player_no < $b->player_no ? -1 : 1;
         });
         $DbUser = new User($this->db);
         foreach ($Players as $key => $player) {
             $Players[$key]->user = $DbUser->getUserFromId($player->user_id);
             unset($Players[$key]->user_id);
         }
         return $Players;
     }
     return false;
 }