rod update start

yeah and also patched a big dupe
master
Lan 5 years ago
parent 42b03074d0
commit e94b02b390
  1. 7
      Kehyeedra3/Commands/Admin.cs
  2. 106
      Kehyeedra3/Commands/Economy.cs
  3. 195
      Kehyeedra3/Migrations/20200408192800_RodUpdate.Designer.cs
  4. 68
      Kehyeedra3/Migrations/20200408192800_RodUpdate.cs
  5. 52
      Kehyeedra3/Migrations/ApplicationDbContextModelSnapshot.cs
  6. 63
      Kehyeedra3/Services/Models/Fishing.cs
  7. 2
      Kehyeedra3/Services/Models/User.cs

@ -80,10 +80,7 @@ namespace Kehyeedra3.Commands
User bank = Database.Users.FirstOrDefault(x => x.Id == 0);
int existing = 0;
for (int i = 0; i < 10; i++)
{
existing += Convert.ToInt32(users[i].Money);
}
users.ForEach(x => existing += Convert.ToInt32(x.Money));
int difference = 1000000 - existing;
string content = "";
if (difference >= 0)
@ -109,7 +106,7 @@ namespace Kehyeedra3.Commands
}
else
{
await Context.Channel.SendMessageAsync($"Economy has been stabilized by removing {difference / 10000d} from bank");
await Context.Channel.SendMessageAsync($"Economy has been stabilized by removing {0-difference / 10000d} from bank");
}
}
}

