fish update

thank you zeus very cool
master
Lan 5 years ago
parent c623734a72
commit 4a50857cc3
  1. 289
      Kehyeedra3/Commands.cs
  2. 209
      Kehyeedra3/Services/Models/Fishing.cs
  3. 10
      Kehyeedra3/Services/Models/Trading.cs

@ -12,6 +12,7 @@ using MySql.Data;
using MySql.Data.MySqlClient; using MySql.Data.MySqlClient;
using Kehyeedra3.Services.Models; using Kehyeedra3.Services.Models;
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.EntityFrameworkCore.Internal;
namespace Kehyeedra3 namespace Kehyeedra3
{ {
@ -359,6 +360,7 @@ namespace Kehyeedra3
"a **Can of Peaches**,", "a **Can of Peaches**,",
"a **Used Deodorant Stick**," "a **Used Deodorant Stick**,"
}; };
readonly string[] discards = new string[] readonly string[] discards = new string[]
{ {
"you presume it is worthless and toss it away", "you presume it is worthless and toss it away",
@ -371,60 +373,62 @@ namespace Kehyeedra3
"you get scared and curb stomp it, shattering it", "you get scared and curb stomp it, shattering it",
"the **Goblins** claim rightful possession of it" "the **Goblins** claim rightful possession of it"
}; };
readonly FishSpecies[] rfish = new FishSpecies[] /*
{ readonly FishSpecies[] rfish = new FishSpecies[]
FishSpecies.Doomfish, {
FishSpecies.Clownfish, FishSpecies.,
FishSpecies.Teracrab, FishSpecies.,
FishSpecies.Blobfish, FishSpecies.,
FishSpecies.Psychedelica FishSpecies.,
}; FishSpecies.
readonly string[] rfishmotes = new string[] };
{ readonly string[] rfishmotes = new string[]
"<:doomfish:651879988232060949>", {
"<:missingRar:682586847100403715>[Clownfish]", "",
"<a:teracrableft:681872487901954123><a:teracrabright:681872487264681984>",
"<:missingRar:682586847100403715>[Blobfish]", ,
"<a:psychedelicaleft:682606276592664666><a:psychedelicaright:682606278354141249>" "",
}; "<a:psychedelicaleft:682606276592664666><a:psychedelicaright:682606278354141249>"
readonly FishSpecies[] ufish = new FishSpecies[] };
{ readonly FishSpecies[] ufish = new FishSpecies[]
FishSpecies.Gigacrab, {
FishSpecies.Dopefish, FishSpecies.Gigacrab,
FishSpecies.Stargazer, FishSpecies.Dopefish,
FishSpecies.Isopod, FishSpecies.Stargazer,
FishSpecies.Sheephead, FishSpecies.Isopod,
}; FishSpecies.Sheephead,
readonly string[] ufishmotes = new string[] };
{ readonly string[] ufishmotes = new string[]
"<:gigacrab:681871426382594208>", {
"<:missingUnc:682586846857003064>[Dopefish]", "<:gigacrab:681871426382594208>",
"<:missingUnc:682586846857003064>[Stargazer]", "<:missingUnc:682586846857003064>[Dopefish]",
"<:missingUnc:682586846857003064>[Isopod]", "<:missingUnc:682586846857003064>[Stargazer]",
"<:sheepheadleft:681200891810021376><:sheepheadright:681200891608563767>" "<:missingUnc:682586846857003064>[Isopod]",
}; "<:sheepheadleft:681200891810021376><:sheepheadright:681200891608563767>"
readonly FishSpecies[] cfish = new FishSpecies[] };
{ readonly FishSpecies[] cfish = new FishSpecies[]
FishSpecies.Cod, {
FishSpecies.Salmon, FishSpecies.Cod,
FishSpecies.Shrimp, FishSpecies.Salmon,
FishSpecies.Crayfish, FishSpecies.Shrimp,
FishSpecies.Betta, FishSpecies.Crayfish,
FishSpecies.Pufferfish, FishSpecies.Betta,
FishSpecies.Carp, FishSpecies.Pufferfish,
FishSpecies.Megacrab FishSpecies.Carp,
}; FishSpecies.Megacrab
readonly string[] cfishmotes = new string[] };
{ readonly string[] cfishmotes = new string[]
"<:codleft:681182238448418891><:codright:681182238628511747>", {
"<:missingCom:682586847079432217> [Salmon]", "<:codleft:681182238448418891><:codright:681182238628511747>",
"<:missingCom:682586847079432217> [Shrimp]", "<:missingCom:682586847079432217> [Salmon]",
"<:missingCom:682586847079432217> [Crayfish]", "<:missingCom:682586847079432217> [Shrimp]",
"<:missingCom:682586847079432217> [Betta]", "<:missingCom:682586847079432217> [Crayfish]",
"<:missingCom:682586847079432217> [Pufferfish]", "<:missingCom:682586847079432217> [Betta]",
"<:missingCom:682586847079432217> [Carp]", "<:missingCom:682586847079432217> [Pufferfish]",
"<:megacrab:681871426319286302>" "<:missingCom:682586847079432217> [Carp]",
}; "<:megacrab:681871426319286302>"
};
*/
readonly string o = "<:ye:677089325208305665>"; readonly string o = "<:ye:677089325208305665>";
readonly string n = "<:no:677091514249248778>"; readonly string n = "<:no:677091514249248778>";
readonly string ye = "<:ya:677179974154715146>"; readonly string ye = "<:ya:677179974154715146>";
@ -523,7 +527,7 @@ namespace Kehyeedra3
} }
} }
[Command("fish"), Ratelimit(6, 2, Measure.Minutes)] [Command("fish"), Ratelimit(6, 2, Measure.Minutes)]
public async Task Fishing() public async Task FishCommand()
{ {
ulong time = ulong.Parse(DateTime.Now.ToString("yyyyMMddHHmm")); ulong time = ulong.Parse(DateTime.Now.ToString("yyyyMMddHHmm"));
ulong lastfish; ulong lastfish;
@ -531,7 +535,9 @@ namespace Kehyeedra3
ulong xp; ulong xp;
ulong level; ulong level;
ulong lvlXp; ulong lvlXp;
List<FishingInventorySlot> inv = new List<FishingInventorySlot>(); Dictionary<FishSpecies, int[]> inv = new Dictionary<FishSpecies, int[]>();
List<Fish> fishes = Fishing.GetFishList();
using (var Database = new ApplicationDbContextFactory().CreateDbContext()) using (var Database = new ApplicationDbContextFactory().CreateDbContext())
{ {
var user = Database.Fishing.FirstOrDefault(x => x.Id == Context.User.Id); var user = Database.Fishing.FirstOrDefault(x => x.Id == Context.User.Id);
@ -574,71 +580,98 @@ namespace Kehyeedra3
rarity = 100 + (ulong)rari; rarity = 100 + (ulong)rari;
} }
FishRarity rarmult; Fish fish;
string rar = "";
FishSpecies fish; if (rarity == 207)
string emote = ""; {
if (rarity > 200) 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)
{ {
rar = "*Rare*"; List<Fish> possibleFishes = fishes.Where(f => (int)f.Rarity == (int)FishRarity.Rare).ToList();
rarmult = FishRarity.Rare; fish = possibleFishes[SRandom.Next(possibleFishes.Count)];
int num = SRandom.Next(rfish.Length);
fish = rfish[num];
emote = rfishmotes[num];
xp = 20; xp = 20;
} }
else if (rarity > 180)
{
List<Fish> possibleFishes = fishes.Where(f => (int)f.Rarity == (int)FishRarity.Uncommon).ToList();
fish = possibleFishes[SRandom.Next(possibleFishes.Count)];
xp = 10;
}
else else
{ {
if (rarity > 180) List<Fish> possibleFishes = fishes.Where(f => (int)f.Rarity == (int)FishRarity.Common).ToList();
{ fish = possibleFishes[SRandom.Next(possibleFishes.Count)];
rar = "*Uncommon*"; xp = 5;
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;
weight = SRandom.Next(200, 4001);
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;
}
}
} }
FishWeight size;
//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) if (weight >= 75)
{ {
size = FishWeight.Medium; size = FishSize.Medium;
if (weight >= (100-Convert.ToInt32(level))) if (weight >= (100 - Convert.ToInt32(level)))
{ {
weight = SRandom.Next(100, 201); weight = SRandom.Next(1, 201);
} }
} }
else else
{ {
size = FishWeight.Small; size = FishSize.Small;
} }
if (weight >= 150) if (weight >= 150)
{ {
size = FishWeight.Large; size = FishSize.Large;
} }
string lvlUp = ""; string lvlUp = "";
@ -657,27 +690,19 @@ namespace Kehyeedra3
{ {
var user = Database.Fishing.FirstOrDefault(x => x.Id == Context.User.Id); var user = Database.Fishing.FirstOrDefault(x => x.Id == Context.User.Id);
if (inv.Any(x => x.Fish.Species == fish && x.Fish.Weight == size && x.Fish.Rarity == rarmult)) inv = user.GetInventory();
{
inv.FirstOrDefault(x => x.Fish.Species == fish && x.Fish.Weight == size && x.Fish.Rarity == rarmult).Amount += 1; int[] amounts;
} if (!inv.TryGetValue(fish.Id, out amounts))
else
{ {
inv.Add(new FishingInventorySlot amounts = new int[] { 0, 0, 0 };
{ inv.Add(fish.Id, amounts);
Fish = new FishObject
{
Species = fish,
Weight = size,
Rarity = rarmult
},
Amount = 1
});
} }
user.SetInventory(inv); int sizeIndex = (int)size;
amounts[sizeIndex]++;
user.SetInventory(inv);
user.TXp += xp; user.TXp += xp;
@ -706,11 +731,11 @@ namespace Kehyeedra3
await Database.SaveChangesAsync().ConfigureAwait(false); // :] await Database.SaveChangesAsync().ConfigureAwait(false); // :]
} }
await Context.Channel.SendMessageAsync($"{Context.User.Mention}\n {emote} You have caught a {weight / 10d}kg **{fish}**, rarity: {rar}\nYou gain **{xp}**xp.\n{lvlUp}"); await Context.Channel.SendMessageAsync($"{Context.User.Mention}\n {fish.Emote} You have caught a {weight / 10d}kg **{fish.Name}**, rarity: {fish.Rarity}\nYou gain **{xp}**xp.\n{lvlUp}");
} }
else else
{ {
await Context.Channel.SendMessageAsync($"Your line snaps. Your disappointment is immeasurable, and your day is ruined."); await Context.Channel.SendMessageAsync($"{Context.User.Mention} Your line snaps. Your disappointment is immeasurable, and your day is ruined.");
} }
} }
else else
@ -723,7 +748,7 @@ namespace Kehyeedra3
public async Task FishInventory() public async Task FishInventory()
{ {
Fishing user; Fishing user;
List<FishingInventorySlot> inv = new List<FishingInventorySlot>(); Dictionary<FishSpecies, int[]> inv = new Dictionary<FishSpecies, int[]>();
using (var Database = new ApplicationDbContextFactory().CreateDbContext()) using (var Database = new ApplicationDbContextFactory().CreateDbContext())
{ {
user = Database.Fishing.FirstOrDefault(x => x.Id == Context.User.Id); user = Database.Fishing.FirstOrDefault(x => x.Id == Context.User.Id);
@ -740,6 +765,7 @@ namespace Kehyeedra3
else else
{ {
inv = user.GetInventory(); inv = user.GetInventory();
} }
await Database.SaveChangesAsync().ConfigureAwait(false); await Database.SaveChangesAsync().ConfigureAwait(false);
@ -747,23 +773,26 @@ namespace Kehyeedra3
if(inv.Any()) if(inv.Any())
{ {
EmbedBuilder embed = new EmbedBuilder //TODO
{ /*
Description = $"{Context.User.Mention}'s Inventory" string inventory;
};
inv.ForEach(x => inv.ForEach(x =>
{ {
string content = $"{x.Fish.Weight.ToString()} {x.Fish.Species.ToString()} "; string content = $"{x.Fish.Weight.ToString()} {x.Fish.Species.ToString()}\n";
embed.AddField(content, x.Amount.ToString(), true);
}); });
await Context.Channel.SendMessageAsync(embed: embed.Build()).ConfigureAwait(false); await Context.Channel.SendMessageAsync($"");
*/
} }
else else
{ {
await Context.Channel.SendMessageAsync("Go fish nigger").ConfigureAwait(false); await Context.Channel.SendMessageAsync("Go fish nigger").ConfigureAwait(false);
} }
}
[Command("trade")]
public async Task Trading()
{
} }
[Command("balance"),Alias("bal","money")] [Command("balance"),Alias("bal","money")]
public async Task Shekels([Remainder] IUser otherUser = null) public async Task Shekels([Remainder] IUser otherUser = null)

@ -4,6 +4,25 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace Kehyeedra3.Services.Models namespace Kehyeedra3.Services.Models
{ {
public enum FishSize
{
Small = 0,
Medium = 1,
Large = 2
}
public enum FishRarity
{
Common, Uncommon, Rare, Legendary
}
public class Fish
{
public FishSpecies Id;
//public byte Ego;
//public byte Superego;
public string Name;
public string Emote;
public FishRarity Rarity;
}
public class Fishing public class Fishing
{ {
public ulong Id { get; set; } = 0; // this is userid incase you get alzheimers you stupid baby waa waa public ulong Id { get; set; } = 0; // this is userid incase you get alzheimers you stupid baby waa waa
@ -13,30 +32,175 @@ namespace Kehyeedra3.Services.Models
public ulong Lvl { get; set; } = 0; public ulong Lvl { get; set; } = 0;
[Column(TypeName="LONGTEXT")] [Column(TypeName="LONGTEXT")]
public string Inventory { get; set; } = "[]"; public string Inventory { get; set; } = "{}";
public List<FishingInventorySlot> GetInventory() public Dictionary<FishSpecies, int[]> GetInventory()
{ {
return JsonConvert.DeserializeObject<List<FishingInventorySlot>>(Inventory); return JsonConvert.DeserializeObject<Dictionary<FishSpecies, int[]>>(Inventory);
} }
public void SetInventory(List<FishingInventorySlot> inv) public void SetInventory(Dictionary<FishSpecies, int[]> inv)
{ {
Inventory = JsonConvert.SerializeObject(inv); Dictionary<int, int[]> temp = new Dictionary<int, int[]>();
foreach(var entry in inv){
temp.Add((int)entry.Key, entry.Value);
}
Inventory = JsonConvert.SerializeObject(temp);
} }
} public static List<Fish> GetFishList()
public class FishObject
{
public FishSpecies Species;
public FishWeight Weight;
public FishRarity Rarity;
public override string ToString()
{ {
return $"{Weight.ToString()} {Rarity.ToString()} {Species.ToString()}"; return new List<Fish>
{
new Fish()
{
Id = FishSpecies.LuckyCatfish,
Name = "Lucky Catfish",
Emote = "<a:catfishleft:682655661422542888><a:catfishright:682655661481525284>",
Rarity = FishRarity.Legendary
},
new Fish()
{
Id = FishSpecies.Doomfish,
Name = "Doomfish",
Emote = "<:doomfish:651879988232060949>",
Rarity = FishRarity.Rare
},
new Fish()
{
Id = FishSpecies.Clownfish,
Name = "Clownfish",
Emote = "<:missingRar:682586847100403715>[Clownfish]",
Rarity = FishRarity.Rare
},
new Fish()
{
Id = FishSpecies.Teracrab,
Name = "Teracrab",
Emote = "<a:teracrableft:681872487901954123><a:teracrabright:681872487264681984>",
Rarity = FishRarity.Rare
},
new Fish()
{
Id = FishSpecies.Blobfish,
Name = "Blobfish",
Emote = "<:missingRar:682586847100403715>[Blobfish]",
Rarity = FishRarity.Rare
},
new Fish()
{
Id = FishSpecies.Psychedelica,
Name = "Psychedelica",
Emote = "<a:psychedelicaleft:682606276592664666><a:psychedelicaright:682606278354141249>",
Rarity = FishRarity.Rare
},
new Fish()
{
Id = FishSpecies.Gigacrab,
Name = "Gigacrab",
Emote = "<:gigacrab:681871426382594208>",
Rarity = FishRarity.Uncommon
},
new Fish()
{
Id = FishSpecies.Dopefish,
Name = "Dopefish",
Emote = "<:missingUnc:682586846857003064>[Dopefish]",
Rarity = FishRarity.Uncommon
},
new Fish()
{
Id = FishSpecies.Stargazer,
Name = "Stargazer",
Emote = "<:missingUnc:682586846857003064>[Stargazer]",
Rarity = FishRarity.Uncommon
},
new Fish()
{
Id = FishSpecies.Isopod,
Name = "Isopod",
Emote = "<:missingUnc:682586846857003064>[Isopod]",
Rarity = FishRarity.Uncommon
},
new Fish()
{
Id = FishSpecies.Sheephead,
Name = "Sheephead",
Emote = "<:sheepheadleft:681200891810021376><:sheepheadright:681200891608563767>",
Rarity = FishRarity.Uncommon
},
new Fish()
{
Id = FishSpecies.Cod,
Name = "Cod",
Emote = "<:codleft:681182238448418891><:codright:681182238628511747>",
Rarity = FishRarity.Common
},
new Fish()
{
Id = FishSpecies.Salmon,
Name = "Salmon",
Emote = "<:missingCom:682586847079432217>[Salmon]",
Rarity = FishRarity.Common
},
new Fish()
{
Id = FishSpecies.Shrimp,
Name = "Shrimp",
Emote = "<:missingCom:682586847079432217>[Shrimp]",
Rarity = FishRarity.Common
},
new Fish()
{
Id = FishSpecies.Crayfish,
Name = "Crayfish",
Emote = "<:missingCom:682586847079432217>[Crayfish]",
Rarity = FishRarity.Common
},
new Fish()
{
Id = FishSpecies.Betta,
Name = "Betta",
Emote = "<:missingCom:682586847079432217>[Betta]",
Rarity = FishRarity.Common
},
new Fish()
{
Id = FishSpecies.Pufferfish,
Name = "Pufferfish",
Emote = "<:missingCom:682586847079432217>[Pufferfish]",
Rarity = FishRarity.Common
},
new Fish()
{
Id = FishSpecies.Carp,
Name = "Carp",
Emote = "<:missingCom:682586847079432217>[Carp]",
Rarity = FishRarity.Common
},
new Fish()
{
Id = FishSpecies.Megacrab,
Name = "Megacrab",
Emote = "<:megacrab:681871426319286302>",
Rarity = FishRarity.Common
}
};
} }
} }
//public class FishObject
//{
// public FishSpecies Species;
// public FishSize Weight;
// public FishRarity Rarity;
// public override string ToString()
// {
// return $"{Weight.ToString()} {Rarity.ToString()} {Species.ToString()}";
// }
//}
public enum FishSpecies public enum FishSpecies
{ {
//legendary //legendary
@ -63,22 +227,9 @@ namespace Kehyeedra3.Services.Models
Carp = 18, Carp = 18,
Megacrab = 19 Megacrab = 19
} }
public enum FishWeight
{
Small = 1,
Medium = 2,
Large = 3
}
public enum FishRarity
{
Common = 1,
Uncommon = 2,
Rare = 3,
Legendary = 4
}
public class FishingInventorySlot public class FishingInventorySlot
{ {
public FishObject Fish; public int Id;
public ulong Amount; public int[] Amount;
} }
} }

@ -0,0 +1,10 @@
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