Beispiel #1
0
		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}");
		}
Beispiel #2
0
		public LotteryWinnerEvent(Lottery lottery)
		{
			if (lottery == null)
			{
				throw new ArgumentNullException("lottery");
			}
			Lottery = lottery;
		}
Beispiel #3
0
		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;
				}
			}
		}