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

Method start

bwapi/TestAIModule/Source/ResearchTest.cpp:18–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16 BWAssertF(researcherType!=UnitTypes::Unknown,{fail=true;return;});
17}
18void ResearchTest::start()
19{
20 if (fail) return;
21 running = true;
22
23 int researcherCount = Broodwar->self()->completedUnitCount(researcherType);
24 BWAssertF(researcherCount>=1,{fail=true;return;});
25 for (Unit u : Broodwar->self()->getUnits())
26 {
27 if (u->getType()==researcherType)
28 {
29 researcher = u;
30 break;
31 }
32 }
33 BWAssertF(researcher!=NULL,{fail=true;return;});
34
35 BWAssertF(researcher->getOrder()==Orders::Nothing,{fail=true;return;});
36 BWAssertF(researcher->isIdle()==true,{fail=true;return;});
37 BWAssertF(researcher->isLifted()==false,{fail=true;return;});
38 BWAssertF(researcher->isResearching()==false,{fail=true;return;});
39 BWAssertF(researcher->isUpgrading()==false,{fail=true;return;});
40 BWAssertF(researcher->getTech()==TechTypes::None,{fail=true;return;});
41 BWAssertF(researcher->getUpgrade()==UpgradeTypes::None,{fail=true;return;});
42 BWAssertF(researcher->getRemainingResearchTime()==0,{fail=true;return;});
43 BWAssertF(Broodwar->self()->hasResearched(techType)==false,{fail=true;return;});
44 correctMineralCount = Broodwar->self()->minerals() - techType.mineralPrice();
45 correctGasCount = Broodwar->self()->gas() - techType.gasPrice();
46
47 researcher->research(techType);
48
49 BWAssertF(researcher->getOrder()==Orders::ResearchTech,{fail=true;return;});
50 BWAssertF(researcher->isIdle()==false,{fail=true;return;});
51 BWAssertF(researcher->isLifted()==false,{fail=true;return;});
52 BWAssertF(researcher->isResearching()==true,{fail=true;return;});
53 BWAssertF(researcher->isUpgrading()==false,{fail=true;return;});
54 BWAssertF(researcher->getTech()==techType,{fail=true;return;});
55 BWAssertF(researcher->getUpgrade()==UpgradeTypes::None,{fail=true;return;});
56 BWAssertF(researcher->getRemainingResearchTime()==techType.researchTime(),
57 {
58 Broodwar->printf("%d %d",researcher->getRemainingResearchTime(),techType.researchTime()/10);
59 fail=true;
60 return;
61 });
62 BWAssertF(Broodwar->self()->hasResearched(techType)==false,{fail=true;return;});
63 BWAssertF(Broodwar->self()->minerals() == correctMineralCount,{fail=true;return;});
64 BWAssertF(Broodwar->self()->gas() == correctGasCount,{fail=true;return;});
65
66 startResearchFrame = Broodwar->getFrameCount();
67 nextUpdateFrame = startResearchFrame;
68
69}
70void ResearchTest::update()
71{
72 if (running == false) return;

Callers

nothing calls this directly

Calls 15

completedUnitCountMethod · 0.80
isIdleMethod · 0.80
isLiftedMethod · 0.80
getUpgradeMethod · 0.80
hasResearchedMethod · 0.80
mineralsMethod · 0.80
gasMethod · 0.80
researchTimeMethod · 0.80
printfMethod · 0.80
selfMethod · 0.45
getUnitsMethod · 0.45

Tested by

no test coverage detected