X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=bs%2Fplanet.cpp;h=01b2125f5c9d428e5f9fb196887e6235dd448403;hb=refs%2Ftags%2FHBS_0_3_1;hp=e6fbe51c006ccb0e87f773b8b5112be6f0a60e08;hpb=2b4577e1d38d07265e2e7a56a115d892255b6c75;p=hbs.git diff --git a/bs/planet.cpp b/bs/planet.cpp index e6fbe51..01b2125 100644 --- a/bs/planet.cpp +++ b/bs/planet.cpp @@ -236,17 +236,15 @@ void Planet::calcOneTick(Planet* friendly, Fleet* hostile, std::map 0) { - float capping = float(planetScore(tick - 1)) / hostile->score() / 10; + setCapping(float(planetScore(tick - 1)) / hostile->score() / 10, tick); - cerr << "Capping is: " << capping << endl; + cerr << "Capping is: " << capping(tick) << endl; - if (capping > 0.15) - capping = 0.15; - if (capping > 0) + if (capping(tick) > 0) { for (RoidList::iterator roid = m_Roids.begin(); roid != m_Roids.end(); ++roid) { - int caproids = capping * roids(roid->first, tick - 1); + int caproids = capping(tick) * roids(roid->first, tick - 1); int freepods = hostiletemp->freeFleet(unittype, 1); cerr << "Possible to steal " << caproids << " " << roid->first << " roids\n"; @@ -258,7 +256,7 @@ void Planet::calcOneTick(Planet* friendly, Fleet* hostile, std::mapfirst, caproids, tick); //FIXME: Going to move this to the distribute roids section instead.. Not really move, I'll keep this, but "regenerate" the pods in the distribute ships function. @@ -292,3 +290,33 @@ void Planet::calculateScoreLoss(std::vector friendly, int tick = 1) } } +////////////////////////////////////////////////////////////////////////// +// +float Planet::capping(int tick = 0) +{ + int ticks = m_Capping.size(); + + --ticks; + + if (ticks < tick) + return 0; + + return m_Capping[tick]; +} + +////////////////////////////////////////////////////////////////////////// +// +void Planet::setCapping(float capping, int tick = 0) +{ + int ticks = m_Capping.size(); + + for (int i = ticks; i <= tick; ++i) + { + m_Capping.push_back(0); + } + + if (capping <= 0.15 && capping >= 0) + m_Capping[tick] = capping; + else + m_Capping[tick] = 0.15; +}