Esempio n. 1
0
        private static ICueBallGame CreatePoolGame(CueBallGameType gameType, ICueBallGameReferee referee, IPlayer player1,
                                                   IPlayer player2)
        {
            LazyInitializer.EnsureInitialized(ref _gameCreationDelegates, SetupGameCreationalDelegates);

            var game = _gameCreationDelegates[gameType](referee, player1, player2);

            return(game);
        }
Esempio n. 2
0
        protected CueBallGame(ICueBallGameReferee cueBallGameReferee, CueBallGameType gameType, IPlayer player1, IPlayer player2)
        {
            _cueBallGameReferee = cueBallGameReferee;
            _ballsOnTable       = new List <Ball>();

            foreach (var ballType in gameType.GetAllGameBalls())
            {
                AddBall(ballType);
            }

            _cueBallGameReferee.Initialize(this);
            _cueBallGameReferee.SetPlayers(player1, player2);
        }
Esempio n. 3
0
 private static IEnumerable <Ball> GetGameBallOfType(CueBallGameType cueBallGameType)
 {
     return(GetAllBalls().Where(gameBall => gameBall.IsBallOfGameType(cueBallGameType)));
 }
Esempio n. 4
0
 public static IEnumerable <Ball> GetAllGameBalls(this CueBallGameType cueBallGameType)
 {
     return(_gameBallCreators[cueBallGameType]());
 }
Esempio n. 5
0
 public bool IsBallOfGameType(CueBallGameType cueBallGameType)
 {
     return(CueBallGameType.HasFlag(cueBallGameType));
 }
Esempio n. 6
0
 public Ball(BallTypes ballType, CueBallGameType cueBallGameType, byte weight, BallGroupTypes ballGroupType)
     : this(ballType, cueBallGameType, weight)
 {
     BallGroupType = ballGroupType;
 }
Esempio n. 7
0
 public Ball(BallTypes ballType, CueBallGameType cueBallGameType, byte weight)
     : this(ballType)
 {
     CueBallGameType = cueBallGameType;
     Weight          = weight;
 }
Esempio n. 8
0
        private static IShotHistoryProvider CreateShotHistoryProvider(CueBallGameType gameType)
        {
            LazyInitializer.EnsureInitialized(ref _shotHistoryProvider, SetupGameStatusProviderStatus);

            return(_shotHistoryProvider[gameType]());
        }
Esempio n. 9
0
 public static TGameType CreatePoolGame <TGameType>(CueBallGameType cueBallGameType,
                                                    IPlayer player1, IPlayer player2)
 {
     return((TGameType)CreatePoolGame(cueBallGameType, CreateGameReferee(cueBallGameType), player1, player2));
 }
Esempio n. 10
0
        public static ICueBallGameReferee CreateGameReferee(CueBallGameType gameType)
        {
            LazyInitializer.EnsureInitialized(ref _gameReferee, SetupGameRefereeCreationalDelegates);

            return(_gameReferee[gameType](CreateShotHistoryProvider(gameType)));
        }