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

Method start

bwapi/TestAIModule/Source/RepairTest.cpp:15–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13 running = false;
14}
15void RepairTest::start()
16{
17 if (fail) return;
18 running = true;
19
20 int userCount = Broodwar->self()->completedUnitCount(unitType);
21 BWAssertF(userCount>=1,{fail=true;return;});
22 for (Unit u : Broodwar->self()->getUnits())
23 if (u->getType()==unitType)
24 unit = u;
25 BWAssertF(unit!=NULL,{fail=true;return;});
26 BWAssertF(unit->exists(),{fail=true;return;});
27
28 int targetCount = Broodwar->self()->completedUnitCount(targetType);
29 BWAssertF(targetCount>=1,{fail=true;return;});
30 for (Unit u : Broodwar->self()->getUnits())
31 if (u->getType()==targetType && u->getHitPoints()<targetType.maxHitPoints())
32 target = u;
33 BWAssertF(target!=NULL,{fail=true;return;});
34 BWAssertF(target->exists(),{fail=true;return;});
35 BWAssertF(unit->isIdle()==true,{fail=true;return;});
36 BWAssertF(unit->repair(target),{Broodwar->printf("%s",Broodwar->getLastError().c_str());fail=true;return;});
37 BWAssertF(unit->getOrder()==Orders::Repair,{Broodwar->printf("%s",unit->getOrder().c_str());fail=true;return;});
38 BWAssertF(unit->getTarget()==target,{fail=true;return;});
39 startFrame = Broodwar->getFrameCount();
40 nextFrame = Broodwar->getFrameCount();
41 stopped = false;
42}
43void RepairTest::update()
44{
45 if (running == false) return;

Callers

nothing calls this directly

Calls 15

completedUnitCountMethod · 0.80
getHitPointsMethod · 0.80
maxHitPointsMethod · 0.80
isIdleMethod · 0.80
printfMethod · 0.80
c_strMethod · 0.80
getLastErrorMethod · 0.80
selfMethod · 0.45
getUnitsMethod · 0.45
getTypeMethod · 0.45
existsMethod · 0.45
repairMethod · 0.45

Tested by

no test coverage detected