From 7147d2f0b1ac815c632ea812ed0fe9354831b7a7 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Wed, 27 Jul 2016 03:03:27 +0200 Subject: [PATCH] More CoC --- NadekoBot/Modules/ClashOfClans/ClashOfClans.cs | 10 +++++----- NadekoBot/Modules/ClashOfClans/ClashOfClansModule.cs | 9 ++++----- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/NadekoBot/Modules/ClashOfClans/ClashOfClans.cs b/NadekoBot/Modules/ClashOfClans/ClashOfClans.cs index 6576ce3d..de3e3079 100644 --- a/NadekoBot/Modules/ClashOfClans/ClashOfClans.cs +++ b/NadekoBot/Modules/ClashOfClans/ClashOfClans.cs @@ -40,7 +40,7 @@ namespace NadekoBot.Classes.ClashOfClans public void ResetTime() { - TimeAdded = DateTime.Now; + TimeAdded = DateTime.UtcNow; } public void Destroy() @@ -59,7 +59,7 @@ namespace NadekoBot.Classes.ClashOfClans public Caller[] Bases { get; set; } public WarState WarState { get; set; } = WarState.Created; //public bool Started { get; set; } = false; - public DateTime StartedAt { get; private set; } + public DateTime StartedAt { get; set; } //public bool Ended { get; private set; } = false; public ulong ServerId { get; set; } @@ -101,7 +101,7 @@ namespace NadekoBot.Classes.ClashOfClans throw new ArgumentException($"@{u} You already claimed base #{i + 1}. You can't claim a new one."); } - Bases[baseNumber] = new Caller(u.Trim(), DateTime.Now, false); + Bases[baseNumber] = new Caller(u.Trim(), DateTime.UtcNow, false); } internal void Start() @@ -112,7 +112,7 @@ namespace NadekoBot.Classes.ClashOfClans // throw new InvalidOperationException(); //Started = true; WarState = WarState.Started; - StartedAt = DateTime.Now; + StartedAt = DateTime.UtcNow; foreach (var b in Bases.Where(b => b != null)) { b.ResetTime(); @@ -155,7 +155,7 @@ namespace NadekoBot.Classes.ClashOfClans } else { - var left =(WarState == WarState.Started) ? callExpire - (DateTime.Now - Bases[i].TimeAdded) : callExpire; + var left =(WarState == WarState.Started) ? callExpire - (DateTime.UtcNow - Bases[i].TimeAdded) : callExpire; sb.AppendLine($"`{i + 1}.` ✅ `{Bases[i].CallUser}` {left.Hours}h {left.Minutes}m {left.Seconds}s left"); } } diff --git a/NadekoBot/Modules/ClashOfClans/ClashOfClansModule.cs b/NadekoBot/Modules/ClashOfClans/ClashOfClansModule.cs index 69ed1163..847d97f4 100644 --- a/NadekoBot/Modules/ClashOfClans/ClashOfClansModule.cs +++ b/NadekoBot/Modules/ClashOfClans/ClashOfClansModule.cs @@ -58,7 +58,6 @@ namespace NadekoBot.Modules.ClashOfClans //Can't this be disabled if the modules is disabled too :) var callExpire = new TimeSpan(2, 0, 0); var warExpire = new TimeSpan(23, 0, 0); - bool changed = false; while (true) { try @@ -77,16 +76,16 @@ namespace NadekoBot.Modules.ClashOfClans if (w.WarState != WarState.Ended) { //and B: the war has not expired - if ((w.WarState == WarState.Started && DateTime.Now - w.StartedAt <= warExpire) || w.WarState == WarState.Created) + if ((w.WarState == WarState.Started && DateTime.UtcNow - w.StartedAt <= warExpire) || w.WarState == WarState.Created) { newVal.Add(w); } } } - //var newVal = cw.Value.Where(w => !(w.Ended || DateTime.Now - w.StartedAt >= warExpire)).ToList(); + //var newVal = cw.Value.Where(w => !(w.Ended || DateTime.UtcNow - w.StartedAt >= warExpire)).ToList(); foreach (var exWar in cw.Value.Except(newVal)) { - await exWar.Channel.SendMessage($"War against {exWar.EnemyClan} has ended"); + await exWar.Channel.SendMessage($"War against {exWar.EnemyClan} ({exWar.Size}v{exWar.Size}) has ended"); } if (newVal.Count == 0) @@ -130,7 +129,7 @@ namespace NadekoBot.Modules.ClashOfClans for (var i = 0; i < Bases.Length; i++) { if (Bases[i] == null) continue; - if (!Bases[i].BaseDestroyed && DateTime.Now - Bases[i].TimeAdded >= callExpire) + if (!Bases[i].BaseDestroyed && DateTime.UtcNow - Bases[i].TimeAdded >= callExpire) { await war.Channel.SendMessage($"❗🔰**Claim from @{Bases[i].CallUser} for a war against {war.ShortPrint()} has expired.**").ConfigureAwait(false); Bases[i] = null;