Now modifyable: Trivia flower win amount (default 0), minimum bet amount (default 3), betflip multiplier (default 1.8), currency drop amount (default 1), betroll multipliers on 67+/91+/100+ (default 2/3/10)

This commit is contained in:
Kwoth 2017-01-12 20:19:56 +01:00
parent cdad149b0d
commit 2ecec9d0a4
7 changed files with 97 additions and 22 deletions

View File

@ -96,8 +96,18 @@ namespace NadekoBot.Migrations
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<float>("BetflipMultiplier");
b.Property<float>("Betroll100Multiplier");
b.Property<float>("Betroll67Multiplier");
b.Property<float>("Betroll91Multiplier");
b.Property<ulong>("BufferSize");
b.Property<int>("CurrencyDropAmount");
b.Property<float>("CurrencyGenerationChance");
b.Property<int>("CurrencyGenerationCooldown");
@ -118,10 +128,14 @@ namespace NadekoBot.Migrations
b.Property<int>("MigrationVersion");
b.Property<int>("MinimumBetAmount");
b.Property<string>("RemindMessageFormat");
b.Property<bool>("RotatingStatuses");
b.Property<int>("TriviaCurrencyReward");
b.HasKey("Id");
b.ToTable("BotConfig");
@ -191,6 +205,27 @@ namespace NadekoBot.Migrations
b.ToTable("CommandCooldown");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.CommandPrice", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<int?>("BotConfigId");
b.Property<string>("CommandName");
b.Property<int>("Price");
b.HasKey("Id");
b.HasIndex("BotConfigId");
b.HasIndex("Price")
.IsUnique();
b.ToTable("CommandPrice");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.ConvertUnit", b =>
{
b.Property<int>("Id")
@ -823,6 +858,13 @@ namespace NadekoBot.Migrations
.HasForeignKey("GuildConfigId");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.CommandPrice", b =>
{
b.HasOne("NadekoBot.Services.Database.Models.BotConfig")
.WithMany("CommandPrices")
.HasForeignKey("BotConfigId");
});
modelBuilder.Entity("NadekoBot.Services.Database.Models.EightBallResponse", b =>
{
b.HasOne("NadekoBot.Services.Database.Models.BotConfig")

View File

@ -53,9 +53,9 @@ namespace NadekoBot.Modules.Gambling
if (guessStr != "H" && guessStr != "T" && guessStr != "HEADS" && guessStr != "TAILS")
return;
if (amount < 3)
if (amount < NadekoBot.BotConfig.MinimumBetAmount)
{
await Context.Channel.SendErrorAsync($"You can't bet less than 3{CurrencySign}.")
await Context.Channel.SendErrorAsync($"You can't bet less than {NadekoBot.BotConfig.MinimumBetAmount}{CurrencySign}.")
.ConfigureAwait(false);
return;
}
@ -84,7 +84,7 @@ namespace NadekoBot.Modules.Gambling
string str;
if (isHeads == result)
{
var toWin = (int)Math.Round(amount * 1.8);
var toWin = (int)Math.Round(amount * NadekoBot.BotConfig.BetflipMultiplier);
str = $"{Context.User.Mention}`You guessed it!` You won {toWin}{CurrencySign}";
await CurrencyHandler.AddCurrencyAsync(Context.User, "Betflip Gamble", toWin, false).ConfigureAwait(false);
}

View File

@ -173,17 +173,17 @@ namespace NadekoBot.Modules.Gambling
}
else if (rng < 91)
{
str += $"Congratulations! You won {amount * 2}{CurrencySign} for rolling above 66";
str += $"Congratulations! You won {amount * NadekoBot.BotConfig.Betroll67Multiplier}{CurrencySign} for rolling above 66";
await CurrencyHandler.AddCurrencyAsync(Context.User, "Betroll Gamble", amount * 2, false).ConfigureAwait(false);
}
else if (rng < 100)
{
str += $"Congratulations! You won {amount * 3}{CurrencySign} for rolling above 90.";
str += $"Congratulations! You won {amount * NadekoBot.BotConfig.Betroll91Multiplier}{CurrencySign} for rolling above 90.";
await CurrencyHandler.AddCurrencyAsync(Context.User, "Betroll Gamble", amount * 3, false).ConfigureAwait(false);
}
else
{
str += $"👑 Congratulations! You won {amount * 10}{CurrencySign} for rolling **100**. 👑";
str += $"👑 Congratulations! You won {amount * NadekoBot.BotConfig.Betroll100Multiplier}{CurrencySign} for rolling **100**. 👑";
await CurrencyHandler.AddCurrencyAsync(Context.User, "Betroll Gamble", amount * 10, false).ConfigureAwait(false);
}

View File

@ -78,14 +78,32 @@ namespace NadekoBot.Modules.Games
{
lastGenerations.AddOrUpdate(channel.Id, DateTime.Now, (id, old) => DateTime.Now);
var sent = await channel.SendFileAsync(
File.Open(GetRandomCurrencyImagePath(), FileMode.OpenOrCreate),
"RandomFlower.jpg",
$"❗ A random { NadekoBot.BotConfig.CurrencyName } appeared! Pick it up by typing `{NadekoBot.ModulePrefixes[typeof(Games).Name]}pick`")
.ConfigureAwait(false);
plantedFlowers.AddOrUpdate(channel.Id, new List<IUserMessage>() { sent }, (id, old) => { old.Add(sent); return old; });
var dropAmount = NadekoBot.BotConfig.CurrencyDropAmount;
if (dropAmount > 0)
{
var msgs = new List<IUserMessage>(dropAmount);
string firstPart;
if (dropAmount == 1)
{
firstPart = $"A random { NadekoBot.BotConfig.CurrencyName } appeared!";
}
else
{
firstPart = $"{dropAmount} random { NadekoBot.BotConfig.CurrencyPluralName } appeared!";
}
var sent = await channel.SendFileAsync(
File.Open(GetRandomCurrencyImagePath(), FileMode.OpenOrCreate),
"RandomFlower.jpg",
$"❗ {firstPart} Pick it up by typing `{NadekoBot.ModulePrefixes[typeof(Games).Name]}pick`")
.ConfigureAwait(false);
msgs.Add(sent);
plantedFlowers.AddOrUpdate(channel.Id, msgs, (id, old) => { old.AddRange(msgs); return old; });
}
}
}
catch { }
@ -108,11 +126,11 @@ namespace NadekoBot.Modules.Games
List<IUserMessage> msgs;
try { await Context.Message.DeleteAsync().ConfigureAwait(false); } catch { }
if (!plantedFlowers.TryRemove(channel.Id, out msgs))
return;
try { await Context.Message.DeleteAsync().ConfigureAwait(false); } catch { }
if (!plantedFlowers.TryRemove(channel.Id, out msgs))
return;
await Task.WhenAll(msgs.Select(toDelete => toDelete.DeleteAsync())).ConfigureAwait(false);
await Task.WhenAll(msgs.Where(m => m != null).Select(toDelete => toDelete.DeleteAsync())).ConfigureAwait(false);
await CurrencyHandler.AddCurrencyAsync((IGuildUser)Context.User, $"Picked {NadekoBot.BotConfig.CurrencyPluralName}", msgs.Count, false).ConfigureAwait(false);
var msg = await channel.SendConfirmAsync($"**{Context.User}** picked {msgs.Count}{NadekoBot.BotConfig.CurrencySign}!").ConfigureAwait(false);

