Exemple #1
0
        private void ProcessPlusPhase(Card _playedCard, Dictionary <CardDirection, Card> _adjacentCardsByDirection, ref Dictionary <GamePhase, ResultPhaseData> _turnResultByPhase)
        {
            List <CardOnBoardWon> cardWonList = new List <CardOnBoardWon>();
            Dictionary <int, List <CardOnBoardWon> > cardWonByAddPowers = new Dictionary <int, List <CardOnBoardWon> >();

            foreach (KeyValuePair <CardDirection, Card> opponentCardItem in _adjacentCardsByDirection)
            {
                bool isRealCard = (opponentCardItem.Value.BoardPosition.HasValue);
                if (isRealCard)
                {
                    CardDirection opponentCardOppositeDirection = GetOppositeDirection(opponentCardItem.Key);

                    int powerAdd = ((int)_playedCard.GetPowerByDirection(opponentCardItem.Key)) + ((int)opponentCardItem.Value.GetPowerByDirection(opponentCardOppositeDirection));

                    List <CardOnBoardWon> powerAddCardWonList;
                    if (!cardWonByAddPowers.TryGetValue(powerAdd, out powerAddCardWonList))
                    {
                        powerAddCardWonList          = new List <CardOnBoardWon>();
                        cardWonByAddPowers[powerAdd] = powerAddCardWonList;
                    }

                    powerAddCardWonList.Add(new CardOnBoardWon(opponentCardItem.Value, opponentCardOppositeDirection));
                }
            }

            foreach (List <CardOnBoardWon> cardWonByAddPowerItem in cardWonByAddPowers.Values)
            {
                if (cardWonByAddPowerItem.Count > 1)
                {
                    cardWonList.AddRange(cardWonByAddPowerItem);
                }
            }

            bool allCardsAreOwnedByCurrentPlayer = true;

            foreach (CardOnBoardWon cardItem in cardWonList)
            {
                if (cardItem.card.PlayerOwner != _playedCard.PlayerOwner)
                {
                    allCardsAreOwnedByCurrentPlayer = false;
                }
            }

            if (cardWonList.Count > 1 && !allCardsAreOwnedByCurrentPlayer)
            {
                ResultPhaseData plusResultPhaseData = new ResultPhaseData();
                foreach (CardOnBoardWon cardItem in cardWonList)
                {
                    cardItem.card.PlayerOwner = _playedCard.PlayerOwner;
                }
                plusResultPhaseData.cardWonList = cardWonList;

                ProcessComboPhase(cardWonList, ref plusResultPhaseData.comboCardList);
                _turnResultByPhase[GamePhase.Plus] = plusResultPhaseData;
            }
        }
Exemple #2
0
        private void ProcessNormalPhase(Card _playedCard, Dictionary <CardDirection, Card> _adjacentCardsByDirection, ref Dictionary <GamePhase, ResultPhaseData> _turnResultByPhase)
        {
            List <CardOnBoardWon> cardWonList = CardFight(_playedCard, _adjacentCardsByDirection);

            if (cardWonList.Count > 0)
            {
                ResultPhaseData normalResultPhaseData = new ResultPhaseData();
                normalResultPhaseData.cardWonList    = cardWonList;
                _turnResultByPhase[GamePhase.Normal] = normalResultPhaseData;
            }
        }
Exemple #3
0
        private void ProcessSamePhase(Card _playedCard, Dictionary <CardDirection, Card> _adjacentCardsByDirection, ref Dictionary <GamePhase, ResultPhaseData> _turnResultByPhase)
        {
            List <CardOnBoardWon> cardWonList = new List <CardOnBoardWon>();

            foreach (KeyValuePair <CardDirection, Card> opponentCardItem in _adjacentCardsByDirection)
            {
                CardDirection oppositeDirection = GetOppositeDirection(opponentCardItem.Key);

                bool isSamePower = (_playedCard.GetPowerByDirection(opponentCardItem.Key) == opponentCardItem.Value.GetPowerByDirection(oppositeDirection));
                bool isRealCard  = (opponentCardItem.Value.BoardPosition.HasValue);
                if (isSamePower && isRealCard)
                {
                    cardWonList.Add(new CardOnBoardWon(opponentCardItem.Value, oppositeDirection));
                }
            }

            bool allCardsAreOwnedByCurrentPlayer = true;

            foreach (CardOnBoardWon cardItem in cardWonList)
            {
                if (cardItem.card.PlayerOwner != _playedCard.PlayerOwner)
                {
                    allCardsAreOwnedByCurrentPlayer = false;
                }
            }

            if (cardWonList.Count > 1 && !allCardsAreOwnedByCurrentPlayer)
            {
                ResultPhaseData sameResultPhaseData = new ResultPhaseData();
                foreach (CardOnBoardWon cardItem in cardWonList)
                {
                    cardItem.card.PlayerOwner = _playedCard.PlayerOwner;
                }
                sameResultPhaseData.cardWonList = cardWonList;

                ProcessComboPhase(cardWonList, ref sameResultPhaseData.comboCardList);

                _turnResultByPhase[GamePhase.Same] = sameResultPhaseData;
            }
        }