after = pl->roids(tr("uninit").latin1(),m_iMaxTick);
lost = after - before;
m_RoidsEditView->slotSetLost(tr("uninit"),lost);
+
+ before = pl->planetScore(m_iMinTick);
+ after = pl->planetScore(m_iMaxTick);
+ lost = after - before;
+ m_RoidsEditView->slotSetLost(tr("scorelost"),lost);
+
+ m_RoidsEditView->slotSetLost(tr("capping"),pl->capping(m_iMaxTick));
+
}
}
{
if (planetScore(tick - 1) > 0)
{
- float capping = float(planetScore(tick - 1)) / hostile->score() / 10;
+ setCapping(float(planetScore(tick - 1)) / hostile->score() / 10, tick);
- cerr << "Capping is: " << capping << endl;
+ cerr << "Capping is: " << capping(tick) << endl;
- if (capping > 0.15)
- capping = 0.15;
- if (capping > 0)
+ if (capping(tick) > 0)
{
for (RoidList::iterator roid = m_Roids.begin(); roid != m_Roids.end(); ++roid)
{
- int caproids = capping * roids(roid->first, tick - 1);
+ int caproids = capping(tick) * roids(roid->first, tick - 1);
int freepods = hostiletemp->freeFleet(unittype, 1);
cerr << "Possible to steal " << caproids << " " << roid->first << " roids\n";
caproids = freepods;
cerr << caproids << " roids stolen\n";
-
+
takeRoids(roid->first, caproids, tick);
//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.
}
}
+//////////////////////////////////////////////////////////////////////////
+//
+float Planet::capping(int tick = 0)
+{
+ int ticks = m_Capping.size();
+
+ --ticks;
+
+ if (ticks < tick)
+ return 0;
+
+ return m_Capping[tick];
+}
+
+//////////////////////////////////////////////////////////////////////////
+//
+void Planet::setCapping(float capping, int tick = 0)
+{
+ int ticks = m_Capping.size();
+
+ for (int i = ticks; i <= tick; ++i)
+ {
+ m_Capping.push_back(0);
+ }
+
+ if (capping <= 0.15 && capping >= 0)
+ m_Capping[tick] = capping;
+ else
+ m_Capping[tick] = 0.15;
+}
void calculateScoreLoss(std::vector<Fleet*> friendly, int tick = 1);
+ float capping(int tick = 0);
+ void setCapping(float capping, int tick = 0);
+
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
void calcOneTick(Planet* friendly, Fleet* hostile, std::map<std::string, std::map<std::string, int> >& stealfriendly, std::map<std::string, std::map<std::string, int> >& stealhostile, int tick = 0);
std::vector <unsigned> m_Score;
+ std::vector <float> m_Capping;
RoidList m_Roids;
};
<rect>
<x>0</x>
<y>0</y>
- <width>236</width>
+ <width>339</width>
<height>115</height>
</rect>
</property>
</widget>
<widget class="QLabel" row="3" column="0">
<property name="name">
- <cstring>ScoreLine</cstring>
+ <cstring>ScoreLabel</cstring>
</property>
<property name="text">
<string>&Score</string>
<cstring>ScoreEdit</cstring>
</property>
</widget>
- <widget class="QLineEdit" row="3" column="1" rowspan="1" colspan="4">
+ <widget class="QLabel" row="3" column="3">
+ <property name="name">
+ <cstring>CappingLabel</cstring>
+ </property>
+ <property name="text">
+ <string>Capping</string>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="3" column="4">
+ <property name="name">
+ <cstring>CappingEdit</cstring>
+ </property>
+ <property name="focusPolicy">
+ <enum>NoFocus</enum>
+ </property>
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="3" column="1">
<property name="name">
<cstring>ScoreEdit</cstring>
</property>
</widget>
+ <widget class="QLineEdit" row="3" column="2">
+ <property name="name">
+ <cstring>ScoreLostEdit</cstring>
+ </property>
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>This box shows how much score the planet lost between the specified ticks.</string>
+ </property>
+ </widget>
</grid>
</widget>
<connections>
<slot>init()</slot>
<slot>setValue( const QString & type, unsigned value )</slot>
<slot>slotValueChanged( const QString & s )</slot>
- <slot>slotSetLost( QString type, int i )</slot>
+ <slot>slotSetLost( QString type, float i )</slot>
</slots>
<pixmapinproject/>
<layoutdefaults spacing="0" margin="2"/>
UninitEdit->setText(QString("%1").arg(value));
else if (type == tr("score"))
ScoreEdit->setText(QString("%1").arg(value));
+
}
}
-void RoidsEditView::slotSetLost( QString type, int i )
+void RoidsEditView::slotSetLost( QString type, float i )
{
if (type == tr("metal"))
MetalLostEdit->setText(QString("%1").arg(i));
EoniumLostEdit->setText(QString("%1").arg(i));
else if (type == tr("uninit"))
UninitLostEdit->setText(QString("%1").arg(i));
- /*else if (type == tr("score"))
- ScoreEdit->setText(QString("%1").arg(i));
- */
+ else if (type == tr("scorelost"))
+ ScoreLostEdit->setText(QString("%1").arg(i));
+ else if (type == tr("capping"))
+ CappingEdit->setText(QString("%1\%").arg(i*100));
}
\ No newline at end of file