mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 01:38:27 -04:00
More target-typed new and redundant paranthesis cleanup
This commit is contained in:
@@ -38,7 +38,7 @@ public sealed class AnimalRace : IDisposable
|
||||
{
|
||||
this._currency = currency;
|
||||
this._options = options;
|
||||
this._animalsQueue = new Queue<RaceAnimal>(availableAnimals);
|
||||
this._animalsQueue = new(availableAnimals);
|
||||
this.MaxUsers = _animalsQueue.Count;
|
||||
|
||||
if (this._animalsQueue.Count == 0)
|
||||
|
@@ -16,7 +16,7 @@ public class Betroll
|
||||
public Betroll(BetRollConfig settings)
|
||||
{
|
||||
_thresholdPairs = settings.Pairs.OrderByDescending(x => x.WhenAbove);
|
||||
_rng = new Random();
|
||||
_rng = new();
|
||||
}
|
||||
|
||||
public Result Roll()
|
||||
@@ -26,14 +26,14 @@ public class Betroll
|
||||
var pair = _thresholdPairs.FirstOrDefault(x => x.WhenAbove < roll);
|
||||
if (pair is null)
|
||||
{
|
||||
return new Result
|
||||
return new()
|
||||
{
|
||||
Multiplier = 0,
|
||||
Roll = roll,
|
||||
};
|
||||
}
|
||||
|
||||
return new Result
|
||||
return new()
|
||||
{
|
||||
Multiplier = pair.MultiplyBy,
|
||||
Roll = roll,
|
||||
|
@@ -35,7 +35,7 @@ public class Blackjack
|
||||
{
|
||||
_cs = cs;
|
||||
_db = db;
|
||||
Dealer = new Dealer();
|
||||
Dealer = new();
|
||||
}
|
||||
|
||||
public void Start()
|
||||
@@ -105,7 +105,7 @@ public class Blackjack
|
||||
{
|
||||
var pause = Task.Delay(20000); //10 seconds to decide
|
||||
CurrentUser = usr;
|
||||
_currentUserMove = new TaskCompletionSource<bool>();
|
||||
_currentUserMove = new();
|
||||
await PrintState().ConfigureAwait(false);
|
||||
// either wait for the user to make an action and
|
||||
// if he doesn't - stand
|
||||
@@ -134,7 +134,7 @@ public class Blackjack
|
||||
return false;
|
||||
}
|
||||
|
||||
Players.Add(new User(user, bet));
|
||||
Players.Add(new(user, bet));
|
||||
var _ = PrintState();
|
||||
return true;
|
||||
}
|
||||
|
@@ -45,7 +45,7 @@ public class CurrencyRaffleGame
|
||||
_users.First().Amount != amount)
|
||||
return false;
|
||||
|
||||
if (!_users.Add(new User
|
||||
if (!_users.Add(new()
|
||||
{
|
||||
DiscordUser = usr,
|
||||
Amount = amount,
|
||||
|
@@ -7,15 +7,15 @@ public class QuadDeck : Deck
|
||||
{
|
||||
protected override void RefillPool()
|
||||
{
|
||||
CardPool = new List<Card>(52 * 4);
|
||||
CardPool = new(52 * 4);
|
||||
for (var j = 1; j < 14; j++)
|
||||
{
|
||||
for (var i = 1; i < 5; i++)
|
||||
{
|
||||
CardPool.Add(new Card((CardSuit)i, j));
|
||||
CardPool.Add(new Card((CardSuit)i, j));
|
||||
CardPool.Add(new Card((CardSuit)i, j));
|
||||
CardPool.Add(new Card((CardSuit)i, j));
|
||||
CardPool.Add(new((CardSuit)i, j));
|
||||
CardPool.Add(new((CardSuit)i, j));
|
||||
CardPool.Add(new((CardSuit)i, j));
|
||||
CardPool.Add(new((CardSuit)i, j));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -60,7 +60,7 @@ public class Deck
|
||||
{
|
||||
var str = string.Empty;
|
||||
|
||||
if (Number <= 10 && Number > 1)
|
||||
if (Number is <= 10 and > 1)
|
||||
{
|
||||
str += "_" + Number;
|
||||
}
|
||||
@@ -101,7 +101,7 @@ public class Deck
|
||||
throw new ArgumentException("Invalid input", nameof(input));
|
||||
}
|
||||
|
||||
return new Card(s, n);
|
||||
return new(s, n);
|
||||
}
|
||||
|
||||
public string GetEmojiString()
|
||||
@@ -189,7 +189,7 @@ public class Deck
|
||||
/// </summary>
|
||||
protected virtual void RefillPool()
|
||||
{
|
||||
CardPool = new List<Card>(52);
|
||||
CardPool = new(52);
|
||||
//foreach suit
|
||||
for (var j = 1; j < 14; j++)
|
||||
{
|
||||
@@ -199,7 +199,7 @@ public class Deck
|
||||
//generate a card of that suit and number and add it to the pool
|
||||
|
||||
// the pool will go from ace of spades,hears,diamonds,clubs all the way to the king of spades. hearts, ...
|
||||
CardPool.Add(new Card((CardSuit)i, j));
|
||||
CardPool.Add(new((CardSuit)i, j));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -256,7 +256,7 @@ public class Deck
|
||||
- cards.Min(card => (int)card.Number) == 4);
|
||||
if (toReturn || cards.All(c => c.Number != 1)) return toReturn;
|
||||
|
||||
var newCards = cards.Select(c => c.Number == 1 ? new Card(c.Suit, 14) : c);
|
||||
var newCards = cards.Select(c => c.Number == 1 ? new(c.Suit, 14) : c);
|
||||
return (newCards.Max(card => (int)card.Number)
|
||||
- newCards.Min(card => (int)card.Number) == 4);
|
||||
}
|
||||
@@ -281,7 +281,7 @@ public class Deck
|
||||
|
||||
bool isStraightFlush(List<Card> cards) => hasStraightFlush(cards) && !isRoyalFlush(cards);
|
||||
|
||||
handValues = new Dictionary<string, Func<List<Card>, bool>>
|
||||
handValues = new()
|
||||
{
|
||||
{ "Royal Flush", isRoyalFlush },
|
||||
{ "Straight Flush", isStraightFlush },
|
||||
|
@@ -54,12 +54,12 @@ public class GameStatusEvent : ICurrencyEvent
|
||||
_channel = ch;
|
||||
_opts = opt;
|
||||
// generate code
|
||||
_code = new string(_sneakyGameStatusChars.Shuffle().Take(5).ToArray());
|
||||
_code = new(_sneakyGameStatusChars.Shuffle().Take(5).ToArray());
|
||||
|
||||
_t = new Timer(OnTimerTick, null, Timeout.InfiniteTimeSpan, TimeSpan.FromSeconds(2));
|
||||
_t = new(OnTimerTick, null, Timeout.InfiniteTimeSpan, TimeSpan.FromSeconds(2));
|
||||
if (_opts.Hours > 0)
|
||||
{
|
||||
_timeout = new Timer(EventTimeout, null, TimeSpan.FromHours(_opts.Hours), Timeout.InfiniteTimeSpan);
|
||||
_timeout = new(EventTimeout, null, TimeSpan.FromHours(_opts.Hours), Timeout.InfiniteTimeSpan);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ public class GameStatusEvent : ICurrencyEvent
|
||||
await _msg.ModifyAsync(m =>
|
||||
{
|
||||
m.Embed = GetEmbed(PotSize).Build();
|
||||
}, new RequestOptions() { RetryMode = RetryMode.AlwaysRetry }).ConfigureAwait(false);
|
||||
}, new() { RetryMode = RetryMode.AlwaysRetry }).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
Log.Information("Awarded {0} users {1} currency.{2}",
|
||||
@@ -175,7 +175,7 @@ public class GameStatusEvent : ICurrencyEvent
|
||||
|
||||
try
|
||||
{
|
||||
await msg.DeleteAsync(new RequestOptions()
|
||||
await msg.DeleteAsync(new()
|
||||
{
|
||||
RetryMode = RetryMode.AlwaysFail
|
||||
});
|
||||
|
@@ -52,10 +52,10 @@ public class ReactionEvent : ICurrencyEvent
|
||||
_opts = opt;
|
||||
_config = config;
|
||||
|
||||
_t = new Timer(OnTimerTick, null, Timeout.InfiniteTimeSpan, TimeSpan.FromSeconds(2));
|
||||
_t = new(OnTimerTick, null, Timeout.InfiniteTimeSpan, TimeSpan.FromSeconds(2));
|
||||
if (_opts.Hours > 0)
|
||||
{
|
||||
_timeout = new Timer(EventTimeout, null, TimeSpan.FromHours(_opts.Hours), Timeout.InfiniteTimeSpan);
|
||||
_timeout = new(EventTimeout, null, TimeSpan.FromHours(_opts.Hours), Timeout.InfiniteTimeSpan);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ public class ReactionEvent : ICurrencyEvent
|
||||
await _msg.ModifyAsync(m =>
|
||||
{
|
||||
m.Embed = GetEmbed(PotSize).Build();
|
||||
}, new RequestOptions() { RetryMode = RetryMode.AlwaysRetry }).ConfigureAwait(false);
|
||||
}, new() { RetryMode = RetryMode.AlwaysRetry }).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
Log.Information("Awarded {0} users {1} currency.{2}",
|
||||
|
@@ -11,15 +11,15 @@ public sealed partial class GamblingConfig : ICloneable<GamblingConfig>
|
||||
{
|
||||
public GamblingConfig()
|
||||
{
|
||||
BetRoll = new BetRollConfig();
|
||||
WheelOfFortune = new WheelOfFortuneSettings();
|
||||
Waifu = new WaifuConfig();
|
||||
Currency = new CurrencyConfig();
|
||||
BetFlip = new BetFlipConfig();
|
||||
Generation = new GenerationConfig();
|
||||
Timely = new TimelyConfig();
|
||||
Decay = new DecayConfig();
|
||||
Slots = new SlotsConfig();
|
||||
BetRoll = new();
|
||||
WheelOfFortune = new();
|
||||
Waifu = new();
|
||||
Currency = new();
|
||||
BetFlip = new();
|
||||
Generation = new();
|
||||
Timely = new();
|
||||
Decay = new();
|
||||
Slots = new();
|
||||
}
|
||||
|
||||
[Comment(@"DO NOT CHANGE")]
|
||||
|
@@ -13,7 +13,7 @@ public abstract class GamblingModule<TService> : NadekoModule<TService>
|
||||
|
||||
protected GamblingModule(GamblingConfigService gambService)
|
||||
{
|
||||
_lazyConfig = new Lazy<GamblingConfig>(() => gambService.Data);
|
||||
_lazyConfig = new(() => gambService.Data);
|
||||
}
|
||||
|
||||
private async Task<bool> InternalCheckBet(long amount)
|
||||
|
@@ -49,7 +49,7 @@ public class RollDuelGame
|
||||
this.Amount = amount;
|
||||
_cs = cs;
|
||||
|
||||
_timeoutTimer = new Timer(async delegate
|
||||
_timeoutTimer = new(async delegate
|
||||
{
|
||||
await _locker.WaitAsync().ConfigureAwait(false);
|
||||
try
|
||||
|
@@ -36,6 +36,6 @@ public class SlotGame
|
||||
else if (rolls.Any(x => x == 5))
|
||||
multi = 1;
|
||||
|
||||
return new Result(multi, rolls);
|
||||
return new(multi, rolls);
|
||||
}
|
||||
}
|
@@ -20,7 +20,7 @@ public class WheelOfFortuneGame
|
||||
|
||||
public WheelOfFortuneGame(ulong userId, long bet, GamblingConfig config, ICurrencyService cs)
|
||||
{
|
||||
_rng = new NadekoRandom();
|
||||
_rng = new();
|
||||
_cs = cs;
|
||||
_bet = bet;
|
||||
_config = config;
|
||||
@@ -36,7 +36,7 @@ public class WheelOfFortuneGame
|
||||
if (amount > 0)
|
||||
await _cs.AddAsync(_userId, "Wheel Of Fortune - won", amount, gamble: true).ConfigureAwait(false);
|
||||
|
||||
return new Result
|
||||
return new()
|
||||
{
|
||||
Index = result,
|
||||
Amount = amount,
|
||||
|
Reference in New Issue
Block a user