public void OnLotteryWinner(LotteryWinnerEvent message) { CurrentLottery = null; message.Lottery.Channel.Say($"Lottery finished, the winner is {message.Lottery.Winner.Name}!"); var value = Wallets.GetCurrency(message.Lottery.Winner, LotteryCurrency); Wallets.SetCurrency(message.Lottery.Winner, LotteryCurrency, value + message.Lottery.Pot); message.Lottery.Winner.Whisper(message.Lottery.Channel, $"Congrats, you have won {message.Lottery.Pot} {LotteryCurrency}"); }
public LotteryWinnerEvent(Lottery lottery) { if (lottery == null) { throw new ArgumentNullException("lottery"); } Lottery = lottery; }
public void CreateLottery() { if (CurrentLottery == null) { CurrentLottery = CreateLotteryInternal(); } else { switch (CurrentLottery.State) { case LotteryState.Open: throw new LotteryException("A lottery already running"); case LotteryState.Finished: CurrentLottery = CreateLotteryInternal(); break; } } }