fish update

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

@ -12,6 +12,7 @@ using MySql.Data;
using MySql.Data.MySqlClient;
using Kehyeedra3.Services.Models;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore.Internal;
namespace Kehyeedra3
{
@ -359,6 +360,7 @@ namespace Kehyeedra3
"a **Can of Peaches**,",
"a **Used Deodorant Stick**,"
};
readonly string[] discards = new string[]
{
"you presume it is worthless and toss it away",
@ -371,20 +373,21 @@ namespace Kehyeedra3
"you get scared and curb stomp it, shattering it",
"the **Goblins** claim rightful possession of it"
};
/*
readonly FishSpecies[] rfish = new FishSpecies[]
{
FishSpecies.Doomfish,
FishSpecies.Clownfish,
FishSpecies.Teracrab,
FishSpecies.Blobfish,
FishSpecies.Psychedelica
FishSpecies.,
FishSpecies.,
FishSpecies.,
FishSpecies.,
FishSpecies.
};
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>"
};
readonly FishSpecies[] ufish = new FishSpecies[]
@ -425,6 +428,7 @@ namespace Kehyeedra3
"<:missingCom:682586847079432217> [Carp]",
"<:megacrab:681871426319286302>"
};
*/
readonly string o = "<:ye:677089325208305665>";
readonly string n = "<:no:677091514249248778>";
readonly string ye = "<:ya:677179974154715146>";
@ -523,7 +527,7 @@ namespace Kehyeedra3
}
}
[Command("fish"), Ratelimit(6, 2, Measure.Minutes)]
public async Task Fishing()
public async Task FishCommand()
{
ulong time = ulong.Parse(DateTime.Now.ToString("yyyyMMddHHmm"));
ulong lastfish;
@ -531,7 +535,9 @@ namespace Kehyeedra3
ulong xp;
ulong level;
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())
{
var user = Database.Fishing.FirstOrDefault(x => x.Id == Context.User.Id);
@ -574,71 +580,98 @@ namespace Kehyeedra3
rarity = 100 + (ulong)rari;
}
FishRarity rarmult;
string rar = "";
FishSpecies fish;
string emote = "";
if (rarity > 200)
Fish fish;
if (rarity == 207)
{
rar = "*Rare*";
rarmult = FishRarity.Rare;
int num = SRandom.Next(rfish.Length);
fish = rfish[num];
emote = rfishmotes[num];
xp = 20;
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 > 180)
else if (rarity > 200)
{
rar = "*Uncommon*";
rarmult = FishRarity.Uncommon;
int num = SRandom.Next(ufish.Length);
fish = ufish[num];
emote = ufishmotes[num];
xp = 10;
List<Fish> possibleFishes = fishes.Where(f => (int)f.Rarity == (int)FishRarity.Rare).ToList();
fish = possibleFishes[SRandom.Next(possibleFishes.Count)];
xp = 20;
}
else
{
if (rarity == 207)
else if (rarity > 180)
{
rar = "***Legendary***";
rarmult = FishRarity.Legendary;
fish = FishSpecies.LuckyCatfish;
weight = SRandom.Next(200, 4001);
emote = "<a:catfishleft:682655661422542888><a:catfishright:682655661481525284>";
xp = 100;
List<Fish> possibleFishes = fishes.Where(f => (int)f.Rarity == (int)FishRarity.Uncommon).ToList();
fish = possibleFishes[SRandom.Next(possibleFishes.Count)];
xp = 10;
}
else
{
rar = "*Common*";
rarmult = FishRarity.Common;
int num = SRandom.Next(cfish.Length);
fish = cfish[num];
emote = cfishmotes[num];
List<Fish> possibleFishes = fishes.Where(f => (int)f.Rarity == (int)FishRarity.Common).ToList();
fish = possibleFishes[SRandom.Next(possibleFishes.Count)];
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)
{
size = FishWeight.Medium;
size = FishSize.Medium;
if (weight >= (100 - Convert.ToInt32(level)))
{
weight = SRandom.Next(100, 201);
weight = SRandom.Next(1, 201);
}
}
else
{
size = FishWeight.Small;
size = FishSize.Small;
}
if (weight >= 150)
{
size = FishWeight.Large;
size = FishSize.Large;
}
string lvlUp = "";
@ -657,27 +690,19 @@ namespace Kehyeedra3
{
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.FirstOrDefault(x => x.Fish.Species == fish && x.Fish.Weight == size && x.Fish.Rarity == rarmult).Amount += 1;
}
else
{
inv.Add(new FishingInventorySlot
{
Fish = new FishObject
inv = user.GetInventory();
int[] amounts;
if (!inv.TryGetValue(fish.Id, out amounts))
{
Species = fish,
Weight = size,
Rarity = rarmult
},
Amount = 1
});
amounts = new int[] { 0, 0, 0 };
inv.Add(fish.Id, amounts);
}
user.SetInventory(inv);
int sizeIndex = (int)size;
amounts[sizeIndex]++;
user.SetInventory(inv);
user.TXp += xp;
@ -706,11 +731,11 @@ namespace Kehyeedra3
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
{
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
@ -723,7 +748,7 @@ namespace Kehyeedra3
public async Task FishInventory()
{
Fishing user;
List<FishingInventorySlot> inv = new List<FishingInventorySlot>();
Dictionary<FishSpecies, int[]> inv = new Dictionary<FishSpecies, int[]>();
using (var Database = new ApplicationDbContextFactory().CreateDbContext())
{
user = Database.Fishing.FirstOrDefault(x => x.Id == Context.User.Id);
@ -740,6 +765,7 @@ namespace Kehyeedra3
else
{
inv = user.GetInventory();
}
await Database.SaveChangesAsync().ConfigureAwait(false);
@ -747,23 +773,26 @@ namespace Kehyeedra3
if(inv.Any())
{
EmbedBuilder embed = new EmbedBuilder
{
Description = $"{Context.User.Mention}'s Inventory"
};
//TODO
/*
string inventory;
inv.ForEach(x =>
{
string content = $"{x.Fish.Weight.ToString()} {x.Fish.Species.ToString()} ";
embed.AddField(content, x.Amount.ToString(), true);
string content = $"{x.Fish.Weight.ToString()} {x.Fish.Species.ToString()}\n";
});
await Context.Channel.SendMessageAsync(embed: embed.Build()).ConfigureAwait(false);
await Context.Channel.SendMessageAsync($"");
*/
}
else
{
await Context.Channel.SendMessageAsync("Go fish nigger").ConfigureAwait(false);
}
}
[Command("trade")]
public async Task Trading()
{
}
[Command("balance"),Alias("bal","money")]
public async Task Shekels([Remainder] IUser otherUser = null)

@ -4,6 +4,25 @@ using System.ComponentModel.DataAnnotations.Schema;
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 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;
[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 class FishObject
{
public FishSpecies Species;
public FishWeight Weight;
public FishRarity Rarity;
public override string ToString()
public static List<Fish> GetFishList()
{
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()
{
return $"{Weight.ToString()} {Rarity.ToString()} {Species.ToString()}";
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
{
//legendary
@ -63,22 +227,9 @@ namespace Kehyeedra3.Services.Models
Carp = 18,
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 FishObject Fish;
public ulong Amount;
public int Id;
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