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

Method start

bwapi/TestAIModule/Source/CancelMorphTest.cpp:36–75  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34 FAILTEST(producerType!=UnitTypes::Unknown);
35}
36void CancelMorphTest::start()
37{
38 if (fail) return;
39 running = true;
40
41 int producerCount = Broodwar->self()->completedUnitCount(producerType);
42 FAILTEST(producerCount>=1);
43 for (Unit u : Broodwar->self()->getUnits())
44 {
45 if (u->getType()==producerType)
46 {
47 producer = u;
48 break;
49 }
50 }
51 correctMineralCount = Broodwar->self()->minerals();
52 correctGasCount = Broodwar->self()->gas();
53 correctSupplyUsedCount = Broodwar->self()->supplyUsed();
54 correctCompletedUnitCount = Broodwar->self()->completedUnitCount(unitType);
55 correctIncompleteUnitCount = Broodwar->self()->incompleteUnitCount(unitType);
56 correctAllUnitCount = Broodwar->self()->allUnitCount(unitType);
57 producer->morph(unitType);
58 BWAssertF(producer->getBuildType()==unitType,
59 {
60 log("%s != %s",producer->getBuildType().c_str(),unitType.c_str());
61 fail=true;
62 return;
63 });
64
65 startFrame = Broodwar->getFrameCount();
66 nextFrame = startFrame;
67 if (producerType.isBuilding())
68 {
69 correctMineralCount -= unitType.mineralPrice();
70 correctGasCount -= unitType.gasPrice();
71 correctMineralCount += (int)(unitType.mineralPrice()*0.75);
72 correctGasCount += (int)(unitType.gasPrice()*0.75);
73 }
74
75}
76void CancelMorphTest::update()
77{
78 if (running == false) return;

Callers

nothing calls this directly

Calls 15

logFunction · 0.85
completedUnitCountMethod · 0.80
mineralsMethod · 0.80
gasMethod · 0.80
supplyUsedMethod · 0.80
incompleteUnitCountMethod · 0.80
allUnitCountMethod · 0.80
getBuildTypeMethod · 0.80
c_strMethod · 0.80
isBuildingMethod · 0.80
selfMethod · 0.45
getUnitsMethod · 0.45

Tested by

no test coverage detected