示例#1
0
        private static void EncodeNOfs(List <byte> bytes, List <CardCodeAndCount> nOfs)
        {
            foreach (CardCodeAndCount ccc in nOfs)
            {
                bytes.AddRange(VarintTranslator.GetVarint(ccc.Count));

                ParseCardCode(ccc.CardCode, out int setNumber, out string factionCode, out int cardNumber);
                int factionNumber = FactionCodeToIntIdentifier[factionCode];

                bytes.AddRange(VarintTranslator.GetVarint(setNumber));
                bytes.AddRange(VarintTranslator.GetVarint(factionNumber));
                bytes.AddRange(VarintTranslator.GetVarint(cardNumber));
            }
        }
示例#2
0
        private static void EncodeGroupOf(List <byte> bytes, List <List <CardCodeAndCount> > groupOf)
        {
            bytes.AddRange(VarintTranslator.GetVarint(groupOf.Count));
            foreach (List <CardCodeAndCount> currentList in groupOf)
            {
                //how many cards in current group?
                bytes.AddRange(VarintTranslator.GetVarint(currentList.Count));

                //what is this group, as identified by a set and faction pair
                string currentCardCode = currentList[0].CardCode;
                ParseCardCode(currentCardCode, out int currentSetNumber, out string currentFactionCode, out int _);
                int currentFactionNumber = FactionCodeToIntIdentifier[currentFactionCode];
                bytes.AddRange(VarintTranslator.GetVarint(currentSetNumber));
                bytes.AddRange(VarintTranslator.GetVarint(currentFactionNumber));

                //what are the cards, as identified by the third section of card code only now, within this group?
                foreach (CardCodeAndCount cd in currentList)
                {
                    string code           = cd.CardCode;
                    int    sequenceNumber = int.Parse(code.Substring(4, 3));
                    bytes.AddRange(VarintTranslator.GetVarint(sequenceNumber));
                }
            }
        }