X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=bs%2Fplanet.cpp;h=3c4404f800d4dee61ae9a968b6015f8eb27dde4a;hb=45577c33bdaab669fd787a0411996d506307708b;hp=1f904f82685ff101d4d392c644a6f269801089c4;hpb=bb4169deef42f91b6afa4c4561f9339fba040f01;p=hbs.git diff --git a/bs/planet.cpp b/bs/planet.cpp index 1f904f8..3c4404f 100644 --- a/bs/planet.cpp +++ b/bs/planet.cpp @@ -131,6 +131,9 @@ void Planet::takeRoids(std::string type, int number, int tick = 0) for (int i = ticks; i <= tick; ++i ) m_Roids[type].push_back(roids); m_Roids[type][tick] -= number; + + if (type != "uninit") + addPlanetScore(-3000*number, tick); } @@ -171,12 +174,21 @@ 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 ); //allFriends.printFleet(); allFriends.distributeLossesGains(friends, tick); + + allHostiles.addPodsForLostRoids(); allHostiles.distributeLossesGains(hostiles, tick); allHostiles.distributeCappedRoids(hostiles, tick); @@ -195,7 +207,7 @@ void Planet::runBattle(std::vector friendly, std::vector hostile ////////////////////////////////////////////////////////////////////////// // -void Planet::calcOneTick(Planet* friendly, Fleet* hostile, std::map >& stealfriendly, std::map >& stealhostile, int tick = 0) +void Planet::calcOneTick(Planet* friendly, Fleet* hostile, std::map >& stealfriendly, std::map >& stealhostile, int tick = 1) { map unitsinit; // order units after their ininitiative for (UnitList::iterator i = s_Units.begin(); i != s_Units.end(); ++i) @@ -231,17 +243,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 +263,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 +285,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 +299,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; +}