| 345 | startFrame = Broodwar->getFrameCount(); |
| 346 | } |
| 347 | void UseTechTest::update() |
| 348 | { |
| 349 | if (running == false) return; |
| 350 | if (fail) |
| 351 | { |
| 352 | running = false; |
| 353 | return; |
| 354 | } |
| 355 | int thisFrame = Broodwar->getFrameCount(); |
| 356 | BWAssert(thisFrame==nextFrame); |
| 357 | nextFrame++; |
| 358 | if (user->exists()) |
| 359 | Broodwar->setScreenPosition(user->getPosition() - Position(320,240)); |
| 360 | else |
| 361 | Broodwar->setScreenPosition(targetUnit->getPosition() - Position(320,240)); |
| 362 | |
| 363 | BWAssertF(user!=NULL,{fail=true;return;}); |
| 364 | if (!isInPosition) |
| 365 | checkPosition(); |
| 366 | |
| 367 | if (user->exists()) |
| 368 | { |
| 369 | if (user->getEnergy()!=currentEnergy) |
| 370 | { |
| 371 | if (user->getEnergy()<currentEnergy) |
| 372 | currentEnergy-=techType.energyCost(); |
| 373 | else |
| 374 | currentEnergy++; |
| 375 | |
| 376 | if (techType!=TechTypes::Archon_Warp && techType!=TechTypes::Dark_Archon_Meld) |
| 377 | { |
| 378 | BWAssertF(abs(user->getEnergy()-currentEnergy)<5,{Broodwar->printf("%d != %d",user->getEnergy(),currentEnergy);fail=true;return;}); |
| 379 | } |
| 380 | |
| 381 | currentEnergy=user->getEnergy(); |
| 382 | } |
| 383 | } |
| 384 | |
| 385 | if (!isInPosition) |
| 386 | return; |
| 387 | |
| 388 | if (!usedTech) |
| 389 | useTech(); |
| 390 | |
| 391 | if (techType==TechTypes::Scanner_Sweep) |
| 392 | { |
| 393 | if (Broodwar->isVisible( TilePosition(targetPosition) )) |
| 394 | testSucceeded = true; |
| 395 | } |
| 396 | else if (techType==TechTypes::Stim_Packs) |
| 397 | { |
| 398 | if (user->isStimmed() && user->getStimTimer()>0 && user->getHitPoints()==user->getType().maxHitPoints()-10) |
| 399 | testSucceeded = true; |
| 400 | } |
| 401 | else if (techType==TechTypes::Optical_Flare) |
| 402 | { |
| 403 | BWAssertF(targetUnit!=NULL,{fail=true;return;}); |
| 404 | if (targetUnit->isBlind()) |
nothing calls this directly
no test coverage detected