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

Method start

bwapi/TestAIModule/Source/BuildTest.cpp:37–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35 FAILTEST(builderType!=UnitTypes::Unknown);
36}
37void BuildTest::start()
38{
39 if (fail) return;
40 running = true;
41
42 int builderCount = Broodwar->self()->completedUnitCount(builderType);
43 FAILTEST(builderCount>=1);
44 for (Unit u : Broodwar->self()->getUnits())
45 {
46 if (u->getType()==builderType && u->getAddon()==NULL)
47 {
48 builder = u;
49 break;
50 }
51 }
52 FAILTEST(builder!=NULL);
53 FAILTEST(builder->isIdle()==true);
54
55
56 if (unitType.isAddon())
57 {
58 FAILTEST(builder->buildAddon(unitType));
59 }
60 else
61 {
62 if (unitType==UnitTypes::Protoss_Pylon)
63 {
64 buildLocation = BuildingPlacer::getBuildLocationNear(builder->getTilePosition(), unitType, 4);
65 }
66 else if ((unitType.getRace()==Races::Zerg && unitType.isResourceDepot()) || unitType==UnitTypes::Protoss_Gateway)
67 {
68 buildLocation = BuildingPlacer::getBuildLocationNear(builder->getTilePosition(), unitType, 2);
69 }
70 {
71 buildLocation = BuildingPlacer::getBuildLocationNear(builder->getTilePosition(), unitType, 1);
72 }
73 FAILTEST(builder->build(unitType, buildLocation));
74 }
75 FAILTEST( !builder->isIdle() );
76 FAILTEST( builder->isConstructing() );
77 BWAssertF(builder->getBuildType()==unitType,
78 {
79 log("Error: %s != %s",builder->getBuildType().c_str(),unitType.c_str());
80 fail=true;
81 return;
82 });
83
84 nextFrame = Broodwar->getFrameCount();
85 previousUnitCount = Broodwar->self()->completedUnitCount(unitType);
86
87}
88void BuildTest::update()
89{
90 if (running == false) return;

Callers

nothing calls this directly

Calls 15

logFunction · 0.85
completedUnitCountMethod · 0.80
getAddonMethod · 0.80
isIdleMethod · 0.80
isAddonMethod · 0.80
getTilePositionMethod · 0.80
isResourceDepotMethod · 0.80
isConstructingMethod · 0.80
getBuildTypeMethod · 0.80
c_strMethod · 0.80
selfMethod · 0.45
getUnitsMethod · 0.45

Tested by

no test coverage detected