From 0913ab8150ff07822ec8e20466c8feead013cdc5 Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Sun, 7 Apr 2002 23:23:15 +0000 Subject: [PATCH] BSDoc should now create a friendly and a hostile vector for the battle simulation, the code compiles, but is untested.. A few comment changes too. --- bs/bsdoc.cpp | 16 ++++++++++++++++ bs/fleet.h | 4 ++-- bs/planet.cpp | 2 +- bs/planet.h | 3 +++ 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/bs/bsdoc.cpp b/bs/bsdoc.cpp index d7e04ce..9d3c21b 100644 --- a/bs/bsdoc.cpp +++ b/bs/bsdoc.cpp @@ -146,6 +146,22 @@ void BSDoc::removeFleet(QString battle, QString group, QString fleet) // void BSDoc::runBattleSimulation() { + for(BattleList::iterator i = m_Battles.begin(); i != m_Battles.end(); ++i) + { + map > battle; + for (map >::iterator j = i->second.begin(); j != i->second.end(); ++j) + { + for (map::iterator k = j->second.begin(); k != j->second.end(); ++k) + battle[j->first].push_back(k->second); + } + + Planet* pl = dynamic_cast(i->second["Friendly"]["Home Planet"]); + + if (pl) + { + pl->runBattle(battle["Friendly"], battle["Hostile"]); + } + } emit documentChanged(); } diff --git a/bs/fleet.h b/bs/fleet.h index 9a0995a..e27c1bf 100644 --- a/bs/fleet.h +++ b/bs/fleet.h @@ -28,8 +28,8 @@ typedef std::map > FleetList; typedef std::map UnitList; typedef std::map > RaceList; -//!This is the engine for the whole battlesystem. -/**This is the engine for the whole battlesystem. +//! An abstraction of a fleet and the engine for the battle simulation. +/**This class and it's derivates is the engine for the whole battlesystem. * One of the few parts that I plan make fully portable. *\todo LOTS (I think ;) *@author Michael Andreen diff --git a/bs/planet.cpp b/bs/planet.cpp index 81d7daa..69cfd7a 100644 --- a/bs/planet.cpp +++ b/bs/planet.cpp @@ -80,7 +80,7 @@ void Planet::setRoids(std::string type, int number) ////////////////////////////////////////////////////////////////////////// // -void runBattle(std::vector friendly, std::vector hostile) +void Planet::runBattle(std::vector friendly, std::vector hostile) { } diff --git a/bs/planet.h b/bs/planet.h index e59007c..a836577 100644 --- a/bs/planet.h +++ b/bs/planet.h @@ -28,6 +28,9 @@ typedef std::map > RoidList; * real life, it's a game engine, and in this engine a planet got all the * attributes that a fleet got + some additions, so I think the inheritance * is fully legal from a OOP standpoint. If it isn't, then please correct me ;) + * + * This class is doing the actual battle simulation (since battles without + * planets aren't available in this game). *@author Michael Andreen */ -- 2.39.2