@ -6,6 +6,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Channels;
using System.Threading.Tasks;
namespace Kehyeedra3.Commands
@ -104,6 +105,7 @@ namespace Kehyeedra3.Commands
var user = Database.Users.FirstOrDefault(x => x.Id == Context.User.Id);
lastmine = user.LastMine;
user.LastMine = time;
user.Username = Context.User.Username;
await Database.SaveChangesAsync();
}
if (lastmine < time)
@ -196,6 +198,7 @@ namespace Kehyeedra3.Commands
ulong xp;
ulong level;
ulong lvlXp;
int rod;
Dictionary<FishSpecies, int[]> inv = new Dictionary<FishSpecies, int[]>();
List<Fish> fishes = Fishing.GetFishList();
@ -220,6 +223,7 @@ namespace Kehyeedra3.Commands
lastfish = user.LastFish;
totalXp = user.TXp;
lvlXp = user.Xp;
rod = user.RodUsed;
await Database.SaveChangesAsync();
}
@ -245,9 +249,24 @@ namespace Kehyeedra3.Commands
if (rarity == 777 || (rarity > 2060 && rarity <= 2070) || (rarity > 2760 && rarity <= 2770))
{
List<Fish> possibleFishes = fishes.Where(f => (int)f.Rarity == (int)FishRarity.Legendary).ToList();
fish = possibleFishes[SRandom.Next(possibleFishes.Count)];
xp = 10;
if (rod == 1)
{
List<Fish> possibleFishes = fishes.Where(f => (int)f.Rarity == (int)FishRarity.T2Legendary).ToList();
fish = possibleFishes[SRandom.Next(possibleFishes.Count)];
xp = 15;
}
else if (rod == 1)
{
List<Fish> possibleFishes = fishes.Where(f => (int)f.Rarity == (int)FishRarity.T3Legendary).ToList();
fish = possibleFishes[SRandom.Next(possibleFishes.Count)];
xp = 20;
}
else
{
List<Fish> possibleFishes = fishes.Where(f => (int)f.Rarity == (int)FishRarity.Legendary).ToList();
fish = possibleFishes[SRandom.Next(possibleFishes.Count)];
xp = 10;
}
if (rarity == 777)
{
xp = 77;
@ -262,10 +281,26 @@ namespace Kehyeedra3.Commands
xp = 10;
if (rarity > 2600)
{
possibleFishes = fishes.Where(f => (int)f.Rarity == (int)FishRarity.Rare).ToList();
fish = possibleFishes[SRandom.Next(possibleFishes.Count)];
xp = 20;
if (rod == 1)
{
possibleFishes = fishes.Where(f => (int)f.Rarity == (int)FishRarity.T2Rare).ToList();
fish = possibleFishes[SRandom.Next(possibleFishes.Count)];
xp = 25;
}
else if (rod == 2)
{
possibleFishes = fishes.Where(f => (int)f.Rarity == (int)FishRarity.T3Rare).ToList();
fish = possibleFishes[SRandom.Next(possibleFishes.Count)];
xp = 30;
}
else
{
possibleFishes = fishes.Where(f => (int)f.Rarity == (int)FishRarity.Rare).ToList();
fish = possibleFishes[SRandom.Next(possibleFishes.Count)];
xp = 20;
}
}
}
else
{
@ -276,7 +311,7 @@ namespace Kehyeedra3.Commands
FishSize size;
if (fish.Rarity == FishRarity.Legendary)
if (fish.Rarity == FishRarity.Legendary || fish.Rarity == FishRarity.T2Legendary || fish.Rarity == FishRarity.T3Legendary)
{
weight = 1000;
}
@ -297,7 +332,7 @@ namespace Kehyeedra3.Commands
if (weight >= 1000)
{
xp = Convert.ToUInt64(Math.Round((xp * w / 1000), 0, MidpointRounding.ToEven));
if (fish.Rarity == FishRarity.Legendary)
if (fish.Rarity == FishRarity.Legendary || fish.Rarity == FishRarity.T2Legendary || fish.Rarity == FishRarity.T3Legendary)
{
if (xp < 100)
{
@ -386,6 +421,51 @@ namespace Kehyeedra3.Commands
}
}
[Command("checkrod"),Summary("Displays what fishing rods you can use, as well as your currently equipped fishing rod")]
public async Task CheckRod()
{
using (var Database = new ApplicationDbContextFactory().CreateDbContext())
{
var user = Database.Fishing.FirstOrDefault(x => x.Id == Context.User.Id);
await Context.Channel.SendMessageAsync($"You have unlocked fishing rods up to **T{user.RodOwned+1}**\nYou have currently equipped a **T{user.RodUsed+1}** rod");
}
}
[Command("setrod"),Summary("Set your fishing rod to the desired tier (for example: 'setrod 1' to set to default rod)")]
public async Task SetRod(byte tier)
{
using (var Database = new ApplicationDbContextFactory().CreateDbContext())
{
var user = Database.Fishing.FirstOrDefault(x => x.Id == Context.User.Id);
if (tier - 1 <= user.RodOwned)
{
user.RodUsed = Convert.ToByte(tier - 1);
string rodtype = "";
if (tier == 1)
{
rodtype = "Basic";
}
else if (tier == 2)
{
rodtype = "Reinforced";
}
else if (tier == 3)
{
rodtype = "Spectral";
}
else
{
rodtype = "Currently unobtainable";
}
await Context.Channel.SendMessageAsync($"You are now using a **{rodtype} (T{tier})** rod");
}
else
{
await Context.Channel.SendMessageAsync($"You don't have that rod. You own rods up to **T{user.RodOwned+1}**");
}
await Database.SaveChangesAsync().ConfigureAwait(false);
}
}
[Command("inventory"), Alias("inv", "fishinv"), Summary("Shows the fish you have currently. Might show other things in the distant future.")]
public async Task FishInventory([Remainder]IGuildUser user = null)
{
@ -672,6 +752,7 @@ namespace Kehyeedra3.Commands
message.AppendLine($"**{store.StoreItemType} Store** has no offers currently");
}
}
await Context.Channel.SendMessageAsync($"{message}");
}
}
}
@ -855,6 +936,7 @@ namespace Kehyeedra3.Commands
using (var Database = new ApplicationDbContextFactory().CreateDbContext())
{
var user = Database.Users.FirstOrDefault(x => x.Id == Context.User.Id);
var pers = Database.Users.FirstOrDefault(x => x.Id == person.Id);
if (user.Money < amount)
{
await Context.Channel.SendMessageAsync($"{Context.User.Mention} You don't have that much money??");
@ -867,12 +949,14 @@ namespace Kehyeedra3.Commands
}
else
{
var transfer = amount - (amount * 2);
if (!user.GrantMoney(Database.Users.FirstOrDefault(x => x.Id == person.Id), transfer))
if (pers.GrantMoney(Database.Users.FirstOrDefault(x => x.Id == 0), amount) && user.GrantMoney(Database.Users.FirstOrDefault(x => x.Id == 0), -amount))
{
await Context.Channel.SendMessageAsync($"{Context.User.Mention} **{amount / 10000d}%** has been transferred from your account.");
}
else
{
await Context.Channel.SendMessageAsync($"{Context.User.Mention} You can't afford that, go back to the mines.");
}
await Context.Channel.SendMessageAsync($"{Context.User.Mention} **{amount / 10000d}%** has been transferred from your account.");
await Database.SaveChangesAsync();
}
}

