From 217cda78005f993fd6b2e575d4abd97c93cec655 Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Thu, 25 Apr 2002 19:41:17 +0000 Subject: [PATCH 01/16] a couple of bugs solved.. --- bs/fleet.cpp | 46 +++++++++++++++++++++++------- bs/fleet.h | 8 ++++-- bs/planet.cpp | 66 ++++++++++++++++++++++++++----------------- bs/ui/resourceview.ui | 4 +-- 4 files changed, 84 insertions(+), 40 deletions(-) diff --git a/bs/fleet.cpp b/bs/fleet.cpp index 13bafb7..136ad22 100644 --- a/bs/fleet.cpp +++ b/bs/fleet.cpp @@ -201,6 +201,23 @@ void Fleet::setFleet(string unittype, int number, int tick = 0) m_Fleet[unittype][tick] = number; } +////////////////////////////////////////////////////////////////////////// +// +void Fleet::addFleet(std::string unittype, int number, int tick = 0) +{ + int earlier = 0; + int ticks = m_Fleet[unittype].size(); + + if (ticks != 0) + earlier = m_Fleet[unittype][ticks - 1]; + + for (int i = ticks; i <= tick; ++i) + { + m_Fleet[unittype].push_back(earlier); + } + m_Fleet[unittype][tick] += number; +} + ////////////////////////////////////////////////////////////////////////// // int Fleet::fleet(string unittype, int tick = 0) @@ -572,10 +589,7 @@ void Fleet::addResource(std::string type, int number, int tick = 0) { int ticks = m_Resources[type].size(); - int latest = 0; - - if (ticks > 0) - latest = m_Resources[type][ticks - 1]; + int latest = resource(type, tick - 1); for (int i = ticks; i <= tick; ++i) m_Resources[type].push_back(latest); @@ -586,6 +600,9 @@ void Fleet::addResource(std::string type, int number, int tick = 0) // int Fleet::resource(std::string type, int tick = 0) const { + if (tick < 0) + return 0; + vectorconst* resource = 0; for (ResourceList::const_iterator i = m_Resources.begin(); i != m_Resources.end(); ++i) { @@ -610,6 +627,13 @@ int Fleet::resource(std::string type, int tick = 0) const return resource->at(tick); } +////////////////////////////////////////////////////////////////////////// +// +void Fleet::resetResources() +{ + m_Resources.clear() ; +} + ////////////////////////////////////////////////////////////////////////// // void Fleet::printFleet() @@ -654,6 +678,7 @@ void Fleet::distributeCappedRoids(std::vector fleets, int tick = 0) { string res = i->first; + cerr << "Distributing type: " << res << endl; for (vector::iterator j = i->second.begin(); j != i->second.end(); ++j) cout << (*j) << endl; @@ -678,17 +703,18 @@ void Fleet::distributeCappedRoids(std::vector fleets, int tick = 0) 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)->setResource(res, (*j)->resource(res,tick-1) + lost, tick); + + //(*j)->setResource(res, (*j)->resource(res,tick-1) + lost, tick); + (*j)->addResource(res,lost, tick); } } } ////////////////////////////////////////////////////////////////////////// // -void Fleet::addPodsForLostRoids(int tick = 1) + +void Fleet::addFleet(std::map units, int tick = 0) { - for (ResourceList::iterator i = m_Resources.begin(); i != m_Resources.end(); ++i) - { - setFleet("Astro Pod", fleet("Astro Pod", tick) + (resource(i->first, tick) - resource(i->first, tick - 1)), tick); - } + for (map::iterator i = units.begin(); i != units.end(); ++i) + addFleet(i->first, i->second, tick); } diff --git a/bs/fleet.h b/bs/fleet.h index 448d4de..93bdee7 100644 --- a/bs/fleet.h +++ b/bs/fleet.h @@ -106,6 +106,11 @@ public: * other is hardly used other than inside the engine. */ void setFleet(std::string unittype, int number, int tick = 0); + + void addFleet(std::string unittype, int number, int tick = 0); + + void addFleet(std::map units, int tick = 0); + /**Returns the numbers of units fo a specific type at a specific tick. * \param unittype The shipname, as a std string * \param tick The tick you want to look at, tick 0 (before battle) is default @@ -164,8 +169,6 @@ public: */ void distributeCappedRoids(std::vector fleets, int tick = 0); - void addPodsForLostRoids(int tick = 1); - /** Checks through the vector with fleets to see who's in time for the * specified tick and staying long enough so they're not too early. * \param fleets a vector with Fleet pointers to use for the calculations @@ -223,6 +226,7 @@ public: */ int resource(std::string type, int tick = 0)const; + void resetResources(); /** This is a little more advanced function. It makes a a number of units * of a specific unittype shoot at the current fleet and calculates the * losses. diff --git a/bs/planet.cpp b/bs/planet.cpp index 3c4404f..f57d208 100644 --- a/bs/planet.cpp +++ b/bs/planet.cpp @@ -146,6 +146,13 @@ void Planet::runBattle(std::vector friendly, std::vector hostile return; int skipped = 0; + + for (vector::iterator i = friendly.begin(); i != friendly.end(); ++i) + (*i)->resetResources(); + + for (vector::iterator i = hostile.begin(); i != hostile.end(); ++i) + (*i)->resetResources(); + for(int tick = 1; skipped < 20; ++tick) { //See who's in the battle at the current tick @@ -177,7 +184,9 @@ void Planet::runBattle(std::vector friendly, std::vector hostile //Reset roids for (RoidList::iterator roid = m_Roids.begin(); roid != m_Roids.end(); ++roid) + { setRoids(roid->first, roids(roid->first, tick-1), tick); + } setPlanetScore(planetScore(tick - 1), tick); @@ -188,7 +197,6 @@ void Planet::runBattle(std::vector friendly, std::vector hostile allFriends.distributeLossesGains(friends, tick); - allHostiles.addPodsForLostRoids(); allHostiles.distributeLossesGains(hostiles, tick); allHostiles.distributeCappedRoids(hostiles, tick); @@ -209,6 +217,14 @@ void Planet::runBattle(std::vector friendly, std::vector hostile // void Planet::calcOneTick(Planet* friendly, Fleet* hostile, std::map >& stealfriendly, std::map >& stealhostile, int tick = 1) { + if (planetScore(tick - 1) > 0) + setCapping(float(planetScore(tick - 1)) / hostile->score() / 10, tick); + else + setCapping(0, tick); + + map pods; + + map unitsinit; // order units after their ininitiative for (UnitList::iterator i = s_Units.begin(); i != s_Units.end(); ++i) unitsinit[i->second.initiative()] = i->first; @@ -241,38 +257,34 @@ void Planet::calcOneTick(Planet* friendly, Fleet* hostile, std::map 0) - { - setCapping(float(planetScore(tick - 1)) / hostile->score() / 10, tick); - - cerr << "Capping is: " << capping(tick) << endl; + cerr << "Capping is: " << capping(tick) << endl; - if (capping(tick) > 0) + if (capping(tick) > 0) + { + for (RoidList::iterator roid = m_Roids.begin(); roid != m_Roids.end(); ++roid) { - for (RoidList::iterator roid = m_Roids.begin(); roid != m_Roids.end(); ++roid) - { - int caproids = capping(tick) * roids(roid->first, tick - 1); - int freepods = hostiletemp->freeFleet(unittype, 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"; - cerr << freepods << " free pods available\n"; - - if (freepods <= 0) - break; - if (freepods < caproids) - caproids = freepods; + cerr << "Possible to steal " << caproids << " " << roid->first << " roids\n"; + cerr << freepods << " free pods available\n"; + + if (freepods <= 0) + break; + if (freepods < caproids) + caproids = freepods; - cerr << caproids << " roids stolen\n"; + cerr << caproids << " roids stolen\n"; - takeRoids(roid->first, caproids, tick); + 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. - hostiletemp->killFleet(unittype, caproids, 1); - //int totroids = caproids + hostiletemp->resource(roid->first, 0); - hostiletemp->addResource(roid->first, caproids, 1); + //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. + hostiletemp->killFleet(unittype, caproids, 1); + pods[unittype] += caproids; + //int totroids = caproids + hostiletemp->resource(roid->first, 0); + hostiletemp->addResource(roid->first, caproids, 1); - cerr << caproids << " stolen " << roid->first << " roids\n"; - } + cerr << caproids << " stolen " << roid->first << " roids\n"; } } } @@ -283,6 +295,8 @@ void Planet::calcOneTick(Planet* friendly, Fleet* hostile, std::mapaddFleet(pods, 1); + } ////////////////////////////////////////////////////////////////////////// diff --git a/bs/ui/resourceview.ui b/bs/ui/resourceview.ui index 376a60a..971f006 100644 --- a/bs/ui/resourceview.ui +++ b/bs/ui/resourceview.ui @@ -62,7 +62,7 @@ - EoniumEdit + UninitEdit NoFocus @@ -92,7 +92,7 @@ - UninitEdit + EoniumEdit NoFocus -- 2.39.2 From 7311d423f454c500dbc60dd822007da3981b0d56 Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Thu, 9 May 2002 17:22:01 +0000 Subject: [PATCH 02/16] added code so you lose ships if you steal.. --- bs/bsdoc.cpp | 1 + bs/bsview.cpp | 3 + bs/fleet.cpp | 36 ++++++++- bs/fleet.h | 22 ++++-- bs/planet.cpp | 6 ++ bs/ui/infoview.ui | 176 +++++++++++++++++++++++--------------------- bs/ui/infoview.ui.h | 13 +++- 7 files changed, 162 insertions(+), 95 deletions(-) diff --git a/bs/bsdoc.cpp b/bs/bsdoc.cpp index 11042b7..462dc75 100644 --- a/bs/bsdoc.cpp +++ b/bs/bsdoc.cpp @@ -69,6 +69,7 @@ int BSDoc::newBattle(QString name) 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]["Friendly"]["Home Fleet"]->setStays(-1); m_Battles[name]["Hostile"]["Evil guy"]->setName("Evil guy"); m_Battles[name]["Hostile"]["Evil guy"]->setETA(1); diff --git a/bs/bsview.cpp b/bs/bsview.cpp index 7adc6db..df3f558 100644 --- a/bs/bsview.cpp +++ b/bs/bsview.cpp @@ -278,6 +278,7 @@ void BSView::slotInfoApply() fl->setETA(m_InfoView->eta()); fl->setName(m_sFleet.latin1()); fl->setRace(m_InfoView->race().latin1()); + fl->setStays(m_InfoView->stays()); m_doc->newFleet(m_sBattle, m_sGroup, m_sFleet, fl); } @@ -317,6 +318,7 @@ void BSView::slotInfoNew() fl->setETA(m_InfoView->eta()); fl->setName(m_sFleet.latin1()); fl->setRace(m_InfoView->race().latin1()); + fl->setStays(m_InfoView->stays()); m_doc->newFleet(m_sBattle, m_sGroup, m_sFleet, fl); @@ -365,6 +367,7 @@ void BSView::updateInfoView() m_InfoView->setEta(fl->ETA()); m_InfoView->setGroup(m_sGroup); m_InfoView->setBattle(m_sBattle); + m_InfoView->setStays(fl->stays()); } ////////////////////////////////////////////////////////////////////////// diff --git a/bs/fleet.cpp b/bs/fleet.cpp index 136ad22..3df0972 100644 --- a/bs/fleet.cpp +++ b/bs/fleet.cpp @@ -28,6 +28,7 @@ UnitList Fleet::s_Units; Fleet::Fleet() { m_iETA = 0; + m_iStays = 3; m_sRace = "Cathaar"; } @@ -332,12 +333,12 @@ std::vector Fleet::calculateSide(std::vector fleets, int stays = vector fl; for (vector::iterator i = fleets.begin(); i != fleets.end(); ++i) { - if (( tick - (*i)->ETA()) >= 0 && (tick - (*i)->ETA()) < stays) + if (( tick - (*i)->ETA()) >= 0 && (tick - (*i)->ETA()) < (*i)->stays()) { fl.push_back((*i)); cerr << "Using fleet " << (*i)->name() << " for tick " << tick << endl; } - else if ((*i)->name() == "Home Planet") + else if ((*i)->stays() < 0) fl.push_back((*i)); } return fl; @@ -712,9 +713,38 @@ void Fleet::distributeCappedRoids(std::vector fleets, int tick = 0) ////////////////////////////////////////////////////////////////////////// // - void Fleet::addFleet(std::map units, int tick = 0) { for (map::iterator i = units.begin(); i != units.end(); ++i) addFleet(i->first, i->second, tick); } + +////////////////////////////////////////////////////////////////////////// +// +int Fleet::stays() const +{ + return m_iStays; +} + +////////////////////////////////////////////////////////////////////////// +// +void Fleet::setStays(int ticks) +{ + m_iStays = ticks; +} + +////////////////////////////////////////////////////////////////////////// +// +void Fleet::calculateLostStealships(string unittype, std::map stolen, int tick = 1) +{ + int stealscore = 0; + for (map::iterator i = stolen.begin(); i != stolen.end(); ++i) + { + stealscore += stolen[i->first] * (s_Units[i->first].totRes() / 10.0); + } + + int lost = stealscore / (s_Units[unittype].totRes() / 10.0); + + cerr << "Lost " << lost << " " << unittype << " due to stealing ships worth: " << stealscore << endl; + killFleet(unittype, lost, tick); +} diff --git a/bs/fleet.h b/bs/fleet.h index 93bdee7..3c690fd 100644 --- a/bs/fleet.h +++ b/bs/fleet.h @@ -227,6 +227,13 @@ public: int resource(std::string type, int tick = 0)const; void resetResources(); + + /** This function tells how many ticks the fleet stays at it's target. + * \returns the number of ticks as an int. + */ + int stays() const; + void setStays(int ticks); + /** This is a little more advanced function. It makes a a number of units * of a specific unittype shoot at the current fleet and calculates the * losses. @@ -257,6 +264,8 @@ public: */ void takeEMP(std::string unittype, int number); + void calculateLostStealships(std::string unittype, std::map stolen, int tick = 1); + /** This function prints out all the ships in the fleet to stderr, * mainly used for debugging. */ @@ -288,13 +297,14 @@ public: protected: - std::string m_sName; - std::string m_sRace; - int m_iETA; - FleetList m_Fleet; - FleetList m_BlockedFleet; + std::string m_sName; + std::string m_sRace; + int m_iETA; + FleetList m_Fleet; + FleetList m_BlockedFleet; ResourceList m_Resources; - ArmorList m_Armor; + ArmorList m_Armor; + int m_iStays; diff --git a/bs/planet.cpp b/bs/planet.cpp index f57d208..d62bf57 100644 --- a/bs/planet.cpp +++ b/bs/planet.cpp @@ -23,6 +23,7 @@ using namespace std; Planet::Planet() { m_sRace = "Planet"; + m_iStays = -1; } Planet::~Planet(){ @@ -225,6 +226,7 @@ void Planet::calcOneTick(Planet* friendly, Fleet* hostile, std::map pods; + //FIXME: Need to change this and allow multiple shiptypes with the same initiative. map unitsinit; // order units after their ininitiative for (UnitList::iterator i = s_Units.begin(); i != s_Units.end(); ++i) unitsinit[i->second.initiative()] = i->first; @@ -247,6 +249,9 @@ void Planet::calcOneTick(Planet* friendly, Fleet* hostile, std::maptakeShoot(unittype, friendly->freeFleet(unittype, 1), stealfriendly[unittype]); friendlytemp->takeShoot(unittype, hostile->freeFleet(unittype, 1), stealhostile[unittype]); + + friendlytemp->calculateLostStealships(unittype, stealfriendly[unittype], 1); + hostiletemp->calculateLostStealships(unittype, stealhostile[unittype], 1); } else { @@ -257,6 +262,7 @@ void Planet::calcOneTick(Planet* friendly, Fleet* hostile, std::map 0) diff --git a/bs/ui/infoview.ui b/bs/ui/infoview.ui index 33135f7..bb57b75 100644 --- a/bs/ui/infoview.ui +++ b/bs/ui/infoview.ui @@ -9,9 +9,9 @@ 0 - 0 + 4 267 - 198 + 221 @@ -25,7 +25,7 @@ 32767 - 200 + 221 @@ -36,10 +36,10 @@ unnamed - 3 + 0 - 2 + 0 @@ -89,72 +89,7 @@ NoInsertion - - - RaceLabel - - - &Race - - - RaceCombo - - - - - NameLine - - - - - NameLabel - - - Na&me - - - NameLine - - - - - RaceCombo - - - - - EtaLabel - - - E&ta - - - EtaSpin - - - - - EtaSpin - - - - - Spacer3 - - - Vertical - - - Expanding - - - - 20 - 20 - - - - + Layout13 @@ -185,7 +120,7 @@ - + Spacer1 @@ -194,12 +129,6 @@ Expanding - - - 20 - 20 - - @@ -225,8 +154,8 @@ - - + + Spacer4 @@ -235,13 +164,88 @@ Expanding - - - 20 - 20 - + + + + RaceLabel + + + &Race + + + RaceCombo + + + + + RaceCombo + + + + + Spacer3 + + + Vertical + + + Expanding + + + NameLabel + + + Na&me + + + NameLine + + + + + EtaLabel + + + E&ta + + + EtaSpin + + + + + NameLine + + + + + EtaSpin + + + + + StayLabel + + + Stays + + + StaySpin + + + Sets the number of ticks the fleet stays at the target, usually 3 for hostile and 6 for friendly. The fleet is disabled if stays is 0, and it stays the whole battle if it's -1 + + + + + StaySpin + + + -1 + + @@ -323,6 +327,8 @@ group() race() slotNameChanged( const QString & s ) + stays() + setStays( int ticks ) diff --git a/bs/ui/infoview.ui.h b/bs/ui/infoview.ui.h index a50bb95..1a7d70d 100644 --- a/bs/ui/infoview.ui.h +++ b/bs/ui/infoview.ui.h @@ -148,4 +148,15 @@ void InfoView::slotNameChanged( const QString & s ) ApplyButton->setEnabled(true); NewButton->setEnabled(false); } -} \ No newline at end of file +} + + +int InfoView::stays() +{ + return StaySpin->value(); +} + +void InfoView::setStays( int ticks ) +{ + StaySpin->setValue(ticks); +} -- 2.39.2 From 6ab17155b82923f4263f1c536133e657970239a4 Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Fri, 10 May 2002 00:26:00 +0000 Subject: [PATCH 03/16] much better indenting.. (thnx vim ;) --- bs/ui/bsappbase.ui.h | 112 +++++++++++++++++------------------ bs/ui/infoview.ui.h | 124 +++++++++++++++++++-------------------- bs/ui/resourceview.ui.h | 42 ++++++------- bs/ui/roidseditview.ui.h | 66 ++++++++++----------- bs/ui/tickviewbase.ui.h | 70 +++++++++++----------- 5 files changed, 207 insertions(+), 207 deletions(-) diff --git a/bs/ui/bsappbase.ui.h b/bs/ui/bsappbase.ui.h index 0b3b30a..305a4ca 100644 --- a/bs/ui/bsappbase.ui.h +++ b/bs/ui/bsappbase.ui.h @@ -1,12 +1,12 @@ /**************************************************************************** -** ui.h extension file, included from the uic-generated form implementation. -** -** If you wish to add, delete or rename slots use Qt Designer which will -** update this file, preserving your code. Create an init() slot in place of -** a constructor, and a destroy() slot in place of a destructor. -*****************************************************************************/ + ** ui.h extension file, included from the uic-generated form implementation. + ** + ** If you wish to add, delete or rename slots use Qt Designer which will + ** update this file, preserving your code. Create an init() slot in place of + ** a constructor, and a destroy() slot in place of a destructor. + *****************************************************************************/ + - void BSAppBase::fileNew() { @@ -55,12 +55,12 @@ void BSAppBase::editCut() void BSAppBase::init() { - conf = new BSConf(); - doc = new BSDoc(); - view = new BSView(this,doc); - connect(this, SIGNAL(ticksChanged(int, int) ), view, SLOT(slotTickChanged(int, int))); - connect(this, SIGNAL(resultModeChanged(int) ), view, SLOT(slotResultModeChanged(int))); - setCentralWidget(view); + conf = new BSConf(); + doc = new BSDoc(); + view = new BSView(this,doc); + connect(this, SIGNAL(ticksChanged(int, int) ), view, SLOT(slotTickChanged(int, int))); + connect(this, SIGNAL(resultModeChanged(int) ), view, SLOT(slotResultModeChanged(int))); + setCentralWidget(view); } void BSAppBase::editPaste() @@ -90,78 +90,78 @@ void BSAppBase::helpAbout() void BSAppBase::battleNew() { - bool ok = FALSE; - QString text = QInputDialog::getText( - tr( "Harvalen's Battlesystem" ), - tr( "Please enter the name of the battle (for example coords)" ), - QLineEdit::Normal, QString::null, &ok, this ); - if ( ok && !text.isEmpty() ) - doc->newBattle(text); - else + bool ok = FALSE; + QString text = QInputDialog::getText( + tr( "Harvalen's Battlesystem" ), + tr( "Please enter the name of the battle (for example coords)" ), + QLineEdit::Normal, QString::null, &ok, this ); + if ( ok && !text.isEmpty() ) + doc->newBattle(text); + else { - // user entered nothing or pressed Cancel + // user entered nothing or pressed Cancel } } void BSAppBase::battleSimulate() { - QApplication::setOverrideCursor( Qt::WaitCursor ); - - doc->runBattleSimulation(); - QApplication::restoreOverrideCursor(); + QApplication::setOverrideCursor( Qt::WaitCursor ); + + doc->runBattleSimulation(); + QApplication::restoreOverrideCursor(); } void BSAppBase::oneTickCheck_toggled( bool b) { - if(b) - { - maxTickSpin->setMinValue(0); - minTickSpin->setDisabled(true); - minTickSpin->setMaxValue(99); - emit ticksChanged( maxTickSpin->value() - 1, maxTickSpin->value()); - } - else - { - minTickSpin->setEnabled(true); - minTickSpin->setMaxValue( maxTickSpin->value()); - if (minTickSpin->value() < maxTickSpin->value()) - maxTickSpin->setMinValue( minTickSpin->value()); + if(b) + { + maxTickSpin->setMinValue(0); + minTickSpin->setDisabled(true); + minTickSpin->setMaxValue(99); + emit ticksChanged( maxTickSpin->value() - 1, maxTickSpin->value()); + } else { - maxTickSpin->setMinValue( maxTickSpin->value()); - minTickSpin->setValue(maxTickSpin->value()); + minTickSpin->setEnabled(true); + minTickSpin->setMaxValue( maxTickSpin->value()); + if (minTickSpin->value() < maxTickSpin->value()) + maxTickSpin->setMinValue( minTickSpin->value()); + else + { + maxTickSpin->setMinValue( maxTickSpin->value()); + minTickSpin->setValue(maxTickSpin->value()); + } + emit ticksChanged( minTickSpin->value(), maxTickSpin->value()); } - emit ticksChanged( minTickSpin->value(), maxTickSpin->value()); - } } void BSAppBase::minTickSpin_valueChanged( int i ) { - if ( !oneTickCheck->isChecked()) - maxTickSpin->setMinValue(i); + if ( !oneTickCheck->isChecked()) + maxTickSpin->setMinValue(i); } void BSAppBase::maxTickSpin_valueChanged( int i ) { - if ( !oneTickCheck->isChecked()) - minTickSpin->setMaxValue(i); + if ( !oneTickCheck->isChecked()) + minTickSpin->setMaxValue(i); } void BSAppBase::slotTicksChanged( int i ) { - if ( oneTickCheck->isChecked()) - { - maxTickSpin->setValue(i); - //minTickSpin->setValue(i-1); - emit ticksChanged( maxTickSpin->value() - 1, maxTickSpin->value()); - return; - } - emit ticksChanged( minTickSpin->value(), maxTickSpin->value()); + if ( oneTickCheck->isChecked()) + { + maxTickSpin->setValue(i); + //minTickSpin->setValue(i-1); + emit ticksChanged( maxTickSpin->value() - 1, maxTickSpin->value()); + return; + } + emit ticksChanged( minTickSpin->value(), maxTickSpin->value()); } void BSAppBase::resultModeCombo_activated( int i ) { - emit resultModeChanged(i); + emit resultModeChanged(i); } diff --git a/bs/ui/infoview.ui.h b/bs/ui/infoview.ui.h index 1a7d70d..14ee7ed 100644 --- a/bs/ui/infoview.ui.h +++ b/bs/ui/infoview.ui.h @@ -10,42 +10,42 @@ void InfoView::destroy() void InfoView::setRaces( std::vector races) { - for (std::vector::iterator i = races.begin(); i != races.end(); ++i) - { - RaceCombo->insertItem((*i)); - } - if ( RaceCombo->count() != 0) - NewButton->setEnabled(true); + for (std::vector::iterator i = races.begin(); i != races.end(); ++i) + { + RaceCombo->insertItem((*i)); + } + if ( RaceCombo->count() != 0) + NewButton->setEnabled(true); } void InfoView::setEta( int eta ) { - EtaSpin->setValue(eta); + EtaSpin->setValue(eta); } void InfoView::setFleetName( QString name ) { - NameLine->setText(name); - m_Name = name; - if (m_Name == "Home Planet" && m_Group == "Friendly") - { - GroupCombo->setEnabled(false); - BattleCombo->setEnabled(false); + NameLine->setText(name); + m_Name = name; + if (m_Name == "Home Planet" && m_Group == "Friendly") + { + GroupCombo->setEnabled(false); + BattleCombo->setEnabled(false); + ApplyButton->setEnabled(true); + NewButton->setEnabled(false); + RemoveButton->setEnabled(false); + return; + } + GroupCombo->setEnabled(true); + BattleCombo->setEnabled(true); ApplyButton->setEnabled(true); - NewButton->setEnabled(false); - RemoveButton->setEnabled(false); - return; - } - GroupCombo->setEnabled(true); - BattleCombo->setEnabled(true); - ApplyButton->setEnabled(true); - NewButton->setEnabled(true); - RemoveButton->setEnabled(true); + NewButton->setEnabled(true); + RemoveButton->setEnabled(true); } void InfoView::setRace( QString name ) { - RaceCombo->setCurrentText(name); + RaceCombo->setCurrentText(name); } void InfoView::InfoView_destroyed( QObject * ) @@ -55,108 +55,108 @@ void InfoView::InfoView_destroyed( QObject * ) void InfoView::CancelButton_clicked() { - emit cancel(); + emit cancel(); } void InfoView::NewButton_clicked() { - emit add(); + emit add(); } void InfoView::RemoveButton_clicked() { - emit remove(); + emit remove(); } void InfoView::setGroup( QString s ) { - GroupCombo->setCurrentText(s); - m_Group = s; + GroupCombo->setCurrentText(s); + m_Group = s; } void InfoView::setBattles( std::vector battles ) { - BattleCombo->clear(); - - for (std::vector::iterator i = battles.begin(); i != battles.end(); ++i) - { - BattleCombo->insertItem(*i); - } + BattleCombo->clear(); + + for (std::vector::iterator i = battles.begin(); i != battles.end(); ++i) + { + BattleCombo->insertItem(*i); + } } void InfoView::setBattle( QString s ) { - BattleCombo->setCurrentText(s); - m_Battle = s; + BattleCombo->setCurrentText(s); + m_Battle = s; } void InfoView::enableNameChange( bool b ) { - NameLine->setReadOnly(!b); + NameLine->setReadOnly(!b); } void InfoView::enableRemove( bool b ) { - RemoveButton->setEnabled(b); + RemoveButton->setEnabled(b); } void InfoView::ApplyButton_clicked() { - emit apply(); + emit apply(); } QString InfoView::battle() { - return BattleCombo->currentText(); + return BattleCombo->currentText(); } int InfoView::eta() { - return EtaSpin->value(); + return EtaSpin->value(); } QString InfoView::fleetName() { - return NameLine->text(); + return NameLine->text(); } QString InfoView::group() { - return GroupCombo->currentText(); + return GroupCombo->currentText(); } QString InfoView::race() { - return RaceCombo->currentText(); + return RaceCombo->currentText(); } void InfoView::slotNameChanged( const QString & s ) { - if (s != "Home Planet" && m_Name == "Home Planet" && m_Group == "Friendly") - { - GroupCombo->setEnabled(true); - BattleCombo->setEnabled(true); - ApplyButton->setEnabled(false); - NewButton->setEnabled(true); - } - if (s == "Home Planet" && m_Name == "Home Planet" && m_Group == "Friendly") - { - GroupCombo->setEnabled(false); - GroupCombo->setCurrentText(m_Group); - BattleCombo->setEnabled(false); - BattleCombo->setCurrentText(m_Battle); - ApplyButton->setEnabled(true); - NewButton->setEnabled(false); - } + if (s != "Home Planet" && m_Name == "Home Planet" && m_Group == "Friendly") + { + GroupCombo->setEnabled(true); + BattleCombo->setEnabled(true); + ApplyButton->setEnabled(false); + NewButton->setEnabled(true); + } + if (s == "Home Planet" && m_Name == "Home Planet" && m_Group == "Friendly") + { + GroupCombo->setEnabled(false); + GroupCombo->setCurrentText(m_Group); + BattleCombo->setEnabled(false); + BattleCombo->setCurrentText(m_Battle); + ApplyButton->setEnabled(true); + NewButton->setEnabled(false); + } } int InfoView::stays() { - return StaySpin->value(); + return StaySpin->value(); } void InfoView::setStays( int ticks ) { - StaySpin->setValue(ticks); + StaySpin->setValue(ticks); } diff --git a/bs/ui/resourceview.ui.h b/bs/ui/resourceview.ui.h index 485c4e5..a193871 100644 --- a/bs/ui/resourceview.ui.h +++ b/bs/ui/resourceview.ui.h @@ -1,27 +1,27 @@ /**************************************************************************** -** ui.h extension file, included from the uic-generated form implementation. -** -** If you wish to add, delete or rename slots use Qt Designer which will -** update this file, preserving your code. Create an init() slot in place of -** a constructor, and a destroy() slot in place of a destructor. -*****************************************************************************/ + ** ui.h extension file, included from the uic-generated form implementation. + ** + ** If you wish to add, delete or rename slots use Qt Designer which will + ** update this file, preserving your code. Create an init() slot in place of + ** a constructor, and a destroy() slot in place of a destructor. + *****************************************************************************/ //test void ResourceView::setLines( QString type, float i ) { - if (type == tr("metal")) - MetalEdit->setText(QString("%1").arg(i)); - else if (type == tr("crystal")) - CrystalEdit->setText(QString("%1").arg(i)); - else if (type == tr("eonium")) - EoniumEdit->setText(QString("%1").arg(i)); - else if (type == tr("uninit")) - UninitEdit->setText(QString("%1").arg(i)); - else if (type == tr("score")) - ScoreEdit->setText(QString("%1").arg(i)); - else if (type == tr("lost")) - ScoreLostEdit->setText(QString("%1").arg(i)); - else if (type == tr("cost")) - CostEdit->setText(QString("%1").arg(i)); -} \ No newline at end of file + if (type == tr("metal")) + MetalEdit->setText(QString("%1").arg(i)); + else if (type == tr("crystal")) + CrystalEdit->setText(QString("%1").arg(i)); + else if (type == tr("eonium")) + EoniumEdit->setText(QString("%1").arg(i)); + else if (type == tr("uninit")) + UninitEdit->setText(QString("%1").arg(i)); + else if (type == tr("score")) + ScoreEdit->setText(QString("%1").arg(i)); + else if (type == tr("lost")) + ScoreLostEdit->setText(QString("%1").arg(i)); + else if (type == tr("cost")) + CostEdit->setText(QString("%1").arg(i)); +} diff --git a/bs/ui/roidseditview.ui.h b/bs/ui/roidseditview.ui.h index 55d22b5..0755205 100644 --- a/bs/ui/roidseditview.ui.h +++ b/bs/ui/roidseditview.ui.h @@ -1,10 +1,10 @@ /**************************************************************************** -** ui.h extension file, included from the uic-generated form implementation. -** -** If you wish to add, delete or rename slots use Qt Designer which will -** update this file, preserving your code. Create an init() slot in place of -** a constructor, and a destroy() slot in place of a destructor. -*****************************************************************************/ + ** ui.h extension file, included from the uic-generated form implementation. + ** + ** If you wish to add, delete or rename slots use Qt Designer which will + ** update this file, preserving your code. Create an init() slot in place of + ** a constructor, and a destroy() slot in place of a destructor. + *****************************************************************************/ void RoidsEditView::init() { @@ -13,25 +13,25 @@ void RoidsEditView::init() void RoidsEditView::setValue( const QString & type, unsigned value ) { - if (type == tr("metal")) - MetalEdit->setText(QString("%1").arg(value)); - else if (type == tr("crystal")) - CrystalEdit->setText(QString("%1").arg(value)); - else if (type == tr("eonium")) - EoniumEdit->setText(QString("%1").arg(value)); - else if (type == tr("uninit")) - UninitEdit->setText(QString("%1").arg(value)); - else if (type == tr("score")) - ScoreEdit->setText(QString("%1").arg(value)); - - + if (type == tr("metal")) + MetalEdit->setText(QString("%1").arg(value)); + else if (type == tr("crystal")) + CrystalEdit->setText(QString("%1").arg(value)); + else if (type == tr("eonium")) + EoniumEdit->setText(QString("%1").arg(value)); + else if (type == tr("uninit")) + UninitEdit->setText(QString("%1").arg(value)); + else if (type == tr("score")) + ScoreEdit->setText(QString("%1").arg(value)); + + } void RoidsEditView::slotValueChanged() { QString type = sender()->name(); - + if (type == "MetalEdit") type = tr("metal"); else if (type == "CrystalEdit") @@ -45,22 +45,22 @@ void RoidsEditView::slotValueChanged() test = type; const QLineEdit *le = dynamic_cast(sender()); if (le) - emit changed(type, le->text().toInt()); + emit changed(type, le->text().toInt()); } void RoidsEditView::slotSetLost( QString type, float i ) { - if (type == tr("metal")) - MetalLostEdit->setText(QString("%1").arg(i)); - else if (type == tr("crystal")) - CrystalLostEdit->setText(QString("%1").arg(i)); - else if (type == tr("eonium")) - EoniumLostEdit->setText(QString("%1").arg(i)); - else if (type == tr("uninit")) - UninitLostEdit->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 + if (type == tr("metal")) + MetalLostEdit->setText(QString("%1").arg(i)); + else if (type == tr("crystal")) + CrystalLostEdit->setText(QString("%1").arg(i)); + else if (type == tr("eonium")) + EoniumLostEdit->setText(QString("%1").arg(i)); + else if (type == tr("uninit")) + UninitLostEdit->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)); +} diff --git a/bs/ui/tickviewbase.ui.h b/bs/ui/tickviewbase.ui.h index 026be8c..d37d629 100644 --- a/bs/ui/tickviewbase.ui.h +++ b/bs/ui/tickviewbase.ui.h @@ -1,52 +1,52 @@ /**************************************************************************** -** ui.h extension file, included from the uic-generated form implementation. -** -** Add custom slot implementations here. Use a slot init() for -** initialization code called during construction, and a slot destroy() -** for cleanup code called during destruction. -** -** This file gets modified by Qt Designer whenever you add, rename or -** remove custom slots. Implementation code does not get lost. -*****************************************************************************/ + ** ui.h extension file, included from the uic-generated form implementation. + ** + ** Add custom slot implementations here. Use a slot init() for + ** initialization code called during construction, and a slot destroy() + ** for cleanup code called during destruction. + ** + ** This file gets modified by Qt Designer whenever you add, rename or + ** remove custom slots. Implementation code does not get lost. + *****************************************************************************/ void CTickViewBase::slotMaxTick(int i) { - if ( !oneTickCheck->isChecked()) - minTickSpin->setMaxValue(i); - + if ( !oneTickCheck->isChecked()) + minTickSpin->setMaxValue(i); + } void CTickViewBase::slotMinTick( int i ) { - if ( !oneTickCheck->isChecked()) - maxTickSpin->setMinValue(i); + if ( !oneTickCheck->isChecked()) + maxTickSpin->setMinValue(i); } void CTickViewBase::slotTickChanged(int i) { - if ( oneTickCheck->isChecked()) - { - maxTickSpin->setValue(i); - //minTickSpin->setValue(i-1); - emit ticksChanged( maxTickSpin->value() - 1, maxTickSpin->value()); - return; - } - emit ticksChanged( minTickSpin->value(), maxTickSpin->value()); + if ( oneTickCheck->isChecked()) + { + maxTickSpin->setValue(i); + //minTickSpin->setValue(i-1); + emit ticksChanged( maxTickSpin->value() - 1, maxTickSpin->value()); + return; + } + emit ticksChanged( minTickSpin->value(), maxTickSpin->value()); } void CTickViewBase::slotOneTick( bool b ) { - if(b) - { - maxTickSpin->setMinValue(0); - minTickSpin->setDisabled(true); - minTickSpin->setMaxValue(99); - } - else - { - minTickSpin->setEnabled(true); - maxTickSpin->setMinValue( minTickSpin->value()); - minTickSpin->setMaxValue( maxTickSpin->value()); - } -} \ No newline at end of file + if(b) + { + maxTickSpin->setMinValue(0); + minTickSpin->setDisabled(true); + minTickSpin->setMaxValue(99); + } + else + { + minTickSpin->setEnabled(true); + maxTickSpin->setMinValue( minTickSpin->value()); + minTickSpin->setMaxValue( maxTickSpin->value()); + } +} -- 2.39.2 From 924d4cd0f8c9c340c8ba6f2e5759fed8f0c83573 Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Fri, 10 May 2002 12:33:31 +0000 Subject: [PATCH 04/16] hbs now handles salvage.. not fully correctly yet though, need to fix the calculations when stolen ships is in.. --- bs/bsconf.cpp | 5 +++- bs/fleet.cpp | 55 ++++++++++++++++++++++++++++++++++++++++++- bs/fleet.h | 3 +++ bs/planet.cpp | 9 ++++++- bs/ui/infoview.ui | 4 ++-- bs/ui/resourceview.ui | 8 +++---- bs/unittype.cpp | 23 +++++++++++++++--- bs/unittype.h | 27 +++++++++++---------- 8 files changed, 110 insertions(+), 24 deletions(-) diff --git a/bs/bsconf.cpp b/bs/bsconf.cpp index 478b8d4..816fd09 100644 --- a/bs/bsconf.cpp +++ b/bs/bsconf.cpp @@ -112,7 +112,10 @@ bool BSConf::loadStats() t1 >> metal; t1 >> crystal; t1 >> eonium; - units[race].setTotalResources(metal.toInt() + crystal.toInt() + eonium.toInt()); + units[race].setResources(tr("metal").latin1(), metal.toInt()); + units[race].setResources(tr("crystal").latin1(), crystal.toInt()); + units[race].setResources(tr("eonium").latin1(), eonium.toInt()); + //units[race].setTotalResources(metal.toInt() + crystal.toInt() + eonium.toInt()); t1 >> temp; units[race].setFuel(temp.toInt()); t1 >> temp; diff --git a/bs/fleet.cpp b/bs/fleet.cpp index 3df0972..19bc386 100644 --- a/bs/fleet.cpp +++ b/bs/fleet.cpp @@ -223,10 +223,14 @@ void Fleet::addFleet(std::string unittype, int number, int tick = 0) // int Fleet::fleet(string unittype, int tick = 0) { + int ticks = m_Fleet[unittype].size(); if (ticks == 0) return 0; + if (tick < 0) + return m_Fleet[unittype][0]; + --ticks; if (ticks < tick) @@ -333,7 +337,9 @@ std::vector Fleet::calculateSide(std::vector fleets, int stays = vector fl; for (vector::iterator i = fleets.begin(); i != fleets.end(); ++i) { - if (( tick - (*i)->ETA()) >= 0 && (tick - (*i)->ETA()) < (*i)->stays()) + if ((*i)->stays() == 0) + continue; + else if (( tick - (*i)->ETA()) >= 0 && (tick - (*i)->ETA()) < (*i)->stays()) { fl.push_back((*i)); cerr << "Using fleet " << (*i)->name() << " for tick " << tick << endl; @@ -748,3 +754,50 @@ void Fleet::calculateLostStealships(string unittype, std::map cerr << "Lost " << lost << " " << unittype << " due to stealing ships worth: " << stealscore << endl; killFleet(unittype, lost, tick); } + +////////////////////////////////////////////////////////////////////////// +// +void Fleet::distributeStolenShips(std::map > stolen, std::vector fleets, int tick = 0) +{ + for(map >::iterator i = stolen.begin(); i != stolen.end(); ++i) + { + int totalstealers = 0; + for (vector::iterator j = fleets.begin(); j != fleets.end(); ++j) + totalstealers += (*j)->fleet(i->first, tick - 1); + + for (map::iterator j = i->second.begin(); j != i->second.end(); ++j) + { + for (vector::iterator k = fleets.begin(); k != fleets.end(); ++k) + { + int stolen = float ((*k)->fleet(i->first, tick - 1)) / totalstealers * j->second; + (*k)->addFleet(j->first, stolen, tick); + } + } + } +} + +////////////////////////////////////////////////////////////////////////// +// +void Fleet::calculateSalvage() +{ + for (FleetList::iterator i = m_Fleet.begin(); i != m_Fleet.end(); ++i) + { + + map res = s_Units[i->first].resources(); + + if (i->second.size() > 0) + cerr << endl << i->first << ": "; + + int tick = 0; + for (vector::iterator j = i->second.begin(); j != i->second.end(); ++j, ++tick) + { + int lostunits = fleet(i->first, tick - 1) - fleet(i->first, tick); + + if (lostunits <= 0) + continue; + cerr << "(" << tick << ":" << fleet(i->first, tick) << ") "; + for (map::iterator k = res.begin(); k != res.end(); ++k) + addResource(k->first, lostunits * k->second * 0.25, tick); + } + } +} diff --git a/bs/fleet.h b/bs/fleet.h index 3c690fd..6696151 100644 --- a/bs/fleet.h +++ b/bs/fleet.h @@ -266,6 +266,9 @@ public: void calculateLostStealships(std::string unittype, std::map stolen, int tick = 1); + void distributeStolenShips(std::map > stolen, std::vector fleets, int tick = 0); + + void calculateSalvage(); /** This function prints out all the ships in the fleet to stderr, * mainly used for debugging. */ diff --git a/bs/planet.cpp b/bs/planet.cpp index d62bf57..f1290ff 100644 --- a/bs/planet.cpp +++ b/bs/planet.cpp @@ -197,9 +197,11 @@ void Planet::runBattle(std::vector friendly, std::vector hostile //allFriends.printFleet(); allFriends.distributeLossesGains(friends, tick); + allFriends.distributeStolenShips(stealfriendly, friends, tick); allHostiles.distributeLossesGains(hostiles, tick); allHostiles.distributeCappedRoids(hostiles, tick); + allHostiles.distributeStolenShips(stealhostile, hostiles, tick); calculateScoreLoss(friends, tick); @@ -207,6 +209,9 @@ void Planet::runBattle(std::vector friendly, std::vector hostile setRoids(i->first, roids(i->first, 1), tick);*/ } + for (vector::iterator i = friendly.begin(); i != friendly.end(); ++i) + (*i)->calculateSalvage(); + for (RoidList::iterator i = m_Roids.begin(); i != m_Roids.end(); ++i) { for (vector::iterator j = i->second.begin(); j != i->second.end(); ++j) @@ -346,6 +351,8 @@ void Planet::setCapping(float capping, int tick = 0) if (capping <= 0.15 && capping >= 0) m_Capping[tick] = capping; - else + else if (capping >= 0.15) m_Capping[tick] = 0.15; + else + m_Capping[tick] = 0; } diff --git a/bs/ui/infoview.ui b/bs/ui/infoview.ui index bb57b75..a8ed7ac 100644 --- a/bs/ui/infoview.ui +++ b/bs/ui/infoview.ui @@ -9,7 +9,7 @@ 0 - 4 + 0 267 221 @@ -235,7 +235,7 @@ StaySpin - Sets the number of ticks the fleet stays at the target, usually 3 for hostile and 6 for friendly. The fleet is disabled if stays is 0, and it stays the whole battle if it's -1 + Sets the number of ticks the fleet stays at the target, usually 3 for hostile and 6 for friendly. The fleet is disabled if stays is 0, and it stays the whole battle if it's -1 <p> <b>If you use -1 for an atttacker and it freeze, IT'S YOUR OWN FAULT! </b> diff --git a/bs/ui/resourceview.ui b/bs/ui/resourceview.ui index 971f006..71eae5a 100644 --- a/bs/ui/resourceview.ui +++ b/bs/ui/resourceview.ui @@ -10,8 +10,8 @@ 0 0 - 551 - 105 + 549 + 110 @@ -25,14 +25,14 @@ 0 - 105 + 110 QGroupBoxForm - Resources and Score + Roids/Salvage and Score diff --git a/bs/unittype.cpp b/bs/unittype.cpp index 20c30a3..36bd4ed 100644 --- a/bs/unittype.cpp +++ b/bs/unittype.cpp @@ -224,16 +224,33 @@ int UnitType::EMP() const ////////////////////////////////////////////////////////////////////////// // -void UnitType::setTotalResources(int iTR) +void UnitType::setResources(std::string type, int i) { - m_iTotalResources = iTR; + m_Resources[type] = i; +} + +////////////////////////////////////////////////////////////////////////// +// +void UnitType::setResources(map res) +{ + m_Resources = res; +} + +////////////////////////////////////////////////////////////////////////// +// +std::map UnitType::resources() +{ + return m_Resources; } ////////////////////////////////////////////////////////////////////////// // int UnitType::totRes() const { - return m_iTotalResources; + int totres = 0; + for (map::const_iterator i = m_Resources.begin(); i != m_Resources.end(); ++i) + totres += i->second; + return totres; } ////////////////////////////////////////////////////////////////////////// diff --git a/bs/unittype.h b/bs/unittype.h index b01de80..ccff1d1 100644 --- a/bs/unittype.h +++ b/bs/unittype.h @@ -134,10 +134,13 @@ public: int EMP() const; /** Sets the resource cost for this unittype. Used for example for score calculation and so on. */ - void setTotalResources(int iTR); + void setResources(std::string type, int i); + void setResources(std::map res); /** Returns the number of total resources this unittype cost. */ int totRes() const; + std::map resources(); + /** Sets the fuelcost for this unittype */ void setFuel(int iFuel); /** Returns the fuelcost */ @@ -158,17 +161,17 @@ protected: int m_iRace; //!< Not really the race, but an indiaction on what race can use it.. std::string m_sClass; std::vector m_vTarget; - int m_iInitiative; - int m_iAgility; - int m_iWeaponSpeed; - int m_iGuns; - int m_iPower; - int m_iArmor; - int m_iEMP; - int m_iTotalResources; - std::string m_sType; //!< normal,emp,cloak,steal,pod - int m_iETA; - int m_iFuel; + int m_iInitiative; + int m_iAgility; + int m_iWeaponSpeed; + int m_iGuns; + int m_iPower; + int m_iArmor; + int m_iEMP; + std::map m_Resources; + std::string m_sType; //!< normal,emp,cloak,steal,pod + int m_iETA; + int m_iFuel; }; #endif -- 2.39.2 From b308a9445cfe1883ea8068d3f4d1a04bfcff9aa8 Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Fri, 10 May 2002 20:45:27 +0000 Subject: [PATCH 05/16] Fixed a bug in the shipstealing code.. --- bs/fleet.cpp | 18 ++++++++++++++++++ bs/fleet.h | 1 + bs/planet.cpp | 4 ++-- bs/ui/resourceview.ui | 5 ++++- 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/bs/fleet.cpp b/bs/fleet.cpp index 19bc386..85304bb 100644 --- a/bs/fleet.cpp +++ b/bs/fleet.cpp @@ -801,3 +801,21 @@ void Fleet::calculateSalvage() } } } + +////////////////////////////////////////////////////////////////////////// +// +void Fleet::resetTicks() +{ + for (FleetList::iterator i = m_Fleet.begin(); i != m_Fleet.end(); ++i) + { + if ( i->second.size() < 2) + continue; + + int temp = i->second[0]; + i->second.clear(); + + if (temp > 0) + i->second.push_back(temp); + } + resetResources(); +} diff --git a/bs/fleet.h b/bs/fleet.h index 6696151..f632093 100644 --- a/bs/fleet.h +++ b/bs/fleet.h @@ -274,6 +274,7 @@ public: */ void printFleet(); + void resetTicks(); //static functions // /** This function is used to set the different races used. diff --git a/bs/planet.cpp b/bs/planet.cpp index f1290ff..4133277 100644 --- a/bs/planet.cpp +++ b/bs/planet.cpp @@ -149,10 +149,10 @@ void Planet::runBattle(std::vector friendly, std::vector hostile int skipped = 0; for (vector::iterator i = friendly.begin(); i != friendly.end(); ++i) - (*i)->resetResources(); + (*i)->resetTicks(); for (vector::iterator i = hostile.begin(); i != hostile.end(); ++i) - (*i)->resetResources(); + (*i)->resetTicks(); for(int tick = 1; skipped < 20; ++tick) { diff --git a/bs/ui/resourceview.ui b/bs/ui/resourceview.ui index 71eae5a..e1faa98 100644 --- a/bs/ui/resourceview.ui +++ b/bs/ui/resourceview.ui @@ -136,7 +136,10 @@ ScoreLostLabel - Lost + Difference + + + Shows the difference in score between the selected ticks. -- 2.39.2 From c3547560c3885eb7f7b436dd10acc17df71de101 Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Mon, 13 May 2002 16:17:51 +0000 Subject: [PATCH 06/16] some changes --- bs/fleet.cpp | 94 +++++++++++++++++++++++++--------------------------- hbs.kdevses | 6 +++- 2 files changed, 51 insertions(+), 49 deletions(-) diff --git a/bs/fleet.cpp b/bs/fleet.cpp index 85304bb..4fc5be5 100644 --- a/bs/fleet.cpp +++ b/bs/fleet.cpp @@ -1,9 +1,9 @@ /*************************************************************************** - fleet.cpp - description - ------------------- - begin : Tue Jan 22 2002 - copyright : (C) 2002 by Michael Andreen - email : whale@linux.nu + fleet.cpp - description + ------------------- +begin : Tue Jan 22 2002 +copyright : (C) 2002 by Michael Andreen +email : whale@linux.nu ***************************************************************************/ /*************************************************************************** @@ -118,29 +118,29 @@ void Fleet::setUnits(UnitList& units) { s_Units = units; - -/* - for (UnitList::iterator i = s_Units.begin(); i != s_Units.end(); i++) - { - cerr << s_Units[(*i).first].Name() << "\t\t" - << s_Units[(*i).first].race() <<"\t" - << s_Units[(*i).first].unitClass() << "\t" - << s_Units[(*i).first].target(0) << "\t" - << s_Units[(*i).first].target(1) << "\t" - << s_Units[(*i).first].target(2) << "\t" - << s_Units[(*i).first].initiative() << "\t" - << s_Units[(*i).first].agility() << "\t" - << s_Units[(*i).first].weaponSpeed() << "\t" - << s_Units[(*i).first].guns() << "\t" - << s_Units[(*i).first].power() << "\t" - << s_Units[(*i).first].armor() << "\t" - << s_Units[(*i).first].EMP() << "\t" - << s_Units[(*i).first].totRes() << "\t" - << s_Units[(*i).first].fuel() << "\t" - << s_Units[(*i).first].ETA() << "\t" - << s_Units[(*i).first].type() << endl; - } -*/ + + /* + for (UnitList::iterator i = s_Units.begin(); i != s_Units.end(); i++) + { + cerr << s_Units[(*i).first].Name() << "\t\t" + << s_Units[(*i).first].race() <<"\t" + << s_Units[(*i).first].unitClass() << "\t" + << s_Units[(*i).first].target(0) << "\t" + << s_Units[(*i).first].target(1) << "\t" + << s_Units[(*i).first].target(2) << "\t" + << s_Units[(*i).first].initiative() << "\t" + << s_Units[(*i).first].agility() << "\t" + << s_Units[(*i).first].weaponSpeed() << "\t" + << s_Units[(*i).first].guns() << "\t" + << s_Units[(*i).first].power() << "\t" + << s_Units[(*i).first].armor() << "\t" + << s_Units[(*i).first].EMP() << "\t" + << s_Units[(*i).first].totRes() << "\t" + << s_Units[(*i).first].fuel() << "\t" + << s_Units[(*i).first].ETA() << "\t" + << s_Units[(*i).first].type() << endl; + } + */ } ////////////////////////////////////////////////////////////////////////// @@ -272,13 +272,13 @@ void Fleet::setBlockedFleet(std::string unittype, int number, int tick = 0) } ////////////////////////////////////////////////////////////////////////// -//FIXME +// void Fleet::addToThis(std::vector fleets, int tick = 0) { for (UnitList::iterator i = s_Units.begin(); i != s_Units.end(); ++i) { if (m_Fleet[i->first].size() == 0) - m_Fleet[i->first].push_back(0); + m_Fleet[i->first].push_back(0); for (vector::iterator j = fleets.begin(); j != fleets.end(); ++j) { @@ -301,17 +301,17 @@ void Fleet::distributeLossesGains(std::vector fleets, int tick = 0) if (m_Fleet[unittype].size() < 1) continue; - if (m_Fleet[unittype][0] == 0) + if (m_Fleet[unittype][0] == 0) continue; - + int totallost = fleet(unittype,1) - fleet(unittype, 0); cerr << "Distributing type: " << unittype << " with a total loss of " << totallost << " units" << endl; cerr << "Total number of units before: " << fleet(unittype, 0) << " and after : " << fleet(unittype, 1) << endl; - + for (vector::iterator j = fleets.begin(); j != fleets.end(); ++j) { int fl1 = (*j)->fleet(unittype, tick - 1); @@ -376,7 +376,7 @@ void Fleet::takeShoot(std::string unittype, int number, std::map::iterator i = s_Units[unittype].target().begin(); i != s_Units[unittype].target().end(); ++i) { string ta = s_Units[unittype].target(count); - cerr << "Shooting at target class: " << ta << endl; + cerr << "Shooting at target class: " << ta << endl; while (gunsleft > 0) { - + map targets; for (UnitList::iterator j = s_Units.begin(); j != s_Units.end(); ++j) { - if (m_Fleet[j->first].size() == 0) continue; @@ -407,10 +406,9 @@ void Fleet::takeShoot(std::string unittype, int number, std::mapfirst][1] > 0 && ( ta == j->second.unitClass() || ta == "All")) { - // cerr << "Looking at target: " << j->first << endl; + // cerr << "Looking at target: " << j->first << endl; targets[j->first] = &m_Fleet[j->first][1]; } - } if (targets.size() == 0) @@ -450,13 +448,13 @@ void Fleet::takeShoot(std::string unittype, int number, std::mapfirst] = s_Units[j->first].armor(); (*j->second)--; hitunits[j->first]++; - + //There is a chance that we're hitting a blocked ship. if (m_BlockedFleet[j->first].size() >= 1) { int test = rand() % m_BlockedFleet[j->first][0]; if (test == 1 - && m_BlockedFleet[j->first][0] > 0) + && m_BlockedFleet[j->first][0] > 0) { if (m_BlockedFleet[j->first].size() == 1) m_BlockedFleet[j->first].push_back(m_BlockedFleet[j->first][0] - 1); @@ -492,10 +490,10 @@ void Fleet::takeEMP(std::string unittype, int number) for (int count = 0; count < 3; ++count)//vector::iterator i = s_Units[unittype].target().begin(); i != s_Units[unittype].target().end(); ++i) { string ta = s_Units[unittype].target(count); - cerr << "Shooting at target class: " << ta << endl; + cerr << "Shooting at target class: " << ta << endl; while (gunsleft > 0) { - + map targets; for (UnitList::iterator j = s_Units.begin(); j != s_Units.end(); ++j) @@ -517,7 +515,7 @@ void Fleet::takeEMP(std::string unittype, int number) if (m_Fleet[j->first][1] > 0 && ( ta == j->second.unitClass() || ta == "All")) { - // cerr << "Looking at target: " << j->first << endl; + // cerr << "Looking at target: " << j->first << endl; targets[j->first] = &m_Fleet[j->first][1]; } @@ -692,17 +690,17 @@ void Fleet::distributeCappedRoids(std::vector fleets, int tick = 0) if (m_Resources[res].size() < 2) continue; - if (m_Resources[res][1] == 0) + if (m_Resources[res][1] == 0) continue; - + int totcapped = resource(res,1) - resource(res, 0); cerr << "Distributing type: " << res << " with a total gain of " << totcapped << " roids" << endl; cerr << "Total number of roids before: " << resource(res, 0) << " and after : " << resource(res, 1) << endl; - + for (vector::iterator j = fleets.begin(); j != fleets.end(); ++j) { unsigned fl1 = (*j)->score(tick - 1); @@ -782,7 +780,7 @@ void Fleet::calculateSalvage() { for (FleetList::iterator i = m_Fleet.begin(); i != m_Fleet.end(); ++i) { - + map res = s_Units[i->first].resources(); if (i->second.size() > 0) diff --git a/hbs.kdevses b/hbs.kdevses index c5d9ecc..1d74bb1 100644 --- a/hbs.kdevses +++ b/hbs.kdevses @@ -2,6 +2,10 @@ - + + + + + (Default) -- 2.39.2 From 20b89dab5346f13dc17b368b92de89eebf00ac11 Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Mon, 13 May 2002 16:46:32 +0000 Subject: [PATCH 07/16] now compiles with gcc 3.1, might not work with gcc 3.0 though (not sure) --- bs/fleet.cpp | 38 +++++++++++++++++++------------------- bs/fleetview.cpp | 2 +- bs/planet.cpp | 20 ++++++++++---------- bs/unittype.cpp | 2 +- 4 files changed, 31 insertions(+), 31 deletions(-) diff --git a/bs/fleet.cpp b/bs/fleet.cpp index 4fc5be5..4072788 100644 --- a/bs/fleet.cpp +++ b/bs/fleet.cpp @@ -166,7 +166,7 @@ vector Fleet::RacesAllowed() const ////////////////////////////////////////////////////////////////////////// // -unsigned Fleet::score(int tick = 0) const +unsigned Fleet::score(int tick) const { unsigned tot_score = 0; @@ -187,7 +187,7 @@ unsigned Fleet::score(int tick = 0) const ////////////////////////////////////////////////////////////////////////// // -void Fleet::setFleet(string unittype, int number, int tick = 0) +void Fleet::setFleet(string unittype, int number, int tick) { int earlier = 0; int ticks = m_Fleet[unittype].size(); @@ -204,7 +204,7 @@ void Fleet::setFleet(string unittype, int number, int tick = 0) ////////////////////////////////////////////////////////////////////////// // -void Fleet::addFleet(std::string unittype, int number, int tick = 0) +void Fleet::addFleet(std::string unittype, int number, int tick) { int earlier = 0; int ticks = m_Fleet[unittype].size(); @@ -221,7 +221,7 @@ void Fleet::addFleet(std::string unittype, int number, int tick = 0) ////////////////////////////////////////////////////////////////////////// // -int Fleet::fleet(string unittype, int tick = 0) +int Fleet::fleet(string unittype, int tick) { int ticks = m_Fleet[unittype].size(); @@ -241,7 +241,7 @@ int Fleet::fleet(string unittype, int tick = 0) ////////////////////////////////////////////////////////////////////////// // -int Fleet::blockedFleet(std::string unittype, int tick = 0) +int Fleet::blockedFleet(std::string unittype, int tick) { int ticks = m_BlockedFleet[unittype].size(); if (ticks == 0) @@ -257,7 +257,7 @@ int Fleet::blockedFleet(std::string unittype, int tick = 0) ////////////////////////////////////////////////////////////////////////// // -void Fleet::setBlockedFleet(std::string unittype, int number, int tick = 0) +void Fleet::setBlockedFleet(std::string unittype, int number, int tick) { int ticks = m_BlockedFleet[unittype].size(); @@ -273,7 +273,7 @@ void Fleet::setBlockedFleet(std::string unittype, int number, int tick = 0) ////////////////////////////////////////////////////////////////////////// // -void Fleet::addToThis(std::vector fleets, int tick = 0) +void Fleet::addToThis(std::vector fleets, int tick) { for (UnitList::iterator i = s_Units.begin(); i != s_Units.end(); ++i) { @@ -292,7 +292,7 @@ void Fleet::addToThis(std::vector fleets, int tick = 0) ////////////////////////////////////////////////////////////////////////// // -void Fleet::distributeLossesGains(std::vector fleets, int tick = 0) +void Fleet::distributeLossesGains(std::vector fleets, int tick) { for (UnitList::iterator i = s_Units.begin(); i != s_Units.end(); ++i) { @@ -332,7 +332,7 @@ void Fleet::distributeLossesGains(std::vector fleets, int tick = 0) ////////////////////////////////////////////////////////////////////////// // -std::vector Fleet::calculateSide(std::vector fleets, int stays = 0, int tick = 0) +std::vector Fleet::calculateSide(std::vector fleets, int stays, int tick) { vector fl; for (vector::iterator i = fleets.begin(); i != fleets.end(); ++i) @@ -352,7 +352,7 @@ std::vector Fleet::calculateSide(std::vector fleets, int stays = ////////////////////////////////////////////////////////////////////////// // -int Fleet::freeFleet(std:: string unittype, int tick = 0) +int Fleet::freeFleet(std:: string unittype, int tick) { int bticks = m_BlockedFleet[unittype].size(); @@ -562,7 +562,7 @@ void Fleet::takeEMP(std::string unittype, int number) ////////////////////////////////////////////////////////////////////////// // -void Fleet::killFleet(std::string unittype, int number, int tick = 0) +void Fleet::killFleet(std::string unittype, int number, int tick) { int earlier = 0; int ticks = m_Fleet[unittype].size(); @@ -579,7 +579,7 @@ void Fleet::killFleet(std::string unittype, int number, int tick = 0) ////////////////////////////////////////////////////////////////////////// // -void Fleet::setResource(std::string type, int number, int tick = 0) +void Fleet::setResource(std::string type, int number, int tick) { int ticks = m_Resources[type].size(); @@ -590,7 +590,7 @@ void Fleet::setResource(std::string type, int number, int tick = 0) ////////////////////////////////////////////////////////////////////////// // -void Fleet::addResource(std::string type, int number, int tick = 0) +void Fleet::addResource(std::string type, int number, int tick) { int ticks = m_Resources[type].size(); @@ -603,7 +603,7 @@ void Fleet::addResource(std::string type, int number, int tick = 0) ////////////////////////////////////////////////////////////////////////// // -int Fleet::resource(std::string type, int tick = 0) const +int Fleet::resource(std::string type, int tick) const { if (tick < 0) return 0; @@ -658,7 +658,7 @@ void Fleet::printFleet() ////////////////////////////////////////////////////////////////////////// // -void Fleet::blockFleet(std::string unittype, int number, int tick = 0) +void Fleet::blockFleet(std::string unittype, int number, int tick) { if (m_BlockedFleet[unittype].size() >= 1) { @@ -677,7 +677,7 @@ void Fleet::blockFleet(std::string unittype, int number, int tick = 0) ////////////////////////////////////////////////////////////////////////// // -void Fleet::distributeCappedRoids(std::vector fleets, int tick = 0) +void Fleet::distributeCappedRoids(std::vector fleets, int tick) { for (ResourceList::iterator i = m_Resources.begin(); i != m_Resources.end(); ++i) { @@ -717,7 +717,7 @@ void Fleet::distributeCappedRoids(std::vector fleets, int tick = 0) ////////////////////////////////////////////////////////////////////////// // -void Fleet::addFleet(std::map units, int tick = 0) +void Fleet::addFleet(std::map units, int tick) { for (map::iterator i = units.begin(); i != units.end(); ++i) addFleet(i->first, i->second, tick); @@ -739,7 +739,7 @@ void Fleet::setStays(int ticks) ////////////////////////////////////////////////////////////////////////// // -void Fleet::calculateLostStealships(string unittype, std::map stolen, int tick = 1) +void Fleet::calculateLostStealships(string unittype, std::map stolen, int tick) { int stealscore = 0; for (map::iterator i = stolen.begin(); i != stolen.end(); ++i) @@ -755,7 +755,7 @@ void Fleet::calculateLostStealships(string unittype, std::map ////////////////////////////////////////////////////////////////////////// // -void Fleet::distributeStolenShips(std::map > stolen, std::vector fleets, int tick = 0) +void Fleet::distributeStolenShips(std::map > stolen, std::vector fleets, int tick) { for(map >::iterator i = stolen.begin(); i != stolen.end(); ++i) { diff --git a/bs/fleetview.cpp b/bs/fleetview.cpp index 3935616..03a24c9 100644 --- a/bs/fleetview.cpp +++ b/bs/fleetview.cpp @@ -227,7 +227,7 @@ void FleetView::slotRoidsChanged(const QString& type, int value) ///////////////////////////////////////////////////////////////////// // -void FleetView::slotViewTickRange(int min = -1, int max = -1) +void FleetView::slotViewTickRange(int min, int max) { if (min > -1) m_iMinTick = min; diff --git a/bs/planet.cpp b/bs/planet.cpp index 4133277..935c65d 100644 --- a/bs/planet.cpp +++ b/bs/planet.cpp @@ -31,7 +31,7 @@ Planet::~Planet(){ ////////////////////////////////////////////////////////////////////////// // -unsigned Planet::planetScore(int tick = 0) const +unsigned Planet::planetScore(int tick) const { int ticks = m_Score.size(); if (ticks == 0) @@ -47,7 +47,7 @@ unsigned Planet::planetScore(int tick = 0) const ////////////////////////////////////////////////////////////////////////// // -void Planet::setPlanetScore(unsigned number, int tick = 0) +void Planet::setPlanetScore(unsigned number, int tick) { int earlier = 0; int ticks = m_Score.size(); @@ -64,7 +64,7 @@ void Planet::setPlanetScore(unsigned number, int tick = 0) ////////////////////////////////////////////////////////////////////////// // -void Planet::addPlanetScore(unsigned number, int tick = 0) +void Planet::addPlanetScore(unsigned number, int tick) { int earlier = 0; int ticks = m_Score.size(); @@ -80,7 +80,7 @@ void Planet::addPlanetScore(unsigned number, int tick = 0) } ////////////////////////////////////////////////////////////////////////// // -int Planet::roids(std::string type, int tick = 0) const +int Planet::roids(std::string type, int tick) const { // const... I would like [] as for const types: int ticks = m_Roids[type].size(); @@ -108,7 +108,7 @@ int Planet::roids(std::string type, int tick = 0) const ////////////////////////////////////////////////////////////////////////// // -void Planet::setRoids(std::string type, int number, int tick = 0) +void Planet::setRoids(std::string type, int number, int tick) { int ticks = m_Roids[type].size(); int roids = 0; @@ -122,7 +122,7 @@ void Planet::setRoids(std::string type, int number, int tick = 0) ////////////////////////////////////////////////////////////////////////// // -void Planet::takeRoids(std::string type, int number, int tick = 0) +void Planet::takeRoids(std::string type, int number, int tick) { int ticks = m_Roids[type].size(); int roids = 0; @@ -221,7 +221,7 @@ void Planet::runBattle(std::vector friendly, std::vector hostile ////////////////////////////////////////////////////////////////////////// // -void Planet::calcOneTick(Planet* friendly, Fleet* hostile, std::map >& stealfriendly, std::map >& stealhostile, int tick = 1) +void Planet::calcOneTick(Planet* friendly, Fleet* hostile, std::map >& stealfriendly, std::map >& stealhostile, int tick) { if (planetScore(tick - 1) > 0) setCapping(float(planetScore(tick - 1)) / hostile->score() / 10, tick); @@ -312,7 +312,7 @@ void Planet::calcOneTick(Planet* friendly, Fleet* hostile, std::map friendly, int tick = 1) +void Planet::calculateScoreLoss(std::vector friendly, int tick) { for (vector::iterator i = friendly.begin(); i != friendly.end(); ++i) { @@ -326,7 +326,7 @@ void Planet::calculateScoreLoss(std::vector friendly, int tick = 1) ////////////////////////////////////////////////////////////////////////// // -float Planet::capping(int tick = 0) +float Planet::capping(int tick) { int ticks = m_Capping.size(); @@ -340,7 +340,7 @@ float Planet::capping(int tick = 0) ////////////////////////////////////////////////////////////////////////// // -void Planet::setCapping(float capping, int tick = 0) +void Planet::setCapping(float capping, int tick) { int ticks = m_Capping.size(); diff --git a/bs/unittype.cpp b/bs/unittype.cpp index 36bd4ed..836ddb9 100644 --- a/bs/unittype.cpp +++ b/bs/unittype.cpp @@ -93,7 +93,7 @@ void UnitType::addTarget(string target) * If it finds the position it inserts the target there, if it reaches the end * before it finds the correct possition it adds the target to the end. */ -void UnitType::insTarget(string target, int index = 0) +void UnitType::insTarget(string target, int index) { vector::iterator i = m_vTarget.begin(); -- 2.39.2 From 6220f28edd1dacabf49523fc60d01a3b5bfb4b8f Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Fri, 31 May 2002 02:47:16 +0000 Subject: [PATCH 08/16] commited the r7 stats.. --- share/stats.conf | 122 ++++++++++++++++++++++------------------------- 1 file changed, 56 insertions(+), 66 deletions(-) diff --git a/share/stats.conf b/share/stats.conf index 5c37f09..cab2ebf 100644 --- a/share/stats.conf +++ b/share/stats.conf @@ -1,108 +1,98 @@ -Mesonic Cutter -5 Co Fi Co -- 49 25 40 1 3 50 -1 400 400 800 0 0 PDS -Tachyon Beamer -5 Fr Fr Co -- 50 20 35 1 10 75 -1 750 750 1500 0 0 PDS -Pulse Cannon -5 De De Fr All 51 15 30 1 20 150 -1 2250 2250 4000 0 0 PDS -Hadron Turret -5 Cr Cr De All 52 10 25 1 30 225 -1 5000 5000 8000 0 0 PDS -Ion Launcher -5 Bs Bs Cr All 53 5 20 1 60 350 -1 10000 10000 16000 0 0 PDS Harpy -1 Fi Fi Co Fr 11 38 37 3 1 5 65 1250 0 0 10 2 Normal +1 Fi Fi Co Fr Normal 11 38 37 3 1 5 65 4 1250 0 10 2 Phoenix -1 Co Fr Co Fi 18 25 22 2 5 10 55 2250 250 0 20 3 Normal +1 Co Fr Co Fi Normal 16 25 22 2 5 10 55 8 2250 250 20 3 Gryphon -1 Co Cr De -- 19 24 13 1 10 12 65 2250 750 0 25 3 Normal +1 Co Cr De -- Normal 17 24 20 1 12 12 6 5 2250 750 25 3 Centaur -1 Fr Fi Co -- 24 23 45 7 2 25 65 3500 2500 0 65 3 Normal +1 Fr Co Fi -- Normal 22 23 45 7 2 25 6 5 3500 2500 65 3 Chimera -1 Fr Fr De All 25 22 23 5 2 35 70 5500 1500 0 80 4 Normal +1 Fr Fr De All Normal 23 22 25 5 4 35 70 12 5500 1500 80 4 Drake -1 Fr De Fr Co 26 19 17 5 3 45 85 6250 2000 0 95 4 Normal +1 Fr De Cr -- Normal 24 19 17 5 3 45 8 5 6250 2000 95 4 Pegasus -1 De Fi Co -- 10 23 45 12 3 50 75 4000 8000 0 135 3 Normal -Unicorn -1 De Bs Cr De 30 17 10 3 25 85 80 12000 4000 0 175 4 Normal +1 De Fi Co -- Normal 10 23 45 12 3 50 70 16 4000 8000 135 4 +Demeter +1 De -- -- -- POD 51 15 0 2 0 45 7 5 10000 2000 175 4 Hydra -1 Cr Fr Co -- 35 13 22 7 16 140 70 14000 9000 0 225 4 Normal +1 Cr Fr Co -- Normal 32 13 22 6 16 155 7 0 15000 10000 225 4 Syren -1 Cr Cr De All 36 10 15 8 15 180 75 22000 8000 0 350 5 Normal +1 Cr Co Fr De Normal 33 10 30 20 5 180 75 20 22000 8000 350 5 Wyvern -1 Bs De Fr -- 28 12 15 12 27 160 90 30000 24000 0 400 4 Normal +1 Bs De Fr -- Normal 26 12 15 12 27 160 90 24 30000 24000 400 4 Dragon -1 Bs Bs Cr -- 39 5 10 12 40 500 95 70000 16000 0 700 5 Normal +1 Bs Bs Cr -- Normal 36 5 10 12 40 500 9 5 70000 16000 700 5 Spider -2 Fi Co Fi -- 0 30 0 1 0 5 65 0 1250 0 10 2 EMP -Vindicator -2 Fi Fi Co -- 14 40 42 1 2 3 50 1250 0 0 10 2 Normal +2 Fi Co Fi -- EMP 0 30 0 1 0 5 65 4 0 1250 10 2 +Beetle +2 Fi Fi -- -- EMP 6 35 0 3 0 4 65 4 1150 500 10 2 Scarab -2 Co Fr Co -- 1 23 0 1 0 20 55 1750 1250 0 20 3 EMP +2 Co Fr Co -- EMP 1 23 0 1 0 20 55 8 1750 1250 20 3 Defender -2 Co Cr De Fr 20 25 15 1 7 20 75 2000 500 0 30 3 Normal +2 Co Cr De Fr Normal 18 25 15 1 7 20 75 8 2000 500 30 3 Roach -2 Co De Cr -- 2 20 0 1 0 25 65 2750 1250 0 40 3 EMP +2 Co De Cr -- EMP 2 20 0 1 0 25 65 8 2750 1250 40 3 Black Widow -2 Fr Co Fr -- 3 20 0 5 0 30 70 4500 3000 0 85 4 EMP -Widow Maker -2 De Bs Cr -- 33 15 10 3 20 100 80 10000 6000 0 160 4 Normal +2 Fr Co Fr -- EMP 3 20 0 5 0 30 70 12 4500 3000 85 4 +Widowmaker +2 De Bs Cr -- Normal 30 15 10 3 27 100 80 16 10000 6000 160 4 Tarantula -2 Cr Cr De All 6 14 0 6 0 135 70 16000 12000 0 320 4 EMP +2 Cr Cr De All EMP 5 14 0 6 0 170 70 20 16000 12000 320 4 Avenger -2 Cr Co Fr All 37 10 27 10 4 150 75 22500 7500 0 340 5 Normal +2 Cr Co Fr All Normal 34 10 27 12 5 190 75 20 22500 7500 340 5 Mantis -2 Cr Bs -- -- 5 7 0 10 0 225 85 20000 13000 0 400 5 EMP +2 Cr -- -- -- POD 53 7 0 3 0 105 80 20 19000 15000 400 5 Guardian -2 Bs Fi Co Fr 41 5 40 25 4 600 96 60000 26000 0 700 5 Normal +2 Bs Fi Co Fr Normal 38 5 40 25 4 700 96 24 60000 26000 700 5 Scorpion -2 Bs Fi Co -- 4 5 0 90 0 400 99 50000 36000 0 750 5 EMP -Vsharrack Fighter -3 Fi Fi Co -- 7 40 45 2 2 3 40 1250 0 0 10 2 Cloak +2 Bs Fi Co -- EMP 4 5 0 90 0 400 99 24 50000 36000 750 5 +Vsharrak Fighter +3 Fi Fi Co -- Normal 7 40 45 2 2 3 40 4 1250 0 10 2 Daeraith Pulsar -3 Fi Fr De -- 8 35 25 3 2 2 45 1300 250 0 10 2 Cloak +3 Fi Fr De -- Normal 8 35 25 4 2 3 45 4 1300 250 10 2 Lyvidian Sentinel -3 Fi Co Fr All 9 30 25 2 3 5 50 1600 350 0 10 3 Cloak +3 Fi Co Fr All Normal 9 30 25 2 3 5 50 4 1600 350 10 3 Culdassa Arrowhead -3 Co Fi Co -- 15 15 40 9 1 10 30 1250 1250 0 20 3 Cloak -Voracean Predator -3 Co Fr Co All 16 25 20 4 2 15 35 1500 1250 0 25 3 Cloak +3 Co Fi Co -- Normal 14 15 40 9 1 13 35 8 1250 1250 20 3 +Vulture +3 Co -- -- -- POD 52 35 0 1 0 11 30 8 2000 1500 25 3 Andvordian Bomber -3 Co Bs Cr De 17 25 20 1 8 10 40 2250 750 0 35 3 Cloak +3 Co Cr De Fr Normal 15 25 20 1 8 10 50 8 2250 750 35 3 Tzen Bolt Thrower -3 Fr Fr Co -- 21 20 23 6 5 30 70 4000 3000 0 65 4 Cloak +3 Fr Fr Co -- Normal 19 20 23 6 5 30 70 12 4000 3000 65 4 Hysperian Lancer -3 Fr De Cr -- 22 18 20 4 7 35 60 3750 3750 0 75 4 Cloak +3 Fr De Fr -- Normal 20 18 20 4 7 35 60 12 3750 3750 75 4 Cryvellian Broadsword -3 Fr Cr Bs -- 23 15 25 3 10 40 60 4250 3750 0 95 4 Cloak +3 Fr Cr Bs -- Normal 21 15 25 3 10 40 65 12 4250 3750 95 4 Kthal Fireblade -3 De Bs De -- 29 10 5 4 50 65 85 18000 6000 0 165 4 Cloak +3 De Bs Cr De Normal 27 10 5 4 50 80 85 16 18000 6000 165 4 Xentrallis Peacekeeper -3 Cr Cr De All 34 15 15 8 10 105 70 18000 12000 0 360 5 Cloak -Valaerian Flagship -3 Bs Co Fi -- 38 5 20 80 5 325 90 44000 34000 0 750 5 Cloak +3 Cr Cr De All Normal 31 15 15 8 20 125 70 20 18000 12000 360 5 +Dreadnaught +3 Bs Co Fi -- Normal 35 5 20 80 5 325 90 24 44000 34000 750 5 Corsair -4 Fi Fr Co -- 12 45 25 2 1 1 15 400 350 0 5 2 Normal +4 Fi Cr De Fr Normal 13 45 20 2 1 1 15 4 350 250 5 2 Cutlass -4 Fi Fi Co Fr 13 30 45 3 1 5 25 1250 0 0 10 2 Normal +4 Fi Fi Co Fr Normal 12 30 45 3 1 5 25 4 1250 0 10 2 Smuggler -4 Co -- -- -- 47 25 0 0 0 12 20 2000 600 0 25 3 Special +4 Co -- -- -- E-CAP 44 25 0 1 0 12 20 8 2000 600 25 3 Thief -4 Fr Co Fi -- 42 20 25 2 4 22 60 1750 2250 0 75 4 Steal +4 Fr Co Fi -- Steal 39 20 25 2 4 25 60 12 1750 2250 75 4 Cutter -4 Fr De Co Fi 27 20 20 4 5 35 60 5500 1500 0 65 4 Normal +4 Fr Fr Co Fi Normal 25 20 30 8 3 35 70 12 5500 1500 65 4 Buccaneer -4 De Bs Cr De 31 15 10 5 15 60 65 10000 6000 0 140 4 Normal +4 De Bs Cr De Normal 28 15 15 5 15 75 75 16 10000 6000 140 4 Clipper -4 De De Fr All 32 18 20 15 5 65 65 4000 10000 0 150 4 Normal +4 De De Fr All Normal 29 18 20 13 5 65 65 16 5000 9000 150 4 Marauder -4 De Fr -- -- 43 10 25 10 5 90 60 7500 8500 0 195 4 Steal +4 De Fr -- -- Steal 40 10 25 10 5 115 60 16 7500 8500 195 4 Rogue -4 Cr De Fr -- 44 10 20 8 10 95 40 8250 9750 0 410 5 Steal +4 Cr De Fr -- Steal 41 10 20 8 10 140 40 20 8250 9750 410 5 Pillager -4 Cr Cr De -- 45 10 20 4 20 125 40 11000 13000 0 420 5 Steal +4 Cr Cr De -- Steal 42 10 20 4 20 175 40 20 11000 13000 420 5 Pirate -4 Bs Bs Cr -- 46 6 10 5 30 275 80 28500 25500 0 700 5 Steal -Man o' War -4 Bs Fr Co Fi 40 5 30 40 6 400 90 36000 40000 0 800 5 Normal +4 Bs Bs Cr -- Steal 43 6 10 5 30 415 80 24 28500 25500 700 5 +Man O War +4 Bs Fr Co Fi Normal 37 5 30 40 6 400 90 24 36000 40000 800 5 Astro Pod -0 Fr -- -- -- 48 20 0 0 0 10 55 1850 1850 0 125 4 Pod +0 Fr -- -- -- POD 50 20 0 1 0 10 55 12 1850 1850 125 4 -- 2.39.2 From 6d1c9d157f48157d2d4038121f9f1b6991c96f20 Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Fri, 31 May 2002 22:43:45 +0000 Subject: [PATCH 09/16] new stats... --- share/stats.conf | 112 ++++++++++++++++++++++++++--------------------- 1 file changed, 61 insertions(+), 51 deletions(-) diff --git a/share/stats.conf b/share/stats.conf index cab2ebf..676079c 100644 --- a/share/stats.conf +++ b/share/stats.conf @@ -1,98 +1,108 @@ +Mesonic Cutter +5 Co Fi Co -- 45 25 40 1 3 50 100 400 400 800 0 0 PDS +Tachyon Beamer +5 Fr Fr Co -- 46 20 35 1 10 75 100 750 750 1500 0 0PDS +Pulse Cannon +5 De De Fr All 47 15 30 1 20 150 100 2250 2250 4000 0 0 PDS +Hadron Turret +5 Cr Cr De All 48 10 25 1 30 225 100 5000 5000 8000 0 0 PDS +Ion Launcher +5 Bs Bs Cr All 49 5 20 1 60 350 100 10000 10000 16000 0 0 PDS Harpy -1 Fi Fi Co Fr Normal 11 38 37 3 1 5 65 4 1250 0 10 2 +1 Fi Fi Co Fr 11 38 37 3 1 5 65 1250 0 0 10 2 Normal Phoenix -1 Co Fr Co Fi Normal 16 25 22 2 5 10 55 8 2250 250 20 3 +1 Co Fr Co Fi 16 25 22 2 5 10 55 2250 250 0 20 3 Normal Gryphon -1 Co Cr De -- Normal 17 24 20 1 12 12 6 5 2250 750 25 3 +1 Co Cr De -- 17 24 20 1 12 12 65 2250 750 0 25 3 Normal Centaur -1 Fr Co Fi -- Normal 22 23 45 7 2 25 6 5 3500 2500 65 3 +1 Fr Co Fi -- 22 23 45 7 2 25 65 3500 2500 0 65 3 Normal Chimera -1 Fr Fr De All Normal 23 22 25 5 4 35 70 12 5500 1500 80 4 +1 Fr Fr De All 23 22 25 5 4 35 70 5500 1500 0 80 4 Normal Drake -1 Fr De Cr -- Normal 24 19 17 5 3 45 8 5 6250 2000 95 4 +1 Fr De Cr -- 24 19 17 5 3 45 85 6250 2000 0 95 4 Normal Pegasus -1 De Fi Co -- Normal 10 23 45 12 3 50 70 16 4000 8000 135 4 +1 De Fi Co -- 10 23 45 12 3 50 70 4000 8000 0 135 4 Normal Demeter -1 De -- -- -- POD 51 15 0 2 0 45 7 5 10000 2000 175 4 +1 De -- -- -- 51 15 0 2 0 45 75 10000 2000 0 175 4 Pod Hydra -1 Cr Fr Co -- Normal 32 13 22 6 16 155 7 0 15000 10000 225 4 +1 Cr Fr Co -- 32 13 22 6 16 155 70 15000 10000 0 225 4 Normal Syren -1 Cr Co Fr De Normal 33 10 30 20 5 180 75 20 22000 8000 350 5 +1 Cr Co Fr De 33 10 30 20 5 180 75 22000 8000 0 350 5 Normal Wyvern -1 Bs De Fr -- Normal 26 12 15 12 27 160 90 24 30000 24000 400 4 +1 Bs De Fr -- 26 12 15 12 27 160 90 30000 24000 0 400 4 Normal Dragon -1 Bs Bs Cr -- Normal 36 5 10 12 40 500 9 5 70000 16000 700 5 +1 Bs Bs Cr -- 36 5 10 12 40 500 95 70000 16000 0 700 5 Normal Spider -2 Fi Co Fi -- EMP 0 30 0 1 0 5 65 4 0 1250 10 2 +2 Fi Co Fi -- 0 30 0 1 0 5 65 0 1250 0 10 2 EMP Beetle -2 Fi Fi -- -- EMP 6 35 0 3 0 4 65 4 1150 500 10 2 +2 Fi Fi -- -- 6 35 0 3 0 4 65 1150 500 0 12 2 EMP Scarab -2 Co Fr Co -- EMP 1 23 0 1 0 20 55 8 1750 1250 20 3 +2 Co Fr Co -- 1 23 0 1 0 20 55 1750 1250 0 20 3 EMP Defender -2 Co Cr De Fr Normal 18 25 15 1 7 20 75 8 2000 500 30 3 +2 Co Cr De Fr 18 25 15 1 7 20 75 2000 500 0 30 3 Normal Roach -2 Co De Cr -- EMP 2 20 0 1 0 25 65 8 2750 1250 40 3 +2 Co De Cr -- 2 20 0 1 0 25 65 2750 1250 0 40 3 EMP Black Widow -2 Fr Co Fr -- EMP 3 20 0 5 0 30 70 12 4500 3000 85 4 -Widowmaker -2 De Bs Cr -- Normal 30 15 10 3 27 100 80 16 10000 6000 160 4 +2 Fr Co Fr -- 3 20 0 5 0 30 70 4500 3000 0 85 4 EMP +Widow Maker +2 De Bs Cr -- 30 15 10 3 27 100 80 10000 6000 0 160 4 Normal Tarantula -2 Cr Cr De All EMP 5 14 0 6 0 170 70 20 16000 12000 320 4 +2 Cr Cr De All 5 14 0 6 0 170 70 16000 12000 0 320 4 EMP Avenger -2 Cr Co Fr All Normal 34 10 27 12 5 190 75 20 22500 7500 340 5 +2 Cr Co Fr All 34 10 27 12 5 190 75 22500 7500 0 340 5 Normal Mantis -2 Cr -- -- -- POD 53 7 0 3 0 105 80 20 19000 15000 400 5 +2 Cr -- -- -- 53 7 0 3 0 105 80 19000 15000 0 400 5 Pod Guardian -2 Bs Fi Co Fr Normal 38 5 40 25 4 700 96 24 60000 26000 700 5 +2 Bs Fi Co Fr 38 5 40 25 4 700 96 60000 26000 0 700 5 Normal Scorpion -2 Bs Fi Co -- EMP 4 5 0 90 0 400 99 24 50000 36000 750 5 +2 Bs Fi Co -- 4 5 0 90 0 400 99 50000 36000 0 750 5 EMP Vsharrak Fighter -3 Fi Fi Co -- Normal 7 40 45 2 2 3 40 4 1250 0 10 2 +3 Fi Fi Co -- 7 40 45 2 2 3 40 1250 0 0 10 2 Cloaked Daeraith Pulsar -3 Fi Fr De -- Normal 8 35 25 4 2 3 45 4 1300 250 10 2 +3 Fi Fr De -- 8 35 25 4 2 3 45 1300 250 0 10 2 Cloaked Lyvidian Sentinel -3 Fi Co Fr All Normal 9 30 25 2 3 5 50 4 1600 350 10 3 +3 Fi Co Fr All 9 30 25 2 3 5 50 1600 350 0 10 3 Cloaked Culdassa Arrowhead -3 Co Fi Co -- Normal 14 15 40 9 1 13 35 8 1250 1250 20 3 +3 Co Fi Co -- 14 15 40 9 1 13 35 1250 1250 0 20 3 Cloaked Vulture -3 Co -- -- -- POD 52 35 0 1 0 11 30 8 2000 1500 25 3 +3 Co -- -- -- 52 35 0 1 0 11 30 2000 1500 0 30 3 Pod Andvordian Bomber -3 Co Cr De Fr Normal 15 25 20 1 8 10 50 8 2250 750 35 3 +3 Co Cr De Fr 15 25 20 1 8 10 50 2250 750 0 35 3 Cloaked Tzen Bolt Thrower -3 Fr Fr Co -- Normal 19 20 23 6 5 30 70 12 4000 3000 65 4 +3 Fr Fr Co -- 19 20 23 6 5 30 70 4000 3000 0 65 4 Cloaked Hysperian Lancer -3 Fr De Fr -- Normal 20 18 20 4 7 35 60 12 3750 3750 75 4 +3 Fr De Fr -- 20 18 20 4 7 35 60 3750 3750 0 75 4 Cloaked Cryvellian Broadsword -3 Fr Cr Bs -- Normal 21 15 25 3 10 40 65 12 4250 3750 95 4 +3 Fr Cr Bs -- 21 15 25 3 10 40 65 4250 3750 0 95 4 Cloaked Kthal Fireblade -3 De Bs Cr De Normal 27 10 5 4 50 80 85 16 18000 6000 165 4 +3 De Bs Cr De 27 10 5 4 50 80 85 18000 6000 0 165 4 Cloaked Xentrallis Peacekeeper -3 Cr Cr De All Normal 31 15 15 8 20 125 70 20 18000 12000 360 5 +3 Cr Cr De All 31 15 15 8 20 125 70 18000 12000 0 360 5 Cloaked Dreadnaught -3 Bs Co Fi -- Normal 35 5 20 80 5 325 90 24 44000 34000 750 5 +3 Bs Co Fi -- 35 5 20 80 5 325 90 44000 34000 0 750 5 Cloaked Corsair -4 Fi Cr De Fr Normal 13 45 20 2 1 1 15 4 350 250 5 2 +4 Fi Cr De Fr 13 45 20 2 1 1 15 350 250 0 5 2 Normal Cutlass -4 Fi Fi Co Fr Normal 12 30 45 3 1 5 25 4 1250 0 10 2 +4 Fi Fi Co Fr 12 30 45 3 1 5 25 1250 0 0 10 2 Normal Smuggler -4 Co -- -- -- E-CAP 44 25 0 1 0 12 20 8 2000 600 25 3 +4 Co -- -- -- 44 25 0 1 0 20 12 2000 600 0 25 3 Special Thief -4 Fr Co Fi -- Steal 39 20 25 2 4 25 60 12 1750 2250 75 4 +4 Fr Co Fi -- 39 20 25 2 4 25 60 1750 2250 0 75 4 Steal Cutter -4 Fr Fr Co Fi Normal 25 20 30 8 3 35 70 12 5500 1500 65 4 +4 Fr Fr Co Fi 25 20 30 8 3 35 70 5500 1500 0 65 4 Normal Buccaneer -4 De Bs Cr De Normal 28 15 15 5 15 75 75 16 10000 6000 140 4 +4 De Cr De Fr 28 15 15 5 15 75 75 10000 6000 0 140 4 Normal Clipper -4 De De Fr All Normal 29 18 20 13 5 65 65 16 5000 9000 150 4 +4 De De Fr All 29 18 20 13 5 65 65 5000 9000 0 150 4 Normal Marauder -4 De Fr -- -- Steal 40 10 25 10 5 115 60 16 7500 8500 195 4 +4 De Fr -- -- 40 10 25 10 5 115 60 7500 8500 0 195 4 Steal Rogue -4 Cr De Fr -- Steal 41 10 20 8 10 140 40 20 8250 9750 410 5 +4 Cr De Fr -- 41 10 20 8 10 140 40 8250 9750 0 410 5 Steal Pillager -4 Cr Cr De -- Steal 42 10 20 4 20 175 40 20 11000 13000 420 5 +4 Cr Cr De -- 42 10 20 4 20 175 40 11000 13000 0 420 5 Steal Pirate -4 Bs Bs Cr -- Steal 43 6 10 5 30 415 80 24 28500 25500 700 5 -Man O War -4 Bs Fr Co Fi Normal 37 5 30 40 6 400 90 24 36000 40000 800 5 +4 Bs Bs Cr -- 43 5 10 6 30 415 80 28500 25500 0 700 5 Steal +Man o' War +4 Bs Fr Co Fi 37 5 30 40 6 400 90 36000 40000 0 800 5 Normal Astro Pod -0 Fr -- -- -- POD 50 20 0 1 0 10 55 12 1850 1850 125 4 +0 Fr -- -- -- 50 20 0 1 0 10 55 1850 1850 0 125 4 Pod -- 2.39.2 From 5b3a1459c35efe60c4255a5c50a1d74fdbe8e8eb Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Tue, 4 Jun 2002 21:08:16 +0000 Subject: [PATCH 10/16] changed the capping functionallity.. --- bs/fleet.cpp | 87 +++++++++++++++++++++++++++++++++++++----------- bs/fleet.h | 24 ++++++++----- bs/planet.cpp | 29 +++++++++++----- share/stats.conf | 2 +- 4 files changed, 105 insertions(+), 37 deletions(-) diff --git a/bs/fleet.cpp b/bs/fleet.cpp index 4072788..bab852f 100644 --- a/bs/fleet.cpp +++ b/bs/fleet.cpp @@ -119,28 +119,27 @@ void Fleet::setUnits(UnitList& units) s_Units = units; - /* + for (UnitList::iterator i = s_Units.begin(); i != s_Units.end(); i++) { - cerr << s_Units[(*i).first].Name() << "\t\t" - << s_Units[(*i).first].race() <<"\t" - << s_Units[(*i).first].unitClass() << "\t" - << s_Units[(*i).first].target(0) << "\t" - << s_Units[(*i).first].target(1) << "\t" - << s_Units[(*i).first].target(2) << "\t" - << s_Units[(*i).first].initiative() << "\t" - << s_Units[(*i).first].agility() << "\t" - << s_Units[(*i).first].weaponSpeed() << "\t" - << s_Units[(*i).first].guns() << "\t" - << s_Units[(*i).first].power() << "\t" - << s_Units[(*i).first].armor() << "\t" - << s_Units[(*i).first].EMP() << "\t" - << s_Units[(*i).first].totRes() << "\t" - << s_Units[(*i).first].fuel() << "\t" - << s_Units[(*i).first].ETA() << "\t" - << s_Units[(*i).first].type() << endl; + cerr << s_Units[(*i).first].Name() << "\t\t" +/* << s_Units[(*i).first].race() <<"\t" + << s_Units[(*i).first].unitClass() << "\t" + << s_Units[(*i).first].target(0) << "\t" + << s_Units[(*i).first].target(1) << "\t" + << s_Units[(*i).first].target(2) << "\t" + << s_Units[(*i).first].initiative() << "\t" + << s_Units[(*i).first].agility() << "\t" + << s_Units[(*i).first].weaponSpeed() << "\t" + << s_Units[(*i).first].guns() << "\t" + << s_Units[(*i).first].power() << "\t" + << s_Units[(*i).first].armor() << "\t" + << s_Units[(*i).first].EMP() << "\t" + << s_Units[(*i).first].totRes() << "\t" + << s_Units[(*i).first].fuel() << "\t" + << s_Units[(*i).first].ETA() << "\t"*/ + << s_Units[(*i).first].type() << endl; } - */ } ////////////////////////////////////////////////////////////////////////// @@ -817,3 +816,53 @@ void Fleet::resetTicks() } resetResources(); } + +////////////////////////////////////////////////////////////////////////// +// +int Fleet::freePodGuns(int tick) +{ + int guns = 0; + for (FleetList::const_iterator i = m_Fleet.begin(); i != m_Fleet.end(); ++i) + { + if (s_Units[i->first].type() == "Pod") + { + guns += freeFleet(i->first, tick) * s_Units[i->first].guns(); + } + } + guns -= usedPodGuns(tick); + return guns; +} + +////////////////////////////////////////////////////////////////////////// +// +int Fleet::usedPodGuns(int tick) const +{ + int ticks = m_UsedPodGuns.size(); + + if (ticks == 0) + return 0; + + if (tick < 0) + return m_UsedPodGuns[0]; + + --ticks; + + if (ticks < tick) + return m_UsedPodGuns[ticks]; + + return m_UsedPodGuns[tick]; + +} + +////////////////////////////////////////////////////////////////////////// +// +void Fleet::usePodGuns(int tick, int guns) +{ + int ticks = m_UsedPodGuns.size(); + + for (int i = ticks; i <= tick; ++i) + { + m_UsedPodGuns.push_back(0); + } + m_UsedPodGuns[tick] += guns; +} diff --git a/bs/fleet.h b/bs/fleet.h index f632093..673eb42 100644 --- a/bs/fleet.h +++ b/bs/fleet.h @@ -275,6 +275,13 @@ public: void printFleet(); void resetTicks(); + + int freePodGuns(int tick = 0); + + int usedPodGuns(int tick = 0) const; + + void usePodGuns(int tick = 0, int guns = 1); + //static functions // /** This function is used to set the different races used. @@ -301,14 +308,15 @@ public: protected: - std::string m_sName; - std::string m_sRace; - int m_iETA; - FleetList m_Fleet; - FleetList m_BlockedFleet; - ResourceList m_Resources; - ArmorList m_Armor; - int m_iStays; + std::string m_sName; + std::string m_sRace; + int m_iETA; + FleetList m_Fleet; + FleetList m_BlockedFleet; + ResourceList m_Resources; + ArmorList m_Armor; + int m_iStays; + std::vector m_UsedPodGuns; diff --git a/bs/planet.cpp b/bs/planet.cpp index 935c65d..fdeb789 100644 --- a/bs/planet.cpp +++ b/bs/planet.cpp @@ -228,10 +228,11 @@ void Planet::calcOneTick(Planet* friendly, Fleet* hostile, std::map pods; + //FIXME: remove this line later.. map pods; - //FIXME: Need to change this and allow multiple shiptypes with the same initiative. + //FIXME: Need to change this and allow multiple shiptypes with the same initiative. + //FIXME: Looks like I don't have to.. map unitsinit; // order units after their ininitiative for (UnitList::iterator i = s_Units.begin(); i != s_Units.end(); ++i) unitsinit[i->second.initiative()] = i->first; @@ -275,29 +276,39 @@ void Planet::calcOneTick(Planet* friendly, Fleet* hostile, std::mapfirst, tick - 1); - int freepods = hostiletemp->freeFleet(unittype, 1); + //int freepods = hostiletemp->freeFleet(unittype, 1); cerr << "Possible to steal " << caproids << " " << roid->first << " roids\n"; - cerr << freepods << " free pods available\n"; + cerr << hostiletemp->freePodGuns(1) << " free pod guns available\n"; - if (freepods <= 0) + if (hostiletemp->freePodGuns(1) <= 0) break; - if (freepods < caproids) - caproids = freepods; + if (hostiletemp->freePodGuns(1) < caproids) + caproids = hostiletemp->freePodGuns(1); cerr << caproids << " roids stolen\n"; takeRoids(roid->first, caproids, tick); + /*FIXME: REMOVE THIS BLOCK LATER //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. hostiletemp->killFleet(unittype, caproids, 1); pods[unittype] += caproids; //int totroids = caproids + hostiletemp->resource(roid->first, 0); + */ hostiletemp->addResource(roid->first, caproids, 1); - + hostiletemp->usePodGuns(1, caproids); cerr << caproids << " stolen " << roid->first << " roids\n"; } } + + //FIXME: This is ugly and I want to change this, but as long as pods shoot last it works.. + *friendly = *friendlytemp; + delete friendlytemp; + *hostile = *hostiletemp; + delete hostiletemp; + + return; } //set the the objects so they point at the modified objects @@ -306,7 +317,7 @@ void Planet::calcOneTick(Planet* friendly, Fleet* hostile, std::mapaddFleet(pods, 1); + //hostile->addFleet(pods, 1); } diff --git a/share/stats.conf b/share/stats.conf index 676079c..554a6fd 100644 --- a/share/stats.conf +++ b/share/stats.conf @@ -1,7 +1,7 @@ Mesonic Cutter 5 Co Fi Co -- 45 25 40 1 3 50 100 400 400 800 0 0 PDS Tachyon Beamer -5 Fr Fr Co -- 46 20 35 1 10 75 100 750 750 1500 0 0PDS +5 Fr Fr Co -- 46 20 35 1 10 75 100 750 750 1500 0 0 PDS Pulse Cannon 5 De De Fr All 47 15 30 1 20 150 100 2250 2250 4000 0 0 PDS Hadron Turret -- 2.39.2 From e0be1e6e8f7a246acf49e1f315c8d5bc5a65bfa3 Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Wed, 19 Jun 2002 20:36:28 +0000 Subject: [PATCH 11/16] some changes.. --- bs/bsconf.cpp | 5 +- bs/bsdoc.h | 2 + bs/bsview.cpp | 12 ++- bs/bsview.h | 1 + bs/planet.cpp | 2 +- bs/ui/bsappbase.ui | 4 +- bs/ui/infoview.ui | 12 +-- bs/ui/resourceview.ui | 8 +- bs/ui/roidseditview.ui | 6 +- bs/ui/scanviewbase.ui | 186 ++++++++++++++++++++++++++++++++--------- 10 files changed, 181 insertions(+), 57 deletions(-) diff --git a/bs/bsconf.cpp b/bs/bsconf.cpp index 816fd09..ea32b7e 100644 --- a/bs/bsconf.cpp +++ b/bs/bsconf.cpp @@ -32,9 +32,10 @@ using namespace std; BSConf::BSConf() { QSettings settings; + //settings.insertSearchPath(QSettings::Unix); - m_sRaceFilename = settings.readEntry("/hbs/RaceFilename", "/usr/share/hbs/race.conf"); - m_sStatsFilename = settings.readEntry("/hbs/StatsFilename", "/usr/share/hbs/stats.conf"); + m_sRaceFilename = settings.readEntry("/hbs/ConfFiles/RaceFilename", "/usr/share/hbs/race.conf"); + m_sStatsFilename = settings.readEntry("/hbs/ConfFiles/StatsFilename", "/usr/share/hbs/stats.conf"); loadRace(); loadStats(); diff --git a/bs/bsdoc.h b/bs/bsdoc.h index bcfcfd0..4cd0ee6 100644 --- a/bs/bsdoc.h +++ b/bs/bsdoc.h @@ -76,6 +76,8 @@ class BSDoc : public QObject void removeFleet(QString battle, QString group, QString fleet); void runBattleSimulation(); + + void parseScan(); signals: void documentChanged(); diff --git a/bs/bsview.cpp b/bs/bsview.cpp index df3f558..9212fb1 100644 --- a/bs/bsview.cpp +++ b/bs/bsview.cpp @@ -85,7 +85,7 @@ BSView::BSView(QWidget *parent, BSDoc *doc) : QSplitter(parent) //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()); @@ -107,6 +107,7 @@ BSView::BSView(QWidget *parent, BSDoc *doc) : QSplitter(parent) connect(m_NumberView, SIGNAL(selectionChanged(QListViewItem *)), SLOT(slotFleetSelection(QListViewItem *))); connect(m_FleetView, SIGNAL(fleetChanged(const Fleet*)), SLOT(slotFleetChanged(const Fleet*))); connect(m_GenericFleetView, SIGNAL(fleetChanged(const Fleet*)), SLOT(slotFleetChanged(const Fleet*))); + connect(m_ScanView, SIGNAL(scanUsed(int,QString, int)), SLOT(slotUseScan(int, QString, int))); } BSView::~BSView() @@ -439,3 +440,12 @@ void BSView::slotResultModeChanged( int i) m_iResultMode = i; } + +////////////////////////////////////////////////////////////////////////// +// +void BSView::slotUseScan(int action, QString text, int fleets) +{ + cerr << "Action: " << action << endl; + cerr << "Text: " << text.latin1() << endl; + cerr << "Fleets: " << fleets << endl; +} diff --git a/bs/bsview.h b/bs/bsview.h index 391a777..b87c1c6 100644 --- a/bs/bsview.h +++ b/bs/bsview.h @@ -61,6 +61,7 @@ class BSView : public QSplitter void slotInfoRemove(); void slotTickChanged(int min, int max); void slotResultModeChanged( int i); + void slotUseScan(int action, QString text, int fleets); protected: diff --git a/bs/planet.cpp b/bs/planet.cpp index fdeb789..c819323 100644 --- a/bs/planet.cpp +++ b/bs/planet.cpp @@ -134,7 +134,7 @@ void Planet::takeRoids(std::string type, int number, int tick) m_Roids[type][tick] -= number; if (type != "uninit") - addPlanetScore(-3000*number, tick); + addPlanetScore(-1000*number, tick); } diff --git a/bs/ui/bsappbase.ui b/bs/ui/bsappbase.ui index 1c0c88f..ed313f6 100644 --- a/bs/ui/bsappbase.ui +++ b/bs/ui/bsappbase.ui @@ -25,7 +25,7 @@ 0 0 700 - 24 + 23 @@ -95,7 +95,7 @@ - Survived unts + Survived units diff --git a/bs/ui/infoview.ui b/bs/ui/infoview.ui index a8ed7ac..2a22c68 100644 --- a/bs/ui/infoview.ui +++ b/bs/ui/infoview.ui @@ -10,8 +10,8 @@ 0 0 - 267 - 221 + 302 + 217 @@ -36,10 +36,10 @@ unnamed - 0 + 4 - 0 + 5 @@ -101,7 +101,7 @@ 0 - 0 + 5 @@ -330,5 +330,5 @@ stays() setStays( int ticks ) - + diff --git a/bs/ui/resourceview.ui b/bs/ui/resourceview.ui index e1faa98..7e2cb63 100644 --- a/bs/ui/resourceview.ui +++ b/bs/ui/resourceview.ui @@ -10,7 +10,7 @@ 0 0 - 549 + 545 110 @@ -39,10 +39,10 @@ unnamed - 11 + 4 - 6 + 5 @@ -194,5 +194,5 @@ setLines( QString type, float i ) - + diff --git a/bs/ui/roidseditview.ui b/bs/ui/roidseditview.ui index f77d5b5..124a69d 100644 --- a/bs/ui/roidseditview.ui +++ b/bs/ui/roidseditview.ui @@ -33,10 +33,10 @@ unnamed - 2 + 4 - 2 + 5 @@ -258,5 +258,5 @@ slotSetLost( QString type, float i ) - + diff --git a/bs/ui/scanviewbase.ui b/bs/ui/scanviewbase.ui index 66275ef..87f63d8 100644 --- a/bs/ui/scanviewbase.ui +++ b/bs/ui/scanviewbase.ui @@ -1,6 +1,5 @@ ScanViewBase - ScanViewBase @@ -9,24 +8,24 @@ 0 0 - 613 - 236 + 719 + 320 Form1 - + unnamed - 1 + 5 - 1 + 4 - + GroupBox1 @@ -38,14 +37,17 @@ unnamed - 11 + 5 - 6 + 4 - TextEdit1 + ScanEdit + + + PlainText @@ -58,19 +60,19 @@ Paste Type - + unnamed - 11 + 5 - 6 + 4 - + - RadioButton1 + NormalRadio overview/unit-/pdsscan @@ -79,23 +81,74 @@ true - + - RadioButton3 + MilitaryRadio Military scan - + - RadioButton3_2 + GalstatusRadio Galaxy status - + + + ReplaceButton + + + Replace + + + + + ReplaceAllButton + + + Replace all + + + + + Spacer1 + + + Vertical + + + Expanding + + + + + AddButton + + + Add + + + + + NewButton + + + New + + + + + NewInfoButton + + + New (use info) + + + @@ -112,14 +165,14 @@ unnamed - 11 + 5 - 6 + 4 - CheckBox4 + BaseCheck Base fleet @@ -127,7 +180,7 @@ - CheckBox1 + Fleet1Check Fleet 1 @@ -135,7 +188,7 @@ - CheckBox3 + Fleet2Check Fleet 2 @@ -143,7 +196,7 @@ - CheckBox2 + Fleet3Check Fleet 3 @@ -153,23 +206,80 @@ - + - - RadioButton3 + + MilitaryRadio toggled(bool) FleetGroup setEnabled(bool) - destroy() - init() + + AddButton + clicked() + ScanViewBase + slotButtonClicked() + + + NewButton + clicked() + ScanViewBase + slotButtonClicked() + + + NewInfoButton + clicked() + ScanViewBase + slotButtonClicked() + + + ReplaceAllButton + clicked() + ScanViewBase + slotButtonClicked() + + + ReplaceButton + clicked() + ScanViewBase + slotButtonClicked() + + + GalstatusRadio + toggled(bool) + AddButton + setDisabled(bool) + + + GalstatusRadio + toggled(bool) + NewInfoButton + setDisabled(bool) + + + GalstatusRadio + toggled(bool) + ReplaceButton + setDisabled(bool) + + + GalstatusRadio + toggled(bool) + ReplaceAllButton + setDisabled(bool) + - - { -} - { - -} - + + scanviewbase.ui.h + + + scanUsed(int, QString, int) + + + destroy() + init() + slotButtonClicked() + + -- 2.39.2 From cb2fabf93c2f6ba8b57833309038adb972f58925 Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Sun, 30 Jun 2002 04:43:28 +0000 Subject: [PATCH 12/16] started to work on the battle report.. almost there =) --- bs/bsview.cpp | 72 +++++++++++++++++++++++++++++++++++++++++-- bs/bsview.h | 5 +++ bs/fleet.cpp | 4 ++- bs/fleet.h | 2 +- bs/fleetview.cpp | 1 + bs/planet.cpp | 44 +++++++++++++++++++++----- bs/planet.h | 4 +++ bs/ui/bsappbase.ui | 10 +++--- bs/ui/bsappbase.ui.h | 1 + bs/ui/scanviewbase.ui | 4 +-- 10 files changed, 128 insertions(+), 19 deletions(-) diff --git a/bs/bsview.cpp b/bs/bsview.cpp index 9212fb1..c6fcc46 100644 --- a/bs/bsview.cpp +++ b/bs/bsview.cpp @@ -28,6 +28,8 @@ using namespace std; //QT includes #include #include +#include +#include #include "battlesum.h" #include "scanview.h" @@ -51,7 +53,16 @@ BSView::BSView(QWidget *parent, BSDoc *doc) : QSplitter(parent) 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); @@ -203,7 +214,13 @@ void BSView::slotFleetSelection(QListViewItem *lvi) { 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(); @@ -449,3 +466,54 @@ void BSView::slotUseScan(int action, QString text, int fleets) 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(fl); + if (pl) + { + ReportList report = pl->report(); + QString t; + + t.append("\n"); + + + for (ReportList::iterator i = report.begin(); i != report.end(); ++i) + { + t.append(QString("Tick number: %0\n").arg(i->first)); + t.append("
    \n"); + for(map > > >::iterator j = i->second.begin(); j != i->second.end(); ++j) + { + t.append(QString("
  • Now handling initiative: %0\n").arg(j->first)); + t.append("
      \n"); + for(map > >::iterator k = j->second.begin(); k != j->second.end(); ++k) + { + for(map >::iterator l = k->second.begin(); l != k->second.end(); ++l) + { + t.append(QString("
    • %0 %1 %2 killing/blocking at: \n").arg(l->second["000"]).arg(k->first.c_str()).arg(l->first.c_str())); + t.append("
        \n"); + + t.append("
      \n"); + t.append("
    • \n"); + } + } + t.append("
    \n"); + t.append("
  • \n"); + } + t.append("
