示例#1
0
        public IEnumerable <BoardDeskAndPackCard> GetCardAvaibleToPosition(int x, int y)
        {
            var resultValue      = new List <BoardDeskAndPackCard>();
            var listCardInserted = new List <CardDefinition>();

            for (int ind = 0; ind < this.PackCard.Items.Count; ind++)
            {
                {
                    CardDefinition card         = this.PackCard.Items[ind];
                    var            rotationCard = (CardDefinition)card.DeepCopy();
                    for (int i = 0; i < CardDefinition.ROTATION_MOVE; i++)
                    {
                        // Rotation card  "all item (Smile and mount) in card is rotation around"
                        rotationCard = i == 0 ? rotationCard : CardDefinition.RotationCardToRight(rotationCard);
                        if (this.IsPossiblePutCardOnBoard(x, y, rotationCard))
                        {
                            if (listCardInserted.Any <CardDefinition>(c => c.IsTheSameCard(rotationCard)) == false) // optimalization (insert evenly card are ignore)
                            {
                                var cloneBoard = (BoardDeskAndPackCard)this.Clone();
                                cloneBoard.boardField[x, y] = rotationCard;
                                cloneBoard.PackCard.RemoveCard(card);
                                listCardInserted.Add(rotationCard);
                                resultValue.Add(cloneBoard);
                            }
                        }
                    }
                }
            }
            ;
            return(resultValue);
        }
示例#2
0
        internal bool IsTheSameCard(CardDefinition RotationCard)
        {
            if (this != RotationCard)
            {
                return(false);
            }

            var rtCard = (CardDefinition)RotationCard.Clone();

            for (int i = 0; i < CardDefinition.ROTATION_MOVE - 1; i++)
            {
                rtCard = CardDefinition.RotationCardToRight(rtCard);
                if (rtCard != this)
                {
                    return(false);
                }
            }
            return(true);
        }