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

Class UnitCommandsFeatureLayer

tests/test_feature_layer.cc:214–312  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

212};
213
214class UnitCommandsFeatureLayer : public TestSequence {
215public:
216 Point2DI camera_pos_;
217 Point2DI offset_pos_;
218 Point2D unit_pos_;
219 Point2DI unit_pos_i_;
220 uint32_t starting_gameloop_;
221
222 void OnTestStart() override {
223 starting_gameloop_ = agent_->Observation()->GetGameLoop();
224 const GameInfo& game_info = agent_->Observation()->GetGameInfo();
225 unit_pos_ = FindCenterOfMap(game_info);
226 agent_->Debug()->DebugCreateUnit(UNIT_TYPEID::ZERG_LURKERMP, unit_pos_);
227 agent_->Debug()->DebugCreateUnit(UNIT_TYPEID::ZERG_LURKERMP, unit_pos_ + Point2D(5,5));
228 agent_->Debug()->SendDebug();
229
230 wait_game_loops_ = 550;
231 }
232
233 void OnStep() override {
234 const ObservationInterface* obs = agent_->Observation();
235 ActionFeatureLayerInterface* action = agent_->ActionsFeatureLayer();
236 if (obs->GetGameLoop() == starting_gameloop_ + 20) {
237 camera_pos_ = ConvertWorldToMinimap(obs->GetGameInfo(), unit_pos_);
238 action->CameraMove(camera_pos_);
239 }
240 if (obs->GetGameLoop() == starting_gameloop_ + 21) {
241 if (obs->GetFeatureLayerActions().camera_moves.empty()) {
242 ReportError("Camera move is not being reported.");
243 }
244 else {
245 Point2DI new_camera_pos = obs->GetFeatureLayerActions().camera_moves.front().center_minimap;
246 if (new_camera_pos != camera_pos_) {
247 ReportError("Camera Move is reporting the incorrect location");
248 }
249 }
250 }
251 if (obs->GetGameLoop() == starting_gameloop_ + 24) {
252 action->Select(Point2DI(0, 0), Point2DI(60, 60));
253 }
254 if (obs->GetGameLoop() == starting_gameloop_ + 25) {
255 unit_pos_i_ = ConvertWorldToCamera(obs->GetGameInfo(), obs->GetCameraPos(), unit_pos_);
256 action->Select(unit_pos_i_, PointSelectionType::PtToggle);
257 if (obs->GetFeatureLayerActions().select_rects.empty()) {
258 ReportError("Rectangle select is not being reported.");
259 }
260 else {
261 if (obs->GetFeatureLayerActions().select_rects.front().select_screen.front().from != Point2DI(0, 0)) {
262 ReportError("Rectangle select is reporting the wrong start location");
263 }
264 if (obs->GetFeatureLayerActions().select_rects.front().select_screen.front().to != Point2DI(60, 60)) {
265 ReportError("Rectangle select is reporting the wrong end location");
266 }
267 }
268 }
269 if (obs->GetGameLoop() == starting_gameloop_ + 26) {
270 action->UnitCommand(ABILITY_ID::MOVE, camera_pos_);
271 if (obs->GetFeatureLayerActions().select_points.empty()) {

Callers 1

FeatureLayerTestBotMethod · 0.85

Calls

no outgoing calls

Tested by 1

FeatureLayerTestBotMethod · 0.68