Ejemplo n.º 1
0
        /// <summary>
        /// Sumbits the simulated hand.
        /// </summary>
        /// <param name="game">The game.</param>
        /// <returns>The opperation outcome</returns>
        public OperationOutcome SumbitSimulatedHand(Game game)
        {
            var teamAdapter = AdapterFactory.GetTeamAdapter();

            var randomHand = this.GetRandomHand();
            var team       = teamAdapter.GetTeamByName(Properties.Settings.Default.SimulatorTeamName);

            return(this.SubmitHandGeneric(randomHand, team.Id, game));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Finds a game.
        /// </summary>
        /// <param name="teamId">The team identifier.</param>
        /// <param name="playAgainstSimulator">if set to <c>true</c> [play against simulator].</param>
        /// <returns>The Game Id</returns>
        public Guid GetNextAvailableGame(Guid teamId, bool playAgainstSimulator = false)
        {
            var gameAdapter = AdapterFactory.GetGameAdapter();
            var teamAdapter = AdapterFactory.GetTeamAdapter();
            var gameId      = Guid.Empty;

            var team = teamAdapter.GetTeamById(teamId);

            if (playAgainstSimulator)
            {
                gameId = GetSimulatedGame(team);
            }
            else
            {
                gameId = (gameAdapter.FindAvailableGame() ?? gameAdapter.RegisiterNewGame()).Id;
            }
            gameAdapter.SaveChanges();
            gameAdapter.JoinExistingGame(team, gameId);
            gameAdapter.SaveChanges();

            if (!playAgainstSimulator)
            {
                return(gameId);
            }

            gameAdapter = AdapterFactory.GetGameAdapter();
            var game = gameAdapter.GetGameById(gameId);

            if (game.IsComplete)
            {
                return(gameId);
            }

            var roundProvider = ProviderFactory.GetRoundProvider();

            roundProvider.SumbitSimulatedHand(game);

            return(gameId);
        }