bool BuildOrderManager::hasResources(BWAPI::UpgradeType t) { if (BWAPI::Broodwar->self()->cumulativeMinerals()-this->usedMinerals< t.mineralPriceBase()+t.mineralPriceFactor()*(BWAPI::Broodwar->self()->getUpgradeLevel(t)-1)) return false; if (BWAPI::Broodwar->self()->cumulativeGas()-this->usedGas<t.gasPriceBase()+t.gasPriceFactor()*(BWAPI::Broodwar->self()->getUpgradeLevel(t)-1)) return false; return true; }
bool BuildOrderManager::hasResources(BWAPI::UpgradeType t, int time) { pair<int, Resources> res; res.first=time; res.second.minerals=t.mineralPrice(this->upgradeManager->getPlannedLevel(t)); res.second.gas=t.gasPrice(this->upgradeManager->getPlannedLevel(t)); return hasResources(res); }
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; }
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; }
ActionID ActionTypeData::GetActionID(const BWAPI::UpgradeType & type) { const RaceID raceID = GetRaceID(type.getRace()); for (ActionID a(0); a < ActionTypeData::GetNumActionTypes(raceID); ++a) { const ActionTypeData & data = GetActionTypeData(raceID, a); if (data.isUpgrade() && data.getUpgradeType() == type) { return data.getActionID(); } } BOSS_ASSERT(false, "Could not find TechType: %d %s", type.getID(), type.getName().c_str()); return 0; }
// UpgradeType action ActionTypeData::ActionTypeData(BWAPI::UpgradeType t, const ActionID id) : type(UpgradeType) , upgrade(t) , actionID(id) , raceID(GetRaceID(t.getRace())) , mineralPriceVal(t.mineralPrice() * Constants::RESOURCE_SCALE) , gasPriceVal(t.gasPrice() * Constants::RESOURCE_SCALE) , supplyRequiredVal(0) , supplyProvidedVal(0) , buildTimeVal(t.upgradeTime()) , numberProduced(1) , name(t.getName()) , metaName(t.getName()) , building(false) , worker(false) , refinery(false) , resourceDepot(false) , supplyProvider(false) , canProduceBool(false) , canAttackBool(false) , whatBuildsUnitType(t.whatUpgrades()) , addon(false) , reqAddon(false) , reqAddonID(0) , morphed(false) { setShortName(); }
UpgradeTest::UpgradeTest(BWAPI::UpgradeType upgradeType) : upgradeType(upgradeType), upgrader(NULL), startUpgradeFrame(-1), nextUpdateFrame(-1) { fail = false; running = false; upgraderType = upgradeType.whatUpgrades(); BWAssertF(upgraderType!=UnitTypes::None,{fail=true;return;});
CancelUpgradeTest::CancelUpgradeTest(BWAPI::UpgradeType upgradeType) : upgradeType(upgradeType), upgraderType(upgradeType.whatUpgrades()), startFrame(-1), nextFrame(-1), upgrader(NULL), correctMineralCount(0), correctGasCount(0), correctSupplyUsedCount(0) { fail = false; running = false; BWAssertF(upgraderType!=UnitTypes::None,{fail=true;return;});
/*** * 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); }
bool CheeseStrategies::StandardPlay::startUpgrade(BWAPI::UpgradeType upgrade) { UnitType upBuildingType = upgrade.whatUpgrades(); if (Broodwar->self()->completedUnitCount(upBuildingType) == 0) { return false; } UnitSet myUnits = BWAPI::Broodwar->self()->getUnits(); UnitSet::iterator it; BWAPI::Unit* upBuilding; for (it=myUnits.begin(); it!=myUnits.end(); it++) { if ((*it)->getType() == upBuildingType) { upBuilding = (*it); } } return upBuilding->upgrade(upgrade); }
void BuildOrderManager::spendResources(BWAPI::UpgradeType t) { this->usedMinerals+=t.mineralPrice(this->upgradeManager->getPlannedLevel(t)); this->usedGas+=t.gasPrice(this->upgradeManager->getPlannedLevel(t)); }
MetaType::MetaType (BWAPI::UpgradeType t) : _upgradeType(t) , _type(MetaTypes::Upgrade) , _race(t.getRace()) { }
Resources::Resources(BWAPI::UpgradeType type, int level) { minerals = type.mineralPrice(level); gas = type.gasPrice(level); supply = 0.0; }
void BuildOrderManager::spendResources(BWAPI::UpgradeType t) { this->usedMinerals+=t.mineralPriceBase()+t.mineralPriceFactor()*(BWAPI::Broodwar->self()->getUpgradeLevel(t)-1); this->usedGas+=t.gasPriceBase()+t.gasPriceFactor()*(BWAPI::Broodwar->self()->getUpgradeLevel(t)-1); }
ActionTypeData ActionTypeData::GetActionTypeData(const BWAPI::UpgradeType & a) { return GetActionTypeData(GetRaceID(a.getRace()), GetActionID(a)); }