mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 17:58:26 -04:00
Reorganizing module and submodule folders
This commit is contained in:
42
src/NadekoBot/Modules/Gambling/Wheel/WheelOfFortune.cs
Normal file
42
src/NadekoBot/Modules/Gambling/Wheel/WheelOfFortune.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
#nullable disable
|
||||
namespace NadekoBot.Modules.Gambling.Common.WheelOfFortune;
|
||||
|
||||
public class WheelOfFortuneGame
|
||||
{
|
||||
private readonly NadekoRandom _rng;
|
||||
private readonly ICurrencyService _cs;
|
||||
private readonly long _bet;
|
||||
private readonly GamblingConfig _config;
|
||||
private readonly ulong _userId;
|
||||
|
||||
public WheelOfFortuneGame(
|
||||
ulong userId,
|
||||
long bet,
|
||||
GamblingConfig config,
|
||||
ICurrencyService cs)
|
||||
{
|
||||
_rng = new();
|
||||
_cs = cs;
|
||||
_bet = bet;
|
||||
_config = config;
|
||||
_userId = userId;
|
||||
}
|
||||
|
||||
public async Task<Result> SpinAsync()
|
||||
{
|
||||
var result = _rng.Next(0, _config.WheelOfFortune.Multipliers.Length);
|
||||
|
||||
var amount = (long)(_bet * _config.WheelOfFortune.Multipliers[result]);
|
||||
|
||||
if (amount > 0)
|
||||
await _cs.AddAsync(_userId, "Wheel Of Fortune - won", amount, true);
|
||||
|
||||
return new() { Index = result, Amount = amount };
|
||||
}
|
||||
|
||||
public class Result
|
||||
{
|
||||
public int Index { get; set; }
|
||||
public long Amount { get; set; }
|
||||
}
|
||||
}
|
@@ -0,0 +1,50 @@
|
||||
#nullable disable
|
||||
using NadekoBot.Modules.Gambling.Common;
|
||||
using NadekoBot.Modules.Gambling.Services;
|
||||
using System.Collections.Immutable;
|
||||
using Wof = NadekoBot.Modules.Gambling.Common.WheelOfFortune.WheelOfFortuneGame;
|
||||
|
||||
namespace NadekoBot.Modules.Gambling;
|
||||
|
||||
public partial class Gambling
|
||||
{
|
||||
public partial class WheelOfFortuneCommands : GamblingSubmodule<GamblingService>
|
||||
{
|
||||
private static readonly ImmutableArray<string> _emojis =
|
||||
new[] { "⬆", "↖", "⬅", "↙", "⬇", "↘", "➡", "↗" }.ToImmutableArray();
|
||||
|
||||
private readonly ICurrencyService _cs;
|
||||
private readonly DbService _db;
|
||||
|
||||
public WheelOfFortuneCommands(ICurrencyService cs, DbService db, GamblingConfigService gamblingConfService)
|
||||
: base(gamblingConfService)
|
||||
{
|
||||
_cs = cs;
|
||||
_db = db;
|
||||
}
|
||||
|
||||
[Cmd]
|
||||
public async partial Task WheelOfFortune(ShmartNumber amount)
|
||||
{
|
||||
if (!await CheckBetMandatory(amount))
|
||||
return;
|
||||
|
||||
if (!await _cs.RemoveAsync(ctx.User.Id, "Wheel Of Fortune - bet", amount, true))
|
||||
{
|
||||
await ReplyErrorLocalizedAsync(strs.not_enough(CurrencySign));
|
||||
return;
|
||||
}
|
||||
|
||||
var result = await _service.WheelOfFortuneSpinAsync(ctx.User.Id, amount);
|
||||
|
||||
var wofMultipliers = _config.WheelOfFortune.Multipliers;
|
||||
await SendConfirmAsync(Format.Bold($@"{ctx.User.ToString()} won: {result.Amount + CurrencySign}
|
||||
|
||||
『{wofMultipliers[1]}』 『{wofMultipliers[0]}』 『{wofMultipliers[7]}』
|
||||
|
||||
『{wofMultipliers[2]}』 {_emojis[result.Index]} 『{wofMultipliers[6]}』
|
||||
|
||||
『{wofMultipliers[3]}』 『{wofMultipliers[4]}』 『{wofMultipliers[5]}』"));
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user