public string[] IdentifyTracks(int[] a1) { string[] tracks = new string[5]; for (int i = 0; i < 5; i++) { string name = "unknown"; int length = NotePad.GetInfoFileLength(trackDirectory + (i + 1) + "\\info.txt"); string[,] theTable = NotePad.ReadInfoFromTXT(trackDirectory + (i + 1) + "\\info.txt"); for (int l = 0; l < length; l++) { if (a1[i] == Convert.ToInt32(theTable[l, 0])) { name = theTable[l, 1]; tracks[i] = name; break; } } if (name == "unknown") { NotePad.DoErrorLog("Неизвестная трасса позиция " + (i + 1)); tracks[i] = "Неизвестная трасса"; } } return(tracks); }
public Car(int carPicture) { IdentifyCar(carPicture); foreach (CarForExcel car in CarsDB.fulltablearray) { if (car.fullname() == carname) { NotePad.DoLog(carname); clearance = clearanceConverter(car.clearance); tires = tiresConverter(car.tires); drive = driveConverter(car.drive); try { acceleration = Convert.ToDouble(car.acceleration); } catch { NotePad.DoErrorLog("can not convert " + car.acceleration + " to double"); } maxSpeed = Convert.ToInt32(car.speed); grip = Convert.ToInt32(car.grip); weight = Convert.ToInt32(car.weight); break; } } }
public void EndRace() { FastCheck fc = new FastCheck(); int flag1 = 0; int flag2 = 0; int flag3 = 0; bool nextstep = false; do { if (flag1 > 3 || flag2 > 3 || flag3 > 3) { NotePad.DoErrorLog("образовалась петля"); RestartBot(); } if (fc.RaceEnd()) { Rat.Clk(PointsAndRectangles.endOfTheFirstRace); //кнопка "пропустить" flag1++; } if (fc.AcceptThrow()) { Rat.Clk(PointsAndRectangles.acceptanceToThrowRaces);//подтвержение "пропуска" flag2++; } if (fc.WonSet()) { Rat.Clk(PointsAndRectangles.endOfRaceSet);//звезды flag3++; } if (fc.LostSet()) { Rat.Clk(PointsAndRectangles.endOfRaceSet);//звезды flag3++; } if (fc.DrawSet()) { Rat.Clk(PointsAndRectangles.endOfRaceSet);//звезды flag3++; } Thread.Sleep(1500); if (fc.Bounty()) { nextstep = true; } if (fc.ClubMap()) { nextstep = true; } if (fc.Ending()) { nextstep = true; } if (fc.Upgrade()) { nextstep = true; } } while (!nextstep); }
public string[] IdentifyWeather(int[] c1) { string[] weathers = new string[5]; for (int i = 0; i < 5; i++) { string name = "unknown"; int length = NotePad.GetInfoFileLength(weatherDirectory + (i + 1) + "\\info.txt"); string[,] theTable = NotePad.ReadInfoFromTXT(weatherDirectory + (i + 1) + "\\info.txt"); for (int l = 0; l < length; l++) { if (c1[i] == Convert.ToInt32(theTable[l, 0])) { name = theTable[l, 1]; weathers[i] = name; break; } } if (name == "unknown") { NotePad.DoErrorLog("Неизвестная погода позиция " + (i + 1)); weathers[i] = "Неизвестная погода"; } } bool dry = false; bool wet = false; foreach (string x in weathers) { if (x == "Дождь") { wet = true; } if (x == "Солнечно") { dry = true; } } Condition.weather = "ясно"; if (wet) { if (dry) { Condition.weather = "с прояснением"; } else { Condition.weather = "дождь"; } } NotePad.LastWeather(Condition.weather); return(weathers); }
public string[] IdentifyGround(int[] b1) { string[] grounds = new string[5]; for (int i = 0; i < 5; i++) { string name = "unknown"; int length = NotePad.GetInfoFileLength(groundDirectory + (i + 1) + "\\info.txt"); string[,] theTable = NotePad.ReadInfoFromTXT(groundDirectory + (i + 1) + "\\info.txt"); for (int l = 0; l < length; l++) { if (b1[i] == Convert.ToInt32(theTable[l, 0])) { name = theTable[l, 1]; grounds[i] = name; break; } } if (name == "unknown") { NotePad.DoErrorLog("Неизвестное покрытие позиция " + (i + 1)); grounds[i] = "Неизвестная покрытие"; } } bool asphalt = false; bool mud = false; foreach (string x in grounds) { if (x == "Асфальт") { asphalt = true; } else { mud = true; } } if (asphalt) { Condition.coverage = "Асфальт"; if (mud) { Condition.coverage = "Смешанное"; } } else { Condition.coverage = "Бездорожье"; } NotePad.LastCoverage(Condition.coverage); return(grounds); }
public static bool Verify(string PATH, string ORIGINALPATH) { bool flag1 = false; if (File.Exists("C:\\Bot\\" + ORIGINALPATH + ".jpg")) { if (File.Exists("C:\\Bot\\" + PATH + ".jpg")) { flag1 = true; Bitmap picturetest = new Bitmap("C:\\Bot\\" + PATH + ".jpg"); Bitmap picture = new Bitmap("C:\\Bot\\" + ORIGINALPATH + ".jpg"); for (int x = 0; x < picturetest.Width; x++) { if (flag1 == true) { for (int y = 0; y < picturetest.Height; y++) { if (picturetest.GetPixel(x, y) != picture.GetPixel(x, y)) { flag1 = false; break; } } } } picturetest.Dispose(); picture.Dispose(); } else { NotePad.DoErrorLog("Отсутствует C:\\Bot\\" + PATH + ".jpg"); } } else { NotePad.DoErrorLog("Отсутствует C:\\Bot\\" + ORIGINALPATH + ".jpg"); } return(flag1); }
public static void MakePicture(Rectangle bounds, string PATH) { PixelFormat format = PixelFormat.Format24bppRgb; captured = new Bitmap(bounds.Width, bounds.Height, format); Graphics gdi = Graphics.FromImage(captured); gdi.CopyFromScreen(bounds.Left + xCorrection, bounds.Top + yCorrection, 0, 0, bounds.Size); if (captured != null) { try { captured.Save("C:\\Bot\\" + PATH + ".jpg", ImageFormat.Jpeg); } catch (Exception ex) { NotePad.DoErrorLog("Unknown error with save picture"); } } gdi.Dispose(); captured.Dispose(); }
public string ConvertPictureToCond(int picture, int cond) { string name = "unknown"; int length = NotePad.GetInfoFileLength(@"C:\Bot\Condition" + cond + @"\info.txt"); string[,] theTable = NotePad.ReadInfoFromTXT(@"C:\Bot\Condition" + cond + @"\info.txt"); for (int i = 0; i < length; i++) { if (picture == Convert.ToInt32(theTable[i, 0])) { name = theTable[i, 1]; NotePad.DoLog(cond + " условие: " + name); break; } } if (name == "unknown") { NotePad.DoErrorLog("Неизвестное условие"); } return(name); }
public static bool VerifyBW(string PATH, string ORIGINALPATH, int maxdiffernces) { bool flag1 = false; if (File.Exists("C:\\Bot\\" + ORIGINALPATH + ".jpg")) { flag1 = true; int differences = 0; Bitmap picturetest = new Bitmap("C:\\Bot\\" + PATH + ".jpg"); Bitmap picture = new Bitmap("C:\\Bot\\" + ORIGINALPATH + ".jpg"); for (int x = 0; x < picturetest.Width; x++) { if (flag1 == true) { for (int y = 0; y < picturetest.Height; y++) { if (Math.Abs((int)picturetest.GetPixel(x, y).R - (int)picture.GetPixel(x, y).R) >= 200) { differences++; if (differences == maxdiffernces) { flag1 = false; break; } } } } } picturetest.Dispose(); picture.Dispose(); } else { NotePad.DoErrorLog("Отсутствует C:\\Bot\\" + ORIGINALPATH + ".jpg"); } return(flag1); }
void IdentifyCar(int carPicture) { string path = @"C:\Bot\NewPL\PictureToCar.txt"; using (StreamReader sr = new StreamReader(path, System.Text.Encoding.Default)) { string line; while ((line = sr.ReadLine()) != null && line != " " && line != "") { if (carPicture.ToString().Equals(NotePad.GetWordFromString(line, 1))) { carname = NotePad.GetWordFromString(line, 2); NotePad.DoLog("машина определена: " + carname); break; } } sr.Close(); } if (carname == "unknown" && carPicture != 10000) { NotePad.DoErrorLog(carPicture + " is unknown car"); } }
public static bool SatisfyCondition(string cond, CarForExcel car) { bool x = false; int year; string tag; string bodytype; switch (cond) { case "empty": x = true; break; case "задний привод": if (car.drive == "rwd") { x = true; } break; case "передний привод": if (car.drive == "fwd") { x = true; } break; case "обычная х3": x = true; break; case "audi": if (car.manufacturer == "Audi") { x = true; } break; case "audi x3": if (car.manufacturer == "Audi") { x = true; } break; case "бензиновые машины": if (car.fuel == "petrol") { x = true; } break; case "дизели": if (car.fuel == "diesel") { x = true; } break; case "обычная": if (car.rarity == "f") { x = true; } break; case "обычная х2": if (car.rarity == "f") { x = true; } break; case "необычная": if (car.rarity == "e") { x = true; } break; case "машины японии": if (car.country == "Japan") { x = true; } break; case "машины японии х3": if (car.country == "Japan") { x = true; } break; case "jaguar": if (car.manufacturer == "Jaguar") { x = true; } break; case "jaguar x3": if (car.manufacturer == "Jaguar") { x = true; } break; case "машины сша": if (car.country == "United States") { x = true; } break; case "italian 60s-80s": if (car.country == "Italy") { year = Convert.ToInt32(car.year); if (year > 1959 && year < 1990) { x = true; } } break; case "редкостная": if (car.rarity == "d") { x = true; } break; case "редкостная х2": if (car.rarity == "d") { x = true; } break; case "экстремальная": if (car.rarity == "b") { x = true; } break; case "standard tyres": case "standard tires": if (car.tires == "std") { x = true; } break; case "пикапы": bodytype = "pickup"; x = SearchBody(car, bodytype); break; case "mercedes-benz": if (car.manufacturer == "Mercedes-Benz") { x = true; } break; case "renault": if (car.manufacturer == "Renault") { x = true; } break; case "renault x3": if (car.manufacturer == "Renault") { x = true; } break; case "suzuki x3": if (car.manufacturer == "Suzuki") { x = true; } break; case "nissan x3": if (car.manufacturer == "Nissan") { x = true; } break; case "полный привод": if (car.drive == "4wd") { x = true; } break; case "машины англии": if (car.country == "United Kingdom") { x = true; } break; case "chrysler": if (car.manufacturer == "Chrysler") { x = true; } break; case "chrysler x3": if (car.manufacturer == "Chrysler") { x = true; } break; case "peugeot": if (car.manufacturer == "Peugeot") { x = true; } break; case "peugeot x3": if (car.manufacturer == "Peugeot") { x = true; } break; case "honda": if (car.manufacturer == "Honda") { x = true; } break; case "honda x3": if (car.manufacturer == "Honda") { x = true; } break; case "alfa romeo": if (car.manufacturer == "Alfa Romeo") { x = true; } break; case "alfa romeo x3": if (car.manufacturer == "Alfa Romeo") { x = true; } break; case "французский ренессанс": tag = "French Renaissance"; x = SearchTag(car, tag); break; case "машины франции": if (car.country == "France") { x = true; } break; case "машины франции х2": if (car.country == "France") { x = true; } break; case "all-surface tyres": if (car.tires == "all") { x = true; } break; case "ford": if (car.manufacturer == "Ford") { x = true; } break; case "bmw": if (car.manufacturer == "BMW") { x = true; } break; case "bmw x3": if (car.manufacturer == "BMW") { x = true; } break; case "машины италии": if (car.country == "Italy") { x = true; } break; case "5-местные": if (Convert.ToInt32(car.seats) == 5) { x = true; } break; case "mazda": if (car.manufacturer == "Mazda") { x = true; } break; case "машины германии": if (car.country == "Germany") { x = true; } break; case "американская мечта": tag = "American Dream"; x = (SearchTag(car, tag)); break; case "dodge": if (car.manufacturer == "Dodge") { x = true; } break; case "dodge x3": if (car.manufacturer == "Dodge") { x = true; } break; case "суперская": if (car.rarity == "c") { x = true; } break; case "машины 1980": year = Convert.ToInt32(car.year); if (year > 1979 && year < 1990) { x = true; } break; case "porsche": if (car.manufacturer == "Porsche") { x = true; } break; case "mercedes-benz x3": if (car.manufacturer == "Mercedes-Benz") { x = true; } break; case "opel": if (car.manufacturer == "Vauxhall") { x = true; } break; case "2-местные": if (Convert.ToInt32(car.seats) == 2) { x = true; } break; case "2000s 4wd": year = Convert.ToInt32(car.year); if (car.drive == "4wd" && (year > 1999 && year < 2010)) { x = true; } break; case "седаны": bodytype = "sedan"; x = SearchBody(car, bodytype); break; case "горячий хэтчбек": tag = "Hot Hatch"; x = SearchTag(car, tag); break; case "экологичная": tag = "Eco Friendly"; x = (SearchTag(car, tag)); break; case "italian renaissance": tag = "Italian Renaissance"; x = (SearchTag(car, tag)); break; case "italian renaissance x3": tag = "Italian Renaissance"; x = (SearchTag(car, tag)); break; case "cadillac": if (car.manufacturer == "Cadillac") { x = true; } break; case "cadillac x3": if (car.manufacturer == "Cadillac") { x = true; } break; case "citroen": if (car.manufacturer == "Citroen") { x = true; } break; case "citroen x3": if (car.manufacturer == "Citroen") { x = true; } break; case "pre-1970": year = Convert.ToInt32(car.year); if (year < 1970) { x = true; } break; case "pontiac": if (car.manufacturer == "Pontiac") { x = true; } break; case "pontiac x3": if (car.manufacturer == "Pontiac") { x = true; } break; case "1975-1984": year = Convert.ToInt32(car.year); if (year > 1974 && year < 1985) { x = true; } break; case "немецкое возрождение": tag = "German Renaissance"; x = (SearchTag(car, tag)); break; case "немецкое возрождение х3": tag = "German Renaissance"; x = (SearchTag(car, tag)); break; case "fiat": if (car.manufacturer == "Fiat") { x = true; } break; case "fiat x3": if (car.manufacturer == "Fiat") { x = true; } break; case "nissan": if (car.manufacturer == "Nissan") { x = true; } break; case "chevrolet": if (car.manufacturer == "Chevrolet") { x = true; } break; case "chevrolet x3": if (car.manufacturer == "Chevrolet") { x = true; } break; case "2000-2004": year = Convert.ToInt32(car.year); if (year > 1999 && year < 2005) { x = true; } break; case "икона стиля": tag = "Style Icon"; x = (SearchTag(car, tag)); break; case "2005-2009": year = Convert.ToInt32(car.year); if (year > 2004 && year < 2010) { x = true; } break; case "1985-1994": year = Convert.ToInt32(car.year); if (year > 1984 && year < 1995) { x = true; } break; case "subaru": if (car.manufacturer == "Subaru") { x = true; } break; case "subaru x3": if (car.manufacturer == "Subaru") { x = true; } break; case "автоспорт": tag = "Motorsport"; x = (SearchTag(car, tag)); break; case "отк. верх": case "отк.верх": bool x1; bool x2; bodytype = "roadster"; x1 = SearchBody(car, bodytype); bodytype = "cabrio"; x2 = SearchBody(car, bodytype); if (x1 || x2) { x = true; } break; case "машины 1990": year = Convert.ToInt32(car.year); if (year > 1989 && year < 2000) { x = true; } break; case "2000 rwd": if (car.drive == "rwd") { year = Convert.ToInt32(car.year); if (year > 1999 && year < 2010) { x = true; } } break; case "машины 1970": year = Convert.ToInt32(car.year); if (year > 1969 && year < 1980) { x = true; } break; case "машины италии х3": if (car.country == "Italy") { x = true; } break; case "машины италии х2": if (car.country == "Italy") { x = true; } break; case "машины франции х3": if (car.country == "France") { x = true; } break; case "машины англии х3": if (car.country == "United Kingdom") { x = true; } break; case "машины англии х2": if (car.country == "United Kingdom") { x = true; } break; case "машины японии х2": if (car.country == "Japan") { x = true; } break; case "машины германии х2": if (car.country == "Germany") { x = true; } break; case "машины германии х3": if (car.country == "Germany") { x = true; } break; case "german 2015-2019 x3": if (car.country == "Germany") { year = Convert.ToInt32(car.year); if (year > 2014 && year < 2020) { x = true; } } break; case "машины сша х2": if (car.country == "United States") { x = true; } break; case "машины сша х3": if (car.country == "United States") { x = true; } break; case "ford x3": if (car.manufacturer == "Ford") { x = true; } break; case "opel x3": if (car.manufacturer == "Vauxhall") { x = true; } break; case "необычная х3": if (car.rarity == "e") { x = true; } break; case "суперская х2": if (car.rarity == "c") { x = true; } break; case "german 2010-2014 x3": if (car.country == "German") { year = Convert.ToInt32(car.year); if (year > 2009 && year < 2015) { x = true; } } break; case "italian 90s x3": if (car.country == "Italy") { year = Convert.ToInt32(car.year); if (year > 1989 && year < 2000) { x = true; } } break; default: NotePad.DoErrorLog("don't know condition: " + cond); x = false; break; } return(x); }