public static async Task ProcessResults(Lottery sender) { //todo: post results in fusion channel ulong tsNow = DateTimeHelper.TimestampNow(); //save the game in case of dispute or a problem paying out string savedGameName = $"{tsNow}.xml"; new ObjectSerializer().Serialize(sender, savedGameName); var n = sender.Numbers; var wn = sender.WinningNumbers; FusionBotConfig cfg = ((FusionBotConfig)Globals.Bot.Config); //pay minor prizes foreach (var w in wn) { RequestError err = await AccountHelper.PayUser((double)sender.Parameters.MinorPrize, cfg.BotId, n[w]); if (err != null) { await Sender.SendPrivateMessage(Globals.Client.GetUser(n[w]), $"You just won {sender.Parameters.MinorPrize}xnv in the lottery, but there was a problem with the payout. Please contact an admin and quote number `{tsNow}`"); } else { await Sender.SendPrivateMessage(Globals.Client.GetUser(n[w]), $"You just won {sender.Parameters.MinorPrize}xnv in the lottery."); } } float jackpot = sender.JackpotAmount; foreach (var w in wn) { if (sender.JackpotNumber == w) { RequestError err = await AccountHelper.PayUser((double)sender.JackpotAmount, cfg.BotId, n[w]); if (err != null) { await Sender.SendPrivateMessage(Globals.Client.GetUser(n[w]), $"You just won the lottery jackpot of {sender.JackpotAmount}xnv, but there was a problem with the payout. Please contact an admin and quote number `{tsNow}`"); } else { await Sender.SendPrivateMessage(Globals.Client.GetUser(n[w]), $"You just won the lottery jackpot of {sender.JackpotAmount}xnv."); } jackpot = 0; } } Restart(jackpot); }
public static Lottery New(GameParameters gp, float existingJackpot) { Lottery game = new Lottery(); game.parameters = gp; game.numbers = new ulong[gp.TicketCount]; game.winningNumbers = new int[5] { -1, -1, -1, -1, -1 }; game.jackpotAmount = gp.JackpotPrize + existingJackpot; return(game); }
public static void Load(string path) { currentGame = new ObjectSerializer().Deserialize <Lottery>(XDocument.Load(path)); Log.Write($"Existing lottery game loaded. Jackpot {currentGame.JackpotAmount}"); }
public static void Restart(float jackpot) { currentGame = Lottery.New(GameParameters.StandardGame, jackpot); Log.Write($"New lottery game started. Jackpot {currentGame.JackpotAmount}"); }