X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=bs%2Fplanet.cpp;h=3e1f39ae65eab751585cde681e1cddc6789c67bd;hb=refs%2Ftags%2FHBS_0_3_2;hp=1f904f82685ff101d4d392c644a6f269801089c4;hpb=bb4169deef42f91b6afa4c4561f9339fba040f01;p=hbs.git diff --git a/bs/planet.cpp b/bs/planet.cpp index 1f904f8..3e1f39a 100644 --- a/bs/planet.cpp +++ b/bs/planet.cpp @@ -171,6 +171,13 @@ void Planet::runBattle(std::vector friendly, std::vector hostile map > stealfriendly; map > stealhostile; + + //Reset roids + for (RoidList::iterator roid = m_Roids.begin(); roid != m_Roids.end(); ++roid) + setRoids(roid->first, roids(roid->first, tick-1), tick); + + setPlanetScore(planetScore(tick - 1), tick); + calcOneTick(&allFriends, &allHostiles, stealfriendly, stealhostile, tick ); @@ -231,17 +238,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"; @@ -253,7 +258,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. @@ -275,6 +280,8 @@ void Planet::calcOneTick(Planet* friendly, Fleet* hostile, std::map friendly, int tick = 1) { for (vector::iterator i = friendly.begin(); i != friendly.end(); ++i) @@ -287,3 +294,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; +}