@ -0,0 +1,195 @@
// <auto-generated />
using System;
using Kehyeedra3;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace Kehyeedra3.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20200408192800_RodUpdate")]
partial class RodUpdate
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "3.1.2")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
modelBuilder.Entity("Kehyeedra3.Services.Models.Fishing", b =>
{
b.Property<ulong>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint unsigned");
b.Property<string>("Inventory")
.HasColumnType("LONGTEXT");
b.Property<ulong>("LastFish")
.HasColumnType("bigint unsigned");
b.Property<ulong>("Lvl")
.HasColumnType("bigint unsigned");
b.Property<byte>("RodOwned")
.HasColumnType("tinyint unsigned");
b.Property<byte>("RodUsed")
.HasColumnType("tinyint unsigned");
b.Property<ulong>("TXp")
.HasColumnType("bigint unsigned");
b.Property<ulong>("Xp")
.HasColumnType("bigint unsigned");
b.HasKey("Id");
b.ToTable("Fishing");
});
modelBuilder.Entity("Kehyeedra3.Services.Models.ItemOffer", b =>
{
b.Property<ulong>("OfferId")
.ValueGeneratedOnAdd()
.HasColumnType("bigint unsigned");
b.Property<int>("Amount")
.HasColumnType("int");
b.Property<ulong>("BuyerId")
.HasColumnType("bigint unsigned");
b.Property<bool>("IsPurchaseFromStore")
.HasColumnType("tinyint(1)");
b.Property<bool>("IsSellOffer")
.HasColumnType("tinyint(1)");
b.Property<ulong>("ItemId")
.HasColumnType("bigint unsigned");
b.Property<int>("OfferAmount")
.HasColumnType("int");
b.Property<ulong?>("StoreFrontId")
.HasColumnType("bigint unsigned");
b.Property<ulong>("StoreId")
.HasColumnType("bigint unsigned");
b.HasKey("OfferId");
b.HasIndex("StoreFrontId");
b.ToTable("ItemOffer");
});
modelBuilder.Entity("Kehyeedra3.Services.Models.Reminder", b =>
{
b.Property<ulong>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint unsigned");
b.Property<ulong>("Created")
.HasColumnType("bigint unsigned");
b.Property<string>("Message")
.HasColumnType("longtext CHARACTER SET utf8mb4");
b.Property<ulong>("Send")
.HasColumnType("bigint unsigned");
b.Property<ulong>("UserId")
.HasColumnType("bigint unsigned");
b.HasKey("Id");
b.ToTable("Reminders");
});
modelBuilder.Entity("Kehyeedra3.Services.Models.StoreFront", b =>
{
b.Property<ulong>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint unsigned");
b.Property<int>("StoreItemType")
.HasColumnType("int");
b.Property<ulong>("UserId")
.HasColumnType("bigint unsigned");
b.HasKey("Id");
b.ToTable("StoreFronts");
});
modelBuilder.Entity("Kehyeedra3.Services.Models.StoreInventory", b =>
{
b.Property<ulong>("InvId")
.ValueGeneratedOnAdd()
.HasColumnType("bigint unsigned");
b.Property<int>("Amount")
.HasColumnType("int");
b.Property<string>("Item")
.HasColumnType("longtext CHARACTER SET utf8mb4");
b.Property<int>("Price")
.HasColumnType("int");
b.Property<ulong?>("StoreFrontId")
.HasColumnType("bigint unsigned");
b.HasKey("InvId");
b.HasIndex("StoreFrontId");
b.ToTable("StoreInventory");
});
modelBuilder.Entity("Kehyeedra3.Services.Models.User", b =>
{
b.Property<ulong>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint unsigned");
b.Property<string>("Avatar")
.HasColumnType("longtext CHARACTER SET utf8mb4");
b.Property<ulong>("LastMine")
.HasColumnType("bigint unsigned");
b.Property<long>("Money")
.HasColumnType("bigint");
b.Property<string>("Username")
.HasColumnType("longtext CHARACTER SET utf8mb4");
b.HasKey("Id");
b.ToTable("Users");
});
modelBuilder.Entity("Kehyeedra3.Services.Models.ItemOffer", b =>
{
b.HasOne("Kehyeedra3.Services.Models.StoreFront", null)
.WithMany("Offers")
.HasForeignKey("StoreFrontId");
});
modelBuilder.Entity("Kehyeedra3.Services.Models.StoreInventory", b =>
{
b.HasOne("Kehyeedra3.Services.Models.StoreFront", null)
.WithMany("Items")
.HasForeignKey("StoreFrontId");
});
#pragma warning restore 612, 618
}
}
}

