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

Method start

bwapi/TestAIModule/Source/CancelConstructionTest.cpp:39–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 15

logFunction · 0.85
completedUnitCountMethod · 0.80
getAddonMethod · 0.80
isIdleMethod · 0.80
mineralsMethod · 0.80
gasMethod · 0.80
supplyUsedMethod · 0.80
isAddonMethod · 0.80
getTilePositionMethod · 0.80
isResourceDepotMethod · 0.80
printfMethod · 0.80
c_strMethod · 0.80

Tested by

no test coverage detected