Exemple #1
0
 private void TryToFlipFlopSpace(BoardCardSpace flippedSpace, BoardCardSpace neighbouringSpace)
 {
     if (neighbouringSpace.Card != null &&
         neighbouringSpace.Owner != flippedSpace.Owner &&
         neighbouringSpace.Card.Value < flippedSpace.Card.Value)
     {
         FlipFlopCard(neighbouringSpace, flippedSpace.Owner);
     }
 }
Exemple #2
0
        private void TryToFlipFlopNeighbours(BoardCardSpace flippedSpace)
        {
            foreach (Direction direction in new[] { Direction.Right, Direction.Left, Direction.Up, Direction.Down })
            {
                BoardCardSpace neighbouringSpace = GetNeighbour(flippedSpace, direction);

                if (neighbouringSpace != null)
                {
                    TryToFlipFlopSpace(flippedSpace, neighbouringSpace);
                }
            }
        }
Exemple #3
0
        public BoardCardSpace GetNeighbour(BoardCardSpace clickedSpace, Direction direction)
        {
            switch (direction)
            {
            case Direction.Left:
                if (clickedSpace.Index % 3 == 1)
                {
                    return(null);
                }
                else
                {
                    return(Spaces.Single(x => x.Index == clickedSpace.Index - 1));
                }

            case Direction.Right:
                if (clickedSpace.Index % 3 == 0)
                {
                    return(null);
                }
                else
                {
                    return(Spaces.Single(x => x.Index == clickedSpace.Index + 1));
                }

            case Direction.Up:
                if (clickedSpace.Index > 6)
                {
                    return(null);
                }
                else
                {
                    return(Spaces.Single(x => x.Index == clickedSpace.Index + 3));
                }

            case Direction.Down:
                if (clickedSpace.Index < 4)
                {
                    return(null);
                }
                else
                {
                    return(Spaces.Single(x => x.Index == clickedSpace.Index - 3));
                }

            default:
                break;
            }
            return(null);
        }
Exemple #4
0
 public void FlipFlopCard(BoardCardSpace clickedSpace, int activePlayerId)
 {
     clickedSpace.ChangeOwner(activePlayerId);
     clickedSpace.SetColorFlipped();
     TryToFlipFlopNeighbours(clickedSpace);
 }