| 45 | state=1; |
| 46 | } |
| 47 | void GatherTest::update() |
| 48 | { |
| 49 | if (running == false) return; |
| 50 | if (fail) |
| 51 | { |
| 52 | running = false; |
| 53 | return; |
| 54 | } |
| 55 | int thisFrame = Broodwar->getFrameCount(); |
| 56 | BWAssert(thisFrame==nextFrame); |
| 57 | nextFrame++; |
| 58 | Broodwar->setScreenPosition(worker->getPosition() - Position(320,240)); |
| 59 | if (state==1 && Broodwar->self()->minerals()>initialMinerals+50 && worker->isGatheringMinerals()) |
| 60 | { |
| 61 | BWAssertF(worker->gather(refinery),{Broodwar->printf("%s",Broodwar->getLastError().c_str());fail=true;return;}) |
| 62 | state = 2; |
| 63 | } |
| 64 | if (state==2 && Broodwar->self()->gas()>initialGas+50 && worker->isGatheringGas() && worker->isCarryingGas()) |
| 65 | { |
| 66 | BWAssertF(worker->stop(),{Broodwar->printf("%s",Broodwar->getLastError().c_str());fail=true;return;}) |
| 67 | startFrame = thisFrame; |
| 68 | state = 3; |
| 69 | } |
| 70 | if (state==3 && thisFrame>startFrame+100) |
| 71 | { |
| 72 | state = 4; |
| 73 | BWAssertF(worker->returnCargo(),{Broodwar->printf("%s",Broodwar->getLastError().c_str());fail=true;return;}) |
| 74 | startFrame = thisFrame; |
| 75 | } |
| 76 | if (state==4 && !worker->isCarryingGas()) |
| 77 | { |
| 78 | BWAssertF(worker->stop(),{Broodwar->printf("%s",Broodwar->getLastError().c_str());fail=true;return;}) |
| 79 | startFrame = thisFrame; |
| 80 | state = 5; |
| 81 | } |
| 82 | if (state==5 && thisFrame>startFrame+100) |
| 83 | { |
| 84 | running=false; |
| 85 | return; |
| 86 | } |
| 87 | |
| 88 | if (state==1) |
| 89 | { |
| 90 | BWAssertF(worker->isGatheringMinerals(),{log("%d",thisFrame-startFrame);fail=true;return;}); |
| 91 | BWAssertF(worker->isGatheringGas()==false,{fail=true;return;}); |
| 92 | } |
| 93 | else if (state==2) |
| 94 | { |
| 95 | BWAssertF(worker->isGatheringGas(),{fail=true;return;}); |
| 96 | BWAssertF(worker->isGatheringMinerals()==false,{fail=true;return;}); |
| 97 | } |
| 98 | else if (state==3) |
| 99 | { |
| 100 | BWAssertF(worker->isGatheringGas()==false,{log("%d",thisFrame-startFrame);fail=true;return;}); |
| 101 | BWAssertF(worker->isGatheringMinerals()==false,{fail=true;return;}); |
| 102 | BWAssertF(worker->isCarryingGas()==true,{fail=true;return;}); |
| 103 | } |
| 104 | else if (state==4) |
nothing calls this directly
no test coverage detected