Update Economy.cs

fixed weight rolls in fishing, changed inventory to be more compact
master
Lan 5 years ago
parent 9f32d58b01
commit 99a62accf3
  1. 152
      Kehyeedra3/Commands/Economy.cs

@ -158,20 +158,16 @@ namespace Kehyeedra3.Commands
} }
} }
if (end == 0) if (end <= 0)
{ {
await Context.Channel.SendMessageAsync($"{marks}\n{Context.User.Mention} You have found {ore} {discard}."); await Context.Channel.SendMessageAsync($"{marks}\n{Context.User.Mention} You have found {ore} {discard}.");
return;
} }
else else if(end < 3)
{
if (end < 3)
{ {
await Context.Channel.SendMessageAsync($"{marks}\n{Context.User.Mention} You found {end / 10000d}% while mining"); await Context.Channel.SendMessageAsync($"{marks}\n{Context.User.Mention} You found {end / 10000d}% while mining");
} }
}
if (end != 0)
{
using (var Database = new ApplicationDbContextFactory().CreateDbContext()) using (var Database = new ApplicationDbContextFactory().CreateDbContext())
{ {
var user = Database.Users.FirstOrDefault(x => x.Id == Context.User.Id); var user = Database.Users.FirstOrDefault(x => x.Id == Context.User.Id);
@ -184,7 +180,7 @@ namespace Kehyeedra3.Commands
await Database.SaveChangesAsync(); await Database.SaveChangesAsync();
} }
}
} }
else else
{ {
@ -238,10 +234,22 @@ namespace Kehyeedra3.Commands
{ {
int rari = (SRandom.Next(0, 2001)); int rari = (SRandom.Next(0, 2001));
int weigh = SRandom.Next(10, 1501+prestige*500); int weigh = SRandom.Next(10, 1501+prestige*500);
int tierRoll = SRandom.Next(0, 101+prestige*100); int tierRoll = SRandom.Next(0, 81+prestige*40);
int dCatchRoll = SRandom.Next(0, 1000+prestige*5);
int dcatch = 1;
ulong rarity; ulong rarity;
int weight; int weight;
if (dCatchRoll > 1000)
{
int many = 995;
while (many+5 <= dCatchRoll)
{
dcatch += 1;
many += 5;
}
}
if (level < 100 && prestige == 0) if (level < 100 && prestige == 0)
{ {
rarity = level * 10 + (ulong)rari; rarity = level * 10 + (ulong)rari;
@ -381,14 +389,14 @@ namespace Kehyeedra3.Commands
{ {
weight = SRandom.Next(100, 2001) + Convert.ToInt32(level * 5 + (Convert.ToUInt64(prestige * 500))); weight = SRandom.Next(100, 2001) + Convert.ToInt32(level * 5 + (Convert.ToUInt64(prestige * 500)));
} }
if (weight >= 1000)
{
if (fish.Rarity == FishRarity.Legendary || fish.Rarity == FishRarity.T2Legendary || fish.Rarity == FishRarity.T3Legendary || fish.Rarity == FishRarity.T4Legendary) if (fish.Rarity == FishRarity.Legendary || fish.Rarity == FishRarity.T2Legendary || fish.Rarity == FishRarity.T3Legendary || fish.Rarity == FishRarity.T4Legendary)
{ {
weight = SRandom.Next(2000 + Convert.ToInt32(level * 20), 40001 + prestige * 10000); weight = SRandom.Next(2000 + Convert.ToInt32(level * 20), 40001 + prestige * 10000);
} }
if (weight >= 1000)
{
if (weight >= 1500) if (weight >= 1500)
{ {
size = FishSize.Large; size = FishSize.Large;
@ -399,7 +407,7 @@ namespace Kehyeedra3.Commands
} }
double w = Convert.ToDouble(weight); double w = Convert.ToDouble(weight);
xp = Convert.ToUInt64(Math.Round((xp * w / 1000), 0, MidpointRounding.ToEven)); xp = Convert.ToUInt64(Math.Round(xp * w / 1000, 0, MidpointRounding.ToEven))*(ulong)dcatch;
if (fish.Rarity == FishRarity.Legendary || fish.Rarity == FishRarity.T2Legendary || fish.Rarity == FishRarity.T3Legendary || fish.Rarity == FishRarity.T4Legendary) if (fish.Rarity == FishRarity.Legendary || fish.Rarity == FishRarity.T2Legendary || fish.Rarity == FishRarity.T3Legendary || fish.Rarity == FishRarity.T4Legendary)
{ {
@ -440,7 +448,7 @@ namespace Kehyeedra3.Commands
} }
int sizeIndex = (int)size; int sizeIndex = (int)size;
amounts[sizeIndex]++; amounts[sizeIndex] += dcatch;
user.SetInventory(inv); user.SetInventory(inv);
@ -502,10 +510,17 @@ namespace Kehyeedra3.Commands
await Database.SaveChangesAsync().ConfigureAwait(false); // :] await Database.SaveChangesAsync().ConfigureAwait(false); // :]
} }
if (dcatch == 1)
{
await Context.Channel.SendMessageAsync($"{Context.User.Mention}\n {fish.Emote} You have caught a {weight / 100d}kg **{fish.Name}**, rarity: {fish.Rarity}\nYou gain **{xp}**xp.\n{lvlUp}"); await Context.Channel.SendMessageAsync($"{Context.User.Mention}\n {fish.Emote} You have caught a {weight / 100d}kg **{fish.Name}**, rarity: {fish.Rarity}\nYou gain **{xp}**xp.\n{lvlUp}");
} }
else else
{
await Context.Channel.SendMessageAsync($"{Context.User.Mention}\n {fish.Emote} You have caught **{dcatch}** {weight / 100d}kg **{fish.Name}**, rarity: {fish.Rarity}\nYou gain **{xp}**xp.\n{lvlUp}");
}
}
else
{ {
await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nYour line snaps. Your disappointment is immeasurable, and your day is ruined."); await Context.Channel.SendMessageAsync($"{Context.User.Mention}\nYour line snaps. Your disappointment is immeasurable, and your day is ruined.");
} }
@ -608,101 +623,58 @@ namespace Kehyeedra3.Commands
Dictionary<FishSpecies, int> med = new Dictionary<FishSpecies, int>(); Dictionary<FishSpecies, int> med = new Dictionary<FishSpecies, int>();
Dictionary<FishSpecies, int> large = new Dictionary<FishSpecies, int>(); Dictionary<FishSpecies, int> large = new Dictionary<FishSpecies, int>();
List<Fish> fishes = Fishing.GetFishList();
List<Fish> legfish = fishes.Where(f => (int)f.Rarity == (int)FishRarity.Legendary).ToList();
List<Fish> rarfish = fishes.Where(f => (int)f.Rarity == (int)FishRarity.Rare).ToList();
List<Fish> uncfish = fishes.Where(f => (int)f.Rarity == (int)FishRarity.Uncommon).ToList();
List<Fish> comfish = fishes.Where(f => (int)f.Rarity == (int)FishRarity.Common).ToList();
string legendary = "";
string rare = "";
string uncommon = "";
string common = "";
int lc = 0;
string fishnam = "";
string fishmote = "";
string fishtext = "";
foreach (var entry in inv) foreach (var entry in inv)
{ {
if (entry.Value.Count() > 0) lc += 1;
{ fishmote = fishes.FirstOrDefault(x => x.Id == entry.Key).Emote;
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($"arr matey this be {user.Mention}'s locker");
}
if (small.Any())
{
EmbedBuilder embed = new EmbedBuilder
{
Title = "small mateys"
};
foreach (var entry in small)
{
if (entry.Key == FishSpecies.LuckyCatfish) if (entry.Key == FishSpecies.LuckyCatfish)
{ {
embed.AddField("Lucky Catfish", $"{entry.Value} feeshie{(entry.Value > 1 ? "s" : "")}", true); fishnam = "Lucky Catfish";
} }
else else
{ {
embed.AddField(entry.Key.ToString(), $"{entry.Value} feeshie{(entry.Value > 1 ? "s" : "")}", true); fishnam = $"{entry.Key}";
}
}
await Context.Channel.SendMessageAsync($"", embed: embed.Build());
} }
fishtext = $"**{fishmote} [S{entry.Value[0]} M{entry.Value[1]} L{entry.Value[2]}]**\n";
if (med.Any()) if (legfish.Any( f => f.Id == entry.Key))
{ {
EmbedBuilder embed = new EmbedBuilder legendary += $"{fishtext}";
{ }
Title = "medium mateys" if (rarfish.Any(f => f.Id == entry.Key))
};
foreach (var entry in med)
{
if (entry.Key == FishSpecies.LuckyCatfish)
{ {
embed.AddField("Lucky Catfish", $"{entry.Value} feeshie{(entry.Value > 1 ? "s" : "")}", true); rare += $"{fishtext}";
} }
else if (uncfish.Any(f => f.Id == entry.Key))
{ {
uncommon += $"{fishtext}";
embed.AddField(entry.Key.ToString(), $"{entry.Value} feeshie{(entry.Value > 1 ? "s" : "")}", true);
} }
if (comfish.Any(f => f.Id == entry.Key))
{
common += $"{fishtext}";
} }
await Context.Channel.SendMessageAsync($"", embed: embed.Build());
} }
if (user.Id != Context.User.Id)
if (large.Any())
{
EmbedBuilder embed = new EmbedBuilder
{
Title = "large mateys"
};
foreach (var entry in large)
{
if (entry.Key == FishSpecies.LuckyCatfish)
{ {
embed.AddField("Lucky Catfish", $"{entry.Value} feeshie{(entry.Value > 1 ? "s" : "")}", true); await Context.Channel.SendMessageAsync($"arr matey this be {user.Mention}'s locker\n{legendary}\n{rare}\n{uncommon}\n{common}");
} }
else else
{ {
embed.AddField(entry.Key.ToString(), $"{entry.Value} feeshie{(entry.Value > 1 ? "s" : "")}", true); await Context.Channel.SendMessageAsync($"arr matey this be {Context.User.Mention}'s locker\n{legendary}\n{rare}\n{uncommon}\n{common}");
}
}
await Context.Channel.SendMessageAsync($"", embed: embed.Build());
} }
} }
else else

Loading…
Cancel
Save