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

Method start

bwapi/TestAIModule/Source/MorphTest.cpp:36–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34 FAILTEST(producerType!=UnitTypes::Unknown);
35}
36void MorphTest::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 && u->isIdle()==true)
46 {
47 producer = u;
48 break;
49 }
50 }
51 FAILTEST(producer!=NULL);
52 FAILTEST(producer->isBeingConstructed()==false);
53 FAILTEST(producer->isBurrowed()==false);
54 FAILTEST(producer->isConstructing()==false);
55 FAILTEST(producer->isCompleted()==true);
56 FAILTEST(producer->isIdle()==true);
57 FAILTEST(producer->isMorphing()==false);
58 FAILTEST(producer->isTraining()==false);
59 FAILTEST(producer->getBuildType()==UnitTypes::None);
60 FAILTEST(producer->getBuildUnit()==NULL);
61 FAILTEST(producer->getRemainingTrainTime()==0);
62 FAILTEST(producer->getRemainingBuildTime()==0);
63 correctMineralCount = Broodwar->self()->minerals() - unitType.mineralPrice();
64 correctGasCount = Broodwar->self()->gas() - unitType.gasPrice();
65 if (unitType.isTwoUnitsInOneEgg())
66 correctSupplyUsedCount = Broodwar->self()->supplyUsed() + unitType.supplyRequired()*2 - producerType.supplyRequired();
67 else
68 correctSupplyUsedCount = Broodwar->self()->supplyUsed() + unitType.supplyRequired() - producerType.supplyRequired();
69
70 FAILTEST(producer->morph(unitType));
71
72 FAILTEST(producer->isBeingConstructed()==true);
73 FAILTEST(producer->isBurrowed()==false);
74 FAILTEST(producer->isConstructing()==true);
75 FAILTEST(producer->isCompleted()==false);
76 FAILTEST(producer->isIdle()==false);
77 FAILTEST(producer->isMorphing()==true);
78 FAILTEST(producer->isTraining()==false);
79 FAILTEST(producer->getBuildType()==unitType);
80 FAILTEST(producer->getBuildUnit()==NULL);
81 FAILTEST(producer->getRemainingTrainTime()==0);
82 FAILTEST(producer->getRemainingBuildTime()==unitType.buildTime());
83 FAILTEST(Broodwar->self()->minerals() == correctMineralCount);
84 FAILTEST(Broodwar->self()->gas() == correctGasCount);
85 FAILTEST(Broodwar->self()->supplyUsed() == correctSupplyUsedCount);
86
87 startFrame = Broodwar->getFrameCount();
88 nextFrame = startFrame;
89 previousUnitCount = Broodwar->self()->completedUnitCount(unitType);
90
91}
92void MorphTest::update()
93{

Callers

nothing calls this directly

Calls 15

completedUnitCountMethod · 0.80
isIdleMethod · 0.80
isBeingConstructedMethod · 0.80
isBurrowedMethod · 0.80
isConstructingMethod · 0.80
isCompletedMethod · 0.80
isMorphingMethod · 0.80
isTrainingMethod · 0.80
getBuildTypeMethod · 0.80
getBuildUnitMethod · 0.80
getRemainingTrainTimeMethod · 0.80
getRemainingBuildTimeMethod · 0.80

Tested by

no test coverage detected