Esempio n. 1
0
        public static async Task <Artifact> CatalogueFromBitmapsAsync(List <Bitmap> bm, int id)
        {
            // Init Variables
            string gearSlot = null;
            string mainStat = null;

            int rarity = 0;

            int level = 0;

            List <SubStat> subStats = new List <SubStat>();

            string setName = null;

            string equippedCharacter = null;

            bool _lock = false;

            if (bm.Count >= 6)
            {
                int a_name = 0; int a_gearSlot = 1; int a_mainStat = 2; int a_level = 3; int a_subStats = 4; int a_equippedCharacter = 5; int a_lock = 6;
                // Get Rarity
                rarity = GetRarity(bm[a_name]);

                // Check for equipped color
                Color equippedColor  = Color.FromArgb(255, 255, 231, 187);
                Color equippedStatus = bm[a_equippedCharacter].GetPixel(5, 5);
                bool  b_equipped     = Scraper.CompareColors(equippedColor, equippedStatus);

                // Check for lock color
                Color lockedColor = Color.FromArgb(255, 70, 80, 100);                 // Dark area around red lock
                Color lockStatus  = bm[a_lock].GetPixel(5, 5);
                _lock = Scraper.CompareColors(lockedColor, lockStatus);

                // Improved Scanning using multi threading
                List <Task> tasks = new List <Task>();

                var taskGear  = Task.Run(() => gearSlot = ScanArtifactGearSlot(bm[a_gearSlot]));
                var taskMain  = taskGear.ContinueWith((antecedent) => mainStat = ScanArtifactMainStat(bm[a_mainStat], antecedent.Result));
                var taskLevel = Task.Run(() => level = ScanArtifactLevel(bm[a_level]));
                var taskSubs  = Task.Run(() => subStats = ScanArtifactSubStats(bm[a_subStats], ref setName));
                var taskEquip = Task.Run(() => equippedCharacter = ScanArtifactEquippedCharacter(bm[a_equippedCharacter]));

                tasks.Add(taskGear);
                tasks.Add(taskMain);
                tasks.Add(taskLevel);
                tasks.Add(taskSubs);
                if (b_equipped)
                {
                    tasks.Add(taskEquip);
                }

                await Task.WhenAll(tasks.ToArray());
            }

            return(new Artifact(setName, rarity, level, gearSlot, mainStat, subStats.ToArray(), subStats.Count, equippedCharacter, id, _lock));
        }
        public static async Task <Weapon> CatalogueFromBitmapsAsync(List <Bitmap> bm, int id)
        {
            // Init Variables
            string name              = null;
            int    level             = -1;
            bool   ascended          = false;
            int    refinementLevel   = -1;
            bool   locked            = false;
            string equippedCharacter = null;
            int    rarity            = 0;

            if (bm.Count >= 4)
            {
                int w_name = 0; int w_level = 1; int w_refinement = 2; int w_lock = 3; int w_equippedCharacter = 4;

                // Check for Rarity
                rarity = GetRarity(bm[w_name]);

                // Check for equipped color
                Color equippedColor  = Color.FromArgb(255, 255, 231, 187);
                Color equippedStatus = bm[w_equippedCharacter].GetPixel(5, 5);
                bool  b_equipped     = Scraper.CompareColors(equippedColor, equippedStatus);

                // Check for lock color
                Color lockedColor = Color.FromArgb(255, 70, 80, 100);                 // Dark area around red lock
                Color lockStatus  = bm[w_lock].GetPixel(5, 5);
                locked = Scraper.CompareColors(lockedColor, lockStatus);

                List <Task> tasks = new List <Task>();

                var taskName       = Task.Run(() => name = ScanName(bm[w_name]));
                var taskLevel      = Task.Run(() => level = ScanLevel(bm[w_level], ref ascended));
                var taskRefinement = Task.Run(() => refinementLevel = ScanRefinement(bm[w_refinement]));
                var taskEquipped   = Task.Run(() => equippedCharacter = ScanEquippedCharacter(bm[w_equippedCharacter]));

                tasks.Add(taskName);
                tasks.Add(taskLevel);
                tasks.Add(taskRefinement);

                if (b_equipped)
                {
                    tasks.Add(taskEquipped);
                }

                await Task.WhenAll(tasks.ToArray());
            }

            return(new Weapon(name, level, ascended, refinementLevel, locked, equippedCharacter, id, rarity));
        }
Esempio n. 3
0
        private static int GetRarity(Bitmap card, double scale = 1)
        {
            using (var scaled = Scraper.ScaleImage(card, scale))
            {
                int x = (int)(0.025 * scaled.Width);
                int y = (int)(0.20 * scaled.Height);

                Color rarityColor = card.GetPixel(x, y);

                Color fiveStar  = Color.FromArgb(255, 188, 105, 50);
                Color fourStar  = Color.FromArgb(255, 161, 86, 224);
                Color threeStar = Color.FromArgb(255, 81, 127, 203);
                Color twoStar   = Color.FromArgb(255, 42, 143, 114);
                Color oneStar   = Color.FromArgb(255, 114, 119, 138);

                if (Scraper.CompareColors(fiveStar, rarityColor))
                {
                    return(5);
                }
                else if (Scraper.CompareColors(fourStar, rarityColor))
                {
                    return(4);
                }
                else if (Scraper.CompareColors(threeStar, rarityColor))
                {
                    return(3);
                }
                else if (Scraper.CompareColors(twoStar, rarityColor))
                {
                    return(2);
                }
                else if (Scraper.CompareColors(oneStar, rarityColor))
                {
                    return(1);
                }
                else
                {
                    return(scale >= 2 ? 0 : GetRarity(card, scale + 0.2));
                }
            }
        }