public static PlayingField ExtractField() { ImageHandler ih = new ImageHandler(); PlayingField field = new PlayingField(); field.SetSlot(true, 0, ih.GetCardAt(XS[0], Y_TOP)); field.SetSlot(true, 1, ih.GetCardAt(XS[1], Y_TOP)); field.SetSlot(true, 2, ih.GetCardAt(XS[2], Y_TOP)); field.SetSlot(true, 3, ih.GetCardAt(X_FLOWER, Y_TOP)); for (int x = 5; x < 8; x++) { ExtractedCard bestExCard = GetCardInOutputSlot(ih, x); field.SetSlot(true, 7, bestExCard); //<- The playing field will place the card in the correct slot } Parallel.For(0, 8, (col) => { for (int row = 0; row < 10; row++) { field.SetSlot(false, col, ih.GetCardAt(XS[col], YS[row])); } }); PlayingFieldPrinter.Print(field); return(field); }
private static ExtractedCard GetCardInOutputSlot(ImageHandler ih, int x) { ExtractedCard bestExCard = ih.GetCardAt(XS[x], 315); for (int y = 314; y >= 300; y--) //<- The higher the card number is, the higher the card is placed on screen! { ExtractedCard exCard = ih.GetCardAt(XS[x], y); if (exCard.Error < bestExCard.Error) { bestExCard = exCard; } } return(bestExCard); }