| 37 | FAILTEST(builderType!=UnitTypes::Unknown); |
| 38 | } |
| 39 | void 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 |
nothing calls this directly
no test coverage detected