]> ruin.nu Git - hbs.git/commitdiff
changed the capping functionallity..
authorMichael Andreen <harv@ruin.nu>
Tue, 4 Jun 2002 21:08:16 +0000 (21:08 +0000)
committerMichael Andreen <harv@ruin.nu>
Tue, 4 Jun 2002 21:08:16 +0000 (21:08 +0000)
bs/fleet.cpp
bs/fleet.h
bs/planet.cpp
share/stats.conf

index 4072788a4af0d142607e8302e2dffb89b4010d83..bab852f0bf704b941a00b464771ac7d4fd37960d 100644 (file)
@@ -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;
+}
index f632093bd51c8e766c2cd00ecc40f3b85a4e0424..673eb42037aa9ef965782ff4e1f81f194aedc0c9 100644 (file)
@@ -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<int> m_UsedPodGuns; 
        
 
 
index 935c65d33fc228c3ab8c271e0a01708a435bcda9..fdeb78989e47e37cf2f7f09a34af04b139f57c31 100644 (file)
@@ -228,10 +228,11 @@ void Planet::calcOneTick(Planet* friendly, Fleet* hostile, std::map<std::string,
        else
                setCapping(0, tick);
                        
-       map<string, int> pods;
+       //FIXME: remove this line later.. map<string, int> 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<int, string> 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::map<std::string,
                                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 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::map<std::string,
                *hostile = *hostiletemp;
                delete hostiletemp;
        }
-       hostile->addFleet(pods, 1);
+       //hostile->addFleet(pods, 1);
        
 }
 
index 676079c44b00048ab55901c2b2dd469ce9c5258a..554a6fdcab63635d9c058073dc1e88f53b5ad74c 100644 (file)
@@ -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