CvBuilderTaskingAI::ScorePlot()
- Defined in
- CvBuilderTaskingAI.cpp, line 2224
- Class
- CvBuilderTaskingAI
- Hook name
CivHooks::CvBuilderTaskingAI_ScorePlot
Hooks
static bool BeforeCvBuilderTaskingAI_ScorePlot(CvBuilderTaskingAI* self, int& result);static void AfterCvBuilderTaskingAI_ScorePlot(CvBuilderTaskingAI* self, int& result);static int ReplaceCvBuilderTaskingAI_ScorePlot(int (*original)(CvBuilderTaskingAI*), CvBuilderTaskingAI* self);CivRegisterBefore<CivHooks::CvBuilderTaskingAI_ScorePlot>(host, &BeforeCvBuilderTaskingAI_ScorePlot);CivRegisterAfter<CivHooks::CvBuilderTaskingAI_ScorePlot>(host, &AfterCvBuilderTaskingAI_ScorePlot);CivRegisterReplace<CivHooks::CvBuilderTaskingAI_ScorePlot>(host, &ReplaceCvBuilderTaskingAI_ScorePlot);
Code
2224int CvBuilderTaskingAI::ScorePlot()2225{2226 if(!m_pTargetPlot)2227 {2228 return -1;2229 }22302231 CvCity* pCity = m_pTargetPlot->getWorkingCity();2232 if(!pCity)2233 {2234 return -1;2235 }22362237 CvCityStrategyAI* pCityStrategy = pCity->GetCityStrategyAI();2238 if(!pCityStrategy)2239 {2240 return -1;2241 }22422243 int iScore = 0;2244 bool bAnyNegativeMultiplier = false;2245 YieldTypes eFocusYield = pCityStrategy->GetFocusYield();2246 for(uint ui = 0; ui < NUM_YIELD_TYPES; ui++)2247 {2248 int iMultiplier = pCityStrategy->GetYieldDeltaTimes100((YieldTypes)ui);2249 int iAbsMultiplier = abs(iMultiplier);2250 int iYieldDelta = m_aiProjectedPlotYields[ui] - m_aiCurrentPlotYields[ui];22512252 // the multiplier being lower than zero means that we need more of this resource2253 if(iMultiplier < 0)2254 {2255 bAnyNegativeMultiplier = true;2256 if(iYieldDelta > 0) // this would be an improvement to the yield2257 {2258 iScore += m_aiProjectedPlotYields[ui] * iAbsMultiplier;2259 }2260 else if(iYieldDelta < 0) // the yield would go down2261 {2262 iScore += iYieldDelta * iAbsMultiplier;2263 }2264 }2265 else2266 {2267 if(iYieldDelta >= 0)2268 {2269 iScore += m_aiProjectedPlotYields[ui]; // provide a nominal score to plots that improve anything2270 }2271 else if(iYieldDelta < 0)2272 {2273 iScore += iYieldDelta * iAbsMultiplier;2274 }2275 }2276 }22772278 if(!bAnyNegativeMultiplier && eFocusYield != NO_YIELD)2279 {2280 int iYieldDelta = m_aiProjectedPlotYields[eFocusYield] - m_aiCurrentPlotYields[eFocusYield];2281 if(iYieldDelta > 0)2282 {2283 iScore += m_aiProjectedPlotYields[eFocusYield] * 100;2284 }2285 }22862287 if (pCity->isCapital()) // this is our capital and needs emphasis2288 {2289 iScore *= 8;2290 }2291 else if (pCity->IsOriginalCapital()) // this was a particularly good city and needs a little emphasis2292 {2293 iScore *= 2;2294 }22952296 return iScore;2297}