Exemple #1
0
        public void TestGettingCardUrl()
        {
            var cardRow = SetTestData.ExampleOneCardInner("Alchemy", "Herbalist");
            var name    = SetParser.GetCardUrl(cardRow);

            Assert.AreEqual("./?card=!herbalist", name);
        }
Exemple #2
0
 /// <summary>
 /// Asserts that a position set string is valid
 /// </summary>
 /// <param name="rangeText"></param>
 /// <exception cref="SetParseException">Thrown if input is invalid</exception>
 public static void ValidateAlgListInput(string rangeText, Dictionary <string, List <int> > nameMap, int max, List <CustomSubset> customSubsets = null)
 {
     if (customSubsets == null)
     {
         customSubsets = new List <CustomSubset>();
     }
     SetParser.Parse(rangeText, nameMap, customSubsets, max);
 }
Exemple #3
0
        public SetInfoScreen(AlgSet set, string rangeList, Dictionary <string, List <int> > nameMap, List <CustomSubset> customSubsets = null, string setName = null)
        {
            InitializeComponent();
            this.StartPosition = FormStartPosition.CenterScreen;
            CubeRows           = new List <CubeRowControl>();
            Set           = set;
            RangeBox.Text = rangeList;
            if (setName != null)
            {
                NameLabel.Text    = setName;
                NameLabel.Visible = true;
            }

            List <int> posNums = SetParser.Parse(rangeList, nameMap, customSubsets ?? new List <CustomSubset>(), Info.GetNumPositionsInSet(set));

            Cubes = posNums.ConvertAll(num =>
            {
                var cube = Info.GetCube(set);
                cube.SetUpPosition(num);
                return(cube);
            }).ToList();

            int          startX       = 40;
            int          startY       = 100;
            int          currY        = startY;
            List <ICube> currRowCubes = new List <ICube>();

            for (int k = 0; k < Cubes.Count; k++)
            {
                currRowCubes.Add(Cubes[k]);

                if (k % 6 == 5)
                {
                    CubeRows.Add(new CubeRowControl(currRowCubes)
                    {
                        Location = new Point(startX, currY)
                    });
                    currY += PixelsBetweenControls;
                    currRowCubes.Clear();
                }
                else if (k == Cubes.Count - 1)
                {
                    while (currRowCubes.Count < 6)
                    {
                        currRowCubes.Add(null);
                    }
                    CubeRows.Add(new CubeRowControl(currRowCubes)
                    {
                        Location = new Point(startX, currY)
                    });
                }
            }

            foreach (var control in CubeRows)
            {
                this.Controls.Add(control);
            }
        }
Exemple #4
0
        public void TestGettingCardRow()
        {
            var set = SetTestData.ExampleSetOneCard("Alchemy", "Herbalist");
            int next;
            var cardRow     = SetParser.GetCardRow(0, set, out next);
            var expectedRow = SetTestData.ExampleOneCardInner("Alchemy", "Herbalist");

            Assert.AreEqual(expectedRow, cardRow);
        }
Exemple #5
0
        public void TestParsingSet()
        {
            var html = SetTestData.ExampleSetMultipleCards("Alchemy");
            var set  = new Set {
                Name = "Alchemy"
            };

            SetParser.ParseSetHtml(set, html);

            Assert.AreEqual(4, set.Cards.Count);
        }
Exemple #6
0
        /// <summary>
        /// Gets a list of alg numbers from the given input text for the given alg set
        /// </summary>
        /// <param name="set">The current alg set</param>
        /// <param name="fromTextBox">The list of ranges or subsets entered by the user</param>
        /// <returns></returns>
        public List <int> GetListFromAlgSet(AlgSet set, string fromTextBox)
        {
            Dictionary <string, List <int> > subsets = XmlSubsetFile.GetNameMap(set);

            return(SetParser.Parse(fromTextBox, subsets, CustomSubsetFile.GetSubsets(Set), Info.GetNumPositionsInSet(set)));
        }
Exemple #7
0
        static void Main(string[] args)
        {
            var rootPath = @"C:\DEV\Private\Dominion\Cards";

            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("Downloading Dominion cards");
            Console.WriteLine("Target path to dump files: " + rootPath);
            Console.WriteLine("-----------------------------------------");
            Console.WriteLine();
            Console.Write("Performing setup and getting root card lists: ");

            var settings = new Settings();
            var parser   = new SetParser(settings, new HttpGetter(), new CardTypeMapper());

            var sets = new List <Set>();

            foreach (var name in settings.SetNames())
            {
                var set = parser.Parse(name);
                sets.Add(set);
                Console.Write("#");
            }
            Console.WriteLine(" complete.");
            Console.WriteLine();

            foreach (var set in sets)
            {
                Console.WriteLine("Downloading " + set.Name + ": ");

                var setNameSafe = set.Name.ToLower().Replace(" ", "").Trim();

                foreach (var card in set.Cards)
                {
                    Console.Write("#");

                    var cardNameSafe = card.Name.ToLower().Replace(" ", "").Trim();
                    var url          = settings.ImageUrl(card.ImageUrl);
                    card.LocalImageFileName = $@"\{setNameSafe}\{cardNameSafe}.jpg";
                    var cardFileName = rootPath + card.LocalImageFileName;
                    ImageGetter.Download(url, cardFileName);
                }

                var json = JsonConvert.SerializeObject(set);

                var path = rootPath + @"\" + setNameSafe;
                if (Directory.Exists(path) == false)
                {
                    Directory.CreateDirectory(path);
                }
                var filePath = path + "\\cards.dom";
                if (File.Exists(filePath))
                {
                    File.Delete(filePath);
                }
                File.AppendAllText(filePath, json);

                Console.WriteLine();
            }
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("Completed everything.");
            Console.ReadKey();
        }