예제 #1
0
        public void BadCardCodes()
        {
            List <CardCodeAndCount> deck = new List <CardCodeAndCount>();

            deck.Add(new CardCodeAndCount()
            {
                CardCode = "01DE02", Count = 1
            });

            try
            {
                string code = LoRDeckEncoder.GetCodeFromDeck(deck);
                Assert.Fail();
            }
            catch (ArgumentException)
            {
            }
            catch
            {
                Assert.Fail();
            }

            deck = new List <CardCodeAndCount>();
            deck.Add(new CardCodeAndCount()
            {
                CardCode = "01XX002", Count = 1
            });

            try
            {
                string code = LoRDeckEncoder.GetCodeFromDeck(deck);
                Assert.Fail();
            }
            catch (ArgumentException)
            {
            }
            catch
            {
                Assert.Fail();
            }

            deck = new List <CardCodeAndCount>();
            deck.Add(new CardCodeAndCount()
            {
                CardCode = "01DE002", Count = 0
            });

            try
            {
                string code = LoRDeckEncoder.GetCodeFromDeck(deck);
                Assert.Fail();
            }
            catch (ArgumentException)
            {
            }
            catch
            {
                Assert.Fail();
            }
        }
예제 #2
0
        // METHODS


        public override List <CardCodeAndCount> GetActiveDeck()
        {
            List <CardCodeAndCount> deck = new List <CardCodeAndCount>();

            if (!_isActive)
            {
                return(deck);
            }

            try
            {
                _client ??= new HttpClient();

                Task <HttpResponseMessage> resp = _client.GetAsync("http://127.0.0.1:21337/static-decklist");
                if (resp.Result.IsSuccessStatusCode)
                {
                    string       respBody     = resp.Result.Content.ReadAsStringAsync().Result;
                    DeckResponse deckResponse = JsonConvert.DeserializeObject <DeckResponse>(respBody);
                    if (deckResponse != null && deckResponse.DeckCode != string.Empty)
                    {
                        deck = LoRDeckEncoder.GetDeckFromCode(deckResponse.DeckCode);
                    }
                }
            }
            catch (AggregateException)
            {
                //TODO: do something about that lol.
            }
            catch (ArgumentException)
            {
                //TODO: do something about that lol.
            }

            return(deck);
        }
예제 #3
0
        private void LoadLor(string line)
        {
            if (string.IsNullOrEmpty(line))
            {
                return;
            }
            if (line.StartsWith("#"))
            {
                if (line.StartsWith("###"))
                {
                    Name = line.Substring(3).Trim();
                }
                return;
            }

            List <CardCodeAndCount> cardCodeAndCounts = LoRDeckEncoder.GetDeckFromCode(line);

            foreach (CardCodeAndCount cardCount in cardCodeAndCounts)
            {
                if (!((UnityCardGame)SourceGame).Cards.TryGetValue(cardCount.CardCode, out UnityCard card))
                {
                    continue;
                }
                for (var i = 0; i < cardCount.Count; i++)
                {
                    _cards.Add(card);
                }
            }
        }
예제 #4
0
        public void BadCardCodes()
        {
            var decks = new[]
            {
                new List <CardCodeAndCount>
                {
                    new CardCodeAndCount {
                        CardCode = "01DE02", Count = 1
                    }
                },
                new List <CardCodeAndCount>
                {
                    new CardCodeAndCount {
                        CardCode = "01XX002", Count = 1
                    }
                },
                new List <CardCodeAndCount>
                {
                    new CardCodeAndCount {
                        CardCode = "01DE002", Count = 0
                    }
                }
            };

            foreach (var deck in decks)
            {
                Assert.ThrowsException <ArgumentException>(() => LoRDeckEncoder.GetCodeFromDeck(deck));
            }
        }
