public bool AddCard(EntityDef cardEntityDef, CardFlair cardFlair, DeckTrayDeckTileVisual deckTileToRemove, bool playSound, Actor animateFromActor = null) { if (!base.IsModeActive()) { return(false); } if (cardEntityDef == null) { UnityEngine.Debug.LogError("Trying to add card EntityDef that is null."); return(false); } string cardId = cardEntityDef.GetCardId(); CollectionDeck taggedDeck = CollectionManager.Get().GetTaggedDeck(this.m_deckType); if (taggedDeck == null) { return(false); } if (playSound) { SoundManager.Get().LoadAndPlay("collection_manager_place_card_in_deck", base.gameObject); } if (taggedDeck.GetTotalCardCount() == 30) { if (deckTileToRemove == null) { UnityEngine.Debug.LogWarning(string.Format("CollectionDeckTray.AddCard(): Cannot add card {0} (flair {1}) without removing one first.", cardEntityDef.GetCardId(), cardFlair)); return(false); } string cardID = deckTileToRemove.GetCardID(); CardFlair flair = deckTileToRemove.GetCardFlair(); if (!taggedDeck.RemoveCard(cardID, flair.Premium, deckTileToRemove.IsOwnedSlot())) { object[] args = new object[] { cardId, cardFlair, cardID, flair }; UnityEngine.Debug.LogWarning(string.Format("CollectionDeckTray.AddCard({0},{1}): Tried to remove card {2} with flair {3}, but it failed!", args)); return(false); } } if (!taggedDeck.AddCard(cardEntityDef, cardFlair.Premium)) { UnityEngine.Debug.LogWarning(string.Format("CollectionDeckTray.AddCard({0},{1}): deck.AddCard failed!", cardId, cardFlair)); return(false); } if (taggedDeck.GetTotalOwnedCardCount() == 30) { DeckHelper.Get().Hide(); } this.UpdateCardList(cardEntityDef, true, animateFromActor); CollectionManagerDisplay.Get().UpdateCurrentPageCardLocks(true); if ((!Options.Get().GetBool(Option.HAS_ADDED_CARDS_TO_DECK, false) && (taggedDeck.GetTotalCardCount() >= 2)) && (!DeckHelper.Get().IsActive() && (taggedDeck.GetTotalCardCount() < 15))) { NotificationManager.Get().CreateInnkeeperQuote(GameStrings.Get("VO_INNKEEPER_CM_PAGEFLIP_28"), "VO_INNKEEPER_CM_PAGEFLIP_28", 0f, null); Options.Get().SetBool(Option.HAS_ADDED_CARDS_TO_DECK, true); } return(true); }
public static CollectionDeckViolationDeckSize GetCollectionDeckViolationDeckOverflow(CollectionDeck deck) { int totalCardCount = deck.GetTotalCardCount(); int totalOwnedCardCount = deck.GetTotalOwnedCardCount(); CollectionDeckViolationDeckSize size = null; if (totalOwnedCardCount != 30) { size = new CollectionDeckViolationDeckSize { DeckID = deck.ID, ViolationType = CollectionDeckViolationType.DECK_UNDERFLOW, TotalCardCount = totalCardCount, TotalOwnedCardCount = totalOwnedCardCount }; } return(size); }