-
-
Save SamuXarick/02ff9c95a80f6ed4b8ec1d4f254af175 to your computer and use it in GitHub Desktop.
The sum of profit this year + profit last year is not working correctly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function LeagueTable::GetMostProfitableVehicle_Val(company) | |
{ | |
if (GSCompany.ResolveCompanyID(company) != GSCompany.COMPANY_INVALID) { | |
local company_scope = GSCompanyMode(company); | |
local total_profits = GSList(); | |
local vehicle_list = GSVehicleList(); | |
if (vehicle_list.Count() == 0) return [ 0, { str = GetMostProfitableVehicle_ElementString(), p = [ -1 ] } ]; | |
vehicle_list.Valuate(GSVehicle.GetProfitThisYear); | |
total_profits.AddList(vehicle_list); | |
vehicle_list.Valuate(GSVehicle.GetProfitLastYear); | |
foreach(vehicle in total_profits) { | |
total_profits.SetValue(vehicle, (total_profits.GetValue(vehicle) + vehicle_list.GetValue(vehicle))); | |
} | |
return [ total_profits.GetValue(total_profits.Begin()), { str = GetMostProfitableVehicle_ElementString(), p = [ total_profits.Begin() ] } ]; | |
} | |
return [ 0, { str = GetMostProfitableVehicle_ElementString(), p = [ -1 ] } ]; | |
} |
glx22
commented
Feb 13, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment