From e058e65a4a9f0c47b170413c0a085e90b172a3ec Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Mon, 22 Apr 2002 17:29:19 +0000 Subject: [PATCH] now shows the lost score for the planet and the capping each tick --- bs/fleetview.cpp | 8 ++++++++ bs/planet.cpp | 42 +++++++++++++++++++++++++++++++++------- bs/planet.h | 4 ++++ bs/ui/roidseditview.ui | 38 ++++++++++++++++++++++++++++++++---- bs/ui/roidseditview.ui.h | 10 ++++++---- 5 files changed, 87 insertions(+), 15 deletions(-) diff --git a/bs/fleetview.cpp b/bs/fleetview.cpp index 1144ca9..3935616 100644 --- a/bs/fleetview.cpp +++ b/bs/fleetview.cpp @@ -316,6 +316,14 @@ void FleetView::slotViewTickRange(int min = -1, int max = -1) 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)); + } } diff --git a/bs/planet.cpp b/bs/planet.cpp index e6fbe51..01b2125 100644 --- a/bs/planet.cpp +++ b/bs/planet.cpp @@ -236,17 +236,15 @@ void Planet::calcOneTick(Planet* friendly, Fleet* hostile, std::map 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"; @@ -258,7 +256,7 @@ void Planet::calcOneTick(Planet* friendly, Fleet* hostile, std::mapfirst, 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. @@ -292,3 +290,33 @@ void Planet::calculateScoreLoss(std::vector friendly, int tick = 1) } } +////////////////////////////////////////////////////////////////////////// +// +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; +} diff --git a/bs/planet.h b/bs/planet.h index 486bd60..093c7f1 100644 --- a/bs/planet.h +++ b/bs/planet.h @@ -87,6 +87,9 @@ public: void calculateScoreLoss(std::vector 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 @@ -101,6 +104,7 @@ protected: void calcOneTick(Planet* friendly, Fleet* hostile, std::map >& stealfriendly, std::map >& stealhostile, int tick = 0); std::vector m_Score; + std::vector m_Capping; RoidList m_Roids; }; diff --git a/bs/ui/roidseditview.ui b/bs/ui/roidseditview.ui index 4060ec4..6d6b6c2 100644 --- a/bs/ui/roidseditview.ui +++ b/bs/ui/roidseditview.ui @@ -9,7 +9,7 @@ 0 0 - 236 + 339 115 @@ -155,7 +155,7 @@ - ScoreLine + ScoreLabel &Score @@ -164,11 +164,41 @@ ScoreEdit - + + + CappingLabel + + + Capping + + + + + CappingEdit + + + NoFocus + + + true + + + ScoreEdit + + + ScoreLostEdit + + + true + + + This box shows how much score the planet lost between the specified ticks. + + @@ -222,7 +252,7 @@ init() setValue( const QString & type, unsigned value ) slotValueChanged( const QString & s ) - slotSetLost( QString type, int i ) + slotSetLost( QString type, float i ) diff --git a/bs/ui/roidseditview.ui.h b/bs/ui/roidseditview.ui.h index 22a8230..d02b348 100644 --- a/bs/ui/roidseditview.ui.h +++ b/bs/ui/roidseditview.ui.h @@ -23,6 +23,7 @@ void RoidsEditView::setValue( const QString & type, unsigned value ) UninitEdit->setText(QString("%1").arg(value)); else if (type == tr("score")) ScoreEdit->setText(QString("%1").arg(value)); + } @@ -46,7 +47,7 @@ void RoidsEditView::slotValueChanged( const QString & s ) } -void RoidsEditView::slotSetLost( QString type, int i ) +void RoidsEditView::slotSetLost( QString type, float i ) { if (type == tr("metal")) MetalLostEdit->setText(QString("%1").arg(i)); @@ -56,7 +57,8 @@ void RoidsEditView::slotSetLost( QString type, int 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 -- 2.39.2