예제 #5
0
        public void MtTargonSet()
        {
            List <CardCodeAndCount> deck = new List <CardCodeAndCount>();

            deck.Add(new CardCodeAndCount()
            {
                CardCode = "01DE002", Count = 4
            });
            deck.Add(new CardCodeAndCount()
            {
                CardCode = "03MT003", Count = 2
            });
            deck.Add(new CardCodeAndCount()
            {
                CardCode = "03MT010", Count = 3
            });
            deck.Add(new CardCodeAndCount()
            {
                CardCode = "02BW004", Count = 5
            });

            string code = LoRDeckEncoder.GetCodeFromDeck(deck);
            List <CardCodeAndCount> decoded = LoRDeckEncoder.GetDeckFromCode(code);

            Assert.True(VerifyRehydration(deck, decoded));
        }
        private string GetDeckCode()
        {
            if (this.expeditionsState != null &&
                this.expeditionsState.Deck?.Any() == true)
            {
                var cards = new List <CardCodeAndCount>();
                foreach (var cardCode in this.expeditionsState.Deck)
                {
                    var card = cards.Find(c => c.CardCode == cardCode);
                    if (card == null)
                    {
                        cards.Add(new CardCodeAndCount {
                            CardCode = cardCode, Count = 1
                        });
                    }
                    else
                    {
                        card.Count++;
                    }
                }

                cards.Sort(new CardComparer());

                var deckCode = LoRDeckEncoder.GetCodeFromDeck(cards);

                this.logger.Debug($"Retrieved active expedition deck code: {deckCode}");

                cards.Print(this.logger);

                return(deckCode);
            }

            return(null);
        }
