Beispiel #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);
        }
Beispiel #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);
        }
 private static IEnumerable <Ball> GetGameBallOfType(CueBallGameType cueBallGameType)
 {
     return(GetAllBalls().Where(gameBall => gameBall.IsBallOfGameType(cueBallGameType)));
 }
 public static IEnumerable <Ball> GetAllGameBalls(this CueBallGameType cueBallGameType)
 {
     return(_gameBallCreators[cueBallGameType]());
 }
Beispiel #5
0
 public bool IsBallOfGameType(CueBallGameType cueBallGameType)
 {
     return(CueBallGameType.HasFlag(cueBallGameType));
 }
Beispiel #6
0
 public Ball(BallTypes ballType, CueBallGameType cueBallGameType, byte weight, BallGroupTypes ballGroupType)
     : this(ballType, cueBallGameType, weight)
 {
     BallGroupType = ballGroupType;
 }
Beispiel #7
0
 public Ball(BallTypes ballType, CueBallGameType cueBallGameType, byte weight)
     : this(ballType)
 {
     CueBallGameType = cueBallGameType;
     Weight          = weight;
 }
Beispiel #8
0
        private static IShotHistoryProvider CreateShotHistoryProvider(CueBallGameType gameType)
        {
            LazyInitializer.EnsureInitialized(ref _shotHistoryProvider, SetupGameStatusProviderStatus);

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

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