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

Method start

bwapi/TestAIModule/Source/RightClickTest.cpp:17–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15 running = false;
16}
17void RightClickTest::start()
18{
19 if (fail) return;
20 running = true;
21
22 int userCount = Broodwar->self()->completedUnitCount(unitType);
23 BWAssertF(userCount>=1,{fail=true;return;});
24 for (Unit u : Broodwar->self()->getUnits())
25 if (u->getType()==unitType)
26 unit = u;
27
28 int enemyCount = Broodwar->self()->completedUnitCount(enemyType);
29 BWAssertF(enemyCount >= 1, { fail = true; return; });
30 for (Unit u : Broodwar->getAllUnits())
31 if (u->getType()==enemyType && u->getPlayer()->isEnemy(Broodwar->self()))
32 enemyUnit = u;
33
34 int friendCount = Broodwar->self()->completedUnitCount(friendlyType);
35 BWAssertF(friendCount >= 1, { fail = true; return; });
36 for (Unit u : Broodwar->getAllUnits())
37 if (u->getType()==friendlyType && u->getPlayer()->isAlly(Broodwar->self()))
38 friendUnit = u;
39 BWAssertF(unit!=NULL,{fail=true;return;});
40 BWAssertF(unit->exists(),{fail=true;return;});
41 BWAssertF(enemyUnit!=NULL,{fail=true;return;});
42 BWAssertF(enemyUnit->exists(),{fail=true;return;});
43 BWAssertF(friendUnit!=NULL,{fail=true;return;});
44 BWAssertF(friendUnit->exists(),{fail=true;return;});
45 targetPosition = unit->getPosition();
46 targetPosition.y-=30*32;
47 targetPosition.makeValid();
48 unit->rightClick(targetPosition);
49 BWAssertF(unit->getOrder()==Orders::Move,{fail=true;return;});
50 BWAssertF(unit->getTargetPosition()==targetPosition,{fail=true;return;});
51 startFrame = Broodwar->getFrameCount();
52 nextFrame = Broodwar->getFrameCount();
53}
54void RightClickTest::update()
55{
56 if (running == false) return;

Callers

nothing calls this directly

Calls 13

completedUnitCountMethod · 0.80
selfMethod · 0.45
getUnitsMethod · 0.45
getTypeMethod · 0.45
isEnemyMethod · 0.45
getPlayerMethod · 0.45
isAllyMethod · 0.45
existsMethod · 0.45
getPositionMethod · 0.45
rightClickMethod · 0.45
getOrderMethod · 0.45
getTargetPositionMethod · 0.45

Tested by

no test coverage detected