예제 #1
0
        public static CrewData GetBest(SearchResults result, CrewData[] crew, out string title)
        {
            var best = crew.OrderBy(c => c.bigbook_tier).ToList();

            var starBest = new List <CrewData>();

            if ((result.crew1.stars > 0) && (result.crew1.stars < crew[0].max_rarity))
            {
                starBest.Add(crew[0]);
            }
            if ((result.crew2.stars > 0) && (result.crew2.stars < crew[1].max_rarity))
            {
                starBest.Add(crew[1]);
            }
            if ((result.crew3.stars > 0) && (result.crew3.stars < crew[2].max_rarity))
            {
                starBest.Add(crew[2]);
            }
            var theStarBest = starBest.OrderBy(c => c.bigbook_tier).ToList();

            if (best[0].bigbook_tier > 9)
            {
                if (theStarBest.Count > 0)
                {
                    title = $"All these options suck, so add a star to {theStarBest[0].name} I guess";
                }
                else
                {
                    title = $"All these options suck, pick {best[0].name} if you have room";
                }
            }
            else
            {
                if ((theStarBest.Count > 0) && (theStarBest[0].name != best[0].name))
                {
                    if (theStarBest[0].bigbook_tier > 9)
                    {
                        title = $"{best[0].name} is your best bet; star up the crappy {theStarBest[0].name} if you don't have any slots to spare";
                    }
                    else
                    {
                        title = $"Add a star to {theStarBest[0].name} or pick {best[0].name} if you have room";
                    }
                }
                else
                {
                    if (best[0].bigbook_tier == best[1].bigbook_tier)
                    {
                        title = $"Pick either {best[0].name} or {best[1].name}";
                    }
                    else
                    {
                        int stars = 0;
                        if (best[0].symbol == result.crew1.symbol)
                        {
                            stars = result.crew1.stars;
                        }
                        else if (best[0].symbol == result.crew2.symbol)
                        {
                            stars = result.crew2.stars;
                        }
                        else
                        {
                            stars = result.crew3.stars;
                        }

                        if (stars == best[0].max_rarity)
                        {
                            if (best[1].bigbook_tier < 8)
                            {
                                title = $"{best[1].name} is your best bet, unless you want to start another {best[0].name}";
                            }
                            else
                            {
                                title = $"It may be worth starting another {best[0].name}, pick {best[1].name} if you don't want dupes";
                            }
                        }
                        else
                        {
                            title = $"{best[0].name} is your best bet";
                        }
                    }
                }
            }

            return(best[0]);
        }
예제 #2
0
        private SearchResults SearchImage(Mat query)
        {
            SearchResults results = new SearchResults();

            results.input_height = query.Rows;
            results.input_width  = query.Cols;

            try
            {
                // First, take the top of the image and look for the title
                Mat top = query.SubMat(0, Math.Min(query.Rows / 13, 80), query.Cols / 3, query.Cols * 2 / 3);
                if (top.Empty())
                {
                    results.top   = null;
                    results.error = "Top row was empty";
                    return(results);
                }

                var topResult = MatchCrew(top);
                results.top = new SearchResult {
                    symbol = topResult.Symbol, score = topResult.score
                };

                if (topResult.Symbol != "behold_title")
                {
                    results.error = "Top row doesn't look like a behold title";
                }

                // split in 3, search for each separately
                Mat crew1 = query.SubMat(query.Rows * 2 / 8, (int)(query.Rows * 4.5 / 8), 30, query.Cols / 3);
                Mat crew2 = query.SubMat(query.Rows * 2 / 8, (int)(query.Rows * 4.5 / 8), query.Cols * 1 / 3 + 30, query.Cols * 2 / 3);
                Mat crew3 = query.SubMat(query.Rows * 2 / 8, (int)(query.Rows * 4.5 / 8), query.Cols * 2 / 3 + 30, query.Cols - 30);

                var c1 = MatchCrew(crew1);
                var c2 = MatchCrew(crew2);
                var c3 = MatchCrew(crew3);

                //crew1.SaveImage("crew1.png");
                //crew2.SaveImage("crew2.png");
                //crew3.SaveImage("crew3.png");

                // TODO: only do this part if valid (to not waste time)
                int starCount1 = 0;
                int starCount2 = 0;
                int starCount3 = 0;
                results.closebuttons = 0;
                if ((c1 != null) && (c2 != null) && (c3 != null))
                {
                    int   starScale = 72;
                    float scale     = query.Cols / 100;
                    Mat   stars1    = query.SubMat((int)(scale * 9.2), (int)(scale * 12.8), 30, query.Cols / 3);
                    Mat   stars2    = query.SubMat((int)(scale * 9.2), (int)(scale * 12.8), query.Cols * 1 / 3 + 30, query.Cols * 2 / 3);
                    Mat   stars3    = query.SubMat((int)(scale * 9.2), (int)(scale * 12.8), query.Cols * 2 / 3 + 30, query.Cols - 30);

                    stars1 = stars1.Resize(new Size(stars1.Cols * starScale / stars1.Rows, starScale));
                    stars2 = stars2.Resize(new Size(stars2.Cols * starScale / stars2.Rows, starScale));
                    stars3 = stars3.Resize(new Size(stars3.Cols * starScale / stars3.Rows, starScale));

                    starCount1 = CountFullStars(stars1, _starFull);
                    starCount2 = CountFullStars(stars2, _starFull);
                    starCount3 = CountFullStars(stars3, _starFull);

                    // If there's a close button, this isn't a behold
                    int upperRightCorner = (int)(Math.Min(query.Rows, query.Cols) * 0.11);
                    Mat corner           = query.SubMat(0, upperRightCorner, query.Cols - upperRightCorner, query.Cols);
                    corner = corner.Resize(new Size(78, 78));
                    results.closebuttons = CountFullStars(corner, _closeButton, 0.7);
                }

                results.crew1 = new SearchResult {
                    symbol = c1.Symbol, score = c1.score, stars = starCount1
                };
                results.crew2 = new SearchResult {
                    symbol = c2.Symbol, score = c2.score, stars = starCount2
                };
                results.crew3 = new SearchResult {
                    symbol = c3.Symbol, score = c3.score, stars = starCount3
                };

                return(results);
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Exception during search: {ex.Message}");
                results.error = $"Exception during search: {ex.Message}";
                return(results);
            }
        }