std::string vshow(const DexField* p) { if (!p) return ""; std::ostringstream ss; ss << accessibility(p->get_access()) << humanize(show(p->get_type())) << " " << humanize(show(p->get_class())) << "." << show(p->get_name()); if (p->get_anno_set()) { ss << "\n annotations:" << show(p->get_anno_set()); } return ss.str(); }
bool UnitClass::isCompleted() { if(exists()) { if(mUnit->isCompleted()) return true; if(mUnit->getPlayer() == BWAPI::Broodwar->self()) return mUnit->getRemainingBuildTime() == 0; return false; } if(accessibility() == AccessType::Prediction) return false; if(mStoredCompleted) return true; return mStoredCompletedTime <= BWAPI::Broodwar->getFrameCount(); }
std::string vshow(const DexClass* p) { if (!p) return ""; std::ostringstream ss; ss << accessibility(p->get_access()) << humanize(show(p->get_type())) << " extends " << humanize(show(p->get_super_class())); if (p->get_interfaces()) { ss << " implements "; bool first = true; for (auto const type : p->get_interfaces()->get_type_list()) { if (first) first = false; else ss << ", "; ss << humanize(show(type)); } } if (p->get_anno_set()) { ss << "\n annotations:" << show(p->get_anno_set()); } return ss.str(); }
void UnitClass::update() { if(exists()) { mStoredTime = BWAPI::Broodwar->getFrameCount(); mStoredPosition = mUnit->getPosition(); mStoredType = mUnit->getType(); mStoredPlayer = mUnit->getPlayer(); mStoredInt = mUnit->getResources(); if(mStoredCompleted && !mUnit->isCompleted()) mStoredCompletedTime = BWAPI::Broodwar->getFrameCount() + mUnit->getType().buildTime(); mStoredCompleted = mUnit->isCompleted(); if(!mStoredMorphing && mUnit->isMorphing()) mStoredCompletedTime = BWAPI::Broodwar->getFrameCount() + mUnit->getBuildType().buildTime(); mStoredMorphing = mUnit->isMorphing(); if(mUnit->getPlayer() == BWAPI::Broodwar->self()) mStoredCompletedTime = BWAPI::Broodwar->getFrameCount() + mUnit->getRemainingBuildTime(); else if(mUnit->isCompleted() && !mUnit->isMorphing()) mStoredCompletedTime = BWAPI::Broodwar->getFrameCount(); mStoredTargetPosition = mUnit->getTargetPosition(); mStoredHealth = mUnit->getHitPoints(); mStoredShield = mUnit->getShields(); if(mUnit->getType().isFlyingBuilding()) mStoredBoolOne = mUnit->isLifted(); else if(mUnit->getType() == BWAPI::UnitTypes::Terran_Siege_Tank_Siege_Mode || mUnit->getType() == BWAPI::UnitTypes::Terran_Siege_Tank_Tank_Mode) mStoredBoolOne = mUnit->isSieged(); mStoredAccessType = accessibility(); } }
void UnitClass::drawUnitPosition() { const Position &pos = getPosition(); const BWAPI::UnitType &type = getType(); Player player = getPlayer(); const int barHeight = 4; if((!isCompleted() || isMorphing()) && accessibility() != AccessType::Prediction) { double progress = getCompletedTime() - BWAPI::Broodwar->getFrameCount(); if(isMorphing()) progress /= getBuildType().buildTime(); else progress /= type.buildTime(); progress = 1.0 - progress; BWAPI::Color barColour = isMorphing() ? BWAPI::Colors::Red : BWAPI::Colors::Purple; Position bottomLeft(pos.x() - type.dimensionLeft(), pos.y() + type.dimensionDown() + barHeight - 1); DrawingHelper::Instance().drawProgressBar(bottomLeft, type.dimensionLeft()+type.dimensionRight(), barHeight, progress, barColour, player->getColor()); } if(type.maxShields() > 0) { double progress = getShield(); progress /= type.maxShields(); Position bottomLeft(pos.x() - type.dimensionLeft(), pos.y() - type.dimensionUp() - barHeight + 2); DrawingHelper::Instance().drawProgressBar(bottomLeft, type.dimensionLeft()+type.dimensionRight(), barHeight, progress, BWAPI::Colors::Blue, player->getColor()); } if(type.maxHitPoints() > 0) { double progress = getHealth(); progress /= type.maxHitPoints(); Position bottomLeft(pos.x() - type.dimensionLeft(), pos.y() - type.dimensionUp() + 1); DrawingHelper::Instance().drawProgressBar(bottomLeft, type.dimensionLeft()+type.dimensionRight(), barHeight, progress, BWAPI::Colors::Green, player->getColor()); } BWAPI::Broodwar->drawBox(BWAPI::CoordinateType::Map, pos.x() - type.dimensionLeft(), pos.y() - type.dimensionUp(), pos.x() + type.dimensionRight(), pos.y() + type.dimensionDown(), player->getColor()); BWAPI::Broodwar->drawTextMap(pos.x() + type.dimensionRight(), pos.y(), "%s", player->getName().c_str()); AccessType access = accessibility(); BWAPI::Broodwar->drawTextMap(pos.x() + type.dimensionRight(), pos.y()+10, "%s", AccessType::getName(access.underlying()).c_str()); int existTime = getExistTime() - BWAPI::Broodwar->getFrameCount(); int completeTime = getCompletedTime() - BWAPI::Broodwar->getFrameCount() - existTime; BWAPI::Broodwar->drawTextMap(pos.x() + type.dimensionRight(), pos.y()+20, "%d : %d", existTime, completeTime); if(isMorphing()) BWAPI::Broodwar->drawTextMap(pos.x() + type.dimensionRight(), pos.y()+30, "Morphing"); else if(isCompleted()) BWAPI::Broodwar->drawTextMap(pos.x() + type.dimensionRight(), pos.y()+30, "Completed"); Position target = getTargetPosition(); BWAPI::Broodwar->drawLine(BWAPI::CoordinateType::Map, pos.x(), pos.y(), target.x(), target.y(), player->getColor()); }
std::string vshow(uint32_t acc) { return accessibility(acc, 32); }