Esempio n. 1
0
    private void CleanCache()
    {
        int num = this.m_cardCache.Count - 60;

        if (num > 0)
        {
            CollectionDeck currentlyOpenDeck = null;
            if (CollectionManager.Get() != null)
            {
                currentlyOpenDeck = CollectionManager.Get().GetTaggedDeck(CollectionManager.DeckTag.Editing);
            }
            List <string> deckHelperCardChoices = (DeckHelper.Get() != null) ? DeckHelper.Get().GetCardIDChoices() : null;
            List <string> names = new List <string>();
            int           index = 0;
            while (index < this.m_cardCache.Count)
            {
                CardCacheItem item = this.m_cardCache[index];
                if (!this.CanClearItem(item, currentlyOpenDeck, deckHelperCardChoices))
                {
                    index++;
                }
                else
                {
                    names.Add(item.m_cardId);
                    this.m_cardCache.RemoveAt(index);
                    DefLoader.Get().ClearCardDef(item.m_cardId);
                    if (names.Count == num)
                    {
                        break;
                    }
                }
            }
            AssetCache.ClearCardPrefabs(names);
        }
    }
 public void ChooseThisCard()
 {
     KeywordHelpPanelManager.Get().HideKeywordHelp();
     this.m_chosen = true;
     this.m_actor.GetSpell(SpellType.DEATHREVERSE).ActivateState(SpellStateType.BIRTH);
     CollectionDeckTray.Get().AddCard(this.m_actor.GetEntityDef(), this.m_actor.GetCardFlair(), null, false, this.m_actor);
     DeckHelper.Get().UpdateChoices();
 }
    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);
    }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="goBackToMainMenu"></param>
 public CardGameScreen(Action goBackToMainMenu)
 {
     GoBackToMainMenu = goBackToMainMenu;
     DeckHelper       = new DeckHelper();
     DbContext        = new DbContext();
     // Get complete deck of cards
     DeckHelper.Get();
     Players = new List <CardPlayer <RestaurantReviewer> >();
     // Game places
     Places = new Hashtable
     {
         { 0, "1st" },
         { 1, "2nd" },
         { 2, "3rd" },
         { 3, "4th" }
     };
 }
        /// <summary>
        /// Print Game Results
        /// </summary>
        private void PrintResult()
        {
            DeckHelper.Get();
            Console.Clear();
            var scoreChecker = 0;
            // sort winners
            IEnumerable <CardPlayer <RestaurantReviewer> > sortedResults = Players.OrderByDescending(p => p.CardValueSummary());

            // print place + player's name + cards + score
            for (int i = 0; i < sortedResults.Count(); i++)
            {
                // get player
                var player = sortedResults.ElementAt(i);
                Console.Write($"{Places[i]} Place: Player {player.Id} - {player.GetPlayerName.PadRight(20, ' ')}");
                ConsoleColor resetForeground = Console.ForegroundColor;
                ConsoleColor resetBackground = Console.BackgroundColor;
                Console.BackgroundColor = ConsoleColor.White;
                // print given cards with format
                foreach (var card in player.Cards)
                {
                    Console.ForegroundColor = card.Color;
                    Console.Write(card);
                    Console.BackgroundColor = resetBackground;
                    Console.ForegroundColor = resetForeground;
                    Console.Write(" ");
                    Console.BackgroundColor = ConsoleColor.White;
                }

                Console.ForegroundColor = resetForeground;
                Console.BackgroundColor = resetBackground;
                // print score
                Console.WriteLine($" Score: {player.CardValueSummary().ToString().PadLeft(3, ' ')}");
                scoreChecker += player.CardValueSummary();
                Console.Write(Environment.NewLine);
            }
            Console.WriteLine($"Score Checker: {scoreChecker}");
        }