Пример #1
0
 public Point(int number, IPosition position, Direction direction, Color colorOfCheckers, int numberOfCheckers)
 {
     if (number < 00 || number > 25)
     {
         throw new BackgammonException("BackgammonException: Invalid number parameter in point constructor.");
     }
     if (position == null)
     {
         throw new BackgammonException("BackgammonException: Invalid position parameter in point constructor.");
     }
     if (direction != Direction.None && direction != Direction.Up && direction != Direction.Down)
     {
         throw new BackgammonException("BackgammonException: Invalid direction parameter in point constructor.");
     }
     if (colorOfCheckers != Color.None && colorOfCheckers != Color.Blue && colorOfCheckers != Color.Red)
     {
         throw new BackgammonException("BackgammonException: Invalid color of checkers parameter in point constructor.");
     }
     if (numberOfCheckers < 0 || numberOfCheckers > 15)
     {
         throw new BackgammonException("BackgammonException: Invalid number of checkers parameter in point constructor.");
     }
     if (direction == Direction.None && ((numberOfCheckers > 0) || (number != 00 && number != 25)))
     {
         throw new BackgammonException("BackgammonException: Invalid parameter combination in point constructor.");
     }
     Number           = number;
     Position         = position;
     Direction        = direction;
     ColorOfCheckers  = colorOfCheckers;
     NumberOfCheckers = numberOfCheckers;
 }
Пример #2
0
 public Player(IBoard board, Color colorOfCheckers)
 {
     if (colorOfCheckers != Color.Blue && colorOfCheckers != Color.Red)
     {
         throw new BackgammonException("BackgammonException: Invalid color parameter in player constructor.");
     }
     ColorOfCheckers = colorOfCheckers;
     Movement        = Setup.StartingMovement;
     Position        = Setup.StartingPosition;
     Direction       = ColorOfCheckers == Color.Blue ? Direction.Down : Direction.Up;
     Dice            = Setup.Dice;
     _game           = new Game(board, this);
 }
Пример #3
0
 public void Display(Color color)
 {
     if (ColorOfCheckers != Color.None && ColorOfCheckers != Color.Blue && ColorOfCheckers != Color.Red)
     {
         throw new BackgammonException("BackgammonException: Invalid color of checkers in point display.");
     }
     if (Direction == Direction.None)
     {
         DisplayBar();
         return;
     }
     if (Direction != Direction.Up && Direction != Direction.Down)
     {
         throw new BackgammonException("BackgammonException: Invalid point direction cannot be displayed.");
     }
     DisplayNumber(Constants.Color.Dictionary[color]);
     DisplayCheckers();
 }