Example #1
0
    //void CmdSubmitDeck(Dictionary<int, int> deckMaine, Dictionary<int, int> deckStrc )
    void CmdSubmitDeck(string deckStr)
    {
        Dictionary <int, int>[] deck = DeckRW.readDeck(deckStr);


        bool checkDeck(Dictionary <int, int> deckL, bool isMain)
        {
            int totalCount = 0;

            foreach (int card in deckL.Keys)
            {
                if (card < 0)
                {
                    return(false);
                }
                if ((isMain && card >= playableCards.main.Count) || (!isMain && card >= playableCards.structures.Count))
                {
                    return(false);
                }
                if (deckL[card] > GameConstants.maxCardDuplicateLimit)
                {
                    return(false);
                }
                totalCount += deckL[card];
            }
            if (totalCount != (isMain? GameConstants.mainDeckSize:GameConstants.structureDeckSize))
            {
                return(false);
            }
            return(true);
        }

        if (!checkDeck(deck[0], true) || !checkDeck(deck[1], false))
        {
            return;
        }



        loadedDeck            = ScriptableObject.CreateInstance <Deck>();
        loadedDeck.main       = deckLookup(deck[0], true);
        loadedDeck.structures = deckLookup(deck[1], false);
    }