return m_Fleet[unittype][tick];
}
+//////////////////////////////////////////////////////////////////////////
+//
+int Fleet::blockedFleet(std::string unittype, int tick = 0)
+{
+ int ticks = m_BlockedFleet[unittype].size();
+ if (ticks == 0)
+ return 0;
+
+ --ticks;
+
+ if (ticks < tick)
+ return 0;
+
+ return m_BlockedFleet[unittype][tick];
+}
+
+//////////////////////////////////////////////////////////////////////////
+//
+void Fleet::setBlockedFleet(std::string unittype, int number, int tick = 0)
+{
+ int ticks = m_BlockedFleet[unittype].size();
+
+ for (int i = ticks; i <= tick; ++i)
+ {
+ m_BlockedFleet[unittype].push_back(0);
+ }
+ m_BlockedFleet[unittype][tick] = number;
+
+ cerr << "This fleet got " << m_BlockedFleet[unittype][tick] << " blocked units tick: " << tick << endl;
+
+}
+
//////////////////////////////////////////////////////////////////////////
//FIXME
void Fleet::addToThis(std::vector<Fleet*> fleets, int tick = 0)
int fl1 = (*j)->fleet(unittype, tick - 1);
float part = float(fl1) / fleet(unittype, 0) ;
int lost = totallost * part;
- cerr << (*j)->name() << " gaining " << lost << " " << unittype << " since it's " << part * 100 << "% of the whole fleet, and it had : " << fl1 << " units last tick.." << endl;
(*j)->setFleet(unittype, (*j)->fleet(unittype, tick - 1) + lost, tick);
+
+ cerr << (*j)->name() << " gaining " << lost << " " << unittype << " since it's " << part * 100 << "% of the whole fleet, and it had : " << fl1 << " units last tick.." << endl;
+
+ lost = part * blockedFleet(unittype, 0);
+
+ cerr << (*j)->name() << " got " << lost << " blocked " << unittype << ", the total number of blocked ships was: " << blockedFleet(unittype, 0) << endl;
+
+ (*j)->setBlockedFleet(unittype, lost, tick);
}
}
}
if (m_Fleet[j->first].size() == 0)
continue;
- if (m_Fleet[j->first].size() == 1)
+
+ 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 (j->second.type() == "PDS")
continue;
+ if (freeFleet(j->first, 1) <= 0)
+ continue;
+
if (m_Fleet[j->first].size() == 0)
continue;
for (map<string, int*>::iterator j = targets.begin(); j != targets.end(); ++j)
{
- int maxguns = (*j->second)/total * guns;
+ float maxguns = float((*j->second))/total * guns;
cerr << "Now shooting at target: " << j->first << endl;
double k = maxguns;
while (k > 0)
{
- if (*(j->second) <= 0)
+ if (*(j->second) <= blockedFleet(j->first, 1))
break;
int eres = s_Units[j->first].EMP();
{
int ticks = m_Resources[type].size();
+ int latest = 0;
+
+ if (ticks > 0)
+ latest = m_Resources[type][ticks - 1];
+
for (int i = ticks; i <= tick; ++i)
- m_Resources[type].push_back(number);
+ m_Resources[type].push_back(latest);
m_Resources[type][tick] += number;
}
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);
}
}
}