X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=bs%2Fplanet.cpp;h=c819323d76bde827bde8414b7b8c3b620ef2355c;hb=e0be1e6e8f7a246acf49e1f315c8d5bc5a65bfa3;hp=4133277d62d7cc080abfee462df05db499a9756e;hpb=b308a9445cfe1883ea8068d3f4d1a04bfcff9aa8;p=hbs.git diff --git a/bs/planet.cpp b/bs/planet.cpp index 4133277..c819323 100644 --- a/bs/planet.cpp +++ b/bs/planet.cpp @@ -31,7 +31,7 @@ Planet::~Planet(){ ////////////////////////////////////////////////////////////////////////// // -unsigned Planet::planetScore(int tick = 0) const +unsigned Planet::planetScore(int tick) const { int ticks = m_Score.size(); if (ticks == 0) @@ -47,7 +47,7 @@ unsigned Planet::planetScore(int tick = 0) const ////////////////////////////////////////////////////////////////////////// // -void Planet::setPlanetScore(unsigned number, int tick = 0) +void Planet::setPlanetScore(unsigned number, int tick) { int earlier = 0; int ticks = m_Score.size(); @@ -64,7 +64,7 @@ void Planet::setPlanetScore(unsigned number, int tick = 0) ////////////////////////////////////////////////////////////////////////// // -void Planet::addPlanetScore(unsigned number, int tick = 0) +void Planet::addPlanetScore(unsigned number, int tick) { int earlier = 0; int ticks = m_Score.size(); @@ -80,7 +80,7 @@ void Planet::addPlanetScore(unsigned number, int tick = 0) } ////////////////////////////////////////////////////////////////////////// // -int Planet::roids(std::string type, int tick = 0) const +int Planet::roids(std::string type, int tick) const { // const... I would like [] as for const types: int ticks = m_Roids[type].size(); @@ -108,7 +108,7 @@ int Planet::roids(std::string type, int tick = 0) const ////////////////////////////////////////////////////////////////////////// // -void Planet::setRoids(std::string type, int number, int tick = 0) +void Planet::setRoids(std::string type, int number, int tick) { int ticks = m_Roids[type].size(); int roids = 0; @@ -122,7 +122,7 @@ void Planet::setRoids(std::string type, int number, int tick = 0) ////////////////////////////////////////////////////////////////////////// // -void Planet::takeRoids(std::string type, int number, int tick = 0) +void Planet::takeRoids(std::string type, int number, int tick) { int ticks = m_Roids[type].size(); int roids = 0; @@ -134,7 +134,7 @@ void Planet::takeRoids(std::string type, int number, int tick = 0) m_Roids[type][tick] -= number; if (type != "uninit") - addPlanetScore(-3000*number, tick); + addPlanetScore(-1000*number, tick); } @@ -221,17 +221,18 @@ void Planet::runBattle(std::vector friendly, std::vector hostile ////////////////////////////////////////////////////////////////////////// // -void Planet::calcOneTick(Planet* friendly, Fleet* hostile, std::map >& stealfriendly, std::map >& stealhostile, int tick = 1) +void Planet::calcOneTick(Planet* friendly, Fleet* hostile, std::map >& stealfriendly, std::map >& stealhostile, int tick) { if (planetScore(tick - 1) > 0) setCapping(float(planetScore(tick - 1)) / hostile->score() / 10, tick); else setCapping(0, tick); - map pods; + //FIXME: remove this line later.. map pods; - //FIXME: Need to change this and allow multiple shiptypes with the same initiative. + //FIXME: Need to change this and allow multiple shiptypes with the same initiative. + //FIXME: Looks like I don't have to.. map unitsinit; // order units after their ininitiative for (UnitList::iterator i = s_Units.begin(); i != s_Units.end(); ++i) unitsinit[i->second.initiative()] = i->first; @@ -275,29 +276,39 @@ void Planet::calcOneTick(Planet* friendly, Fleet* hostile, std::mapfirst, tick - 1); - int freepods = hostiletemp->freeFleet(unittype, 1); + //int freepods = hostiletemp->freeFleet(unittype, 1); cerr << "Possible to steal " << caproids << " " << roid->first << " roids\n"; - cerr << freepods << " free pods available\n"; + cerr << hostiletemp->freePodGuns(1) << " free pod guns available\n"; - if (freepods <= 0) + if (hostiletemp->freePodGuns(1) <= 0) break; - if (freepods < caproids) - caproids = freepods; + if (hostiletemp->freePodGuns(1) < caproids) + caproids = hostiletemp->freePodGuns(1); cerr << caproids << " roids stolen\n"; takeRoids(roid->first, caproids, tick); + /*FIXME: REMOVE THIS BLOCK LATER //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. hostiletemp->killFleet(unittype, caproids, 1); pods[unittype] += caproids; //int totroids = caproids + hostiletemp->resource(roid->first, 0); + */ hostiletemp->addResource(roid->first, caproids, 1); - + hostiletemp->usePodGuns(1, caproids); cerr << caproids << " stolen " << roid->first << " roids\n"; } } + + //FIXME: This is ugly and I want to change this, but as long as pods shoot last it works.. + *friendly = *friendlytemp; + delete friendlytemp; + *hostile = *hostiletemp; + delete hostiletemp; + + return; } //set the the objects so they point at the modified objects @@ -306,13 +317,13 @@ void Planet::calcOneTick(Planet* friendly, Fleet* hostile, std::mapaddFleet(pods, 1); + //hostile->addFleet(pods, 1); } ////////////////////////////////////////////////////////////////////////// // -void Planet::calculateScoreLoss(std::vector friendly, int tick = 1) +void Planet::calculateScoreLoss(std::vector friendly, int tick) { for (vector::iterator i = friendly.begin(); i != friendly.end(); ++i) { @@ -326,7 +337,7 @@ void Planet::calculateScoreLoss(std::vector friendly, int tick = 1) ////////////////////////////////////////////////////////////////////////// // -float Planet::capping(int tick = 0) +float Planet::capping(int tick) { int ticks = m_Capping.size(); @@ -340,7 +351,7 @@ float Planet::capping(int tick = 0) ////////////////////////////////////////////////////////////////////////// // -void Planet::setCapping(float capping, int tick = 0) +void Planet::setCapping(float capping, int tick) { int ticks = m_Capping.size();