MCPcopy Create free account
hub / github.com/bwapi/bwapi / onFrame

Method onFrame

bwapi/TestAIModule/Source/TestMap1.cpp:266–367  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

264{
265}
266void TestMap1::onFrame()
267{
268 Broodwar->drawTextScreen(0,0,"Assert success count: %d",assert_success_count);
269 Broodwar->drawTextScreen(0,20,"Assert failed count: %d",assert_fail_count);
270 int frame=Broodwar->getFrameCount();
271 if (frame==100)
272 {
273 BWAssert(Broodwar->isInGame()==true);
274 BWAssert(Broodwar->isMultiplayer()==false);
275 BWAssert(Broodwar->isPaused()==false);
276 BWAssert(Broodwar->isReplay()==false);
277 BWAssert(Broodwar->self()->minerals()==10050);
278 BWAssert(Broodwar->self()->gas()==10000);
279 BWAssert(Broodwar->self()->gatheredMinerals()==50);
280 BWAssert(Broodwar->self()->gatheredGas()==0);
281 for (Unit u : Broodwar->self()->getUnits())
282 {
283 if (u->getType().isFlyingBuilding())
284 {
285 u->lift();
286 }
287 }
288 }
289 else if (frame==200)
290 {
291 for (Unit u : Broodwar->self()->getUnits())
292 {
293 if (u->getType()==UnitTypes::Terran_Command_Center ||
294 u->getType()==UnitTypes::Terran_Barracks ||
295 u->getType()==UnitTypes::Terran_Engineering_Bay ||
296 u->getType()==UnitTypes::Terran_Factory ||
297 u->getType()==UnitTypes::Terran_Starport ||
298 u->getType()==UnitTypes::Terran_Science_Facility)
299 {
300 BWAssert(u->isLifted()==true);
301 u->land(TilePosition(u->getTilePosition().x,u->getTilePosition().y+2));
302 }
303 else
304 {
305 BWAssert(u->isLifted()==false);
306 }
307 }
308 }
309 else if (frame==300)
310 {
311 for (Unit u : Broodwar->self()->getUnits())
312 {
313 BWAssert(u->isLifted()==false);
314 BWAssert(u->isTraining()==false);
315 if (u->getType()==UnitTypes::Terran_Command_Center)
316 u->train(UnitTypes::Terran_SCV);
317 if (u->getType()==UnitTypes::Terran_Barracks)
318 u->train(UnitTypes::Terran_Marine);
319 if (u->getType()==UnitTypes::Terran_Factory)
320 u->train(UnitTypes::Terran_Vulture);
321 if (u->getType()==UnitTypes::Terran_Starport)
322 u->train(UnitTypes::Terran_Wraith);
323 }

Callers

nothing calls this directly

Calls 15

drawTextScreenMethod · 0.80
mineralsMethod · 0.80
gasMethod · 0.80
gatheredMineralsMethod · 0.80
gatheredGasMethod · 0.80
isFlyingBuildingMethod · 0.80
isLiftedMethod · 0.80
getTilePositionMethod · 0.80
isTrainingMethod · 0.80
isIdleMethod · 0.80
getTrainingQueueMethod · 0.80
completedUnitCountMethod · 0.80

Tested by

no test coverage detected