From: Michael Andreen Date: Mon, 8 Apr 2002 23:39:38 +0000 (+0000) Subject: The work on the combat algorithm is going forward, nothing worth compiling yet though. X-Git-Tag: HBS_0_1_0~19 X-Git-Url: https://ruin.nu/git/?p=hbs.git;a=commitdiff_plain;h=3ae63f013b2ac281d17acec43bc054a132861d35 The work on the combat algorithm is going forward, nothing worth compiling yet though. --- diff --git a/bs/bsview.cpp b/bs/bsview.cpp index c050952..005c443 100644 --- a/bs/bsview.cpp +++ b/bs/bsview.cpp @@ -182,11 +182,11 @@ void BSView::slotFleetSelection(QListViewItem *lvi) { if (lvi->text(0) == tr("Friendly")) { -// m_FleetView->slotAttacker(false); + // m_FleetView->slotAttacker(false); } else { -// m_FleetView->slotAttacker(true); + // m_FleetView->slotAttacker(true); } m_FleetViews->raiseWidget(2); diff --git a/bs/fleet.cpp b/bs/fleet.cpp index ee22ae7..97be5aa 100644 --- a/bs/fleet.cpp +++ b/bs/fleet.cpp @@ -200,4 +200,25 @@ int Fleet::fleet(string unittype, int tick = 0) return m_Fleet[unittype][tick]; } - +////////////////////////////////////////////////////////////////////////// +// +void Fleet::addToThis(std::vector fleets, int tick = 0) +{ + for (UnitList::iterator i = s_Units.begin(); i != s_Units.end(); ++i) + { + if (m_Fleet[i->first].size() == 0) + m_Fleet[i->first].push_back(0); + + for (vector::iterator j = fleets.begin(); j != fleets.end(); ++j) + { + // FIXTHIS!! m_Fleet[i->first][0] += j->fleet(i->first, tick); + } + } +} + +////////////////////////////////////////////////////////////////////////// +// +void distributeLossesGains(std::vector fleets, int tick = 0) +{ +} + diff --git a/bs/fleet.h b/bs/fleet.h index e27c1bf..f1d96af 100644 --- a/bs/fleet.h +++ b/bs/fleet.h @@ -96,7 +96,16 @@ public: static const RaceList& Races(); static const UnitList& Units(); + void addToThis(std::vector fleets, int tick = 0); + + void distributeLossesGains(std::vector fleets, int tick = 0); + + std::vector calculateSide(std::vector fleets, int stays = 0, int tick = 0); + + protected: + + std::string m_sName; std::string m_sRace; int m_iETA; diff --git a/bs/planet.cpp b/bs/planet.cpp index 69cfd7a..9c421cc 100644 --- a/bs/planet.cpp +++ b/bs/planet.cpp @@ -81,6 +81,33 @@ void Planet::setRoids(std::string type, int 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 = calcualteSide(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); + + calculateOneTick(&allFriends, &allHostiles); + + allFriends.distributeLossesGains(friends, tick); + allHostile.distributeLossesGains(friends, tick); + } +} + +////////////////////////////////////////////////////////////////////////// +// +void calcOneTick(Planet* friendly, Fleet* Hostile) { } diff --git a/bs/planet.h b/bs/planet.h index a836577..a19a858 100644 --- a/bs/planet.h +++ b/bs/planet.h @@ -48,6 +48,8 @@ public: void runBattle(std::vector friendly, std::vector hostile); protected: + void calcOneTick(Planet* friendly, Fleet* Hostile); + unsigned m_iScore; RoidList m_Roids;