Esempio n. 1
0
        public void GiveCoins(int amount)
        {
            var   topUserStm = $"SELECT USER_ID, COINS FROM USERS ORDER BY COINS DESC LIMIT 1";
            ulong topUserID;
            int   topUserAmount;

            using (var con = new SQLiteConnection(Constants.Values.DB_CONNECTION_STRING))
            {
                con.Open();

                using (var com = new SQLiteCommand(topUserStm, con))
                {
                    using (var reader = com.ExecuteReader())
                    {
                        reader.Read();
                        topUserID     = (ulong)reader.GetInt64(0);
                        topUserAmount = reader.GetInt32(1);
                    }
                }
                con.Close();
            }
            AddData("coins", amount);
            using (var con = new SQLiteConnection(Constants.Values.DB_CONNECTION_STRING))
            {
                con.Open();
                ulong newtopUserID;
                using (var com = new SQLiteCommand(topUserStm, con))
                {
                    newtopUserID = (ulong)(long)com.ExecuteScalar();
                }

                if (topUserID != newtopUserID)
                {
                    var name1    = Bot.client.GetUser(topUserID).Username;
                    var name2    = Bot.client.GetUser(newtopUserID).Username;
                    var headline = $"{name2.ToUpper()} TAKES {name1.ToUpper()}'S PLACE AS THE RICHEST!";
                    var content  = $"{name2}'s net worth has finally increased beyond {name1}! On {Var.CurrentDate().ToString("dddd, MMMM dd")} at {Var.CurrentDate().ToString("h:mm tt")}," +
                                   $" {name2} gained {amount} coins, and it was just enough to put them over {name1}'s current {topUserAmount}. If you need a loan, then" +
                                   $" it looks like {name2} is the person to get it from!";
                    if (amount < 0)
                    {
                        headline = $"{name1.ToUpper()}'S NET WORTH PLUMMETS BELOW {name2.ToUpper()}!";
                        content  = $"{name1}'s total coins has just gone down past {name2}'s! On {Var.CurrentDate().ToString("dddd, MMMM dd")} at {Var.CurrentDate().ToString("h:mm tt")}," +
                                   $" {name1} lost {Math.Abs(amount)} coins, and it was just enough to put them under {name2}. If you need a loan, then" +
                                   $" it looks like {name2} is the person to call!";
                    }
                    DBFunctions.AddNews(headline, content);
                }
            }

            var forkbot = new User(Constants.Users.FORKBOT);

            if (ID == forkbot.ID)
            {
                return;
            }
            forkbot.GiveCoins(-amount);
        }
Esempio n. 2
0
        public void AddStat(string stat, int addition)
        {
            using (var con = new SQLiteConnection(Constants.Values.DB_CONNECTION_STRING))
            {
                con.Open();

                var topUserStm = $"SELECT USER_ID, {stat} FROM USER_STATS ORDER BY {stat} DESC LIMIT 1";

                ulong topUserID;
                int   topUserAmount;
                using (var com = new SQLiteCommand(topUserStm, con))
                {
                    using (var reader = com.ExecuteReader())
                    {
                        reader.Read();
                        topUserID     = (ulong)reader.GetInt64(0);
                        topUserAmount = reader.GetInt32(1);
                    }
                }

                var stm = $"UPDATE USER_STATS SET {stat} = {stat}+@addition WHERE USER_ID = @userid";

                using (var com = new SQLiteCommand(stm, con))
                {
                    com.Parameters.AddWithValue("@addition", addition);
                    com.Parameters.AddWithValue("@userid", ID);
                    var obj = com.ExecuteNonQuery();
                }

                ulong newtopUserID;
                using (var com = new SQLiteCommand(topUserStm, con))
                {
                    newtopUserID = (ulong)(long)com.ExecuteScalar();
                }

                if (topUserID != newtopUserID)
                {
                    var name1    = Functions.GetUser(topUserID).GetName(null);
                    var name2    = Functions.GetUser(newtopUserID).GetName(null);
                    var headline = $"{name2} TAKES {name1}'S PLACE AS THE KING OF {stat.ToUpper()}!";
                    var content  = $"Outstandingly, {name2} has taken over as the new leader of {stat}! They smashed the current record of {topUserAmount} with ease " +
                                   $"on {Var.CurrentDate().ToString("dddd, MMMM dd")} at {Var.CurrentDate().ToString("h:mm tt")}. If you were looking to be the person with the most {stat}," +
                                   $" then {name2} is your new rival!";
                    DBFunctions.AddNews(headline, content);
                }
            }
        }
Esempio n. 3
0
 public double GetWinnings()
 {
     for (int i = 0; i < slotOptions.Count(); i++)
     {
         if (SlotCount("gem") == 3)
         {
             var jackpot = Properties.Settings.Default.jackpot;
             Properties.Settings.Default.jackpot = 0;
             Properties.Settings.Default.Save();
             DBFunctions.AddNews($"{gambler.Username.ToUpper()} TAKES THE JACKPOT!", $"{Var.CurrentDateFormatted()} {gambler.Username} scored big time, and got those lucky three gems in a row " +
                                 $"from the Slots! They went home with a whopping {jackpot} coins and a big smile! Just don't spend it all in one place!");
             return(jackpot);
         }
         else if (Slots[0][spins[0]].ToString() == slotOptions[i].ToString() && Slots[1][spins[1]].ToString() == slotOptions[i].ToString() && Slots[2][spins[2]].ToString() == slotOptions[i].ToString())
         {
             return(slotOptions[i].GetValue() * bet);
         }
         else if (SlotCount("seven") == 2)
         {
             return(5 * bet);
         }
         else if (CategoryCount("fruit") == 3)
         {
             return(1.5 * bet);
         }
         else if (CategoryCount("fruit") == 2)
         {
             return(1.2 * bet);
         }
         else if (SlotCount("cherries") == 2)
         {
             return(2 * bet);
         }
     }
     return(0);
 }