//QT includes
#include <qlistview.h>
#include <qwidgetstack.h>
+#include <qtabwidget.h>
+#include <qtextedit.h>
#include "battlesum.h"
#include "scanview.h"
m_doc = doc;
m_LeftSplit = new QSplitter(QSplitter::Vertical, this);
- m_RightSplit = new QSplitter(QSplitter::Vertical, this);
+
+ m_Pages = new QTabWidget(this);
+
+ m_RightSplit = new QSplitter(QSplitter::Vertical);
+ m_Pages->addTab(m_RightSplit, tr("Units"));
+
+ m_Report = new QTextEdit();
+ m_Report->setReadOnly(true);
+ m_Pages->addTab(m_Report, tr("Report"));
+
//setting up the listview
m_NumberView = new QListView(m_LeftSplit);
{
m_sFleet = lvi->text(0);
m_sGroup = lvi->parent()->text(0);
- m_sBattle = lvi->parent()->parent()->text(0);
+ QString temp = lvi->parent()->parent()->text(0);
+
+ if (temp != m_sBattle)
+ {
+ m_sBattle = temp;
+ slotGenerateReport();
+ }
updateInfoView();
updateFleetView();
cerr << "Text: " << text.latin1() << endl;
cerr << "Fleets: " << fleets << endl;
}
+
+
+//////////////////////////////////////////////////////////////////////////
+//
+void BSView::slotGenerateReport()
+{
+ const Fleet *fl = m_doc->specificFleet(m_sBattle, "Friendly", "Home Planet");
+
+ const Planet* pl = dynamic_cast<const Planet*>(fl);
+ if (pl)
+ {
+ ReportList report = pl->report();
+ QString t;
+
+ t.append("<qt>\n");
+
+
+ for (ReportList::iterator i = report.begin(); i != report.end(); ++i)
+ {
+ t.append(QString("Tick number: %0\n").arg(i->first));
+ t.append("<ul>\n");
+ for(map<int, map<string, map<string, map<string, int> > > >::iterator j = i->second.begin(); j != i->second.end(); ++j)
+ {
+ t.append(QString("<li>Now handling initiative: %0\n").arg(j->first));
+ t.append("<ul type=circle>\n");
+ for(map<string, map<string, map<string, int> > >::iterator k = j->second.begin(); k != j->second.end(); ++k)
+ {
+ for(map<string, map<string, int> >::iterator l = k->second.begin(); l != k->second.end(); ++l)
+ {
+ t.append(QString("<li>%0 %1 %2 killing/blocking at: \n").arg(l->second["000"]).arg(k->first.c_str()).arg(l->first.c_str()));
+ t.append("<ul type=square>\n");
+
+ t.append("</ul>\n");
+ t.append("</li>\n");
+ }
+ }
+ t.append("</ul>\n");
+ t.append("</li>\n");
+ }
+ t.append("</ul>\n");
+
+ t.append("<hr>\n");
+ }
+ t.append("</qt>\n");
+ //cerr << t.latin1();
+ m_Report->clear();
+ m_Report->setText(t);
+
+ }
+ //m_Report->append("<b>test\n<b>");
+}
class QSplitter;
class QWidgetStack;
class QListViewItem;
+class QTabWidget;
+class QTextEdit;
/**
* This class provides an incomplete base for your application view.
FleetView *m_GenericFleetView;
BSDoc *m_doc;
std::map<QString, std::map<QString, bool> > m_TreeExpanded;
+ QTabWidget *m_Pages;
+ QTextEdit *m_Report;
QString m_sBattle;
QString m_sGroup;
void slotFleetSelection(QListViewItem *lvi);
void slotItemExpanded(QListViewItem *lvi);
void slotItemCollapsed(QListViewItem *lvi);
+ void slotGenerateReport();
};
#endif
hitunits[j->first]++;
//There is a chance that we're hitting a blocked ship.
+ /*Not anymore..
if (m_BlockedFleet[j->first].size() >= 1)
{
int test = rand() % m_BlockedFleet[j->first][0];
m_BlockedFleet[j->first][1]--;
}
}
+ */
}
}
//////////////////////////////////////////////////////////////////////////
//
-void Fleet::takeEMP(std::string unittype, int number)
+void Fleet::takeEMP(std::string unittype, int number, std::map<std::string, int>& hitunits)
{
int guns = s_Units[unittype].guns() * number;
if (guns == 0)
* very similar stuff in both the take* functions.
* \sa takeShoot
*/
- void takeEMP(std::string unittype, int number);
+ void takeEMP(std::string unittype, int number, std::map<std::string, int>& hitunits);
void calculateLostStealships(std::string unittype, std::map<std::string, int> stolen, int tick = 1);
//
void FleetView::viewFleet(const Fleet* fleet, bool friendly)
{
+ friendly = true;
if (m_Fleet->race() != fleet->race())
{
findNames();
for (vector<Fleet*>::iterator i = hostile.begin(); i != hostile.end(); ++i)
(*i)->resetTicks();
+ m_Report.clear();
+
for(int tick = 1; skipped < 20; ++tick)
{
//See who's in the battle at the current tick
for (UnitList::iterator i = s_Units.begin(); i != s_Units.end(); ++i)
unitsinit[i->second.initiative()] = i->first;
+
+
for (map<int, string>::iterator i = unitsinit.begin(); i != unitsinit.end(); ++i)
{
Fleet* hostiletemp = new Fleet(*hostile);
Planet* friendlytemp = new Planet(*friendly);
string unittype = i->second;
+ int init = i->first;
+
+ int freefriendly = friendly->freeFleet(unittype, 1);
+ int freehostile = hostile->freeFleet(unittype, 1);
+
+ if ( freefriendly <= 0 && freehostile <= 0)
+ continue;
//cerr << "Initiative: " << s_Units[unittype].initiative() << " with unit: " << unittype << endl;
+
+ map<string, int> friendlyhits;
+ map<string, int> hostilehits;
if (s_Units[unittype].type() == "EMP")
{
- hostiletemp->takeEMP(unittype, friendly->freeFleet(unittype, 1));
- friendlytemp->takeEMP(unittype, hostile->freeFleet(unittype, 1));
+ hostiletemp->takeEMP(unittype, freefriendly, friendlyhits);
+ friendlytemp->takeEMP(unittype, freehostile, hostilehits);
}
else if (s_Units[unittype].type() == "Steal")
{
- hostiletemp->takeShoot(unittype, friendly->freeFleet(unittype, 1), stealfriendly[unittype]);
- friendlytemp->takeShoot(unittype, hostile->freeFleet(unittype, 1), stealhostile[unittype]);
+ hostiletemp->takeShoot(unittype, freefriendly, stealfriendly[unittype]);
+ friendlytemp->takeShoot(unittype, freehostile, stealhostile[unittype]);
+
+ friendlyhits = stealfriendly[unittype];
+ hostilehits = stealhostile[unittype];
friendlytemp->calculateLostStealships(unittype, stealfriendly[unittype], 1);
hostiletemp->calculateLostStealships(unittype, stealhostile[unittype], 1);
}
else
{
- map<string, int> temp;
- hostiletemp->takeShoot(unittype, friendly->freeFleet(unittype, 1), temp);
- friendlytemp->takeShoot(unittype, hostile->freeFleet(unittype, 1), temp);
+ hostiletemp->takeShoot(unittype, freefriendly, friendlyhits);
+ friendlytemp->takeShoot(unittype, freehostile, hostilehits);
}
+
if (s_Units[unittype].type() == "Pod")
{
//FIXME: Prolly need to recode the whole capping section for r7, due to multiple pods thingy
{
for (RoidList::iterator roid = m_Roids.begin(); roid != m_Roids.end(); ++roid)
{
- int caproids = capping(tick) * roids(roid->first, tick - 1);
+ int caproids = int(capping(tick) * roids(roid->first, tick - 1));
//int freepods = hostiletemp->freeFleet(unittype, 1);
cerr << "Possible to steal " << caproids << " " << roid->first << " roids\n";
return;
}
+ m_Report[tick][init]["Friendly"][unittype] = friendlyhits;
+ m_Report[tick][init]["Friendly"][unittype]["000"] = freefriendly;
+ m_Report[tick][init]["Hostile"][unittype] = hostilehits;
+ m_Report[tick][init]["Hostile"][unittype]["000"] = freehostile;
//set the the objects so they point at the modified objects
*friendly = *friendlytemp;
else
m_Capping[tick] = 0;
}
+
+//////////////////////////////////////////////////////////////////////////
+//
+ReportList Planet::report() const
+{
+ return m_Report;
+}
#include "fleet.h"
typedef std::map<std::string, std::vector<int> > RoidList;
+typedef std::map<int, std::map<int, std::map<std::string, std::map<std::string, std::map<std::string, int> > > > > ReportList;
/**This class is the implementation of a planet.
*
float capping(int tick = 0);
void setCapping(float capping, int tick = 0);
+ ReportList report() const;
+
protected:
/** This function is used to start the calculations of a single tick of the
* battle on the current planet. It's protected because it's not really meant
std::vector <unsigned> m_Score;
std::vector <float> m_Capping;
RoidList m_Roids;
+ ReportList m_Report;
};
<slot>helpAbout()</slot>
<slot>battleNew()</slot>
<slot>battleSimulate()</slot>
- <slot>oneTickCheck_toggled( bool b )</slot>
- <slot>minTickSpin_valueChanged( int i )</slot>
- <slot>maxTickSpin_valueChanged( int i )</slot>
- <slot>slotTicksChanged( int i )</slot>
- <slot>resultModeCombo_activated( int i )</slot>
+ <slot>oneTickCheck_toggled(bool b)</slot>
+ <slot>minTickSpin_valueChanged(int i)</slot>
+ <slot>maxTickSpin_valueChanged(int i)</slot>
+ <slot>slotTicksChanged(int i)</slot>
+ <slot>resultModeCombo_activated(int i)</slot>
</slots>
<layoutdefaults spacing="6" margin="11"/>
</UI>
QApplication::setOverrideCursor( Qt::WaitCursor );
doc->runBattleSimulation();
+ view->slotGenerateReport();
QApplication::restoreOverrideCursor();
}
<rect>
<x>0</x>
<y>0</y>
- <width>719</width>
- <height>320</height>
+ <width>518</width>
+ <height>371</height>
</rect>
</property>
<property name="caption">