コード例 #1
0
ファイル: GameManager.cs プロジェクト: densom/KenoTrials
        private static decimal CalculatePayout(GameTicket ticket, Game game)
        {
            var amount = CalculatePayout(ticket.NumbersToBetPerGame, NumberOfMatches(ticket.NumbersPlayed, game.NumbersDrawn));
            if (ticket.BetKicker)
            {
                amount *= 2;
            }

            return amount;
        }
コード例 #2
0
ファイル: GameManager.cs プロジェクト: densom/KenoTrials
        private IEnumerable<GameResult> ProcessResults(Game currentGame)
        {
            var results = new List<GameResult>();

            foreach (GameTicket registeredTicket in currentGame.RegisteredTickets)
            {
                decimal amount = CalculatePayout(registeredTicket, currentGame);
                results.Add(new GameResult(currentGame.NumbersDrawn, amount > 0, amount, currentGame.GameId, registeredTicket.NumbersToBetPerGame, NumbersMatched(registeredTicket.NumbersPlayed, currentGame.NumbersDrawn).ToArray()));
            }
            _completedGames.Add(currentGame);
            return results.AsReadOnly();
        }
コード例 #3
0
ファイル: GameManager.cs プロジェクト: densom/KenoTrials
 public IEnumerable<GameResult> Run()
 {
     while (_availableGames.Peek().RegisteredTickets.Count > 0)
     {
         _currentGame = _availableGames.Dequeue();
         _currentGame.GameState = GameState.Active;
         _currentGame.NumbersDrawn = DrawNumbers();
         _currentGame.GameState = GameState.Complete;
         IEnumerable<GameResult> gameResults = ProcessResults(_currentGame);
         _currentGame = null;
         RefreshAvailableGames();
         foreach (GameResult gameResult in gameResults)
         {
             yield return gameResult;
         }
     }
 }