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

Method update

bwapi/TestAIModule/Source/CloakTest.cpp:41–89  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39
40}
41void CloakTest::update()
42{
43 if (running == false) return;
44 if (fail)
45 {
46 running = false;
47 return;
48 }
49 int thisFrame = Broodwar->getFrameCount();
50 BWAssert(thisFrame==nextFrame);
51 nextFrame++;
52 Broodwar->setScreenPosition(unit->getPosition() - Position(320,240));
53 if (unit->getEnergy()!=currentEnergy)
54 {
55 currentEnergy++;
56 BWAssertF(abs(unit->getEnergy()-currentEnergy)<5,{Broodwar->printf("%d != %d",unit->getEnergy(),currentEnergy);fail=true;return;});
57 currentEnergy=unit->getEnergy();
58 }
59
60 if (completedCloak==false)
61 {
62 if (unit->getOrder()!=Orders::Cloak && thisFrame>startFrame+60)
63 {
64 BWAssertF(unit->isCloaked()==true,{fail=true;return;});
65 completedCloak=true;
66 unit->decloak();
67 BWAssertF(unit->getOrder()==Orders::Decloak,{fail=true;return;});
68 startFrame=thisFrame;
69 }
70 else
71 {
72 if (thisFrame>startFrame+300)
73 fail = true;
74 }
75 }
76 else
77 {
78 if (unit->getOrder()!=Orders::Decloak && thisFrame>startFrame+60)
79 {
80 BWAssertF(unit->isCloaked()==false,{fail=true;return;});
81 running = false;
82 }
83 else
84 {
85 if (thisFrame>startFrame+300)
86 fail = true;
87 }
88 }
89}
90
91void CloakTest::stop()
92{

Callers

nothing calls this directly

Calls 9

getEnergyMethod · 0.80
printfMethod · 0.80
isCloakedMethod · 0.80
PositionClass · 0.50
getFrameCountMethod · 0.45
setScreenPositionMethod · 0.45
getPositionMethod · 0.45
getOrderMethod · 0.45
decloakMethod · 0.45

Tested by

no test coverage detected