You can now gift items to waifus with '.gift' command
This commit is contained in:
parent
7a1895bf31
commit
d74a23d215
1711
src/NadekoBot/Migrations/20170814044636_waifu-items.Designer.cs
generated
Normal file
1711
src/NadekoBot/Migrations/20170814044636_waifu-items.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
46
src/NadekoBot/Migrations/20170814044636_waifu-items.cs
Normal file
46
src/NadekoBot/Migrations/20170814044636_waifu-items.cs
Normal file
@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace NadekoBot.Migrations
|
||||
{
|
||||
public partial class waifuitems : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "WaifuItem",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
DateAdded = table.Column<DateTime>(nullable: true),
|
||||
Item = table.Column<int>(nullable: false),
|
||||
ItemEmoji = table.Column<string>(nullable: true),
|
||||
Price = table.Column<int>(nullable: false),
|
||||
WaifuInfoId = table.Column<int>(nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_WaifuItem", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_WaifuItem_WaifuInfo_WaifuInfoId",
|
||||
column: x => x.WaifuInfoId,
|
||||
principalTable: "WaifuInfo",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_WaifuItem_WaifuInfoId",
|
||||
table: "WaifuItem",
|
||||
column: "WaifuInfoId");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "WaifuItem");
|
||||
}
|
||||
}
|
||||
}
|
@ -1297,6 +1297,28 @@ namespace NadekoBot.Migrations
|
||||
b.ToTable("WaifuInfo");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("NadekoBot.Services.Database.Models.WaifuItem", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<DateTime?>("DateAdded");
|
||||
|
||||
b.Property<int>("Item");
|
||||
|
||||
b.Property<string>("ItemEmoji");
|
||||
|
||||
b.Property<int>("Price");
|
||||
|
||||
b.Property<int?>("WaifuInfoId");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("WaifuInfoId");
|
||||
|
||||
b.ToTable("WaifuItem");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("NadekoBot.Services.Database.Models.WaifuUpdate", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@ -1654,6 +1676,13 @@ namespace NadekoBot.Migrations
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("NadekoBot.Services.Database.Models.WaifuItem", b =>
|
||||
{
|
||||
b.HasOne("NadekoBot.Services.Database.Models.WaifuInfo")
|
||||
.WithMany("Items")
|
||||
.HasForeignKey("WaifuInfoId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("NadekoBot.Services.Database.Models.WaifuUpdate", b =>
|
||||
{
|
||||
b.HasOne("NadekoBot.Services.Database.Models.DiscordUser", "New")
|
||||
|
@ -459,11 +459,74 @@ namespace NadekoBot.Modules.Gambling
|
||||
.AddField(efb => efb.WithName(GetText("likes")).WithValue(w.Affinity?.ToString() ?? nobody).WithIsInline(true))
|
||||
.AddField(efb => efb.WithName(GetText("changes_of_heart")).WithValue($"{affInfo.Count} - \"the {affInfo.Title}\"").WithIsInline(true))
|
||||
.AddField(efb => efb.WithName(GetText("divorces")).WithValue(divorces.ToString()).WithIsInline(true))
|
||||
.AddField(efb => efb.WithName($"Waifus ({claims.Count})").WithValue(claims.Count == 0 ? nobody : string.Join("\n", claims.OrderBy(x => rng.Next()).Take(30).Select(x => x.Waifu))).WithIsInline(true));
|
||||
.AddField(efb => efb.WithName(GetText("gifts")).WithValue(!w.Items.Any() ? "-" : string.Join("\n", w.Items.OrderBy(x => x.Price).GroupBy(x => x.ItemEmoji).Select(x => $"{x.Key} x{x.Count()}"))).WithIsInline(true))
|
||||
.AddField(efb => efb.WithName($"Waifus ({claims.Count})").WithValue(claims.Count == 0 ? nobody : string.Join("\n", claims.OrderBy(x => rng.Next()).Take(30).Select(x => x.Waifu))).WithIsInline(false));
|
||||
|
||||
await Context.Channel.EmbedAsync(embed).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[Priority(1)]
|
||||
public async Task WaifuGift()
|
||||
{
|
||||
var embed = new EmbedBuilder()
|
||||
.WithTitle(GetText("waifu_gift_shop"))
|
||||
.WithOkColor();
|
||||
|
||||
Enum.GetValues(typeof(WaifuItem.ItemName))
|
||||
.Cast<WaifuItem.ItemName>()
|
||||
.Select(x => WaifuItem.GetItem(x))
|
||||
.ForEach(x => embed.AddField(f => f.WithName(x.ItemEmoji + " " + x.Item).WithValue(x.Price).WithIsInline(true)));
|
||||
|
||||
await Context.Channel.EmbedAsync(embed).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[NadekoCommand, Usage, Description, Aliases]
|
||||
[RequireContext(ContextType.Guild)]
|
||||
[Priority(0)]
|
||||
public async Task WaifuGift(WaifuItem.ItemName item, [Remainder] IUser waifu)
|
||||
{
|
||||
var itemObj = WaifuItem.GetItem(item);
|
||||
|
||||
using (var uow = _db.UnitOfWork)
|
||||
{
|
||||
var w = uow.Waifus.ByWaifuUserId(waifu.Id);
|
||||
|
||||
//try to buy the item first
|
||||
|
||||
if (!await _cs.RemoveAsync(Context.User.Id, "Bought waifu item", itemObj.Price, uow))
|
||||
{
|
||||
await ReplyErrorLocalized("not_enough", _bc.BotConfig.CurrencySign).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
if (w == null)
|
||||
{
|
||||
uow.Waifus.Add(w = new WaifuInfo()
|
||||
{
|
||||
Affinity = null,
|
||||
Claimer = null,
|
||||
Price = 1,
|
||||
Waifu = uow.DiscordUsers.GetOrCreate(waifu),
|
||||
});
|
||||
|
||||
w.Waifu.Username = waifu.Username;
|
||||
w.Waifu.Discriminator = waifu.Discriminator;
|
||||
}
|
||||
w.Items.Add(itemObj);
|
||||
if (w.Claimer?.UserId == Context.User.Id)
|
||||
{
|
||||
w.Price += itemObj.Price;
|
||||
}
|
||||
else
|
||||
w.Price += itemObj.Price / 2;
|
||||
|
||||
await uow.CompleteAsync().ConfigureAwait(false);
|
||||
}
|
||||
|
||||
await ReplyConfirmLocalized("waifu_gift", Format.Bold(item.ToString() + " " +itemObj.ItemEmoji), Format.Bold(waifu.ToString())).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
|
||||
public struct WaifuProfileTitle
|
||||
{
|
||||
|
@ -2259,87 +2259,6 @@
|
||||
<data name="butts_usage" xml:space="preserve">
|
||||
<value>`{0}butts` or `{0}ass`</value>
|
||||
</data>
|
||||
<data name="createwar_cmd" xml:space="preserve">
|
||||
<value>createwar cw</value>
|
||||
</data>
|
||||
<data name="createwar_desc" xml:space="preserve">
|
||||
<value>Creates a new war by specifying a size (>10 and multiple of 5) and enemy clan name.</value>
|
||||
</data>
|
||||
<data name="createwar_usage" xml:space="preserve">
|
||||
<value>`{0}cw 15 The Enemy Clan`</value>
|
||||
</data>
|
||||
<data name="startwar_cmd" xml:space="preserve">
|
||||
<value>startwar sw</value>
|
||||
</data>
|
||||
<data name="startwar_desc" xml:space="preserve">
|
||||
<value>Starts a war with a given number.</value>
|
||||
</data>
|
||||
<data name="startwar_usage" xml:space="preserve">
|
||||
<value>`{0}sw 15`</value>
|
||||
</data>
|
||||
<data name="listwar_cmd" xml:space="preserve">
|
||||
<value>listwar lw</value>
|
||||
</data>
|
||||
<data name="listwar_desc" xml:space="preserve">
|
||||
<value>Shows the active war claims by a number. Shows all wars in a short way if no number is specified.</value>
|
||||
</data>
|
||||
<data name="listwar_usage" xml:space="preserve">
|
||||
<value>`{0}lw [war_number]` or `{0}lw`</value>
|
||||
</data>
|
||||
<data name="basecall_cmd" xml:space="preserve">
|
||||
<value>basecall</value>
|
||||
</data>
|
||||
<data name="basecall_desc" xml:space="preserve">
|
||||
<value>Claims a certain base from a certain war. You can supply a name in the third optional argument to claim in someone else's place.</value>
|
||||
</data>
|
||||
<data name="basecall_usage" xml:space="preserve">
|
||||
<value>`{0}basecall [war_number] [base_number] [optional_other_name]`</value>
|
||||
</data>
|
||||
<data name="callfinish_cmd" xml:space="preserve">
|
||||
<value>callfinish cf</value>
|
||||
</data>
|
||||
<data name="callfinish_desc" xml:space="preserve">
|
||||
<value>Finish your claim with 3 stars if you destroyed a base. First argument is the war number, optional second argument is a base number if you want to finish for someone else.</value>
|
||||
</data>
|
||||
<data name="callfinish_usage" xml:space="preserve">
|
||||
<value>`{0}cf 1` or `{0}cf 1 5`</value>
|
||||
</data>
|
||||
<data name="callfinish2_cmd" xml:space="preserve">
|
||||
<value>callfinish2 cf2</value>
|
||||
</data>
|
||||
<data name="callfinish2_desc" xml:space="preserve">
|
||||
<value>Finish your claim with 2 stars if you destroyed a base. First argument is the war number, optional second argument is a base number if you want to finish for someone else.</value>
|
||||
</data>
|
||||
<data name="callfinish2_usage" xml:space="preserve">
|
||||
<value>`{0}cf2 1` or `{0}cf2 1 5`</value>
|
||||
</data>
|
||||
<data name="callfinish1_cmd" xml:space="preserve">
|
||||
<value>callfinish1 cf1</value>
|
||||
</data>
|
||||
<data name="callfinish1_desc" xml:space="preserve">
|
||||
<value>Finish your claim with 1 star if you destroyed a base. First argument is the war number, optional second argument is a base number if you want to finish for someone else.</value>
|
||||
</data>
|
||||
<data name="callfinish1_usage" xml:space="preserve">
|
||||
<value>`{0}cf1 1` or `{0}cf1 1 5`</value>
|
||||
</data>
|
||||
<data name="unclaim_cmd" xml:space="preserve">
|
||||
<value>uncall</value>
|
||||
</data>
|
||||
<data name="unclaim_desc" xml:space="preserve">
|
||||
<value>Removes your claim from a certain war. Optional second argument denotes a person in whose place to unclaim</value>
|
||||
</data>
|
||||
<data name="unclaim_usage" xml:space="preserve">
|
||||
<value>`{0}uc [war_number] [optional_other_name]`</value>
|
||||
</data>
|
||||
<data name="endwar_cmd" xml:space="preserve">
|
||||
<value>endwar ew</value>
|
||||
</data>
|
||||
<data name="endwar_desc" xml:space="preserve">
|
||||
<value>Ends the war with a given index.</value>
|
||||
</data>
|
||||
<data name="endwar_usage" xml:space="preserve">
|
||||
<value>`{0}ew [war_number]`</value>
|
||||
</data>
|
||||
<data name="translate_cmd" xml:space="preserve">
|
||||
<value>translate trans</value>
|
||||
</data>
|
||||
@ -3087,6 +3006,15 @@
|
||||
<data name="waifuclaim_usage" xml:space="preserve">
|
||||
<value>`{0}claim 50 @Himesama`</value>
|
||||
</data>
|
||||
<data name="waifugift_cmd" xml:space="preserve">
|
||||
<value>waifugift gift gifts</value>
|
||||
</data>
|
||||
<data name="waifugift_desc" xml:space="preserve">
|
||||
<value>Gift an item to someone. This will increase their waifu value by 50% of the gifted item's value if they don't have affinity set towards you, or 100% if they do. Provide no arguments to see a list of items that you can gift.</value>
|
||||
</data>
|
||||
<data name="waifugift_usage" xml:space="preserve">
|
||||
<value>`{0}gifts` or `{0}gift Rose @Himesama`</value>
|
||||
</data>
|
||||
<data name="waifuleaderboard_cmd" xml:space="preserve">
|
||||
<value>waifus waifulb</value>
|
||||
</data>
|
||||
|
@ -1,4 +1,5 @@
|
||||
using NadekoBot.Extensions;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace NadekoBot.Services.Database.Models
|
||||
{
|
||||
@ -14,6 +15,7 @@ namespace NadekoBot.Services.Database.Models
|
||||
public DiscordUser Affinity { get; set; }
|
||||
|
||||
public int Price { get; set; }
|
||||
public List<WaifuItem> Items { get; set; } = new List<WaifuItem>();
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
|
87
src/NadekoBot/Services/Database/Models/WaifuItem.cs
Normal file
87
src/NadekoBot/Services/Database/Models/WaifuItem.cs
Normal file
@ -0,0 +1,87 @@
|
||||
using System;
|
||||
|
||||
namespace NadekoBot.Services.Database.Models
|
||||
{
|
||||
public class WaifuItem : DbEntity
|
||||
{
|
||||
public string ItemEmoji { get; set; }
|
||||
public int Price { get; set; }
|
||||
public ItemName Item { get; set; }
|
||||
|
||||
public enum ItemName
|
||||
{
|
||||
Cookie,
|
||||
Rose,
|
||||
LoveLetter,
|
||||
Chocolate,
|
||||
Rice,
|
||||
MovieTicket,
|
||||
Book,
|
||||
Lipstick,
|
||||
Laptop,
|
||||
Violin,
|
||||
Ring,
|
||||
Helicopter,
|
||||
}
|
||||
|
||||
public WaifuItem()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public WaifuItem(string itemEmoji, int price, ItemName item)
|
||||
{
|
||||
ItemEmoji = itemEmoji;
|
||||
Price = price;
|
||||
Item = item;
|
||||
}
|
||||
|
||||
public static WaifuItem GetItem(ItemName itemName)
|
||||
{
|
||||
switch (itemName)
|
||||
{
|
||||
case ItemName.Cookie:
|
||||
return new WaifuItem("🍪", 10, itemName);
|
||||
case ItemName.Rose:
|
||||
return new WaifuItem("🌹", 50, itemName);
|
||||
case ItemName.LoveLetter:
|
||||
return new WaifuItem("💌", 100, itemName);
|
||||
case ItemName.Chocolate:
|
||||
return new WaifuItem("🍫", 200, itemName);
|
||||
case ItemName.Rice:
|
||||
return new WaifuItem("🍚", 400, itemName);
|
||||
case ItemName.MovieTicket:
|
||||
return new WaifuItem("🎟", 800, itemName);
|
||||
case ItemName.Book:
|
||||
return new WaifuItem("📔", 1500, itemName);
|
||||
case ItemName.Lipstick:
|
||||
return new WaifuItem("💄", 3000, itemName);
|
||||
case ItemName.Laptop:
|
||||
return new WaifuItem("💻", 5000, itemName);
|
||||
case ItemName.Violin:
|
||||
return new WaifuItem("🎻", 7500, itemName);
|
||||
case ItemName.Ring:
|
||||
return new WaifuItem("💍", 10000, itemName);
|
||||
case ItemName.Helicopter:
|
||||
return new WaifuItem("🚁", 20000, itemName);
|
||||
default:
|
||||
throw new ArgumentException(nameof(itemName));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
🍪 Cookie 10
|
||||
🌹 Rose 50
|
||||
💌 Love Letter 100
|
||||
🍫 Chocolate 200
|
||||
🍚 Rice 400
|
||||
🎟 Movie Ticket 800
|
||||
📔 Book 1.5k
|
||||
💄 Lipstick 3k
|
||||
💻 Laptop 5k
|
||||
🎻 Violin 7.5k
|
||||
💍 Ring 10k
|
||||
*/
|
@ -17,6 +17,7 @@ namespace NadekoBot.Services.Database.Repositories.Impl
|
||||
return _set.Include(wi => wi.Waifu)
|
||||
.Include(wi => wi.Affinity)
|
||||
.Include(wi => wi.Claimer)
|
||||
.Include(wi => wi.Items)
|
||||
.FirstOrDefault(wi => wi.Waifu.UserId == userId);
|
||||
}
|
||||
|
||||
@ -25,6 +26,7 @@ namespace NadekoBot.Services.Database.Repositories.Impl
|
||||
return _set.Include(wi => wi.Waifu)
|
||||
.Include(wi => wi.Affinity)
|
||||
.Include(wi => wi.Claimer)
|
||||
.Include(wi => wi.Items)
|
||||
.Where(wi => wi.Claimer != null && wi.Claimer.UserId == userId)
|
||||
.ToList();
|
||||
}
|
||||
|
@ -327,6 +327,9 @@
|
||||
"gambling_waifu_recent_divorce": "You divorced recently. You must wait {0} hours and {1} minutes to divorce again.",
|
||||
"gambling_nobody": "Nobody",
|
||||
"gambling_waifu_divorced_notlike": "You have divorced a waifu who doesn't like you. You received {0} back.",
|
||||
"gambling_waifu_gift": "Gifted {0} to {1}",
|
||||
"gambling_waifu_gift_shop": "Waifu gift shop",
|
||||
"gambling_gifts": "Gifts",
|
||||
"games_8ball": "8ball",
|
||||
"games_acrophobia": "Acrophobia",
|
||||
"games_acro_ended_no_sub": "Game ended with no submissions.",
|
||||
|
Loading…
Reference in New Issue
Block a user