Exemplo n.º 1
0
        private void FillGap(Coordinates playerCoordinates, Direction direction, Slot <ICard <CardType> > originalSlot)
        {
            Direction oppositeDirection      = direction.GetOpposite();
            Direction perpendicularDirection = direction.GetPerpendicular();

            if (_grid.CoordinatesInBounds(playerCoordinates.Get(oppositeDirection)))
            {
                Coordinates nextCardCoordinates = playerCoordinates.Get(oppositeDirection);
                var         nextCardSlot        = GetSlot(nextCardCoordinates);
                originalSlot.Card = nextCardSlot.Card;
                nextCardSlot.Card = GameBuilder.GetRandomStartCard();
            }
            else
            {
                Slot <ICard <CardType> > currentSlot = originalSlot;
                var nextSlots = _grid.GetAllCardsNextTo(playerCoordinates, perpendicularDirection);

                foreach (var nextSlot in nextSlots)
                {
                    currentSlot.Card = nextSlot.Card;
                    currentSlot      = nextSlot;
                }

                currentSlot.Card = GameBuilder.GetRandomStartCard();
            }
        }