Exemple #1
0
 public void SaveEverything()
 {
     if (SafeToSave())
     {
         mapsPersistence.SaveAllMaps(nameOfMapsToSave, dataOfMapsToSave);
         classesPersistence.SaveClasses(classesSerializableToSave);
         deckPersistence.Save(deckSerializableToSave);
         if (cardsCollectionToSave == null)
         {
             cardsCollectionToSave = new DeckSerializable(CardsCollection.GetCardsCollectionAmounts());
         }
         cardsCollectionPersistence.Save(cardsCollectionToSave);
         cardsLevelPersistence.Save(cardsLevelToSave);
     }
     else
     {
         string whatsnull = ("maps: " + dataOfMapsToSave + "mapName: " + nameOfMapsToSave + "classes: " + classesSerializableToSave
                             + "deck: " + deckSerializableToSave + " levels: " + cardsLevelToSave);
         L.ogWarning("SaveEverything was called, but at least one attribute is still null. " +
                     "This is ok if there is nothing to save.\n" + whatsnull, this);
     }
 }
Exemple #2
0
    private void PopulateAmountOfEachCard()
    {
        amountOfEachCard = new int[cards.Length];

        int[] cardAmounts = CardsCollection.GetCardsCollectionAmounts();

        Card[] currentDeck = PlayerAndEnemyDeckHolder.GetPreparedCardsForThePlayerWithTheRandomCards();

        // For each card on Deck, subtract 1 from it's amount in the collection.
        for (int i = 0; i < cards.Length; i++)
        {
            int amount = cardAmounts[i];
            for (int k = 0; k < currentDeck.Length; k++)
            {
                if (cards[i].IsAnotherInstanceOf(currentDeck[k]))
                {
                    amount--;
                }
            }

            amountOfEachCard[i] = amount;
        }
    }