@ -0,0 +1,68 @@
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Kehyeedra3.Migrations
{
public partial class RodUpdate : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<byte>(
name: "RodOwned",
table: "Fishing",
nullable: false,
defaultValue: (byte)0);
migrationBuilder.AddColumn<byte>(
name: "RodUsed",
table: "Fishing",
nullable: false,
defaultValue: (byte)0);
migrationBuilder.CreateTable(
name: "ItemOffer",
columns: table => new
{
OfferId = table.Column<ulong>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
BuyerId = table.Column<ulong>(nullable: false),
StoreId = table.Column<ulong>(nullable: false),
ItemId = table.Column<ulong>(nullable: false),
Amount = table.Column<int>(nullable: false),
OfferAmount = table.Column<int>(nullable: false),
IsPurchaseFromStore = table.Column<bool>(nullable: false),
IsSellOffer = table.Column<bool>(nullable: false),
StoreFrontId = table.Column<ulong>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_ItemOffer", x => x.OfferId);
table.ForeignKey(
name: "FK_ItemOffer_StoreFronts_StoreFrontId",
column: x => x.StoreFrontId,
principalTable: "StoreFronts",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateIndex(
name: "IX_ItemOffer_StoreFrontId",
table: "ItemOffer",
column: "StoreFrontId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ItemOffer");
migrationBuilder.DropColumn(
name: "RodOwned",
table: "Fishing");
migrationBuilder.DropColumn(
name: "RodUsed",
table: "Fishing");
}
}
}

@ -14,7 +14,7 @@ namespace Kehyeedra3.Migrations
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "3.1.1")
.HasAnnotation("ProductVersion", "3.1.2")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
modelBuilder.Entity("Kehyeedra3.Services.Models.Fishing", b =>
@ -32,6 +32,12 @@ namespace Kehyeedra3.Migrations
b.Property<ulong>("Lvl")
.HasColumnType("bigint unsigned");
b.Property<byte>("RodOwned")
.HasColumnType("tinyint unsigned");
b.Property<byte>("RodUsed")
.HasColumnType("tinyint unsigned");
b.Property<ulong>("TXp")
.HasColumnType("bigint unsigned");
@ -43,6 +49,43 @@ namespace Kehyeedra3.Migrations
b.ToTable("Fishing");
});
modelBuilder.Entity("Kehyeedra3.Services.Models.ItemOffer", b =>
{
b.Property<ulong>("OfferId")
.ValueGeneratedOnAdd()
.HasColumnType("bigint unsigned");
b.Property<int>("Amount")
.HasColumnType("int");
b.Property<ulong>("BuyerId")
.HasColumnType("bigint unsigned");
b.Property<bool>("IsPurchaseFromStore")
.HasColumnType("tinyint(1)");
b.Property<bool>("IsSellOffer")
.HasColumnType("tinyint(1)");
b.Property<ulong>("ItemId")
.HasColumnType("bigint unsigned");
b.Property<int>("OfferAmount")
.HasColumnType("int");
b.Property<ulong?>("StoreFrontId")
.HasColumnType("bigint unsigned");
b.Property<ulong>("StoreId")
.HasColumnType("bigint unsigned");
b.HasKey("OfferId");
b.HasIndex("StoreFrontId");
b.ToTable("ItemOffer");
});
modelBuilder.Entity("Kehyeedra3.Services.Models.Reminder", b =>
{
b.Property<ulong>("Id")
@ -131,6 +174,13 @@ namespace Kehyeedra3.Migrations
b.ToTable("Users");
});
modelBuilder.Entity("Kehyeedra3.Services.Models.ItemOffer", b =>
{
b.HasOne("Kehyeedra3.Services.Models.StoreFront", null)
.WithMany("Offers")
.HasForeignKey("StoreFrontId");
});
modelBuilder.Entity("Kehyeedra3.Services.Models.StoreInventory", b =>
{
b.HasOne("Kehyeedra3.Services.Models.StoreFront", null)

@ -12,7 +12,9 @@ namespace Kehyeedra3.Services.Models
}
public enum FishRarity
{
Common, Uncommon, Rare, Legendary
Common, Uncommon, Rare, Legendary,
T2Rare, T2Legendary,
T3Rare, T3Legendary
}
public class Fish
{
@ -30,6 +32,8 @@ namespace Kehyeedra3.Services.Models
public ulong Xp { get; set; } = 50;
public ulong TXp { get; set; } = 0;
public ulong Lvl { get; set; } = 0;
public byte RodOwned { get; set; } = 0;
public byte RodUsed { get; set; } = 0;
[Column(TypeName="LONGTEXT")]
public string Inventory { get; set; } = "{}";
@ -184,22 +188,40 @@ namespace Kehyeedra3.Services.Models
Name = "Megacrab",
Emote = "<:megacrab:681871426319286302>",
Rarity = FishRarity.Common
},
new Fish()
{
Id = FishSpecies.T2Circusfish,
Name = "Circusfish",
Emote = "<:missingLeg:682586847830081551>",
Rarity = FishRarity.T2Legendary
},
new Fish()
{
Id = FishSpecies.T2Swolefish,
Name = "Pumped Up Swolefish",
Emote = "<:missingLeg:682586847830081551>",
Rarity = FishRarity.T2Rare
},
new Fish()
{
Id = FishSpecies.T3Doomfish,
Name = "Spectral Doomfish",
Emote = "<:missingLeg:682586847830081551>",
Rarity = FishRarity.T3Legendary
},
new Fish()
{
Id = FishSpecies.T3Crab,
Name = "Revenant Crab",
Emote = "<:missingLeg:682586847830081551>",
Rarity = FishRarity.T3Rare
}
};
}
}
//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
{
@ -225,7 +247,20 @@ namespace Kehyeedra3.Services.Models
Crayfish = 16,
Betta = 17,
Carp = 18,
Megacrab = 19
Megacrab = 19,
//T2 Legendary
T2Circusfish = 20,
//T2 Rare
T2Swolefish = 21,
//T3 Legendary
T3Doomfish = 22,
//T3 Rare
T3Crab = 23,
//T4 Legendary
//T4 Rare
}
public class FishingInventorySlot
{

@ -12,7 +12,7 @@
{
if(bank.Money > amount)
{
Money += amount % bank.Money;
Money += amount;
bank.Money -= amount;
return true;
}

Loading…
Cancel
Save