MCPcopy Create free account
hub / github.com/Blizzard/s2client-api / TestCancelBuildInProgressFactory

Class TestCancelBuildInProgressFactory

tests/test_unit_command.cc:395–456  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

393 //
394
395 class TestCancelBuildInProgressFactory : public TestUnitCommandNoTarget {
396 public:
397 Unit test_factory_;
398 bool factory_built_ = false;
399
400 TestCancelBuildInProgressFactory() {
401 test_unit_type_ = UNIT_TYPEID::TERRAN_SCV;
402 test_ability_ = ABILITY_ID::CANCEL;
403 }
404
405 void SetTestTime() override {
406 wait_game_loops_ = 100;
407 }
408
409 void OnStep() override {
410 const ObservationInterface* obs = agent_->Observation();
411 ActionInterface* act = agent_->Actions();
412
413 if (obs->GetGameLoop() < order_on_game_loop_) {
414 return;
415 }
416
417 const Units& units = obs->GetUnits(Unit::Alliance::Self);
418 for (const Unit& unit : units) {
419 if (unit.unit_type == test_unit_type_) {
420 test_unit_ = unit;
421 }
422 }
423
424 if (!factory_built_) {
425 act->UnitCommand(test_unit_, ABILITY_ID::BUILD_FACTORY, origin_pt_);
426 factory_built_ = true;
427 }
428
429 for (const Unit& unit : units) {
430 if (unit.unit_type == UNIT_TYPEID::TERRAN_FACTORY) {
431 test_factory_ = unit;
432 }
433 }
434
435 if (obs->GetGameLoop() < order_on_game_loop_ + 10) {
436 return;
437 }
438
439 if (!orders_verified_ && factory_built_) {
440 VerifyUnitOrders(test_unit_, ABILITY_ID::BUILD_FACTORY);
441 }
442
443 if (!ability_command_sent_) {
444 VerifyUnitExistsAndComplete(UNIT_TYPEID::TERRAN_FACTORY, false);
445 act->UnitCommand(test_factory_, test_ability_);
446 ability_command_sent_ = true;
447 }
448
449 }
450
451 void OnTestFinish() override {
452 VerifyUnitIdleAfterOrder(test_unit_type_);

Callers 1

UnitCommandTestBotMethod · 0.85

Calls

no outgoing calls

Tested by 1

UnitCommandTestBotMethod · 0.68