Exemple #1
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 #2
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 #3
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 #4
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();
        }