re-added --start-time (-s) to .race, updated libraries, version upped to 2.6.0, added 'options' field to help if command has extra options (only .race atm)

This commit is contained in:
Master Kwoth
2017-11-29 13:53:16 +07:00
parent e266489076
commit 4ab2ac1f1d
17 changed files with 76 additions and 36 deletions

View File

@ -43,7 +43,6 @@ namespace NadekoBot.Modules.Gambling.Common.AnimalRacing
public AnimalRace(RaceOptions options, CurrencyService currency, RaceAnimal[] availableAnimals)
{
NormalizeOptions(options);
this._currency = currency;
this._options = options;
this._animalsQueue = new Queue<RaceAnimal>(availableAnimals);
@ -53,17 +52,11 @@ namespace NadekoBot.Modules.Gambling.Common.AnimalRacing
CurrentPhase = Phase.Ended;
}
private void NormalizeOptions(RaceOptions options)
{
if (options.StartDelay < 10 || options.StartDelay > 120)
options.StartDelay = 20;
}
public void Initialize() //lame name
{
var _t = Task.Run(async () =>
{
await Task.Delay(_options.StartDelay * 1000).ConfigureAwait(false);
await Task.Delay(_options.StartTime * 1000).ConfigureAwait(false);
await _locker.WaitAsync().ConfigureAwait(false);
try

View File

@ -4,7 +4,13 @@ namespace NadekoBot.Core.Modules.Gambling.Common.AnimalRacing
{
public class RaceOptions
{
[Option("start-delay", Default = 20, Required = false)]
public int StartDelay { get; set; }
[Option('s', "start-time", Default = 20, Required = false)]
public int StartTime { get; set; } = 20;
public void NormalizeOptions()
{
if (this.StartTime < 10 || this.StartTime > 120)
this.StartTime = 20;
}
}
}