X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=bs%2Fplanet.cpp;h=a5541cbebaee4b89dd68d5f79d9de96d6d94838a;hb=ac13ca5453360c59eaa0b8ad4242ea0837825bc1;hp=03c45370700acb53018ce2c342cebaa477cc0992;hpb=0fcfaff680c6974a9b3f2a63704a8eb788d3fe94;p=hbs.git diff --git a/bs/planet.cpp b/bs/planet.cpp index 03c4537..a5541cb 100644 --- a/bs/planet.cpp +++ b/bs/planet.cpp @@ -17,7 +17,97 @@ #include "planet.h" -Planet::Planet(){ +using namespace std; + +Planet::Planet() +{ + m_sRace = "Planet"; + m_iScore = 0; } + Planet::~Planet(){ } + +////////////////////////////////////////////////////////////////////////// +// +unsigned Planet::planetScore() const +{ + return m_iScore; +} + +////////////////////////////////////////////////////////////////////////// +// +void Planet::setPlanetScore(unsigned i) +{ + m_iScore = i; +} + +////////////////////////////////////////////////////////////////////////// +// +int Planet::roids(std::string type, int tick = 0) const +{ + // const... I would like [] as for const types: int ticks = m_Roids[type].size(); + + vectorconst* roids = 0; + for (RoidList::const_iterator i = m_Roids.begin(); i != m_Roids.end(); ++i) + { + if (i->first == type) + { + roids = &i->second; + break; + } + } + if (roids == 0) + return 0; + + int ticks = roids->size(); + + if( ticks == 0) + return 0; + if (ticks < tick) + return roids->at(ticks); + return roids->at(tick); +} + +////////////////////////////////////////////////////////////////////////// +// +void Planet::setRoids(std::string type, int number) +{ + if (m_Roids[type].size() == 0) + m_Roids[type].push_back(number); + m_Roids[type][0] = number; +} + +////////////////////////////////////////////////////////////////////////// +// +void Planet::runBattle(std::vector friendly, std::vector hostile) +{ + for(int tick = 1; ; ++tick) + { + //See who's in the battle at the current tick + vector friends = calculateSide(friendly, 6, tick); + vector hostiles = calculateSide(hostile, 3, tick); + + // No idea to calculate anything if noone is there.. ;) + if (hostiles.size() == 0) + break; + + Planet allFriends; + allFriends.addToThis(friends); + + Fleet allHostiles; + allHostiles.addToThis(hostiles); + + calcOneTick(&allFriends, &allHostiles); + + allFriends.distributeLossesGains(friends, tick); + allHostiles.distributeLossesGains(friends, tick); + } +} + +////////////////////////////////////////////////////////////////////////// +// +void Planet::calcOneTick(Planet* friendly, Fleet* Hostile) +{ +} +