Пример #1
0
        public bool Equals(CardCount cc)
        {
            if ((object)cc == null)
            {
                return(false);
            }

            return((Standard == cc.Standard) && (Golden == cc.Golden));
        }
Пример #2
0
        public static CardCount Recognize(string file, bool legend = false)
        {
            CardCount count = new CardCount();

            try
            {
                // full screen capture
                var           bmp = new Bitmap(file);
                CardPositions pos = new CardPositions(bmp.Width, bmp.Height);
                // 1 - Check for existence at position 0
                var exists1 = ReadRegion(bmp, pos.Get(0, RegionType.Mana), 90, 360, 0, 1);
                if (exists1)
                {
                    var count1 = ReadRegion(bmp, pos.Get(0, RegionType.Count), 0, 40, 0, 0.4);
                    // 2 - Check for existence at position 1
                    var exists2 = ReadRegion(bmp, pos.Get(1, RegionType.Mana), 90, 360, 0, 1);
                    if (exists2)
                    {
                        var count2 = ReadRegion(bmp, pos.Get(1, RegionType.Count), 0, 40, 0, 0.4);
                        // 2a - true => standard & gold (TODO: special cases)
                        count.Standard = count1 ? 2 : 1;
                        count.Golden   = count2 ? 2 : 1;
                    }
                    else
                    {
                        // 2b - false => position 0 may be gold, check it
                        var goldRegion = pos.Get(0, RegionType.Gold);
                        if (legend)
                        {
                            goldRegion = pos.Get(0, RegionType.GoldLegend);
                        }
                        var gold1 = ReadRegion(bmp, goldRegion, 40, 57, 0.55, 1);
                        if (gold1)
                        {
                            count.Golden = count1 ? 2 : 1;
                        }
                        else
                        {
                            count.Standard = count1 ? 2 : 1;
                        }
                    }
                }
                else
                {
                    // no matches
                    return(count);
                }


                bmp.Dispose(); // TODO: add finally
            }
            catch (FileNotFoundException e)
            {
                Logger.Write("Exception: " + e, "Recognize");
            }
            return(count);
        }
Пример #3
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            CardCount cc = obj as CardCount;

            if ((object)cc == null)
            {
                return(false);
            }
            return((Standard == cc.Standard) && (Golden == cc.Golden));
        }