Small nunchi fix, global nadeko improvement

This commit is contained in:
Master Kwoth 2017-08-04 19:43:25 +02:00
parent 47125ed687
commit dea9a935a4
6 changed files with 24 additions and 11 deletions

View File

@ -12,9 +12,11 @@ using NadekoBot.Services;
using NadekoBot.Services.Database.Models;
using NadekoBot.Services.Impl;
using NLog;
using NadekoBot.Common;
namespace NadekoBot.Modules.Administration.Services
{
[NoPublicBot]
public class LogCommandService : INService
{

View File

@ -22,7 +22,7 @@ namespace NadekoBot.Modules.Games.Common.Nunchi
public Phase CurrentPhase { get; private set; } = Phase.Joining;
public event Func<Nunchi, Task> OnGameStarted;
public event Func<Nunchi, Task> OnRoundStarted;
public event Func<Nunchi, int, Task> OnRoundStarted;
public event Func<Nunchi, Task> OnUserGuessed;
public event Func<Nunchi, (ulong Id, string Name)?, Task> OnRoundEnded; // tuple of the user who failed
public event Func<Nunchi, string, Task> OnGameEnded; // name of the user who won
@ -87,7 +87,7 @@ namespace NadekoBot.Modules.Games.Common.Nunchi
CurrentPhase = Phase.Playing;
var _ = OnGameStarted?.Invoke(this);
var __ = OnRoundStarted?.Invoke(this);
var __ = OnRoundStarted?.Invoke(this, CurrentNumber);
return true;
}
finally { _locker.Release(); }
@ -164,7 +164,7 @@ namespace NadekoBot.Modules.Games.Common.Nunchi
{
await Task.Delay(_nextRoundTimeout).ConfigureAwait(false);
CurrentPhase = Phase.Playing;
var ___ = OnRoundStarted?.Invoke(this);
var ___ = OnRoundStarted?.Invoke(this, CurrentNumber);
});
}

View File

@ -5,9 +5,7 @@ using NadekoBot.Common.Attributes;
using NadekoBot.Modules.Games.Common.Nunchi;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NadekoBot.Modules.Games
@ -100,9 +98,11 @@ namespace NadekoBot.Modules.Games
}
}
private Task Nunchi_OnRoundStarted(Nunchi arg)
private Task Nunchi_OnRoundStarted(Nunchi arg, int cur)
{
return ConfirmLocalized("nunchi_round_started", Format.Bold(arg.CurrentNumber.ToString()));
return ConfirmLocalized("nunchi_round_started",
Format.Bold(arg.ParticipantCount.ToString()),
Format.Bold(cur.ToString()));
}
private Task Nunchi_OnUserGuessed(Nunchi arg)

View File

@ -20,7 +20,7 @@ namespace NadekoBot.Services.Impl
private readonly IBotCredentials _creds;
private readonly DateTime _started;
public const string BotVersion = "1.6";
public const string BotVersion = "1.6.1";
public string Author => "Kwoth#2560";
public string Library => "Discord.Net";

View File

@ -7,6 +7,10 @@ using System.Reflection;
using System.Linq;
using System.Diagnostics;
using NLog;
#if GLOBAL_NADEKO
using NadekoBot.Common;
#endif
namespace NadekoBot.Services
{
@ -42,11 +46,18 @@ namespace NadekoBot.Services
{
var allTypes = assembly.GetTypes();
var services = new Queue<Type>(allTypes
.Where(x => x.GetInterfaces().Contains(typeof(INService)) && !x.GetTypeInfo().IsInterface && !x.GetTypeInfo().IsAbstract)
.Where(x => x.GetInterfaces().Contains(typeof(INService))
&& !x.GetTypeInfo().IsInterface && !x.GetTypeInfo().IsAbstract
#if GLOBAL_NADEKO
&& x.GetTypeInfo().GetCustomAttribute<NoPublicBot>() == null
#endif
)
.ToArray());
var interfaces = new HashSet<Type>(allTypes
.Where(x => x.GetInterfaces().Contains(typeof(INService)) && x.GetTypeInfo().IsInterface));
.Where(x => x.GetInterfaces().Contains(typeof(INService))
&& x.GetTypeInfo().IsInterface));
var alreadyFailed = new Dictionary<Type, int>();

View File

@ -374,7 +374,7 @@
"games_nunchi_started": "Nunchi game started with {0} participants.",
"games_nunchi_round_ended": "Nunchi round ended. {0} is out of the game.",
"games_nunchi_round_ended_boot": "Nunchi round ended due to timeout of some users. These users are still in the game: {0}",
"games_nunchi_round_started": "Nunchi round started. Start counting from the number {0}.",
"games_nunchi_round_started": "Nunchi round started with {0} users. Start counting from the number {0}.",
"games_nunchi_next_number": "Number registered. Last number was {0}.",
"games_nunchi_failed_to_start": "Nunchi failed to start because there were not enough participants.",
"games_nunchi_created": "Nunchi game created. Waiting for users to join.",