\n"); + + t.append("
\n"); + } + t.append("
\n"); + //cerr << t.latin1(); + m_Report->clear(); + m_Report->setText(t); + + } + //m_Report->append("test\n"); +} diff --git a/bs/bsview.h b/bs/bsview.h index b87c1c6..86e7b45 100644 --- a/bs/bsview.h +++ b/bs/bsview.h @@ -38,6 +38,8 @@ class QListView; class QSplitter; class QWidgetStack; class QListViewItem; +class QTabWidget; +class QTextEdit; /** * This class provides an incomplete base for your application view. @@ -81,6 +83,8 @@ class BSView : public QSplitter FleetView *m_GenericFleetView; BSDoc *m_doc; std::map > m_TreeExpanded; + QTabWidget *m_Pages; + QTextEdit *m_Report; QString m_sBattle; QString m_sGroup; @@ -98,6 +102,7 @@ public slots: // Public slots void slotFleetSelection(QListViewItem *lvi); void slotItemExpanded(QListViewItem *lvi); void slotItemCollapsed(QListViewItem *lvi); + void slotGenerateReport(); }; #endif diff --git a/bs/fleet.cpp b/bs/fleet.cpp index bab852f..cd558a6 100644 --- a/bs/fleet.cpp +++ b/bs/fleet.cpp @@ -449,6 +449,7 @@ void Fleet::takeShoot(std::string unittype, int number, std::mapfirst]++; //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]; @@ -461,6 +462,7 @@ void Fleet::takeShoot(std::string unittype, int number, std::mapfirst][1]--; } } + */ } } @@ -477,7 +479,7 @@ void Fleet::takeShoot(std::string unittype, int number, std::map& hitunits) { int guns = s_Units[unittype].guns() * number; if (guns == 0) diff --git a/bs/fleet.h b/bs/fleet.h index 673eb42..9aea01c 100644 --- a/bs/fleet.h +++ b/bs/fleet.h @@ -262,7 +262,7 @@ public: * 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& hitunits); void calculateLostStealships(std::string unittype, std::map stolen, int tick = 1); diff --git a/bs/fleetview.cpp b/bs/fleetview.cpp index 03a24c9..e3290a6 100644 --- a/bs/fleetview.cpp +++ b/bs/fleetview.cpp @@ -82,6 +82,7 @@ FleetView::~FleetView(){ // void FleetView::viewFleet(const Fleet* fleet, bool friendly) { + friendly = true; if (m_Fleet->race() != fleet->race()) { findNames(); diff --git a/bs/planet.cpp b/bs/planet.cpp index c819323..e5aba85 100644 --- a/bs/planet.cpp +++ b/bs/planet.cpp @@ -154,6 +154,8 @@ void Planet::runBattle(std::vector friendly, std::vector hostile for (vector::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 @@ -237,35 +239,50 @@ void Planet::calcOneTick(Planet* friendly, Fleet* hostile, std::mapsecond.initiative()] = i->first; + + for (map::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 friendlyhits; + map 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 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 @@ -275,7 +292,7 @@ void Planet::calcOneTick(Planet* friendly, Fleet* hostile, std::mapfirst, 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"; @@ -310,6 +327,10 @@ void Planet::calcOneTick(Planet* friendly, Fleet* hostile, std::map > RoidList; +typedef std::map > > > > ReportList; /**This class is the implementation of a planet. * @@ -90,6 +91,8 @@ public: 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 @@ -106,6 +109,7 @@ protected: std::vector m_Score; std::vector m_Capping; RoidList m_Roids; + ReportList m_Report; }; diff --git a/bs/ui/bsappbase.ui b/bs/ui/bsappbase.ui index ed313f6..9615c0f 100644 --- a/bs/ui/bsappbase.ui +++ b/bs/ui/bsappbase.ui @@ -615,11 +615,11 @@ helpAbout() battleNew() battleSimulate() - oneTickCheck_toggled( bool b ) - minTickSpin_valueChanged( int i ) - maxTickSpin_valueChanged( int i ) - slotTicksChanged( int i ) - resultModeCombo_activated( int i ) + oneTickCheck_toggled(bool b) + minTickSpin_valueChanged(int i) + maxTickSpin_valueChanged(int i) + slotTicksChanged(int i) + resultModeCombo_activated(int i) diff --git a/bs/ui/bsappbase.ui.h b/bs/ui/bsappbase.ui.h index 305a4ca..2f30bb9 100644 --- a/bs/ui/bsappbase.ui.h +++ b/bs/ui/bsappbase.ui.h @@ -108,6 +108,7 @@ void BSAppBase::battleSimulate() QApplication::setOverrideCursor( Qt::WaitCursor ); doc->runBattleSimulation(); + view->slotGenerateReport(); QApplication::restoreOverrideCursor(); } diff --git a/bs/ui/scanviewbase.ui b/bs/ui/scanviewbase.ui index 87f63d8..33594f1 100644 --- a/bs/ui/scanviewbase.ui +++ b/bs/ui/scanviewbase.ui @@ -8,8 +8,8 @@ 0 0 - 719 - 320 + 518 + 371 -- 2.39.2 From 935b6de2d1428854d76acc20b1727eb4a30f9273 Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Mon, 1 Jul 2002 04:20:31 +0000 Subject: [PATCH 13/16] the battlereport works now.. --- bs/bsview.cpp | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++- bs/bsview.h | 1 + bs/fleet.cpp | 38 +++++++++++++++-------------- bs/fleet.h | 2 +- bs/planet.cpp | 18 +++++++++----- 5 files changed, 100 insertions(+), 26 deletions(-) diff --git a/bs/bsview.cpp b/bs/bsview.cpp index c6fcc46..b5e25b0 100644 --- a/bs/bsview.cpp +++ b/bs/bsview.cpp @@ -185,6 +185,7 @@ void BSView::slotDocumentChanged() } m_InfoView->setBattles(battlenames); updateInfoView(); + setCurrentListViewItem(); updateFleetView(); } @@ -196,9 +197,28 @@ void BSView::slotFleetSelection(QListViewItem *lvi) if (lvi->parent() == '\0') { m_FleetViews->raiseWidget(0); + m_sFleet = QString::null; + m_sGroup = QString::null; + QString temp = lvi->text(0); + + if (temp != m_sBattle) + { + m_sBattle = temp; + slotGenerateReport(); + } } else if (lvi->parent()->parent() == '\0') { + m_sFleet = QString::null; + m_sGroup = lvi->text(0); + QString temp = lvi->parent()->text(0); + + if (temp != m_sBattle) + { + m_sBattle = temp; + slotGenerateReport(); + } + if (lvi->text(0) == tr("Friendly")) { // m_FleetView->slotAttacker(false); @@ -477,6 +497,7 @@ void BSView::slotGenerateReport() const Planet* pl = dynamic_cast(fl); if (pl) { + cerr << "generating....." << endl; ReportList report = pl->report(); QString t; @@ -491,6 +512,7 @@ void BSView::slotGenerateReport() { t.append(QString("
  • Now handling initiative: %0\n").arg(j->first)); t.append("
      \n"); + for(map > >::iterator k = j->second.begin(); k != j->second.end(); ++k) { for(map >::iterator l = k->second.begin(); l != k->second.end(); ++l) @@ -498,6 +520,12 @@ void BSView::slotGenerateReport() t.append(QString("
    • %0 %1 %2 killing/blocking at: \n").arg(l->second["000"]).arg(k->first.c_str()).arg(l->first.c_str())); t.append("
        \n"); + for(map::iterator m = l->second.begin(); m != l->second.end(); ++m) + { + if (m->first != "000") + t.append(QString("
      • %0 %1
      • ").arg(m->second).arg(m->first.c_str())); + } + t.append("
      \n"); t.append("
    • \n"); } @@ -511,9 +539,46 @@ void BSView::slotGenerateReport() } t.append("\n"); //cerr << t.latin1(); - m_Report->clear(); + //m_Report->clear(); m_Report->setText(t); } //m_Report->append("test\n"); } + +////////////////////////////////////////////////////////////////////////// +// +void BSView::setCurrentListViewItem() +{ + QListViewItemIterator i(m_NumberView); + while ( i.current() != 0) + { + QListViewItem* lvi = i.current(); + if (lvi->parent() == '\0') + { + if (m_sFleet.isNull() && m_sGroup.isNull() && m_sBattle == lvi->text(0)) + { + m_NumberView->setCurrentItem(lvi); + return; + } + } + else if (lvi->parent()->parent() == '\0') + { + if (m_sFleet.isNull() && m_sGroup == lvi->text(0) && m_sBattle == lvi->parent()->text(0)) + { + m_NumberView->setCurrentItem(lvi); + return; + } + } + else + { + if (m_sFleet == lvi->text(0) && m_sGroup == lvi->parent()->text(0) && m_sBattle == lvi->parent()->parent()->text(0)) + { + m_NumberView->setCurrentItem(lvi); + return; + } + } + ++i; + } + m_NumberView->setCurrentItem(m_NumberView->firstChild()); +} diff --git a/bs/bsview.h b/bs/bsview.h index 86e7b45..644dc1d 100644 --- a/bs/bsview.h +++ b/bs/bsview.h @@ -69,6 +69,7 @@ class BSView : public QSplitter void updateInfoView(); void updateFleetView(); + void setCurrentListViewItem(); BattleSum *m_BattleSum; diff --git a/bs/fleet.cpp b/bs/fleet.cpp index cd558a6..01ceb2b 100644 --- a/bs/fleet.cpp +++ b/bs/fleet.cpp @@ -119,11 +119,11 @@ void Fleet::setUnits(UnitList& units) s_Units = units; - +/* for (UnitList::iterator i = s_Units.begin(); i != s_Units.end(); i++) { cerr << s_Units[(*i).first].Name() << "\t\t" -/* << s_Units[(*i).first].race() <<"\t" + << s_Units[(*i).first].race() <<"\t" << s_Units[(*i).first].unitClass() << "\t" << s_Units[(*i).first].target(0) << "\t" << s_Units[(*i).first].target(1) << "\t" @@ -137,9 +137,10 @@ void Fleet::setUnits(UnitList& units) << s_Units[(*i).first].EMP() << "\t" << s_Units[(*i).first].totRes() << "\t" << s_Units[(*i).first].fuel() << "\t" - << s_Units[(*i).first].ETA() << "\t"*/ + << s_Units[(*i).first].ETA() << "\t" << s_Units[(*i).first].type() << endl; } + */ } ////////////////////////////////////////////////////////////////////////// @@ -315,12 +316,12 @@ void Fleet::distributeLossesGains(std::vector fleets, int tick) { int fl1 = (*j)->fleet(unittype, tick - 1); float part = float(fl1) / fleet(unittype, 0) ; - int lost = totallost * part; + int lost = int(totallost * part); (*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); + lost = int(part * blockedFleet(unittype, 0)); cerr << (*j)->name() << " got " << lost << " blocked " << unittype << ", the total number of blocked ships was: " << blockedFleet(unittype, 0) << endl; @@ -331,7 +332,7 @@ void Fleet::distributeLossesGains(std::vector fleets, int tick) ////////////////////////////////////////////////////////////////////////// // -std::vector Fleet::calculateSide(std::vector fleets, int stays, int tick) +std::vector Fleet::calculateSide(std::vector fleets, int tick) { vector fl; for (vector::iterator i = fleets.begin(); i != fleets.end(); ++i) @@ -379,13 +380,13 @@ void Fleet::takeShoot(std::string unittype, int number, std::map::iterator i = s_Units[unittype].target().begin(); i != s_Units[unittype].target().end(); ++i) { string ta = s_Units[unittype].target(count); - cerr << "Shooting at target class: " << ta << endl; + //cerr << "Shooting at target class: " << ta << endl; while (gunsleft > 0) { @@ -467,7 +468,7 @@ void Fleet::takeShoot(std::string unittype, int number, std::mapfirst] << " units of type: " << j->first << "killed\n"; + //cerr << hitunits[j->first] << " units of type: " << j->first << "killed\n"; if (k <= 0) gunsleft -= maxguns; else @@ -485,13 +486,13 @@ void Fleet::takeEMP(std::string unittype, int number, std::map if (guns == 0) return; - cerr << unittype << ": with " << guns << " guns\n"; + //cerr << unittype << ": with " << guns << " guns\n"; float gunsleft = guns; for (int count = 0; count < 3; ++count)//vector::iterator i = s_Units[unittype].target().begin(); i != s_Units[unittype].target().end(); ++i) { string ta = s_Units[unittype].target(count); - cerr << "Shooting at target class: " << ta << endl; + //cerr << "Shooting at target class: " << ta << endl; while (gunsleft > 0) { @@ -532,7 +533,7 @@ void Fleet::takeEMP(std::string unittype, int number, std::map for (map::iterator j = targets.begin(); j != targets.end(); ++j) { float maxguns = float((*j->second))/total * guns; - cerr << "Now shooting at target: " << j->first << endl; + //cerr << "Now shooting at target: " << j->first << endl; double k = maxguns; @@ -548,10 +549,11 @@ void Fleet::takeEMP(std::string unittype, int number, std::map k -= float(100)/(100-eres); hits++; + hitunits[j->first]++; blockFleet(j->first, 1); } - cerr << hits << " units of type: " << j->first << " blocked\n"; + //cerr << hits << " units of type: " << j->first << " blocked\n"; if (k <= 0) gunsleft -= maxguns; else @@ -706,7 +708,7 @@ void Fleet::distributeCappedRoids(std::vector fleets, int tick) { unsigned fl1 = (*j)->score(tick - 1); float part = float(fl1) / score(0) ; - int lost = totcapped * part; + int lost = int(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; @@ -745,10 +747,10 @@ void Fleet::calculateLostStealships(string unittype, std::map int stealscore = 0; for (map::iterator i = stolen.begin(); i != stolen.end(); ++i) { - stealscore += stolen[i->first] * (s_Units[i->first].totRes() / 10.0); + stealscore += int(stolen[i->first] * (s_Units[i->first].totRes() / 10.0)); } - int lost = stealscore / (s_Units[unittype].totRes() / 10.0); + int lost = int(stealscore / (s_Units[unittype].totRes() / 10.0)); cerr << "Lost " << lost << " " << unittype << " due to stealing ships worth: " << stealscore << endl; killFleet(unittype, lost, tick); @@ -768,7 +770,7 @@ void Fleet::distributeStolenShips(std::map::iterator k = fleets.begin(); k != fleets.end(); ++k) { - int stolen = float ((*k)->fleet(i->first, tick - 1)) / totalstealers * j->second; + int stolen = int(float ((*k)->fleet(i->first, tick - 1)) / totalstealers * j->second); (*k)->addFleet(j->first, stolen, tick); } } @@ -796,7 +798,7 @@ void Fleet::calculateSalvage() continue; cerr << "(" << tick << ":" << fleet(i->first, tick) << ") "; for (map::iterator k = res.begin(); k != res.end(); ++k) - addResource(k->first, lostunits * k->second * 0.25, tick); + addResource(k->first, int(lostunits * k->second * 0.25), tick); } } } diff --git a/bs/fleet.h b/bs/fleet.h index 9aea01c..6946d3c 100644 --- a/bs/fleet.h +++ b/bs/fleet.h @@ -179,7 +179,7 @@ public: * and are staying long enough. * \todo add the stays part as a integrated part of each fleet. */ - std::vector calculateSide(std::vector fleets, int stays = 0, int tick = 0); + std::vector calculateSide(std::vector fleets, int tick = 0); /** Kill some ships of the specified type in the current fleet. * \param unittype the name of the unit to kill diff --git a/bs/planet.cpp b/bs/planet.cpp index e5aba85..94fa432 100644 --- a/bs/planet.cpp +++ b/bs/planet.cpp @@ -159,8 +159,8 @@ void Planet::runBattle(std::vector friendly, std::vector hostile for(int tick = 1; skipped < 20; ++tick) { //See who's in the battle at the current tick - vector friends = calculateSide(friendly, 6, tick); - vector hostiles = calculateSide(hostile, 3, tick); + vector friends = calculateSide(friendly, tick); + vector hostiles = calculateSide(hostile, tick); // No idea to calculate anything if noone is there.. ;) if (hostiles.size() == 0) @@ -327,10 +327,16 @@ void Planet::calcOneTick(Planet* friendly, Fleet* hostile, std::map 0) + { + m_Report[tick][init]["Friendly"][unittype] = friendlyhits; + m_Report[tick][init]["Friendly"][unittype]["000"] = freefriendly; + } + if (freehostile > 0) + { + 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; -- 2.39.2 From a4366efa718d0f6a883cb5ef9cf1ed9c1bdede4c Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Mon, 1 Jul 2002 18:49:57 +0000 Subject: [PATCH 14/16] added colors to the battle report.. --- bs/bsview.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bs/bsview.cpp b/bs/bsview.cpp index b5e25b0..48b0c59 100644 --- a/bs/bsview.cpp +++ b/bs/bsview.cpp @@ -517,7 +517,13 @@ void BSView::slotGenerateReport() { for(map >::iterator l = k->second.begin(); l != k->second.end(); ++l) { - t.append(QString("
    • %0 %1 %2 killing/blocking at: \n").arg(l->second["000"]).arg(k->first.c_str()).arg(l->first.c_str())); + QString color; + if (k->first == "Friendly") + color = "#46AA1B"; + if (k->first == "Hostile") + color = "#FF0000"; + + t.append(QString("
    • %0 %1 %2 killing/blocking at: \n").arg(l->second["000"]).arg(k->first.c_str()).arg(l->first.c_str()).arg(color)); t.append("
        \n"); for(map::iterator m = l->second.begin(); m != l->second.end(); ++m) -- 2.39.2 From 9fa0d25038087d8417c0849a495eeae1abcb9504 Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Sun, 7 Jul 2002 23:07:01 +0000 Subject: [PATCH 15/16] code cleenup.. --- bs/fleet.cpp | 92 ++++++++++++++++++++-------------------------------- bs/fleet.h | 2 ++ 2 files changed, 37 insertions(+), 57 deletions(-) diff --git a/bs/fleet.cpp b/bs/fleet.cpp index 01ceb2b..0b8598c 100644 --- a/bs/fleet.cpp +++ b/bs/fleet.cpp @@ -389,35 +389,12 @@ void Fleet::takeShoot(std::string unittype, int number, std::map 0) { - - map targets; - - for (UnitList::iterator j = s_Units.begin(); j != s_Units.end(); ++j) - { - if (m_Fleet[j->first].size() == 0) - continue; - - - if (m_Fleet[j->first].size() == 1 ) - m_Fleet[j->first].push_back(m_Fleet[j->first][0]); - - //cerr << "Target is class: " << j->second.type() << endl; - - if (m_Fleet[j->first][1] > 0 && ( ta == j->second.unitClass() || ta == "All")) - { - - // cerr << "Looking at target: " << j->first << endl; - targets[j->first] = &m_Fleet[j->first][1]; - } - } + int total = 0; + map targets = findTargets(ta,total, 0); if (targets.size() == 0) break; - int total = 0; - for (map::iterator j = targets.begin(); j != targets.end(); ++j) - total += (*j->second); - for (map::iterator j = targets.begin(); j != targets.end(); ++j) { float maxguns = float((*j->second))/total * guns; @@ -495,44 +472,15 @@ void Fleet::takeEMP(std::string unittype, int number, std::map //cerr << "Shooting at target class: " << ta << endl; while (gunsleft > 0) { - - map targets; - - for (UnitList::iterator j = s_Units.begin(); j != s_Units.end(); ++j) - { - if (j->second.type() == "PDS") - continue; - - if (freeFleet(j->first, 1) <= 0) - continue; - - if (m_Fleet[j->first].size() == 0) - continue; - - if (m_Fleet[j->first].size() == 1) - m_Fleet[j->first].push_back(m_Fleet[j->first][0]); - - //cerr << "Target is class: " << j->second.type() << endl; - - if (m_Fleet[j->first][1] > 0 && ( ta == j->second.unitClass() || ta == "All")) - { - - // cerr << "Looking at target: " << j->first << endl; - targets[j->first] = &m_Fleet[j->first][1]; - } - - } + int total = 0; + map targets = findTargets(ta, total, 1); if (targets.size() == 0) break; - int total = 0; - for (map::iterator j = targets.begin(); j != targets.end(); ++j) - total += (*j->second); - for (map::iterator j = targets.begin(); j != targets.end(); ++j) { - float maxguns = float((*j->second))/total * guns; + float maxguns = float((*j->second))/total * gunsleft; //cerr << "Now shooting at target: " << j->first << endl; double k = maxguns; @@ -870,3 +818,33 @@ void Fleet::usePodGuns(int tick, int guns) } m_UsedPodGuns[tick] += guns; } + +////////////////////////////////////////////////////////////////////////// +// +std::map Fleet::findTargets(std::string targetClass,int& total, int attackerType) +{ + map targets; + + for (UnitList::iterator i = s_Units.begin(); i != s_Units.end(); ++i) + { + if (m_Fleet[i->first].size() == 0) + continue; + + + if (m_Fleet[i->first].size() == 1 ) + m_Fleet[i->first].push_back(m_Fleet[i->first][0]); + + //cerr << "Target is class: " << j->second.type() << endl; + + if (m_Fleet[i->first][1] > 0 && ( targetClass == i->second.unitClass() || targetClass == "All")) + { + if (i->second.unitClass() == "PDS" && attackerType == 1) + continue; + // cerr << "Looking at target: " << j->first << endl; + targets[i->first] = &m_Fleet[i->first][1]; + total += m_Fleet[i->first][1]; + } + } + + return targets; +} diff --git a/bs/fleet.h b/bs/fleet.h index 6946d3c..2ae03e7 100644 --- a/bs/fleet.h +++ b/bs/fleet.h @@ -282,6 +282,8 @@ public: void usePodGuns(int tick = 0, int guns = 1); + std::map findTargets(std::string targetClass,int& total, int attackerType = 0); + //static functions // /** This function is used to set the different races used. -- 2.39.2 From 147b9d8a408c0ac8b4f284c98fcb5af41873ce9a Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Sat, 24 Aug 2002 22:16:39 +0000 Subject: [PATCH 16/16] some --- bs/fleet.cpp | 45 ++++----------------------------------------- 1 file changed, 4 insertions(+), 41 deletions(-) diff --git a/bs/fleet.cpp b/bs/fleet.cpp index 0b8598c..73923b5 100644 --- a/bs/fleet.cpp +++ b/bs/fleet.cpp @@ -380,13 +380,11 @@ void Fleet::takeShoot(std::string unittype, int number, std::map::iterator i = s_Units[unittype].target().begin(); i != s_Units[unittype].target().end(); ++i) + for (int count = 0; count < 3; ++count) { string ta = s_Units[unittype].target(count); - //cerr << "Shooting at target class: " << ta << endl; + while (gunsleft > 0) { int total = 0; @@ -398,14 +396,11 @@ void Fleet::takeShoot(std::string unittype, int number, std::map::iterator j = targets.begin(); j != targets.end(); ++j) { float maxguns = float((*j->second))/total * guns; - //cerr << "Now shooting at target: " << j->first << endl; if (m_Armor[j->first] <= 0 || m_Armor[j->first] > s_Units[j->first].armor()) m_Armor[j->first] = s_Units[j->first].armor(); double k = maxguns; - //cerr << "Targets agility: " << s_Units[j->first].agility() << endl; - //cerr << "Weaponspeed: " << s_Units[unittype].weaponSpeed() << endl; while (k > 0) { @@ -416,8 +411,6 @@ void Fleet::takeShoot(std::string unittype, int number, std::mapfirst].agility(); k -= float(100)/(25 + wpsp - agil); - //cout << "Used " << blaha << " guns to hit with one shot.\n"; - //cout << "WPSP: " << wpsp << "\nAgil: " << agil << endl; m_Armor[j->first] -= s_Units[unittype].power(); if (m_Armor[j->first] <= 0) @@ -425,27 +418,9 @@ void Fleet::takeShoot(std::string unittype, int number, std::mapfirst] = s_Units[j->first].armor(); (*j->second)--; 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]; - if (test == 1 - && m_BlockedFleet[j->first][0] > 0) - { - if (m_BlockedFleet[j->first].size() == 1) - m_BlockedFleet[j->first].push_back(m_BlockedFleet[j->first][0] - 1); - else if (m_BlockedFleet[j->first][1] > 0) - m_BlockedFleet[j->first][1]--; - } - } - */ } } - - //cerr << hitunits[j->first] << " units of type: " << j->first << "killed\n"; if (k <= 0) gunsleft -= maxguns; else @@ -463,13 +438,11 @@ void Fleet::takeEMP(std::string unittype, int number, std::map if (guns == 0) return; - //cerr << unittype << ": with " << guns << " guns\n"; - float gunsleft = guns; - for (int count = 0; count < 3; ++count)//vector::iterator i = s_Units[unittype].target().begin(); i != s_Units[unittype].target().end(); ++i) + for (int count = 0; count < 3; ++count) { string ta = s_Units[unittype].target(count); - //cerr << "Shooting at target class: " << ta << endl; + while (gunsleft > 0) { int total = 0; @@ -481,10 +454,7 @@ void Fleet::takeEMP(std::string unittype, int number, std::map for (map::iterator j = targets.begin(); j != targets.end(); ++j) { float maxguns = float((*j->second))/total * gunsleft; - //cerr << "Now shooting at target: " << j->first << endl; - double k = maxguns; - int hits = 0; while (k > 0) @@ -500,8 +470,6 @@ void Fleet::takeEMP(std::string unittype, int number, std::map hitunits[j->first]++; blockFleet(j->first, 1); } - - //cerr << hits << " units of type: " << j->first << " blocked\n"; if (k <= 0) gunsleft -= maxguns; else @@ -830,21 +798,16 @@ std::map Fleet::findTargets(std::string targetClass,int& tota if (m_Fleet[i->first].size() == 0) continue; - if (m_Fleet[i->first].size() == 1 ) m_Fleet[i->first].push_back(m_Fleet[i->first][0]); - //cerr << "Target is class: " << j->second.type() << endl; - if (m_Fleet[i->first][1] > 0 && ( targetClass == i->second.unitClass() || targetClass == "All")) { if (i->second.unitClass() == "PDS" && attackerType == 1) continue; - // cerr << "Looking at target: " << j->first << endl; targets[i->first] = &m_Fleet[i->first][1]; total += m_Fleet[i->first][1]; } } - return targets; } -- 2.39.2