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

Method onFrame

bwapi/TestAIModule/Source/EventTest.cpp:64–195  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

62 return;
63}
64void EventTest::onFrame()
65{
66 BWAssert(onStartCalled==true);
67 BWAssert(onEndCalled==false);
68 strictEventChecking = true;
69 if (Broodwar->getFrameCount()<5) return;
70 Broodwar->drawTextScreen(0,0,"FPS: %d",Broodwar->getFPS());
71 Broodwar->drawTextScreen(0,20,"Assert success count: %d",assert_success_count);
72 if (assert_fail_count==0)
73 Broodwar->drawTextScreen(0,40,"Assert failed count: %d",assert_fail_count);
74 else
75 Broodwar->drawTextScreen(0,40,"\x08 Assert failed count: %d",assert_fail_count);
76 if (state == Start)
77 {
78 state = TrainingSCV;
79
80 Unit cc = NULL;
81 for (Unit u : Broodwar->self()->getUnits())
82 if (u->getType()==UnitTypes::Terran_Command_Center)
83 cc = u;
84 BWAssert(cc!=NULL);
85
86 cc->train(UnitTypes::Terran_SCV);
87 expectedEvents.push_back(Event::UnitCreate(NULL));
88 expectedEvents.push_back(Event::UnitDiscover(NULL));
89 expectedEvents.push_back(Event::UnitShow(NULL));
90 }
91 else if (state == TrainingSCV)
92 {
93 if (expectedEvents.empty())
94 {
95 state = BuildingRefinery;
96
97 Unit scv = NULL;
98 for (Unit u : Broodwar->self()->getUnits())
99 if (u->getType()==UnitTypes::Terran_SCV && u->isCompleted())
100 scv = u;
101 BWAssert(scv!=NULL);
102
103 TilePosition tilePosition=TilePositions::None;
104 for (Unit u : Broodwar->getGeysers())
105 tilePosition=u->getTilePosition();
106 scv->build(UnitTypes::Terran_Refinery,tilePosition);
107 expectedEvents.push_back(Event::UnitMorph(NULL));
108 expectedEvents.push_back(Event::UnitRenegade(NULL));
109 }
110 }
111 else if (state == BuildingRefinery)
112 {
113 if (expectedEvents.empty())
114 {
115 state = KillingSCV;
116
117 Unit scv = NULL;
118 for (Unit u : Broodwar->self()->getUnits())
119 if (u->getType()==UnitTypes::Terran_SCV && u->isCompleted())
120 scv=u;
121 BWAssert(scv!=NULL);

Callers

nothing calls this directly

Calls 15

UnitMorphClass · 0.85
drawTextScreenMethod · 0.80
isCompletedMethod · 0.80
getTilePositionMethod · 0.80
isIdleMethod · 0.80
hasNukeMethod · 0.80
PositionClass · 0.50
getFrameCountMethod · 0.45
getFPSMethod · 0.45
getUnitsMethod · 0.45
selfMethod · 0.45
getTypeMethod · 0.45

Tested by

no test coverage detected