View File

@ -2,6 +2,7 @@
using Discord.Net;
using Discord.WebSocket;
using NadekoBot.Extensions;
using NadekoBot.Services;
using NLog;
using System;
using System.Collections.Concurrent;
@ -177,7 +178,10 @@ namespace NadekoBot.Modules.Games.Trivia
if (Users[guildUser] == WinRequirement)
{
ShouldStopGame = true;
await channel.SendConfirmAsync("Trivia Game", $"{guildUser.Mention} guessed it and WON the game! The answer was: **{CurrentQuestion.Answer}**").ConfigureAwait(false);
try { await channel.SendConfirmAsync("Trivia Game", $"{guildUser.Mention} guessed it and WON the game! The answer was: **{CurrentQuestion.Answer}**").ConfigureAwait(false); } catch { }
var reward = NadekoBot.BotConfig.TriviaCurrencyReward;
if (reward > 0)
await CurrencyHandler.AddCurrencyAsync(guildUser.Id, "Won trivia", reward).ConfigureAwait(false);
return;
}
await channel.SendConfirmAsync("Trivia Game", $"{guildUser.Mention} guessed it! The answer was: **{CurrentQuestion.Answer}**").ConfigureAwait(false);

View File

@ -18,12 +18,22 @@ namespace NadekoBot.Services.Database.Models
public bool RotatingStatuses { get; set; } = false;
public string RemindMessageFormat { get; set; } = "❗⏰**I've been told to remind you to '%message%' now by %user%.**⏰❗";
//currency
public string CurrencySign { get; set; } = "🌸";
public string CurrencyName { get; set; } = "Nadeko Flower";
public string CurrencyPluralName { get; set; } = "Nadeko Flowers";
public int TriviaCurrencyReward { get; set; } = 0;
public int MinimumBetAmount { get; set; } = 3;
public float BetflipMultiplier { get; set; } = 1.8f;
public int CurrencyDropAmount { get; set; } = 1;
public float Betroll67Multiplier { get; set; } = 2;
public float Betroll91Multiplier { get; set; } = 3;
public float Betroll100Multiplier { get; set; } = 10;
public HashSet<CommandPrice> CommandPrices { get; set; } = new HashSet<CommandPrice>();
public HashSet<EightBallResponse> EightBallResponses { get; set; } = new HashSet<EightBallResponse>();
public HashSet<RaceAnimal> RaceAnimals { get; set; } = new HashSet<RaceAnimal>();

View File

@ -234,9 +234,10 @@ namespace NadekoBot.Services.Database
#endregion
#region Protection
#region CommandPrice
modelBuilder.Entity<CommandPrice>()
.HasIndex(cp => cp.Price)
.IsUnique();
#endregion
}
}