// Handle all of the scene matching conditions

        // Pass in list of Rectmaps that have conditionals set
        // ie RectMap Scene Name Required Match and Passing Requiremetn, ie true or false.

        public static bool HandleConditions(List <ConditionMap> conditions, ScriptBase script)
        {
            var mainscript = script as Script;

            bool Passed = true;

            foreach (ConditionMap condition in conditions)
            {
                if (script.MatchTemplate(condition.RectMap, condition.Match) != condition.Required)
                {
                    Passed = false;
                    Bitmap image = script.CropFrame(Helper.RectmapToRectangle(condition.RectMap));
                    image.Save(condition.Name + "_" + condition.RectMap.Hash.ToString() + ".png");
                }
            }

            if (Passed != true)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Esempio n. 2
0
        public static bool MatchTemplate(this ScriptBase script, MatchedValue matchedValue)
        {
            bool matched = script.MatchTemplate(matchedValue.Position, matchedValue.Hash, matchedValue.Similarity);

#if DEBUG
            if (Settings.Default.CreateDebugScreenshots)
            {
                var cropped    = script.CropFrame(script.CurrentFrame, matchedValue.Position);
                var hash       = ImageHashing.AverageHash(cropped);
                var similarity = ImageHashing.Similarity(hash, matchedValue.Hash);
                if (!matched)
                {
                    cropped.Save($"lastnotmatch_{matchedValue.ID}.png");
                }
            }
#endif
            return(matched);
        }