m_Battles[name]["Friendly"]["Home Planet"]->setName("Home Planet");
m_Battles[name]["Friendly"]["Home Fleet"]->setName("Home Fleet");
+ m_Battles[name]["Friendly"]["Home Fleet"]->setRace("Terran");
m_Battles[name]["Hostile"]["Evil guy"]->setName("Evil guy");
- //Planet* pl = dynamic_cast<Planet*>(m_Battles[name]["Friendly"]["Home Planet"]);
+
modified = true;
emit documentChanged();
return 0;
//the right side
//m_TickView = new TickView(m_RightSplit);
m_FleetViews = new QWidgetStack(m_RightSplit);
- m_ScanView = new ScanView(m_RightSplit);
+ //m_ScanView = new ScanView(m_RightSplit);
Fleet fl1;
//fl1.setRace(tr("Terran").latin1());
m_FleetView = new FleetView(fl, friendly);
connect(m_FleetView, SIGNAL(fleetChanged(const Fleet*)), SLOT(slotFleetChanged(const Fleet*)));
m_FleetView->slotViewTickRange(m_iMinTick, m_iMaxTick);
+ m_FleetView->slotSetResultMode(m_iResultMode);
m_FleetViews->addWidget(m_FleetView, 1);
}
m_FleetViews->raiseWidget(2);
//
void BSView::slotResultModeChanged( int i)
{
- //FIXME
- /*m_FleetView->slotSetResultMode(i);
+ m_FleetView->slotSetResultMode(i);
m_GenericFleetView->slotSetResultMode(i);
- */
+
m_iResultMode = i;
}
return m_Fleet[unittype][tick];
}
+//////////////////////////////////////////////////////////////////////////
+//
+int Fleet::blockedFleet(std::string unittype, int tick = 0)
+{
+ int ticks = m_BlockedFleet[unittype].size();
+ if (ticks == 0)
+ return 0;
+
+ --ticks;
+
+ if (ticks < tick)
+ return 0;
+
+ return m_BlockedFleet[unittype][tick];
+}
+
+//////////////////////////////////////////////////////////////////////////
+//
+void Fleet::setBlockedFleet(std::string unittype, int number, int tick = 0)
+{
+ int ticks = m_BlockedFleet[unittype].size();
+
+ for (int i = ticks; i <= tick; ++i)
+ {
+ m_BlockedFleet[unittype].push_back(0);
+ }
+ m_BlockedFleet[unittype][tick] = number;
+
+ cerr << "This fleet got " << m_BlockedFleet[unittype][tick] << " blocked units tick: " << tick << endl;
+
+}
+
//////////////////////////////////////////////////////////////////////////
//FIXME
void Fleet::addToThis(std::vector<Fleet*> fleets, int tick = 0)
int fl1 = (*j)->fleet(unittype, tick - 1);
float part = float(fl1) / fleet(unittype, 0) ;
int lost = totallost * part;
- cerr << (*j)->name() << " gaining " << lost << " " << unittype << " since it's " << part * 100 << "% of the whole fleet, and it had : " << fl1 << " units last tick.." << endl;
(*j)->setFleet(unittype, (*j)->fleet(unittype, tick - 1) + lost, tick);
+
+ cerr << (*j)->name() << " gaining " << lost << " " << unittype << " since it's " << part * 100 << "% of the whole fleet, and it had : " << fl1 << " units last tick.." << endl;
+
+ lost = part * blockedFleet(unittype, 0);
+
+ cerr << (*j)->name() << " got " << lost << " blocked " << unittype << ", the total number of blocked ships was: " << blockedFleet(unittype, 0) << endl;
+
+ (*j)->setBlockedFleet(unittype, lost, tick);
}
}
}
int lost = totcapped * part;
cerr << (*j)->name() << " gaining " << lost << " " << res << " since it's " << part * 100 << "% of the whole score, and it had : " << fl1 << " score last tick.. compared to fleet total of: " << score(0) << endl;
- (*j)->addResource(res, lost, tick);
+ (*j)->setResource(res, (*j)->resource(res,tick-1) + lost, tick);
}
}
}
* \return returns the number of units that params specifies.
*/
int freeFleet(std:: string unittype, int tick = 0);
+
+ /** This function is used to see how many ships of a specific type got
+ * blocked at a specific tick.
+ * \param unittype the name of the unittype
+ * \param tick what tick you want to look at
+ * \return the number of ships that got blocked at the specified tick.
+ */
+ int blockedFleet(std::string unittype, int tick = 0);
+ void setBlockedFleet(std::string unittype, int number, int tick = 0);
+
/** This function takes the vector with fleets and adds all their units of the
* specific tick to the current fleet's first tick. Main usage is for battle
* calculations.
void printFleet();
//static functions
+ //
/** This function is used to set the different races used.
* \param races a Simple RaceList which holds all the info
*/
FleetView::FleetView(const Fleet* fleet, bool friendly, QWidget *parent, const char *name ) : QWidget(parent,name)
{
+ m_iMinTick = 0;
+ m_iMaxTick = 0;
+ m_iResultMode = 0;
+
m_Modified = false;
const Planet* planet = 0;
if((planet = dynamic_cast<const Planet*>(fleet)))
}
m_ResourceView = new ResourceView(this);
m_MainLayout->addWidget(m_ResourceView);
- fillTable();
+ fillTable();
}
FleetView::~FleetView(){
m_RoidsEditView->setValue(tr("eonium"),pl->roids(tr("eonium").latin1()));
m_RoidsEditView->setValue(tr("uninit"),pl->roids(tr("uninit").latin1()));
}
+ slotViewTickRange();
}
/////////////////////////////////////////////////////////////////////
m_iMinTick = min;
if (max > -1)
m_iMaxTick = max;
-
+
+ int before = 0;
+ int after = 0;
for(vector<QString>::iterator i = m_Names.begin(); i != m_Names.end(); ++i)
{
- int before = m_Fleet->fleet(i->latin1(), m_iMinTick);
- int after = m_Fleet->fleet(i->latin1(), m_iMaxTick);
- m_UnitsLostSurvivedView[(*i)]->setText(QString("%1").arg(after - before));
+ int show;
+ if (m_iResultMode == 1) //Blocked
+ {
+ show = m_Fleet->blockedFleet(i->latin1(), m_iMaxTick);
+ }
+ else if (m_iResultMode == 2) //Survived
+ {
+ show = m_Fleet->fleet(i->latin1(), m_iMaxTick);
+ }
+ else
+ {
+ before = m_Fleet->fleet(i->latin1(), m_iMinTick);
+ after = m_Fleet->fleet(i->latin1(), m_iMaxTick);
+ show = after - before;
+ }
+ m_UnitsLostSurvivedView[(*i)]->setText(QString("%1").arg( show ));
}
int lost;
- int before;
- int after;
int init = 0;
m_RoidsEditView->slotSetLost(tr("uninit"),lost);
}
}
+
+//////////////////////////////////////////////////////////////////////////
+//
+void FleetView::slotSetResultMode(int i)
+{
+ m_iResultMode = i;
+ slotViewTickRange();
+}
public slots:
void slotViewTickRange(int min = -1 , int max = -1);
+ void slotSetResultMode(int i);
signals:
void fleetChanged(const Fleet*);
int m_iMinTick;
int m_iMaxTick;
+ int m_iResultMode;
std::vector<QString> m_Names;
std::map<QString, QLabel*> m_UnitsLabel;
<string>Survived unts</string>
</property>
</item>
- <item>
- <property name="text">
- <string>New (stolen) untis</string>
- </property>
- </item>
</widget>
<separator/>
<widget class="QLabel">