Created
July 13, 2018 00:28
-
-
Save phytal/3fa264d3578918d5bfa9a67b0520eb62 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
using System.Threading.Tasks; | |
using System.Timers; | |
using Discord.WebSocket; | |
using Wsashi.Features; | |
using Wsashi.Features.GlobalAccounts; | |
namespace Wsashi | |
{ | |
internal static class Timers | |
{ | |
private static DiscordSocketClient _client; | |
private static Timer loopingtimer; | |
private static SocketTextChannel channel; | |
private static SocketGuildUser user; | |
internal static Task StartTimer() | |
{ | |
var fourHoursInMiliSeconds = 14400000; | |
loopingtimer = new Timer() | |
{ | |
Interval = fourHoursInMiliSeconds, | |
AutoReset = true, | |
Enabled = true | |
}; | |
loopingtimer.Elapsed += OnTimerTicked; | |
Console.WriteLine("Initialized Mission - Cripple Wasagotchi"); | |
return Task.CompletedTask; | |
} | |
//try to get something so that all pets will experience soemthing | |
private static void OnTimerTicked(object sender, ElapsedEventArgs e) | |
{ | |
var config = GlobalWasagotchiUserAccounts.GetFilteredAccounts(usrAcc => true); | |
foreach (var userAcc in config) | |
{ | |
if (userAcc.Have == true) | |
{ | |
if (userAcc.Hunger > 0) | |
userAcc.Hunger = userAcc.Hunger - 1; | |
else userAcc.Hunger = 0; | |
if (userAcc.Waste < 20) | |
userAcc.Waste = userAcc.Waste + 1; | |
else userAcc.Waste = 20; | |
if (userAcc.Attention > 0) | |
userAcc.Attention = userAcc.Attention - 1; | |
else userAcc.Attention = 0; | |
GlobalWasagotchiUserAccounts.SaveAccounts(); | |
} | |
else | |
{ | |
return; | |
} | |
} | |
Console.WriteLine("Successfully executed pet crippling effects."); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment