class MoneyTest { function DoMoneyTest() { local price = GetPrice(); if (WrightAI.HasMoney(price)) { WrightAI.GetMoney(price); } if (DoBuild()) { WrightAI.RepayLoan(); return true; } WrightAI.RepayLoan(); return false; } } class TestBuildAirport extends MoneyTest { loc = null; tp = null; id = null; function DoBuild() { return AIExecMode() && AIAirport.BuildAirport(loc, tp, id); } function GetPrice() { local last_cost = AIAccounting(); AITestMode() && AIAirport.BuildAirport(loc, tp, id); return last_cost.GetCosts(); } function TryBuild(location, type, theid) { loc = location; tp = type; id = theid; if (DoMoneyTest()) { return true; } else { assert(AIError.GetLastError() != AIError.ERR_STATION_TOO_SPREAD_OUT); return false; } } } class TestBuildVehicle extends MoneyTest { h = null; e = null; v = null; function DoBuild() { v = AIVehicle.BuildVehicle(h, e); if (!AIVehicle.IsValidVehicle(v)) { return false; } return true; } function GetPrice() { return AIEngine.GetPrice(e); } function TryBuild(best_hangar, engine) { h = best_hangar; e = engine; if (DoMoneyTest()) { return v; } return null; } }