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

Class TestCancelTrainingQueue

tests/test_unit_command.cc:463–512  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

461 //
462
463 class TestCancelTrainingQueue : public TestUnitCommandNoTarget {
464 public:
465 bool marine_trained_ = false;
466
467 TestCancelTrainingQueue() {
468 test_unit_type_ = UNIT_TYPEID::TERRAN_BARRACKS;
469 test_ability_ = ABILITY_ID::CANCEL_LAST;
470 }
471
472 void SetTestTime() override {
473 wait_game_loops_ = 100;
474 }
475
476 void OnStep() override {
477 const ObservationInterface* obs = agent_->Observation();
478 ActionInterface* act = agent_->Actions();
479
480 if (obs->GetGameLoop() < order_on_game_loop_) {
481 return;
482 }
483
484 const Units& units = obs->GetUnits(Unit::Alliance::Self);
485 for (const Unit& unit : units) {
486 if (unit.unit_type == test_unit_type_) {
487 test_unit_ = unit;
488 }
489 }
490
491 if (!marine_trained_) {
492 act->UnitCommand(test_unit_, ABILITY_ID::TRAIN_MARINE);
493 marine_trained_ = true;
494 }
495
496 if (obs->GetGameLoop() < order_on_game_loop_ + 10) {
497 return;
498 }
499
500 if (!orders_verified_ && marine_trained_) {
501 VerifyUnitOrders(test_unit_, ABILITY_ID::TRAIN_MARINE);
502 }
503
504 IssueUnitCommand(act);
505 }
506
507 void OnTestFinish() override {
508 VerifyUnitIdleAfterOrder(test_unit_type_);
509 VerifyUnitDoesNotExist(UNIT_TYPEID::TERRAN_MARINE);
510 KillAllUnits();
511 }
512 };
513
514
515 //

Callers 1

UnitCommandTestBotMethod · 0.85

Calls

no outgoing calls

Tested by 1

UnitCommandTestBotMethod · 0.68