private List <CardVo> DeletePlayerCardsIfNoPossibleMoves(Turn targetTurn) { List <CardVo> currentPlayerDeck = targetTurn == Turn.PLAYER ? _playerDeck : _opponentDeck; var possibleMovesCound = 0; foreach (CardVo playerCard in currentPlayerDeck) { var possibleMoves = FindPossibleMoves(playerCard); possibleMovesCound += possibleMoves.Count; } if (possibleMovesCound == 0) { Dictionary <GameConfig.MatchType, List <CardVo> > matchedCardsByMatchType = new Dictionary <GameConfig.MatchType, List <CardVo> >(); matchedCardsByMatchType.Add(GameConfig.MatchType.BY_RANK, CloneList(currentPlayerDeck)); MatchedPlayerCards.Invoke(matchedCardsByMatchType, targetTurn); return(currentPlayerDeck); } else { return(new List <CardVo>());; } }
private List <CardVo> CheckForPlayerMatchingCards(Turn targetTurn) { Debug.Log("CheckForPlayerMatchingCards target player " + targetTurn); List <CardVo> currentPlayerDeck = targetTurn == Turn.PLAYER ? _playerDeck : _opponentDeck; List <CardVo> cardsToRemove = new List <CardVo>(); List <CardVo> matchedCards = new List <CardVo>(); List <CardVo> allMatchedCards = new List <CardVo>(); Dictionary <GameConfig.MatchType, List <CardVo> > matchedCardsByMatchType = new Dictionary <GameConfig.MatchType, List <CardVo> >(); matchedCards = MatchCardsByRank(currentPlayerDeck); if (matchedCards.Count >= GameConfig.CARDS_AMOUNT_TO_MATCH) { Debug.Log("Cards matched by rank amount: " + matchedCards.Count); allMatchedCards.AddRange(matchedCards); matchedCardsByMatchType.Add(GameConfig.MatchType.BY_RANK, CloneList(matchedCards)); } matchedCards = MatchCardsByColor(currentPlayerDeck); if (matchedCards.Count >= GameConfig.CARDS_AMOUNT_TO_MATCH) { Debug.Log("Cards matched by color amount: " + matchedCards.Count); allMatchedCards.AddRange(matchedCards); matchedCardsByMatchType.Add(GameConfig.MatchType.BY_COLOR, CloneList(matchedCards)); } matchedCards = MatchCardsBySuit(currentPlayerDeck); if (matchedCards.Count >= GameConfig.CARDS_AMOUNT_TO_MATCH) { Debug.Log("Cards matched by suit amount: " + matchedCards.Count); allMatchedCards.AddRange(matchedCards); matchedCardsByMatchType.Add(GameConfig.MatchType.BY_SUIT, CloneList(matchedCards)); } for (int i = 0; i < allMatchedCards.Count; i++) { var index = cardsToRemove.IndexOf(allMatchedCards[i]); if (index == -1) { cardsToRemove.Add(allMatchedCards[i]); } } if (matchedCardsByMatchType.Count > 0) { Debug.Log("dispatch matched cards "); MatchedPlayerCards.Invoke(matchedCardsByMatchType, targetTurn); } return(cardsToRemove); }