static Classes.Car GetCarAfterPartsChangeAndWear(Classes.Car car, bool testing, Classes.Track track, Classes.Driver driver, Classes.TechnicalDirector td, Classes.StaffFacilities sf, int ct, int[] carPartsBought) { Classes.Car carAfterWear = (Classes.Car)car.Clone(); //all properties are value type carAfterWear.UpdateCarWearAndLevelAfterCarUpdate(carPartsBought); carAfterWear.UpdateCarWearAfterRace(track, driver, ct); if (testing) { carAfterWear.DoTesting(td, track, sf); } return(carAfterWear); }
static internal SeasonPlannerFullLine ProcessSeasonPlanner(SeasonPlannerFullLine spFull) { #region Initial Values Classes.RaceTab rt = spFull.spOptimizer.raceTab; Classes.SeasonPlannerForDataTable spForDataTable = spFull.spTable; //null. Filled later Classes.TechnicalDirector td = spFull.spOptimizer.technicalDirector; Classes.Car car = (Classes.Car)spFull.spOptimizer.car.Clone(); Classes.Car carAfterRace = (Classes.Car)car.Clone(); Classes.Driver driver = spFull.spOptimizer.driver; int trackId = DB.SeasonTrack.GetTrackId(spFull.spTable.SeasonRaceNumber); Classes.Track track = DB.Track.ReadTrackFromDB(trackId); Classes.StaffFacilities sf = spFull.spOptimizer.staffFacilities; Classes.TyresSupplier tyre = DB.Tyres.ReadActiveTyreSupplierFromDB(); int seasonRaceNumber = rt.SeasonTrackIndex; //float balanceM = spFull.spTab.StartingBalanceM; float balanceM = spFull.spTable.BalanceAfterRaceM; int[] carPartsBought = new int[11]; Divisions division = (Divisions)spFull.spTab.Division; int trainning = (int)spFull.spDecisions.Training; bool testing = spFull.spDecisions.Testing; int targetCarLevel = spFull.spDecisions.TargetCarLevelEngBra; int targetCarLevel2 = spFull.spDecisions.TargetCarLevelOthers; int ct = spFull.spDecisions.CT; #endregion #region Process carAfterRace.UpdateCarWearAfterRace(track, driver, ct); if (testing) { carAfterRace.DoTesting(td, track, sf); } carPartsBought = GetWhichCarPartsChange(car, carAfterRace, targetCarLevel, targetCarLevel2); carAfterRace = (Classes.Car)car.Clone(); carAfterRace = GetCarAfterPartsChangeAndWear(car, testing, track, driver, td, sf, ct, carPartsBought); int qualPosition = SpHelper.GetQualPosition(driver, car, division); int racePosition = SpHelper.GetRacePosition(driver, car, division, ct); int racePoints = SpHelper.GetPoints(racePosition); //Expenses processing float balanceAfterRaceM = ((balanceM * 1000000) + GetAfterRaceBalance(driver, td, sf, testing, tyre, car, division, qualPosition, racePosition, trainning, carPartsBought)) / 1000000f; #endregion #region Output SeasonPlannerDecision spDecisionsNext = new SeasonPlannerDecision(); spDecisionsNext = (Classes.SeasonPlannerDecision)spFull.spDecisions.Clone(); SeasonPlannerForDataTable spTableNext = new SeasonPlannerForDataTable(); spTableNext.SeasonRaceNumber = spFull.spTable.SeasonRaceNumber + 1; spTableNext.BalanceAfterRaceM = balanceAfterRaceM; spTableNext.CarPartsChanged = carPartsBought; spTableNext.CarWearAfterRace = carAfterRace.GetWears(); spTableNext.QualPosition = qualPosition; spTableNext.RacePosition = racePosition; SeasonPlannerForOptimizer spOptimizerNext = new SeasonPlannerForOptimizer(); spOptimizerNext.car = (Classes.Car)carAfterRace.Clone(); driver.DoTrainning((DriverTrainning)trainning); driver.DriverUpdateAfterRace(racePosition); spOptimizerNext.driver = driver; spOptimizerNext.Id = spFull.spOptimizer.Id + 1; spOptimizerNext.raceTab = rt; //How to update trackId? spOptimizerNext.staffFacilities = sf; //To Do: Update sf after races (convert levels to float type) spOptimizerNext.technicalDirector = td; SeasonPlannerTab spTabNext = new SeasonPlannerTab(); spTabNext.CurrentPoints = spFull.spTab.CurrentPoints + racePoints; spTabNext.Division = spFull.spTab.Division; spTabNext.StartingBalanceM = balanceAfterRaceM; spTabNext.TargetPoints = spFull.spTab.TargetPoints; SeasonPlannerFullLine spFullNext = new SeasonPlannerFullLine(spDecisionsNext, spTableNext, spOptimizerNext, spTabNext); return(spFullNext); #endregion }