mainly work on trading
master
Lan 5 years ago
parent 4a50857cc3
commit 2b2209ca64
  1. 2
      Kehyeedra3/Bot.cs
  2. 28
      Kehyeedra3/Command handler.cs
  3. 376
      Kehyeedra3/Commands.cs
  4. 58
      Kehyeedra3/Event handlers.cs
  5. 58
      Kehyeedra3/Services/Models/StoreFront.cs
  6. 10
      Kehyeedra3/Services/Models/Trading.cs

@ -92,7 +92,7 @@ namespace Kehyeedra3
InstallChatService();
Clockboy.Elapsed += Clockboy_Elapsed;
Clockboy.Interval = 3600000;
Clockboy.Interval = SRandom.Next(3600000, 14400000);
//1200000 = 20 minutes
RmService = new ReminderService();

@ -109,18 +109,22 @@ namespace Kehyeedra3
}
var jrole = context.Guild.GetRole(375289794999091201);
var euser = await context.Guild.GetUserAsync(context.User.Id).ConfigureAwait(false);
var jas = await context.Guild.GetUserAsync(236952555265982464).ConfigureAwait(false);
if (euser.RoleIds.Any(id => id == 682109241363922965))
{
if (message.Content.Contains("thot begone")) //add
{
await jas.AddRoleAsync(jrole);
}
}
if (message.Content.Contains("thot return")) //remove
{
await jas.RemoveRoleAsync(jrole);
}
//var jas = await context.Guild.GetUserAsync(236952555265982464).ConfigureAwait(false);
//var cat = await context.Guild.GetUserAsync(194439970797256706).ConfigureAwait(false);
//if (euser.RoleIds.Any(id => id == 682109241363922965))
//{
// if (message.Content.ToLowerInvariant().Contains("thot begone"))
// {
// await jas.AddRoleAsync(jrole);
// await cat.AddRoleAsync(jrole);
// }
// if (message.Content.ToLowerInvariant().Contains("thot return"))
// {
// await jas.RemoveRoleAsync(jrole);
// await cat.RemoveRoleAsync(jrole);
// }
//}
if (message.Content.ToLowerInvariant().Contains("jojo"))
{
var jojoke = WeebClient.DownloadString("https://api.skuldbot.uk/fun/jojoke/?raw");

@ -235,9 +235,8 @@ namespace Kehyeedra3
public async Task RollDice([Remainder] string input)
{
int dinput = int.Parse(input.Substring(input.IndexOf("d")).Replace("d", ""));
Random rando = new Random();
int output = rando.Next(dinput+1);
await Context.Channel.SendMessageAsync("" + output);
int output = SRandom.Next(dinput);
await Context.Channel.SendMessageAsync("" + output+1);
}
[Command("remind")]
public async Task Reminder(ulong d, ulong h, ulong m, [Remainder] string r)
@ -271,8 +270,8 @@ namespace Kehyeedra3
var drole = Context.Guild.GetRole(682109241363922965);
if (user.RoleIds.Any(id => id == 682109241363922965))
{
await ouser.AddRoleAsync(drole);
await user.RemoveRoleAsync(drole);
await ouser.AddRoleAsync(drole);
await Context.Channel.SendMessageAsync($"*{ouser.Mention} the power of daycare rests in the palm of your hands*");
}
else
@ -373,62 +372,7 @@ namespace Kehyeedra3
"you get scared and curb stomp it, shattering it",
"the **Goblins** claim rightful possession of it"
};
/*
readonly FishSpecies[] rfish = new FishSpecies[]
{
FishSpecies.,
FishSpecies.,
FishSpecies.,
FishSpecies.,
FishSpecies.
};
readonly string[] rfishmotes = new string[]
{
"",
,
"",
"<a:psychedelicaleft:682606276592664666><a:psychedelicaright:682606278354141249>"
};
readonly FishSpecies[] ufish = new FishSpecies[]
{
FishSpecies.Gigacrab,
FishSpecies.Dopefish,
FishSpecies.Stargazer,
FishSpecies.Isopod,
FishSpecies.Sheephead,
};
readonly string[] ufishmotes = new string[]
{
"<:gigacrab:681871426382594208>",
"<:missingUnc:682586846857003064>[Dopefish]",
"<:missingUnc:682586846857003064>[Stargazer]",
"<:missingUnc:682586846857003064>[Isopod]",
"<:sheepheadleft:681200891810021376><:sheepheadright:681200891608563767>"
};
readonly FishSpecies[] cfish = new FishSpecies[]
{
FishSpecies.Cod,
FishSpecies.Salmon,
FishSpecies.Shrimp,
FishSpecies.Crayfish,
FishSpecies.Betta,
FishSpecies.Pufferfish,
FishSpecies.Carp,
FishSpecies.Megacrab
};
readonly string[] cfishmotes = new string[]
{
"<:codleft:681182238448418891><:codright:681182238628511747>",
"<:missingCom:682586847079432217> [Salmon]",
"<:missingCom:682586847079432217> [Shrimp]",
"<:missingCom:682586847079432217> [Crayfish]",
"<:missingCom:682586847079432217> [Betta]",
"<:missingCom:682586847079432217> [Pufferfish]",
"<:missingCom:682586847079432217> [Carp]",
"<:megacrab:681871426319286302>"
};
*/
readonly string o = "<:ye:677089325208305665>";
readonly string n = "<:no:677091514249248778>";
readonly string ye = "<:ya:677179974154715146>";
@ -582,24 +526,36 @@ namespace Kehyeedra3
Fish fish;
if (rarity == 207)
if (rarity == 207 || rarity == 277)
{
rarity = Convert.ToUInt64(SRandom.Next(207, 301))+level;
if (rarity > 250)
{
List<Fish> possibleFishes = fishes.Where(f => (int)f.Rarity == (int)FishRarity.Legendary).ToList();
fish = possibleFishes[SRandom.Next(possibleFishes.Count)];
weight = SRandom.Next(200, 4001);
xp = 100;
}
else if (rarity > 200)
else
{
List<Fish> possibleFishes = fishes.Where(f => (int)f.Rarity == (int)FishRarity.Rare).ToList();
fish = possibleFishes[SRandom.Next(possibleFishes.Count)];
xp = 20;
}
else if (rarity > 180)
}
else if (rarity > 170)
{
rarity = Convert.ToUInt64(SRandom.Next(180, 281));
List<Fish> possibleFishes = fishes.Where(f => (int)f.Rarity == (int)FishRarity.Uncommon).ToList();
fish = possibleFishes[SRandom.Next(possibleFishes.Count)];
xp = 10;
if (rarity > 260)
{
possibleFishes = fishes.Where(f => (int)f.Rarity == (int)FishRarity.Rare).ToList();
fish = possibleFishes[SRandom.Next(possibleFishes.Count)];
xp = 20;
}
}
else
{
@ -608,52 +564,6 @@ namespace Kehyeedra3
xp = 5;
}
//if (rarity > 200)
//{
// rar = "*Rare*";
// rarmult = FishRarity.Rare;
// int num = SRandom.Next(rfish.Length);
// fish = Fish.Name;
// emote = Fish.Emote[num];
// xp = 20;
//}
//else
//{
// if (rarity > 180)
// {
// rar = "*Uncommon*";
// rarmult = FishRarity.Uncommon;
// int num = SRandom.Next(ufish.Length);
// fish = ufish[num];
// emote = ufishmotes[num];
// xp = 10;
// }
// else
// {
// if (rarity == 207)
// {
// rar = "***Legendary***";
// rarmult = FishRarity.Legendary;
// fish = FishSpecies.LuckyCatfish;
//
// emote = "<a:catfishleft:682655661422542888><a:catfishright:682655661481525284>";
// xp = 100;
// }
// else
// {
// rar = "*Common*";
// rarmult = FishRarity.Common;
// int num = SRandom.Next(cfish.Length);
// fish = cfish[num];
// emote = cfishmotes[num];
// xp = 5;
// }
// }
//}
FishSize size;
if (weight >= 75)
@ -744,55 +654,233 @@ namespace Kehyeedra3
}
}
[Command("inventory"),Alias("inv","fishinv")]
public async Task FishInventory()
[Command("inventory"), Alias("inv", "fishinv")]
public async Task FishInventory([Remainder]IGuildUser user = null)
{
Fishing user;
if (user == null)
user = Context.User as IGuildUser;
Fishing feeshUser;
Dictionary<FishSpecies, int[]> inv = new Dictionary<FishSpecies, int[]>();
using (var Database = new ApplicationDbContextFactory().CreateDbContext())
{
user = Database.Fishing.FirstOrDefault(x => x.Id == Context.User.Id);
feeshUser = Database.Fishing.FirstOrDefault(x => x.Id == user.Id);
if (feeshUser == null)
{
feeshUser = new Fishing
{
Id = user.Id
};
Database.Fishing.Add(feeshUser);
}
else
{
inv = feeshUser.GetInventory();
}
if (user == null)
await Database.SaveChangesAsync().ConfigureAwait(false);
}
if (inv.Any())
{
user = new Fishing
Dictionary<FishSpecies, int> small = new Dictionary<FishSpecies, int>();
Dictionary<FishSpecies, int> med = new Dictionary<FishSpecies, int>();
Dictionary<FishSpecies, int> large = new Dictionary<FishSpecies, int>();
foreach (var entry in inv)
{
Id = Context.User.Id
if(entry.Value.Count() > 0)
{
if (entry.Value[0] > 0)
{
small.Add(entry.Key, entry.Value[0]);
}
}
if(entry.Value.Count() > 1)
{
if (entry.Value[1] > 0)
{
med.Add(entry.Key, entry.Value[1]);
}
}
if(entry.Value.Count() > 2)
{
if (entry.Value[2] > 0)
{
large.Add(entry.Key, entry.Value[2]);
}
}
}
if (user.Id != Context.User.Id)
{
await Context.Channel.SendMessageAsync($"FEESH INVENTOGleS of {user.Mention}");
}
if(small.Any())
{
EmbedBuilder embed = new EmbedBuilder
{
Title = "SMONKL FEESH"
};
Database.Fishing.Add(user);
foreach (var entry in small)
{
if (entry.Key == FishSpecies.LuckyCatfish)
{
embed.AddField("Lucky Catfish", $"{entry.Value} feeshie{(entry.Value > 1 ? "s" : "")}", true);
}
else
{
inv = user.GetInventory();
embed.AddField(entry.Key.ToString(), $"{entry.Value} feeshie{(entry.Value > 1 ? "s" : "")}", true);
}
}
await Context.Channel.SendMessageAsync($"", embed: embed.Build());
}
await Database.SaveChangesAsync().ConfigureAwait(false);
if(med.Any())
{
EmbedBuilder embed = new EmbedBuilder
{
Title = "MED FEESH"
};
foreach (var entry in med)
{
if (entry.Key == FishSpecies.LuckyCatfish)
{
embed.AddField("Lucky Catfish", $"{entry.Value} feeshie{(entry.Value > 1 ? "s" : "")}", true);
}
else
{
embed.AddField(entry.Key.ToString(), $"{entry.Value} feeshie{(entry.Value > 1 ? "s" : "")}", true);
}
}
if(inv.Any())
await Context.Channel.SendMessageAsync($"", embed: embed.Build());
}
if(large.Any())
{
//TODO
/*
string inventory;
inv.ForEach(x =>
EmbedBuilder embed = new EmbedBuilder
{
string content = $"{x.Fish.Weight.ToString()} {x.Fish.Species.ToString()}\n";
});
Title = "LARG FEESH"
};
foreach (var entry in large)
{
if(entry.Key == FishSpecies.LuckyCatfish)
{
embed.AddField("Lucky Catfish", $"{entry.Value} feeshie{(entry.Value > 1 ? "s" : "")}", true);
}
else
{
embed.AddField(entry.Key.ToString(), $"{entry.Value} feeshie{(entry.Value > 1 ? "s" : "")}", true);
}
}
await Context.Channel.SendMessageAsync($"");
*/
await Context.Channel.SendMessageAsync($"", embed: embed.Build());
}
}
else
{
await Context.Channel.SendMessageAsync("Go fish nigger").ConfigureAwait(false);
}
}
[Command("trade")]
public async Task Trading()
[Command("buy")]
public async Task TradingBuy(int amount, string itemtype, int price, [Remainder] string item)
{
string contents = "trade info";
FishSize size = 0;
FishSpecies species = 0;
List<Fish> fishes = Fishing.GetFishList();
if (itemtype.ToLowerInvariant() == "fish")
{
if (item.ToLowerInvariant().Contains("large"))
{
size = FishSize.Large;
}
else if (item.ToLowerInvariant().Contains("medium"))
{
size = FishSize.Medium;
}
else if (item.ToLowerInvariant().Contains("small"))
{
size = FishSize.Small;
}
else
{
await Context.Channel.SendMessageAsync($"{Context.User.Mention} Your size is not up to my standards.");
return;
}
if (fishes.Any(z => item.ToLowerInvariant().Contains(z.Name.ToLowerInvariant())))
{
species = fishes.FirstOrDefault(z => item.ToLowerInvariant().Contains(z.Name.ToLowerInvariant())).Id;
}
else
{
await Context.Channel.SendMessageAsync($"{Context.User.Mention} The goo pool contains no such fish.");
return;
}
contents += $"\ntype: sell\nitem: {size} {species}\namount: {amount}\nprice: {price/10000d}%\n";
await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nTrade offer to buy item **{size} {species}** for **{price / 10000d}%**").ConfigureAwait(false);
await Context.Channel.SendMessageAsync($"{contents}").ConfigureAwait(false);
}
else
{
await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nInvalid trade type. Come back when the error command is fixed lmaoy").ConfigureAwait(false);
}
}
[Command("sell")]
public async Task TradingSell(int amount, string itemtype, int price, [Remainder] string item)
{
string contents = "trade info";
FishSize size = 0;
FishSpecies species = 0;
List<Fish> fishes = Fishing.GetFishList();
if (itemtype.ToLowerInvariant() == "fish")
{
if (item.ToLowerInvariant().Contains("large"))
{
size = FishSize.Large;
}
else if (item.ToLowerInvariant().Contains("medium"))
{
size = FishSize.Medium;
}
else if (item.ToLowerInvariant().Contains("small"))
{
size = FishSize.Small;
}
else
{
await Context.Channel.SendMessageAsync($"{Context.User.Mention} Your size is not up to my standards.");
return;
}
if (fishes.Any(z => item.ToLowerInvariant().Contains(z.Name.ToLowerInvariant())))
{
species = fishes.FirstOrDefault(z => item.ToLowerInvariant().Contains(z.Name.ToLowerInvariant())).Id;
}
else
{
await Context.Channel.SendMessageAsync($"{Context.User.Mention} The goo pool contains no such fish.");
return;
}
contents += $"\ntype: sell\nitem: {size} {species}\namount: {amount}\nprice: {price / 10000d}%\n";
await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nTrade offer to sell item **{size} {species}** for **{price / 10000d}%**").ConfigureAwait(false);
await Context.Channel.SendMessageAsync($"{contents}").ConfigureAwait(false);
}
else
{
await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nInvalid trade type. Come back when the error command is fixed lmaoy").ConfigureAwait(false);
}
}
[Command("balance"),Alias("bal","money")]
public async Task Shekels([Remainder] IUser otherUser = null)
@ -879,21 +967,15 @@ namespace Kehyeedra3
{
wager = wager*4;
}
else
{
if (res1 >= 95)
else if (res1 >= 95)
{
wager = wager * 3;
}
else
{
if (res1 == 77)
else if (res1 == 77)
{
wager = wager * 7;
}
else
{
if (res1 < 50)
else if (res1 < 50)
{
wager = 0;
}
@ -901,9 +983,6 @@ namespace Kehyeedra3
{
wager = wager * 2;
}
}
}
}
using (var Database = new ApplicationDbContextFactory().CreateDbContext())
{
var user = Database.Users.FirstOrDefault(x => x.Id == Context.User.Id);
@ -928,9 +1007,7 @@ namespace Kehyeedra3
embed.AddField($"**Rolled: Lucky cat!**", $"Result: +{((wager) - loss) / 10000d}%\nBalance: {(user.Money) / 10000d}%");
await ReplyAsync($"{Context.User.Mention}", false, embed.Build());
}
else
{
if (((wager) - loss) > 0)
else if (((wager) - loss) > 0)
{
embed.AddField($"**Rolled: {res1}**", $"Result: +{((wager) - loss) / 10000d}%\nBalance: {(user.Money) / 10000d}%");
await ReplyAsync($"{Context.User.Mention}", false, embed.Build());
@ -941,7 +1018,6 @@ namespace Kehyeedra3
await ReplyAsync($"{Context.User.Mention}", false, embed.Build());
}
}
}
else
{
await ReplyAsync($"Hey, stop that.");
@ -1027,7 +1103,7 @@ namespace Kehyeedra3
// var hearole = Context.Guild.GetRole(672759930666876991);
// if (name.RoleIds.Any(id => id == 672755435454988294))
// {
// await ReplyAsync($"{name.Mention}'s hazmat suit is protecting them from the corona");
// await ReplyAsync($"{name.Username}'s hazmat suit is protecting them from the corona");
// }
// else
// {
@ -1036,7 +1112,7 @@ namespace Kehyeedra3
// Console.WriteLine($"{Context.User.Username} has infected {name.Username}");
// await ReplyAsync($"{Context.User.Mention} has infected {name.Mention}");
// await ReplyAsync($"{Context.User.Username} has infected {name.Username}");
// await ReplyAsync($"Corona has been cured for now haha yeah");
// }
// }
@ -1051,7 +1127,7 @@ namespace Kehyeedra3
// var infrole = Context.Guild.GetRole(672517021732438026);
// if (name.RoleIds.Any(id => id == 672785044699611139))
// {
// await ReplyAsync($"{name.Mention} absolutely refuses to be vaccinated");
// await ReplyAsync($"{name.Username} absolutely refuses to be vaccinated");
// }
// else
// {
@ -1062,11 +1138,11 @@ namespace Kehyeedra3
// Console.WriteLine($"{Context.User.Username} has cured {name.Username}");
// await ReplyAsync($"{Context.User.Mention} has vaccinated {name.Mention}");
// await ReplyAsync($"{Context.User.Username} has vaccinated {name.Username}");
// }
// else
// {
// await ReplyAsync($"{name.Mention} is not infected??? are you super retarded???");
// await ReplyAsync($"{name.Username} is not infected??? are you super retarded???");
// }
// }
// }

@ -10,7 +10,7 @@ namespace Kehyeedra3
public static void InstallEventHandlers()
{
_bot.Log += _bot_Log;
//_bot.UserVoiceStateUpdated += _bot_UserVoiceStateUpdated;
_bot.UserVoiceStateUpdated += _bot_UserVoiceStateUpdated;
_cmds.CommandExecuted += _cmds_CommandExecuted;
}
@ -30,34 +30,34 @@ namespace Kehyeedra3
}
//voice join/leave add/remove role
//static async Task _bot_UserVoiceStateUpdated(Discord.WebSocket.SocketUser arg1, Discord.WebSocket.SocketVoiceState arg2, Discord.WebSocket.SocketVoiceState arg3)
//{
// if (!arg1.IsBot)
// {
// if (arg2.VoiceChannel == null && arg3.VoiceChannel != null)
// {
// IGuild guild = arg3.VoiceChannel.Guild;
// if (guild.Id == 296739813380587521)
// {
// Console.WriteLine($"{arg1.Username} joined voice on Gulag");
// var role = guild.GetRole(411185260819251211);
// var user = await guild.GetUserAsync(arg1.Id);
// await user.AddRoleAsync(role);
// }
// }
// if (arg2.VoiceChannel != null && arg3.VoiceChannel == null)
// {
// IGuild guild = arg2.VoiceChannel.Guild;
// if (guild.Id == 296739813380587521)
// {
// Console.WriteLine($"{arg1.Username} left voice on Gulag");
// var role = guild.GetRole(411185260819251211);
// var user = await guild.GetUserAsync(arg1.Id);
// await user.RemoveRoleAsync(role);
// }
// }
// }
//}
static async Task _bot_UserVoiceStateUpdated(Discord.WebSocket.SocketUser arg1, Discord.WebSocket.SocketVoiceState arg2, Discord.WebSocket.SocketVoiceState arg3)
{
if (!arg1.IsBot)
{
if (arg2.VoiceChannel == null && arg3.VoiceChannel != null)
{
IGuild guild = arg3.VoiceChannel.Guild;
if (guild.Id == 296739813380587521)
{
Console.WriteLine($"{arg1.Username} joined voice on Gulag");
var role = guild.GetRole(411185260819251211);
var user = await guild.GetUserAsync(arg1.Id);
await user.AddRoleAsync(role);
}
}
if (arg2.VoiceChannel != null && arg3.VoiceChannel == null)
{
IGuild guild = arg2.VoiceChannel.Guild;
if (guild.Id == 296739813380587521)
{
Console.WriteLine($"{arg1.Username} left voice on Gulag");
var role = guild.GetRole(411185260819251211);
var user = await guild.GetUserAsync(arg1.Id);
await user.RemoveRoleAsync(role);
}
}
}
}
private static Task _bot_Log(LogMessage message)
{

@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
namespace Kehyeedra3.Services.Models
{
public class StoreFront
{
public ulong Id { get; set; } = 0;
public ulong UserId { get; set; } = 0;
public StoreItemType StoreItemType { get; set; } = 0;
public ICollection<StoreInventory> Items { get; set; }
}
public enum StoreItemType
{
Fish = 0,
Reminders = 1
}
public class StoreInventory
{
public ulong ItemId { get; set; } = 0;
public ulong UserId { get; set; } = 0;
public StoreItemType StoreItemType { get; set; } = 0;
public string Item { get; set; } = "";
public int Amount { get; set; } = 0;
public int Price { get; set; } = 0;
}
public class ItemOffer
{
public ulong OfferId { get; set; }
public ulong BuyerId { get; set; }
public ulong StoreId { get; set; }
public StoreItemType StoreType { get; set; }
public ulong ItemId { get; set; }
public int Amount { get; set; }
public int OfferAmount { get; set; }
public bool IsPurchaseFromStore { get; set; }
}
public static class StoreUtilities
{
public static readonly Dictionary<StoreItemType, Type> StoreItemTypeToObject = new Dictionary<StoreItemType, Type>
{
{ StoreItemType.Fish, typeof(FishSpecies) },
{ StoreItemType.Reminders, typeof(Reminder) }
};
public static dynamic GetObjectDataFromJson(string json, StoreItemType store)
{
var type = StoreItemTypeToObject.GetValueOrDefault(store);
return Newtonsoft.Json.JsonConvert.DeserializeObject(json, type);
}
}
}

@ -1,10 +0,0 @@
namespace Kehyeedra3.Services.Models
{
public class Trading
{
public ulong Id { get; set; } = 0;
public ulong UserId { get; set; } = 0;
public ulong Price { get; set; } = 0;
}
}
Loading…
Cancel
Save