public bool ShouldSerializePlayerCards() => PlayerCards.Any();
public void ChooseCard(int i) { PlayingCard = PlayerCards[i]; PlayerCards.RemoveAt(i); }
//to add a card to the pleyer public void AddCardToPlayer(Card newCard) { PlayerCards.Add(newCard); }
public void AddCardtoPlayingDeck(Card card, string playerId) { GameObject playerObject = GetPlayerObject(playerId); List <CardObj> listOfPlayerCard = playerObject.GetComponent <PlayerCardList>().cardObjs; PlayerCards playerCard = cardManager.GetPlayerCardFromPlayerId(playerId); if (PhotonNetwork.LocalPlayer.NickName == playerId) { CardObj co = GetCardObj(listOfPlayerCard, card); co.gameObject.transform.SetSiblingIndex(0); listOfPlayerCard.Remove(co); AddCardToPlayingDeck(co); SpaceAllCards(); } else { CardObj co = listOfPlayerCard[listOfPlayerCard.Count - 1]; co.gameObject.transform.SetSiblingIndex(0); listOfPlayerCard.Remove(co); co.SetCardValue(card); co.SetCardFacedUp(); AddCardToPlayingDeck(co); } //Display Card Message //string actionMessage = DisplayCardMessage(card, playerCard.player); //if (actionMessage != "NULL") //{ // StartCoroutine(ShowNextPlayer(actionMessage)); //} string nextPlayerMessage = DisplayNextPlayerMessage(card, playerCard.player); StartCoroutine(ShowCardAction(nextPlayerMessage)); //END >>> if (cardManager.IsCardsPoolEmpty()) { // Calculate and return winner Debug.Log("Game Over Cards Finished"); } if (cardManager.IsPlayerCardRemainingOne(playerCard.player)) { // Show Last Card Warning Debug.Log("Last Card" + playerCard.player.NickName); } if (cardManager.IsPlayerCardFinish(playerCard.player)) { // return winner Debug.Log("Winner" + playerCard.player.NickName); } }
public void Refuse() { PlayerCards.RemoveAt(PlayerCards.Count - 1); }
/// <summary> /// Play a game of recursive combat. /// </summary> /// <param name="playerCards">The starting player cards.</param> /// <returns>The players' cards at the end of the game.</returns> private PlayerCards PlayRecursiveCombat(PlayerCards playerCards) { // We keep track of any previous games to avoid recursion. HashSet <PlayerCards> history = new HashSet <PlayerCards>() { (PlayerCards)playerCards.Clone() }; var player1Cards = playerCards.Player1Cards; var player2Cards = playerCards.Player2Cards; while (player1Cards.Count != 0 && player2Cards.Count != 0) { // Remove the top cards from each player's hand. var player1Value = player1Cards[0]; player1Cards.RemoveAt(0); var player2Value = player2Cards[0]; player2Cards.RemoveAt(0); int winner = 1; if (!history.Contains(playerCards)) { history.Add((PlayerCards)playerCards.Clone()); if (player1Cards.Count >= player1Value && player2Cards.Count >= player2Value) { // If both players have enough cards to play a sub-game recursively, // we do that. // We build a sub-deck containing copies of the cards from each hand // based on the number of the drawn card. var subDeck = new PlayerCards() { Player1Cards = player1Cards.GetRange(0, player1Value), Player2Cards = player2Cards.GetRange(0, player2Value), }; // Play recusive combat, and decide the winner of this round. PlayerCards result = PlayRecursiveCombat(subDeck); if (result.Player2Cards.Count != 0) { winner = 2; } } else { // Otherwise, the winner is the player with the higher card. if (player2Value > player1Value) { winner = 2; } } } // The winner gets the drawn cards. if (winner == 1) { player1Cards.Add(player1Value); player1Cards.Add(player2Value); } else { player2Cards.Add(player2Value); player2Cards.Add(player1Value); } } return(playerCards); }
private void DeleteCard(PlayerCardModel parameter) { PlayerCards.Remove(parameter); }
public void AddCardToHand(Card card) { PlayerCards.Add(card); }
// Clear List Card public void GiveBackCards() { PlayerCards.Clear(); }
public static string GetResult(PlayerCards player1, PlayerCards player2) { return(string.Empty); //todo }