mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 17:58:26 -04:00
More target-typed new and redundant paranthesis cleanup
This commit is contained in:
@@ -34,7 +34,7 @@ public class CurrencyRaffleService : INService
|
||||
if (!Games.TryGetValue(channelId, out var crg))
|
||||
{
|
||||
newGame = true;
|
||||
crg = new CurrencyRaffleGame(mixed
|
||||
crg = new(mixed
|
||||
? CurrencyRaffleGame.Type.Mixed
|
||||
: CurrencyRaffleGame.Type.Normal);
|
||||
Games.Add(channelId, crg);
|
||||
|
@@ -24,7 +24,7 @@ public sealed class GamblingConfigService : ConfigServiceBase<GamblingConfig>
|
||||
AddParsedProp("gen.min", gs => gs.Generation.MinAmount, int.TryParse, ConfigPrinters.ToString, val => val >= 1);
|
||||
AddParsedProp("gen.max", gs => gs.Generation.MaxAmount, int.TryParse, ConfigPrinters.ToString, val => val >= 1);
|
||||
AddParsedProp("gen.cd", gs => gs.Generation.GenCooldown, int.TryParse, ConfigPrinters.ToString, val => val > 0);
|
||||
AddParsedProp("gen.chance", gs => gs.Generation.Chance, decimal.TryParse, ConfigPrinters.ToString, val => val >= 0 && val <= 1);
|
||||
AddParsedProp("gen.chance", gs => gs.Generation.Chance, decimal.TryParse, ConfigPrinters.ToString, val => val is >= 0 and <= 1);
|
||||
AddParsedProp("gen.has_pw", gs => gs.Generation.HasPassword, bool.TryParse, ConfigPrinters.ToString);
|
||||
AddParsedProp("bf.multi", gs => gs.BetFlip.Multiplier, decimal.TryParse, ConfigPrinters.ToString, val => val >= 1);
|
||||
AddParsedProp("waifu.min_price", gs => gs.Waifu.MinPrice, int.TryParse, ConfigPrinters.ToString, val => val >= 0);
|
||||
@@ -35,7 +35,7 @@ public sealed class GamblingConfigService : ConfigServiceBase<GamblingConfig>
|
||||
AddParsedProp("waifu.multi.all_gifts", gs => gs.Waifu.Multipliers.AllGiftPrices, decimal.TryParse, ConfigPrinters.ToString, val => val > 0);
|
||||
AddParsedProp("waifu.multi.gift_effect", gs => gs.Waifu.Multipliers.GiftEffect, decimal.TryParse, ConfigPrinters.ToString, val => val >= 0);
|
||||
AddParsedProp("waifu.multi.negative_gift_effect", gs => gs.Waifu.Multipliers.NegativeGiftEffect, decimal.TryParse, ConfigPrinters.ToString, val => val >= 0);
|
||||
AddParsedProp("decay.percent", gs => gs.Decay.Percent, decimal.TryParse, ConfigPrinters.ToString, val => val >= 0 && val <= 1);
|
||||
AddParsedProp("decay.percent", gs => gs.Decay.Percent, decimal.TryParse, ConfigPrinters.ToString, val => val is >= 0 and <= 1);
|
||||
AddParsedProp("decay.maxdecay", gs => gs.Decay.MaxDecay, int.TryParse, ConfigPrinters.ToString, val => val >= 0);
|
||||
AddParsedProp("decay.threshold", gs => gs.Decay.MinThreshold, int.TryParse, ConfigPrinters.ToString, val => val >= 0);
|
||||
|
||||
|
@@ -39,7 +39,7 @@ public class GamblingService : INService
|
||||
|
||||
if (_bot.Client.ShardId == 0)
|
||||
{
|
||||
_decayTimer = new Timer(_ =>
|
||||
_decayTimer = new(_ =>
|
||||
{
|
||||
var config = _gss.Data;
|
||||
var maxDecay = config.Decay.MaxDecay;
|
||||
@@ -85,7 +85,7 @@ WHERE CurrencyAmount > {config.Decay.MinThreshold} AND UserId!={_client.CurrentU
|
||||
|
||||
if (!takeRes)
|
||||
{
|
||||
return new SlotResponse
|
||||
return new()
|
||||
{
|
||||
Error = GamblingError.NotEnough
|
||||
};
|
||||
|
@@ -48,7 +48,7 @@ public class PlantPickService : INService
|
||||
_fonts = fonts;
|
||||
_cs = cs;
|
||||
_cmdHandler = cmdHandler;
|
||||
_rng = new NadekoRandom();
|
||||
_rng = new();
|
||||
_client = client;
|
||||
_gss = gss;
|
||||
|
||||
@@ -62,7 +62,7 @@ public class PlantPickService : INService
|
||||
.Where(x => guildIds.Contains(x.GuildId))
|
||||
.ToList();
|
||||
|
||||
_generationChannels = new ConcurrentHashSet<ulong>(configs
|
||||
_generationChannels = new(configs
|
||||
.SelectMany(c => c.GenerateCurrencyChannelIds.Select(obj => obj.ChannelId)));
|
||||
}
|
||||
}
|
||||
@@ -155,7 +155,7 @@ public class PlantPickService : INService
|
||||
img.Mutate(x =>
|
||||
{
|
||||
// measure the size of the text to be drawing
|
||||
var size = TextMeasurer.Measure(pass, new RendererOptions(font, new PointF(0, 0)));
|
||||
var size = TextMeasurer.Measure(pass, new(font, new PointF(0, 0)));
|
||||
|
||||
// fill the background with black, add 5 pixels on each side to make it look better
|
||||
x.FillPolygon(Color.ParseHex("00000080"),
|
||||
@@ -168,7 +168,7 @@ public class PlantPickService : INService
|
||||
x.DrawText(pass,
|
||||
font,
|
||||
SixLabors.ImageSharp.Color.White,
|
||||
new PointF(0, 0));
|
||||
new(0, 0));
|
||||
});
|
||||
// return image as a stream for easy sending
|
||||
return (img.ToStream(format), format.FileExtensions.FirstOrDefault() ?? "png");
|
||||
@@ -364,7 +364,7 @@ public class PlantPickService : INService
|
||||
{
|
||||
using (var uow = _db.GetDbContext())
|
||||
{
|
||||
uow.PlantedCurrency.Add(new PlantedCurrency
|
||||
uow.PlantedCurrency.Add(new()
|
||||
{
|
||||
Amount = amount,
|
||||
GuildId = gid,
|
||||
|
@@ -42,7 +42,7 @@ public class VoteRewardService : INService, IReadyExecutor
|
||||
if (_client.ShardId != 0)
|
||||
return;
|
||||
|
||||
_http = new HttpClient(new HttpClientHandler()
|
||||
_http = new(new HttpClientHandler()
|
||||
{
|
||||
AllowAutoRedirect = false,
|
||||
ServerCertificateCustomValidationCallback = delegate { return true; }
|
||||
|
@@ -175,14 +175,14 @@ public class WaifuService : INService
|
||||
}
|
||||
else
|
||||
{
|
||||
uow.WaifuInfo.Add(w = new WaifuInfo()
|
||||
uow.WaifuInfo.Add(w = new()
|
||||
{
|
||||
Waifu = waifu,
|
||||
Claimer = claimer,
|
||||
Affinity = null,
|
||||
Price = amount
|
||||
});
|
||||
uow.WaifuUpdates.Add(new WaifuUpdate()
|
||||
uow.WaifuUpdates.Add(new()
|
||||
{
|
||||
User = waifu,
|
||||
Old = null,
|
||||
@@ -205,7 +205,7 @@ public class WaifuService : INService
|
||||
w.Price = amount + (amount / 4);
|
||||
result = WaifuClaimResult.Success;
|
||||
|
||||
uow.WaifuUpdates.Add(new WaifuUpdate()
|
||||
uow.WaifuUpdates.Add(new()
|
||||
{
|
||||
User = w.Waifu,
|
||||
Old = oldClaimer,
|
||||
@@ -227,7 +227,7 @@ public class WaifuService : INService
|
||||
w.Price = amount;
|
||||
result = WaifuClaimResult.Success;
|
||||
|
||||
uow.WaifuUpdates.Add(new WaifuUpdate()
|
||||
uow.WaifuUpdates.Add(new()
|
||||
{
|
||||
User = w.Waifu,
|
||||
Old = oldClaimer,
|
||||
@@ -264,7 +264,7 @@ public class WaifuService : INService
|
||||
else if (w is null)
|
||||
{
|
||||
var thisUser = uow.GetOrCreateUser(user);
|
||||
uow.WaifuInfo.Add(new WaifuInfo()
|
||||
uow.WaifuInfo.Add(new()
|
||||
{
|
||||
Affinity = newAff,
|
||||
Waifu = thisUser,
|
||||
@@ -273,7 +273,7 @@ public class WaifuService : INService
|
||||
});
|
||||
success = true;
|
||||
|
||||
uow.WaifuUpdates.Add(new WaifuUpdate()
|
||||
uow.WaifuUpdates.Add(new()
|
||||
{
|
||||
User = thisUser,
|
||||
Old = null,
|
||||
@@ -288,7 +288,7 @@ public class WaifuService : INService
|
||||
w.Affinity = newAff;
|
||||
success = true;
|
||||
|
||||
uow.WaifuUpdates.Add(new WaifuUpdate()
|
||||
uow.WaifuUpdates.Add(new()
|
||||
{
|
||||
User = w.Waifu,
|
||||
Old = oldAff,
|
||||
@@ -353,7 +353,7 @@ public class WaifuService : INService
|
||||
var oldClaimer = w.Claimer;
|
||||
w.Claimer = null;
|
||||
|
||||
uow.WaifuUpdates.Add(new WaifuUpdate()
|
||||
uow.WaifuUpdates.Add(new()
|
||||
{
|
||||
User = w.Waifu,
|
||||
Old = oldClaimer,
|
||||
@@ -382,7 +382,7 @@ public class WaifuService : INService
|
||||
.Include(x => x.Claimer));
|
||||
if (w is null)
|
||||
{
|
||||
uow.WaifuInfo.Add(w = new WaifuInfo()
|
||||
uow.WaifuInfo.Add(w = new()
|
||||
{
|
||||
Affinity = null,
|
||||
Claimer = null,
|
||||
@@ -393,7 +393,7 @@ public class WaifuService : INService
|
||||
|
||||
if (!itemObj.Negative)
|
||||
{
|
||||
w.Items.Add(new WaifuItem()
|
||||
w.Items.Add(new()
|
||||
{
|
||||
Name = itemObj.Name.ToLowerInvariant(),
|
||||
ItemEmoji = itemObj.ItemEmoji,
|
||||
@@ -428,17 +428,17 @@ public class WaifuService : INService
|
||||
var wi = uow.GetWaifuInfo(targetId);
|
||||
if (wi is null)
|
||||
{
|
||||
wi = new WaifuInfoStats
|
||||
wi = new()
|
||||
{
|
||||
AffinityCount = 0,
|
||||
AffinityName = null,
|
||||
ClaimCount = 0,
|
||||
ClaimerName = null,
|
||||
Claims = new List<string>(),
|
||||
Fans = new List<string>(),
|
||||
Claims = new(),
|
||||
Fans = new(),
|
||||
DivorceCount = 0,
|
||||
FullName = null,
|
||||
Items = new List<WaifuItem>(),
|
||||
Items = new(),
|
||||
Price = 1
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user