bool UpgradeManager::upgrade(BWAPI::UpgradeType type)
{
  int level=BWAPI::Broodwar->self()->getUpgradeLevel(type)+1;
  if (level>type.maxRepeats()) return false;
  Upgrade newUpgrade;
  newUpgrade.type=type;
  newUpgrade.level=level;
  upgradeQueues[*type.whatUpgrades()].push_back(newUpgrade);
  plannedLevel[type]=level;
  return true;
}
Пример #2
0
bool UpgradeManager::upgrade(BWAPI::UpgradeType type, int level)
{
	if (level<=0)
		level=this->getPlannedLevel(type)+1;
	if (level>type.maxRepeats()) return false;
	Upgrade newUpgrade;
	newUpgrade.type=type;
	newUpgrade.level=level;
	upgradeQueues[type.whatUpgrades()].push_back(newUpgrade);
	plannedLevel[type]=level;
	return true;
}
Пример #3
0
/***
 * Researches the UpgradeType t
 */
void Producer::researchUpgrade(BWAPI::UpgradeType t)
{
	if (Broodwar->self()->getUpgradeLevel(t) >= t.maxRepeats())
		return;
	checkCanUpgrade(t);
	for (list<UpgradeType>::const_iterator it = _upgradesQueue.begin();
		it != _upgradesQueue.end(); ++it)
	{
		if (*it == t)
			return;
	}
	_upgradesQueue.push_back(t);
}