From 6cff0b753bcd6aea9e651de32977f4b81e99eb7f Mon Sep 17 00:00:00 2001 From: Lan <50151341+Lannnnnnnnn@users.noreply.github.com> Date: Tue, 18 Feb 2020 19:35:40 +0200 Subject: [PATCH] yeeted shit and added shit removed databaseservice.cs due to useless made changes to mine command worked on fish command --- Kehyeedra3/ApplicationDbContext.cs | 1 + Kehyeedra3/Commands.cs | 96 ++++++++++++- Kehyeedra3/Services/DatabaseService.cs | 183 ------------------------- Kehyeedra3/Services/Models/Fishing.cs | 17 +++ 4 files changed, 111 insertions(+), 186 deletions(-) delete mode 100644 Kehyeedra3/Services/DatabaseService.cs create mode 100644 Kehyeedra3/Services/Models/Fishing.cs diff --git a/Kehyeedra3/ApplicationDbContext.cs b/Kehyeedra3/ApplicationDbContext.cs index e465228..ee4a901 100644 --- a/Kehyeedra3/ApplicationDbContext.cs +++ b/Kehyeedra3/ApplicationDbContext.cs @@ -10,5 +10,6 @@ namespace Kehyeedra3 public DbSet Users { get; set; } public DbSet Reminders { get; set; } + //public DbSet Fishing { get; set; } } } diff --git a/Kehyeedra3/Commands.cs b/Kehyeedra3/Commands.cs index d277369..661e0b9 100644 --- a/Kehyeedra3/Commands.cs +++ b/Kehyeedra3/Commands.cs @@ -150,7 +150,6 @@ namespace Kehyeedra3 //} public class Stuff : ModuleBase /////////////////////////////////////////////// { - //public DatabaseService dbService { get; set; } [Command("delet")] public async Task DeletThis() @@ -265,7 +264,7 @@ namespace Kehyeedra3 } } - public class Money : ModuleBase + public class Economy : ModuleBase { readonly string[] ores = new string[] { @@ -304,6 +303,7 @@ namespace Kehyeedra3 "**Copper**,", "**Volatile Motes**,", "a **Diamond**,", + "a **Girlfriend**,", "**Thorium**,", "a **Fresh Apple**,", "**Raid Shadow Legends** sponsorship money,", @@ -329,6 +329,31 @@ namespace Kehyeedra3 "a **Can of Peaches**,", "a **Used Deodorant Stick**," }; + readonly string[] discards = new string[] + { + "you presume it is worthless and toss it away", + "you drop it and lose it", + "a vicious furry takes it from you", + "it appears to have vanished", + "but it seems like you were hallucinating", + "but it is seized by the communists", + "you mistake it for a chance to succeed in life and throw it away" + }; + readonly string[] rfish = new string[] + { + "Clownfish", + "Doomfish" + }; + readonly string[] ufish = new string[] + { + "Mantis Shrimp", + "Gigacrab" + }; + readonly string[] cfish = new string[] + { + "Cod", + "Salmon" + }; readonly string o = "<:ye:677089325208305665>"; readonly string n = "<:no:677091514249248778>"; readonly string ye = "<:ya:677179974154715146>"; @@ -353,7 +378,9 @@ namespace Kehyeedra3 int end = 0; string marks = $"{n}{n}{n}"; int num = SRandom.Next(ores.Length); + int numd = SRandom.Next(discards.Length); string ore = ores[num]; + string discard = discards[numd]; if (res1 > 20) { end = 1; @@ -394,7 +421,7 @@ namespace Kehyeedra3 if (end == 0) { - await Context.Channel.SendMessageAsync($"{marks}\n{Context.User.Mention} You have found {ore} you presume it is worthless and toss it away."); + await Context.Channel.SendMessageAsync($"{marks}\n{Context.User.Mention} You have found {ore} {discard}."); } else { @@ -425,6 +452,69 @@ namespace Kehyeedra3 await Context.Channel.SendMessageAsync($"{Context.User.Mention} wait 1 minute ok next minute yeah? yeah buddy?"); } } + [Command("fish")] + public async Task Fishing() + { + int rarity = SRandom.Next(0, 201); + int rarmult = 0; + string rar = ""; + string fish = ""; + if (rarity > 180) + { + rar = "*Rare*"; + rarmult = 3; + int num = SRandom.Next(rfish.Length); + fish = rfish[num]; + } + else + { + if (rarity > 120) + { + rar = "*Uncommon*"; + rarmult = 2; + int num = SRandom.Next(ufish.Length); + fish = ufish[num]; + } + else + { + if (rarity == 7) + { + rar = "***Glorious***"; + rarmult = 7; + fish = "Lucky Catfish"; + } + else + { + rar = "*Common*"; + rarmult = 1; + int num = SRandom.Next(cfish.Length); + fish = cfish[num]; + } + } + } + + int weight = SRandom.Next(1, 201); + int size = 0; + + if (weight > 150 || rarmult == 7) + { + size = 3; + } + else + { + if (weight > 100) + { + size = 2; + } + else + { + size = 1; + } + } + int value = size + rarmult; + + await Context.Channel.SendMessageAsync($"You have caught a {weight/10d}kg **{fish}**, rarity: {rar}"); + } [Command("balance")] public async Task Shekels([Remainder] IUser otherUser = null) { diff --git a/Kehyeedra3/Services/DatabaseService.cs b/Kehyeedra3/Services/DatabaseService.cs deleted file mode 100644 index e818c96..0000000 --- a/Kehyeedra3/Services/DatabaseService.cs +++ /dev/null @@ -1,183 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using MySql.Data; -using MySql.Data.MySqlClient; -using Kehyeedra3.Services.Models; -using Discord; -using System.Timers; - -namespace Kehyeedra3.Services -{ - public class DatabaseService - {/* - private readonly string ConnectionString; - private MySqlConnection Connection; - public DatabaseService(string host, ushort port, string user, string password, string database) - { - ConnectionString = $"Server={host};Port={port};Database={database};Uid={user};Pwd={password}"; - } - private async Task ConnectOrCreateAsync() - { - if (Connection == null) - { - Connection = new MySqlConnection(ConnectionString); - } - if (Connection.State == System.Data.ConnectionState.Open) - return; - else - { - await Connection.OpenAsync(); - return; - } - } - public async Task CreateUserAsync(IUser user) - { - await ConnectOrCreateAsync(); - - MySqlCommand command = new MySqlCommand("INSERT INTO `users` (UserID, Avatar, UName) VALUES (@uid, @avatar, @uname);"); //userinfo - - command.Parameters.AddWithValue("@uid", user.Id); - command.Parameters.AddWithValue("@avatar", user.GetAvatarUrl()); - command.Parameters.AddWithValue("@uname", user.Username); - - command.Connection = Connection; - try - { - await command.ExecuteScalarAsync(); - command.Dispose(); - return true; - } - catch(Exception ex) - { - Console.WriteLine(ex); - } - finally - { - command.Dispose(); - } - return false; - } - - public async Task DoesUserExistAsync(IUser user) - { - await ConnectOrCreateAsync(); - - var command = new MySqlCommand("SELECT 1 FROM `users` WHERE UserID = @userId;"); - - command.Connection = Connection; - - command.Parameters.AddWithValue("@userId", user.Id); - - return Convert.ToBoolean(await command.ExecuteScalarAsync()); - } - public async Task GetUserAsync(ulong userID) - { - var command = new MySqlCommand("SELECT * FROM `users` WHERE UserID = @userId;"); - - command.Connection = Connection; - command.Parameters.AddWithValue("@userId", userID); - - var result = await command.ExecuteReaderAsync(); - if (result.HasRows) - { - while(await result.ReadAsync()) - { - return new DatabaseUser //userinfo - { - UserID = ulong.Parse(result["UserId"].ToString()), - Avatar = result["Avatar"].ToString(), - UName = result["UName"].ToString(), - }; - } - } - return null; - } - public async Task CreateReminderAsync(ulong rUserID, string rMessage, ulong rSend) - { - await ConnectOrCreateAsync(); - - MySqlCommand command = new MySqlCommand("INSERT INTO `reminders` (UserID, RMessage, RSend) VALUES (@uid, @rmsg, @rsend);"); //reminderinfo - - command.Parameters.AddWithValue("@uid", rUserID); - command.Parameters.AddWithValue("@rmsg", rMessage); - command.Parameters.AddWithValue("@rsend", rSend); - command.Connection = Connection; - try - { - await command.ExecuteScalarAsync(); - command.Dispose(); - return true; - } - catch (Exception ex) - { - Console.WriteLine(ex); - } - finally - { - command.Dispose(); - } - return false; - } - public async Task DoesReminderExistAsync(IUser user) - { - await ConnectOrCreateAsync(); - - var command = new MySqlCommand("SELECT 1 FROM `reminders` WHERE UserID = @userId;"); - - command.Connection = Connection; - - command.Parameters.AddWithValue("@userId", user.Id); - - return Convert.ToBoolean(await command.ExecuteScalarAsync()); - } - public async Task GetReminderAsync(ulong userID) - { - var command = new MySqlCommand("SELECT * FROM `reminders` WHERE UserID = @userId;"); - - command.Connection = Connection; - command.Parameters.AddWithValue("@userId", userID); - - var result = await command.ExecuteReaderAsync(); - if (result.HasRows) - { - while (await result.ReadAsync()) - { - return new DatabaseReminder //reminderinfo - { - rUserID = ulong.Parse(result["rUserID"].ToString()), - rMessage = result["rMessage"].ToString(), - rSend = ulong.Parse(result["rSend"].ToString()) - }; - } - } - return null; - } - public async Task> GetAllReminderAsync() - { - var command = new MySqlCommand("SELECT * FROM `reminders`;"); - - command.Connection = Connection; - - var Reminders = new List(); - var result = await command.ExecuteReaderAsync(); - if (result.HasRows) - { - while (await result.ReadAsync()) - { - Reminders.Add (new DatabaseReminder //reminderinfo - { - rUserID = ulong.Parse(result["rUserID"].ToString()), - rMessage = result["rMessage"].ToString(), - rSend = ulong.Parse(result["rSend"].ToString()) - }); - } - return Reminders; - } - return null; - } - */ - } -} diff --git a/Kehyeedra3/Services/Models/Fishing.cs b/Kehyeedra3/Services/Models/Fishing.cs new file mode 100644 index 0000000..403363b --- /dev/null +++ b/Kehyeedra3/Services/Models/Fishing.cs @@ -0,0 +1,17 @@ +//namespace Kehyeedra3.Services.Models +//{ +// class Fishing +// { +// public ulong UserId { get; set; } = 0; +// public ulong LastFish { get; set; } = 0; +// public ulong CFish { get; set; } = 0; +// public ulong CVal {get; set;} = 0; +// public ulong UFish { get; set; } = 0; +// public ulong UVal {get; set;} = 0; +// public ulong RFish { get; set; } = 0; +// public ulong RVal { get; set; } = 0; +// public ulong LFish { get; set; } = 0; +// public ulong LVal { get; set; } = 0; +// public ulong XP { get; set; } = 0; +// } +//}