예제 #7
0
        public static IEnumerable <CardData> GetCardsFromCode(this string deckCode, ILogger logger = null)
        {
            logger ??= new FileLogger();

            var cards = new List <CardData>();

            // Gather all card data to map to current deck.
            try
            {
                var allCardData = new List <CardData>();

                var cardDataFilePaths = Directory.GetFiles(@$ "{Directory.GetCurrentDirectory()}\wwwroot\assets", "set*-en_us.json", SearchOption.AllDirectories);
                foreach (var cardDataFilePath in cardDataFilePaths)
                {
                    var cardData = JsonConvert.DeserializeObject <IEnumerable <CardData> >(File.ReadAllText(cardDataFilePath));

                    allCardData.AddRange(cardData);
                }

                var cardCodeAndCounts = LoRDeckEncoder.GetDeckFromCode(deckCode);
                foreach (var cardCodeAndCount in cardCodeAndCounts)
                {
                    int.TryParse(cardCodeAndCount.CardCode.Substring(0, 2), out int cardSet);

                    var card = allCardData.FirstOrDefault(c => c.CardCode == cardCodeAndCount.CardCode);
                    if (card != null)
                    {
                        cards.Add(new CardData
                        {
                            CardCode           = cardCodeAndCount.CardCode,
                            Count              = cardCodeAndCount.Count,
                            Name               = card.Name,
                            Description        = card.Description,
                            LevelupDescription = card.LevelupDescription,
                            Region             = card.Region,
                            RegionRef          = card.RegionRef,
                            Cost               = card.Cost,
                            Attack             = card.Attack,
                            Health             = card.Health,
                            Type               = card.Type,
                            FlavorText         = card.FlavorText,
                            Keywords           = card.Keywords,
                            SpellSpeed         = card.SpellSpeed,
                            Subtype            = card.Subtype,
                            Subtypes           = card.Subtypes,
                            Supertype          = card.Supertype,
                            Rarity             = card.Rarity,
                            Collectible        = card.Collectible
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error($"Error occurred getting card data from assets: {ex.Message}");
            }

            return(cards.OrderBy(c => c.Cost));
        }
예제 #8
0
        public void GarbageDecoding()
        {
            var badEncodingNotBase32 = "I'm no card code!";
            var badEncoding32        = "ABCDEFG";
            var badEncodingEmpty     = "";

            Assert.ThrowsException <ArgumentException>(() => LoRDeckEncoder.GetDeckFromCode(badEncodingNotBase32));
            Assert.ThrowsException <ArgumentException>(() => LoRDeckEncoder.GetDeckFromCode(badEncoding32));
            Assert.ThrowsException <ArgumentException>(() => LoRDeckEncoder.GetDeckFromCode(badEncodingEmpty));
        }
        public static string GetCodeFromDeck(List <CardCodeAndCount> cardCodeAndCounts)
        {
            bool isValid = LoRDeckEncoder.ValidCardCodesAndCounts(cardCodeAndCounts);

            if (!isValid)
            {
                return("");
            }

            return(LoRDeckEncoder.GetCodeFromDeck(cardCodeAndCounts));
        }
예제 #10
0
        public string ToLor()
        {
            var cardCounts        = GetCardCounts();
            var cardCodeAndCounts = cardCounts.Select(
                cardCount => new CardCodeAndCount()
            {
                CardCode = cardCount.Key.Id, Count = cardCount.Value
            }).ToList();

            return(LoRDeckEncoder.GetCodeFromDeck(cardCodeAndCounts) + Environment.NewLine);
        }
예제 #11
0
        public void SmallDeck()
        {
            var deck = new List <CardCodeAndCount>
            {
                new CardCodeAndCount {
                    CardCode = "01DE002", Count = 1
                }
            };

            string code    = LoRDeckEncoder.GetCodeFromDeck(deck);
            var    decoded = LoRDeckEncoder.GetDeckFromCode(code);

            Assert.IsTrue(VerifyRehydration(deck, decoded));
        }
예제 #12
0
        public void SmallDeck()
        {
            List <CardCodeAndCount> deck = new List <CardCodeAndCount>();

            deck.Add(new CardCodeAndCount()
            {
                CardCode = "01DE002", Count = 1
            });

            string code = LoRDeckEncoder.GetCodeFromDeck(deck);
            List <CardCodeAndCount> decoded = LoRDeckEncoder.GetDeckFromCode(code);

            Assert.True(VerifyRehydration(deck, decoded));
        }
예제 #13
0
        public void GarbageDecoding()
        {
            string badEncodingNotBase32 = "I'm no card code!";
            string badEncoding32        = "ABCDEFG";
            string badEncodingEmpty     = "";

            bool failed = false;

            try
            {
                List <CardCodeAndCount> deck = LoRDeckEncoder.GetDeckFromCode(badEncodingNotBase32);
            }
            catch (ArgumentException)
            {
                failed = true;
            }
            catch (Exception e)
            {
                Assert.True(false, $"Expected to throw an ArgumentException, but it threw {e}.");
            }
            Assert.True(failed, "Expected to throw an ArgumentException, but it succeeded.");

            failed = false;
            try
            {
                List <CardCodeAndCount> deck = LoRDeckEncoder.GetDeckFromCode(badEncoding32);
            }
            catch (ArgumentException)
            {
                failed = true;
            }
            catch (Exception e)
            {
                Assert.True(false, $"Expected to throw an ArgumentException, but it threw {e}.");
            }
            Assert.True(failed, "Expected to throw an ArgumentException, but it succeeded.");

            failed = false;
            try
            {
                List <CardCodeAndCount> deck = LoRDeckEncoder.GetDeckFromCode(badEncodingEmpty);
            }
            catch
            {
                failed = true;
            }
            Assert.True(failed, "Expected to throw an ArgumentException, but it succeeded.");
        }
예제 #14
0
        private static void TryDecodeCollection()
        {
            List <CardCodeAndCount> cards = LoRDeckEncoder.GetDeckFromCode(
                "CEKQCAYDCIBAGBQGBYBAGBARCIBAGAAGBQEQGAQBAIBQQCIKBMIRECQCAIAQEAYEAUDAOCAJBIFAEBABAIBQIBIGA4EASCQKAIA" +
                "ACAQDAQCQMBYIBEFAUAQFAEBAGBAFAYDQQCIKBIBACAICAMCAKBQHBAEQUCQDAUBAGBAFAYDQUDANBYFAEAYBAIBQIBIGA4EASC" +
                "QKAMAQEBAFAYDQQCQLCEJDAAYJAMDAODAOB4IBCEYUCULRUGY4DUQSGJBGE4USYLZQGM3DQOR6H5DUQSKLJRIVEVCVKZLVQWK4L" +
                "ZQGENABAEAQGBAFAYDQQCIKBMGA2DQQCEJBGFAVCYLRQGI2DMOR4IBBEIRSIJJGE4UCSKRLFUXC6MBRGIZTINJWG44DSNIBAAAQ" +
                "EAYEAYDQSCQLBQGQ4DYRCIJRIFIWC4MBSGQ3DQOR4HZAEERCGJBFEYTSQKJKFMWC2LRPGAYTEMZUGU3DOOBVAECACAQDAQCQMBY" +
                "IBEFAYDIOCAIREEYUCULRQGI2DMOB2HQ7EERCGJBGE4UCUKZMFUXC6MBRGIZTINJWG44DSOR3GUAQEAICAMCAKBQHBAEQUCYMBU" +
                "HA6EARCIJRIFIWC4MBUGY4DUPB6IBBEQSSMJZIFEVCWLBNFYXTAMJSGQ2TMNZYHE2QCAYCAMCAKBQHBAEQUCYMBUHA6EARCMKBK" +
                "FQXDAMRUGY5DYPSAIJCEMSCKJRHFAUSUKZMFUXC6MBRGIZTINJWG44DKAIFAEBQIBIGA4EQUCYMBYHRAEQTCQKRMFYZDINRYHI6" +
                "D4QCCIRDEQSSMJZIFEVCWLBNFYXTAMJSGM2DKNRXHA4TUPQCAYAQEAYEAUDAOCAJBIFQYDIOB4IBCEQTCQKRMFYYDENBWHA5DYP" +
                "SAIJCEMSCKJRHFAUSUKZMFUXC6MBRGIZTKNRXHA4TUOZ4HU7D6AQBAMBBGAYDBEBBSPACAEBQGEIBAEAR6");

            cards.ForEach(c => Console.WriteLine($"{c.CardCode}: {c.Count}"));
        }
예제 #15
0
        public void OrderShouldNotMatter2()
        {
            //importantly this order test includes more than 1 card with counts >3, which are sorted by card code and appending to the <=3 encodings.
            List <CardCodeAndCount> deck1 = new List <CardCodeAndCount>();

            deck1.Add(new CardCodeAndCount()
            {
                CardCode = "01DE002", Count = 4
            });
            deck1.Add(new CardCodeAndCount()
            {
                CardCode = "01DE003", Count = 2
            });
            deck1.Add(new CardCodeAndCount()
            {
                CardCode = "02DE003", Count = 3
            });
            deck1.Add(new CardCodeAndCount()
            {
                CardCode = "01DE004", Count = 5
            });

            List <CardCodeAndCount> deck2 = new List <CardCodeAndCount>();

            deck2.Add(new CardCodeAndCount()
            {
                CardCode = "01DE004", Count = 5
            });
            deck2.Add(new CardCodeAndCount()
            {
                CardCode = "01DE003", Count = 2
            });
            deck2.Add(new CardCodeAndCount()
            {
                CardCode = "02DE003", Count = 3
            });
            deck2.Add(new CardCodeAndCount()
            {
                CardCode = "01DE002", Count = 4
            });

            string code1 = LoRDeckEncoder.GetCodeFromDeck(deck1);
            string code2 = LoRDeckEncoder.GetCodeFromDeck(deck2);

            Assert.Equal(code1, code2);
        }
예제 #16
0
        public void BadVersion()
        {
            // make sure that a deck with an invalid version fails

            List <CardCodeAndCount> deck = new List <CardCodeAndCount>();

            deck.Add(new CardCodeAndCount()
            {
                CardCode = "01DE002", Count = 4
            });
            deck.Add(new CardCodeAndCount()
            {
                CardCode = "01DE003", Count = 2
            });
            deck.Add(new CardCodeAndCount()
            {
                CardCode = "02DE003", Count = 3
            });
            deck.Add(new CardCodeAndCount()
            {
                CardCode = "01DE004", Count = 5
            });

            List <byte> bytesFromDeck = Base32.Decode(LoRDeckEncoder.GetCodeFromDeck(deck)).ToList();

            List <byte> result = new List <byte>();

            byte[] formatAndVersion = new byte[] { 88 }; // arbitrary invalid format/version
            result.AddRange(formatAndVersion);

            bytesFromDeck.RemoveAt(0);    // remove the actual format/version
            result.Concat(bytesFromDeck); // replace with invalid one

            try
            {
                string badVersionDeckCode       = Base32.Encode(result.ToArray());
                List <CardCodeAndCount> deckBad = LoRDeckEncoder.GetDeckFromCode(badVersionDeckCode);
            }
            catch (ArgumentException e)
            {
                string expectedErrorMessage = "The provided code requires a higher version of this library; please update.";
                Console.WriteLine(e.Message);
                Assert.Equal(expectedErrorMessage, e.Message);
            }
        }
예제 #17
0
        public void BadCount()
        {
            List <CardCodeAndCount> deck = new List <CardCodeAndCount>();

            deck.Add(new CardCodeAndCount()
            {
                CardCode = "01DE002", Count = 0
            });
            bool failed = false;

            try
            {
                string code = LoRDeckEncoder.GetCodeFromDeck(deck);
            }
            catch (ArgumentException)
            {
                failed = true;
            }
            catch (Exception e)
            {
                Assert.True(false, $"Expected to throw an ArgumentException, but it threw {e}.");
            }
            Assert.True(failed, "Expected to throw an ArgumentException, but it succeeded.");

            failed = false;
            deck   = new List <CardCodeAndCount>();
            deck.Add(new CardCodeAndCount()
            {
                CardCode = "01DE002", Count = -1
            });
            try
            {
                string code = LoRDeckEncoder.GetCodeFromDeck(deck);
            }
            catch (ArgumentException)
            {
                failed = true;
            }
            catch (Exception e)
            {
                Assert.True(false, $"Expected to throw an ArgumentException, but it threw {e}.");
            }
            Assert.True(failed, "Expected to throw an ArgumentException, but it succeeded.");
        }
예제 #18
0
        public static bool GetDeckFromCode(out List <CardCodeAndCount> deck, string deckCode)
        {
            deck = new List <CardCodeAndCount>();

            try
            {
                deck = LoRDeckEncoder.GetDeckFromCode(deckCode);
            }
            catch (ArgumentException)
            {
                return(false);
            }
            catch
            {
                return(false);
            }

            return(true);
        }
예제 #19
0
        public void GarbageDecoding()
        {
            string badEncodingNotBase32 = "I'm no card code!";
            string badEncoding32        = "ABCDEFG";
            string badEncodingEmpty     = "";

            try
            {
                List <CardCodeAndCount> deck = LoRDeckEncoder.GetDeckFromCode(badEncodingNotBase32);
                Assert.Fail();
            }
            catch (ArgumentException)
            {
            }
            catch
            {
                Assert.Fail();
            }

            try
            {
                List <CardCodeAndCount> deck = LoRDeckEncoder.GetDeckFromCode(badEncoding32);
                Assert.Fail();
            }
            catch (ArgumentException)
            {
            }
            catch
            {
                Assert.Fail();
            }

            try
            {
                List <CardCodeAndCount> deck = LoRDeckEncoder.GetDeckFromCode(badEncodingEmpty);
                Assert.Fail();
            }
            catch
            {
            }
        }
예제 #20
0
        public void DeckVersionIsTheMinimumLibraryVersionThatSupportsTheContainedFactions(string faction, int expectedVersion)
        {
            List <CardCodeAndCount> deck = new List <CardCodeAndCount>();

            deck.Add(new CardCodeAndCount()
            {
                CardCode = "01DE001", Count = 1
            });
            deck.Add(new CardCodeAndCount()
            {
                CardCode = $"01{faction}002", Count = 1
            });
            deck.Add(new CardCodeAndCount()
            {
                CardCode = "01FR001", Count = 1
            });
            string deckCode = LoRDeckEncoder.GetCodeFromDeck(deck);

            int minSupportedLibraryVersion = ExtractVersionFromDeckCode(deckCode);

            Assert.Equal(expectedVersion, minSupportedLibraryVersion);
        }
예제 #21
0
        public void EncodeDecodeRecommendedDecks()
        {
            List <string> codes = new List <string>();
            List <List <CardCodeAndCount> > decks = new List <List <CardCodeAndCount> >();

            //Load the test data from file.
            string line;

            using (StreamReader myReader = new StreamReader(GetTestDataFilePath()))
            {
                while ((line = myReader.ReadLine()) != null)
                {
                    codes.Add(line);
                    List <CardCodeAndCount> newDeck = new List <CardCodeAndCount>();
                    while (!string.IsNullOrEmpty(line = myReader.ReadLine()))
                    {
                        string[] parts = line.Split(new char[] { ':' });
                        newDeck.Add(new CardCodeAndCount()
                        {
                            Count = int.Parse(parts[0]), CardCode = parts[1]
                        });
                    }
                    decks.Add(newDeck);
                }
            }

            //Encode each test deck and ensure it's equal to the correct string.
            //Then decode and ensure the deck is unchanged.
            for (int i = 0; i < decks.Count; i++)
            {
                string encoded = LoRDeckEncoder.GetCodeFromDeck(decks[i]);
                Assert.Equal(codes[i], encoded);

                List <CardCodeAndCount> decoded = LoRDeckEncoder.GetDeckFromCode(encoded);
                Assert.True(VerifyRehydration(decks[i], decoded));
            }
        }
예제 #22
0
        public void OrderShouldNotMatter1()
        {
            var deck1 = new List <CardCodeAndCount>
            {
                new CardCodeAndCount {
                    CardCode = "01DE002", Count = 1
                },
                new CardCodeAndCount {
                    CardCode = "01DE003", Count = 2
                },
                new CardCodeAndCount {
                    CardCode = "02DE003", Count = 3
                }
            };

            var deck2 = new List <CardCodeAndCount>
            {
                new CardCodeAndCount {
                    CardCode = "01DE003", Count = 2
                },
                new CardCodeAndCount {
                    CardCode = "02DE003", Count = 3
                },
                new CardCodeAndCount {
                    CardCode = "01DE002", Count = 1
                }
            };

            string code1 = LoRDeckEncoder.GetCodeFromDeck(deck1);
            string code2 = LoRDeckEncoder.GetCodeFromDeck(deck2);

            Assert.AreEqual(code1, code2);

            var deck3 = new List <CardCodeAndCount>
            {
                new CardCodeAndCount {
                    CardCode = "01DE002", Count = 4
                },
                new CardCodeAndCount {
                    CardCode = "01DE003", Count = 2
                },
                new CardCodeAndCount {
                    CardCode = "02DE003", Count = 3
                }
            };

            var deck4 = new List <CardCodeAndCount>
            {
                new CardCodeAndCount {
                    CardCode = "01DE003", Count = 2
                },
                new CardCodeAndCount {
                    CardCode = "02DE003", Count = 3
                },
                new CardCodeAndCount {
                    CardCode = "01DE002", Count = 4
                }
            };

            string code3 = LoRDeckEncoder.GetCodeFromDeck(deck1);
            string code4 = LoRDeckEncoder.GetCodeFromDeck(deck2);

            Assert.AreEqual(code3, code4);
        }
예제 #23
0
        public void OrderShouldNotMatter1()
        {
            List <CardCodeAndCount> deck1 = new List <CardCodeAndCount>();

            deck1.Add(new CardCodeAndCount()
            {
                CardCode = "01DE002", Count = 1
            });
            deck1.Add(new CardCodeAndCount()
            {
                CardCode = "01DE003", Count = 2
            });
            deck1.Add(new CardCodeAndCount()
            {
                CardCode = "02DE003", Count = 3
            });

            List <CardCodeAndCount> deck2 = new List <CardCodeAndCount>();

            deck2.Add(new CardCodeAndCount()
            {
                CardCode = "01DE003", Count = 2
            });
            deck2.Add(new CardCodeAndCount()
            {
                CardCode = "02DE003", Count = 3
            });
            deck2.Add(new CardCodeAndCount()
            {
                CardCode = "01DE002", Count = 1
            });

            string code1 = LoRDeckEncoder.GetCodeFromDeck(deck1);
            string code2 = LoRDeckEncoder.GetCodeFromDeck(deck2);

            Assert.Equal(code1, code2);

            List <CardCodeAndCount> deck3 = new List <CardCodeAndCount>();

            deck3.Add(new CardCodeAndCount()
            {
                CardCode = "01DE002", Count = 4
            });
            deck3.Add(new CardCodeAndCount()
            {
                CardCode = "01DE003", Count = 2
            });
            deck3.Add(new CardCodeAndCount()
            {
                CardCode = "02DE003", Count = 3
            });

            List <CardCodeAndCount> deck4 = new List <CardCodeAndCount>();

            deck4.Add(new CardCodeAndCount()
            {
                CardCode = "01DE003", Count = 2
            });
            deck4.Add(new CardCodeAndCount()
            {
                CardCode = "02DE003", Count = 3
            });
            deck4.Add(new CardCodeAndCount()
            {
                CardCode = "01DE002", Count = 4
            });

            string code3 = LoRDeckEncoder.GetCodeFromDeck(deck1);
            string code4 = LoRDeckEncoder.GetCodeFromDeck(deck2);

            Assert.Equal(code3, code4);
        }
예제 #24
0
        public void WorstCaseLength()
        {
            List <CardCodeAndCount> deck = new List <CardCodeAndCount>();

            deck.Add(new CardCodeAndCount()
            {
                CardCode = "01DE002", Count = 4
            });
            deck.Add(new CardCodeAndCount()
            {
                CardCode = "01DE003", Count = 4
            });
            deck.Add(new CardCodeAndCount()
            {
                CardCode = "01DE004", Count = 4
            });
            deck.Add(new CardCodeAndCount()
            {
                CardCode = "01DE005", Count = 4
            });
            deck.Add(new CardCodeAndCount()
            {
                CardCode = "01DE006", Count = 4
            });
            deck.Add(new CardCodeAndCount()
            {
                CardCode = "01DE007", Count = 5
            });
            deck.Add(new CardCodeAndCount()
            {
                CardCode = "01DE008", Count = 6
            });
            deck.Add(new CardCodeAndCount()
            {
                CardCode = "01DE009", Count = 7
            });
            deck.Add(new CardCodeAndCount()
            {
                CardCode = "01DE010", Count = 8
            });
            deck.Add(new CardCodeAndCount()
            {
                CardCode = "01DE011", Count = 9
            });
            deck.Add(new CardCodeAndCount()
            {
                CardCode = "01DE012", Count = 4
            });
            deck.Add(new CardCodeAndCount()
            {
                CardCode = "01DE013", Count = 4
            });
            deck.Add(new CardCodeAndCount()
            {
                CardCode = "01DE014", Count = 4
            });
            deck.Add(new CardCodeAndCount()
            {
                CardCode = "01DE015", Count = 4
            });
            deck.Add(new CardCodeAndCount()
            {
                CardCode = "01DE016", Count = 4
            });
            deck.Add(new CardCodeAndCount()
            {
                CardCode = "01DE017", Count = 4
            });
            deck.Add(new CardCodeAndCount()
            {
                CardCode = "01DE018", Count = 4
            });
            deck.Add(new CardCodeAndCount()
            {
                CardCode = "01DE019", Count = 4
            });
            deck.Add(new CardCodeAndCount()
            {
                CardCode = "01DE020", Count = 4
            });
            deck.Add(new CardCodeAndCount()
            {
                CardCode = "01DE021", Count = 4
            });

            string code = LoRDeckEncoder.GetCodeFromDeck(deck);
            List <CardCodeAndCount> decoded = LoRDeckEncoder.GetDeckFromCode(code);

            Assert.True(VerifyRehydration(deck, decoded));
        }
예제 #25
0
        public void ArgumentExceptionOnFutureVersion()
        {
            const string singleCardDeckWithVersion5 = "CUAAAAIBAUAAC";

            Assert.Throws <ArgumentException>(() => LoRDeckEncoder.GetDeckFromCode(singleCardDeckWithVersion5));
        }
예제 #26
0
        public void LargeDeck()
        {
            var deck = new List <CardCodeAndCount>
            {
                new CardCodeAndCount {
                    CardCode = "01DE002", Count = 3
                },
                new CardCodeAndCount {
                    CardCode = "01DE003", Count = 3
                },
                new CardCodeAndCount {
                    CardCode = "01DE004", Count = 3
                },
                new CardCodeAndCount {
                    CardCode = "01DE005", Count = 3
                },
                new CardCodeAndCount {
                    CardCode = "01DE006", Count = 3
                },
                new CardCodeAndCount {
                    CardCode = "01DE007", Count = 3
                },
                new CardCodeAndCount {
                    CardCode = "01DE008", Count = 3
                },
                new CardCodeAndCount {
                    CardCode = "01DE009", Count = 3
                },
                new CardCodeAndCount {
                    CardCode = "01DE010", Count = 3
                },
                new CardCodeAndCount {
                    CardCode = "01DE011", Count = 3
                },
                new CardCodeAndCount {
                    CardCode = "01DE012", Count = 3
                },
                new CardCodeAndCount {
                    CardCode = "01DE013", Count = 3
                },
                new CardCodeAndCount {
                    CardCode = "01DE014", Count = 3
                },
                new CardCodeAndCount {
                    CardCode = "01DE015", Count = 3
                },
                new CardCodeAndCount {
                    CardCode = "01DE016", Count = 3
                },
                new CardCodeAndCount {
                    CardCode = "01DE017", Count = 3
                },
                new CardCodeAndCount {
                    CardCode = "01DE018", Count = 3
                },
                new CardCodeAndCount {
                    CardCode = "01DE019", Count = 3
                },
                new CardCodeAndCount {
                    CardCode = "01DE020", Count = 3
                },
                new CardCodeAndCount {
                    CardCode = "01DE021", Count = 3
                }
            };

            string code    = LoRDeckEncoder.GetCodeFromDeck(deck);
            var    decoded = LoRDeckEncoder.GetDeckFromCode(code);

            Assert.IsTrue(VerifyRehydration(deck, decoded));
        }