mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-10 17:28:27 -04:00
Added .config games hangman.currency_reward and a property with the same name in games.yml
This commit is contained in:
@@ -9,6 +9,8 @@ Experimental changelog. Mostly based on [keepachangelog](https://keepachangelog.
|
|||||||
- Added `.massban` to ban multiple people at once. 30 second cooldown
|
- Added `.massban` to ban multiple people at once. 30 second cooldown
|
||||||
- Added `.youtubeuploadnotif` / `.yun` as a shortcut for subscribing to a youtube channel's rss feed
|
- Added `.youtubeuploadnotif` / `.yun` as a shortcut for subscribing to a youtube channel's rss feed
|
||||||
- Added `.imageonlychannel` / `.imageonly` to prevent users from posting anything but images in the channel
|
- Added `.imageonlychannel` / `.imageonly` to prevent users from posting anything but images in the channel
|
||||||
|
- Added `.config games hangman.currency_reward` and a property with the same name in games.yml
|
||||||
|
- If set, users will gain the specified amount of currency for each hangman win
|
||||||
- Fully translated to Spanish, Russian and Ukrainian 🎉
|
- Fully translated to Spanish, Russian and Ukrainian 🎉
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
@@ -8,6 +8,15 @@ namespace NadekoBot.Modules.Games.Common
|
|||||||
[Cloneable]
|
[Cloneable]
|
||||||
public sealed partial class GamesConfig : ICloneable<GamesConfig>
|
public sealed partial class GamesConfig : ICloneable<GamesConfig>
|
||||||
{
|
{
|
||||||
|
[Comment("DO NOT CHANGE")]
|
||||||
|
public int Version { get; set; }
|
||||||
|
|
||||||
|
[Comment("Hangman related settings (.hangman command)")]
|
||||||
|
public HangmanConfig Hangman { get; set; } = new HangmanConfig()
|
||||||
|
{
|
||||||
|
CurrencyReward = 0
|
||||||
|
};
|
||||||
|
|
||||||
[Comment("Trivia related settings (.t command)")]
|
[Comment("Trivia related settings (.t command)")]
|
||||||
public TriviaConfig Trivia { get; set; } = new TriviaConfig()
|
public TriviaConfig Trivia { get; set; } = new TriviaConfig()
|
||||||
{
|
{
|
||||||
@@ -57,6 +66,13 @@ namespace NadekoBot.Modules.Games.Common
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Cloneable]
|
||||||
|
public sealed partial class HangmanConfig
|
||||||
|
{
|
||||||
|
[Comment("The amount of currency awarded to the winner of a hangman game")]
|
||||||
|
public long CurrencyReward { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
[Cloneable]
|
[Cloneable]
|
||||||
public sealed partial class TriviaConfig
|
public sealed partial class TriviaConfig
|
||||||
{
|
{
|
||||||
|
@@ -45,7 +45,7 @@ namespace NadekoBot.Modules.Games.Common.Hangman
|
|||||||
public uint Errors { get; private set; } = 0;
|
public uint Errors { get; private set; } = 0;
|
||||||
public uint MaxErrors { get; } = 6;
|
public uint MaxErrors { get; } = 6;
|
||||||
|
|
||||||
public event Func<Hangman, string, Task> OnGameEnded = delegate { return Task.CompletedTask; };
|
public event Func<Hangman, string, ulong, Task> OnGameEnded = delegate { return Task.CompletedTask; };
|
||||||
public event Func<Hangman, string, char, Task> OnLetterAlreadyUsed = delegate { return Task.CompletedTask; };
|
public event Func<Hangman, string, char, Task> OnLetterAlreadyUsed = delegate { return Task.CompletedTask; };
|
||||||
public event Func<Hangman, string, char, Task> OnGuessFailed = delegate { return Task.CompletedTask; };
|
public event Func<Hangman, string, char, Task> OnGuessFailed = delegate { return Task.CompletedTask; };
|
||||||
public event Func<Hangman, string, char, Task> OnGuessSucceeded = delegate { return Task.CompletedTask; };
|
public event Func<Hangman, string, char, Task> OnGuessSucceeded = delegate { return Task.CompletedTask; };
|
||||||
@@ -68,7 +68,7 @@ namespace NadekoBot.Modules.Games.Common.Hangman
|
|||||||
{
|
{
|
||||||
if (++Errors > MaxErrors)
|
if (++Errors > MaxErrors)
|
||||||
{
|
{
|
||||||
var _ = OnGameEnded(this, null);
|
var _ = OnGameEnded(this, null, 0);
|
||||||
CurrentPhase = Phase.Ended;
|
CurrentPhase = Phase.Ended;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -102,7 +102,7 @@ namespace NadekoBot.Modules.Games.Common.Hangman
|
|||||||
if (input != Term.Word) // failed
|
if (input != Term.Word) // failed
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var _ = OnGameEnded?.Invoke(this, userName);
|
var _ = OnGameEnded?.Invoke(this, userName, userId);
|
||||||
CurrentPhase = Phase.Ended;
|
CurrentPhase = Phase.Ended;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -127,7 +127,7 @@ namespace NadekoBot.Modules.Games.Common.Hangman
|
|||||||
else if (Term.Word.All(x => _previousGuesses.IsSupersetOf(Term.Word.ToLowerInvariant()
|
else if (Term.Word.All(x => _previousGuesses.IsSupersetOf(Term.Word.ToLowerInvariant()
|
||||||
.Where(char.IsLetterOrDigit))))
|
.Where(char.IsLetterOrDigit))))
|
||||||
{
|
{
|
||||||
var _ = OnGameEnded.Invoke(this, userName); // if all letters are guessed
|
var _ = OnGameEnded.Invoke(this, userName, userId); // if all letters are guessed
|
||||||
CurrentPhase = Phase.Ended;
|
CurrentPhase = Phase.Ended;
|
||||||
}
|
}
|
||||||
else // guessed but not last letter
|
else // guessed but not last letter
|
||||||
|
@@ -8,6 +8,7 @@ using NadekoBot.Common.Attributes;
|
|||||||
using NadekoBot.Modules.Games.Common.Hangman;
|
using NadekoBot.Modules.Games.Common.Hangman;
|
||||||
using NadekoBot.Modules.Games.Services;
|
using NadekoBot.Modules.Games.Services;
|
||||||
using NadekoBot.Modules.Games.Common.Hangman.Exceptions;
|
using NadekoBot.Modules.Games.Common.Hangman.Exceptions;
|
||||||
|
using NadekoBot.Services;
|
||||||
|
|
||||||
namespace NadekoBot.Modules.Games
|
namespace NadekoBot.Modules.Games
|
||||||
{
|
{
|
||||||
@@ -17,10 +18,14 @@ namespace NadekoBot.Modules.Games
|
|||||||
public class HangmanCommands : NadekoSubmodule<GamesService>
|
public class HangmanCommands : NadekoSubmodule<GamesService>
|
||||||
{
|
{
|
||||||
private readonly DiscordSocketClient _client;
|
private readonly DiscordSocketClient _client;
|
||||||
|
private readonly ICurrencyService _cs;
|
||||||
|
private readonly GamesConfigService _gcs;
|
||||||
|
|
||||||
public HangmanCommands(DiscordSocketClient client)
|
public HangmanCommands(DiscordSocketClient client, ICurrencyService cs, GamesConfigService gcs)
|
||||||
{
|
{
|
||||||
_client = client;
|
_client = client;
|
||||||
|
_cs = cs;
|
||||||
|
_gcs = gcs;
|
||||||
}
|
}
|
||||||
|
|
||||||
[NadekoCommand, Aliases]
|
[NadekoCommand, Aliases]
|
||||||
@@ -83,7 +88,7 @@ namespace NadekoBot.Modules.Games
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Task Hm_OnGameEnded(Hangman game, string winner)
|
Task Hm_OnGameEnded(Hangman game, string winner, ulong userId)
|
||||||
{
|
{
|
||||||
if (winner is null)
|
if (winner is null)
|
||||||
{
|
{
|
||||||
@@ -99,6 +104,10 @@ namespace NadekoBot.Modules.Games
|
|||||||
return ctx.Channel.EmbedAsync(loseEmbed);
|
return ctx.Channel.EmbedAsync(loseEmbed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var reward = _gcs.Data.Hangman.CurrencyReward;
|
||||||
|
if (reward > 0)
|
||||||
|
_cs.AddAsync(userId, "hangman win", reward, true);
|
||||||
|
|
||||||
var winEmbed = _eb.Create().WithTitle($"Hangman Game ({game.TermType}) - Ended")
|
var winEmbed = _eb.Create().WithTitle($"Hangman Game ({game.TermType}) - Ended")
|
||||||
.WithDescription(Format.Bold($"{winner} Won."))
|
.WithDescription(Format.Bold($"{winner} Won."))
|
||||||
.AddField("It was", game.Term.GetWord())
|
.AddField("It was", game.Term.GetWord())
|
||||||
|
@@ -18,6 +18,25 @@ namespace NadekoBot.Modules.Games.Services
|
|||||||
ConfigPrinters.ToString, val => val > 0);
|
ConfigPrinters.ToString, val => val > 0);
|
||||||
AddParsedProp("trivia.currency_reward", gs => gs.Trivia.CurrencyReward, long.TryParse,
|
AddParsedProp("trivia.currency_reward", gs => gs.Trivia.CurrencyReward, long.TryParse,
|
||||||
ConfigPrinters.ToString, val => val >= 0);
|
ConfigPrinters.ToString, val => val >= 0);
|
||||||
|
AddParsedProp("hangman.currency_reward", gs => gs.Hangman.CurrencyReward, long.TryParse,
|
||||||
|
ConfigPrinters.ToString, val => val >= 0);
|
||||||
|
|
||||||
|
Migrate();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Migrate()
|
||||||
|
{
|
||||||
|
if (_data.Version < 1)
|
||||||
|
{
|
||||||
|
ModifyConfig(c =>
|
||||||
|
{
|
||||||
|
c.Version = 1;
|
||||||
|
c.Hangman = new HangmanConfig()
|
||||||
|
{
|
||||||
|
CurrencyReward = 0
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,3 +1,9 @@
|
|||||||
|
# DO NOT CHANGE
|
||||||
|
version: 1
|
||||||
|
# Hangman related settings (.hangman command)
|
||||||
|
hangman:
|
||||||
|
# The amount of currency awarded to the winner of a hangman game
|
||||||
|
currencyReward: 0
|
||||||
# Trivia related settings (.t command)
|
# Trivia related settings (.t command)
|
||||||
trivia:
|
trivia:
|
||||||
# The amount of currency awarded to the winner of the trivia game.
|
# The amount of currency awarded to the winner of the trivia game.
|
||||||
|
Reference in New Issue
Block a user