TestMove.cpp
#include "TestMove.h" #include "Grid.h" #include "Player.h" #include "GameObject.h" #include "Cell.h" #include "Input.h" #include "Output.h" TestMove::TestMove(ApplicationManager* pApp) : Action(pApp) { } void TestMove::ReadActionParameters() { // Get a Pointer to the Input / Output Interfaces Grid* pGrid = pManager->GetGrid(); Output* pOut = pGrid->GetOutput(); Input* pIn = pGrid->GetInput(); // Read player num pOut->PrintMessage("TestMove: Enter the player number you want to move ..."); int playerNum = pIn->GetInteger(pOut); // Get the player pPlayer = pGrid->GetPlayerByNum(playerNum); // Read the targetCell parameter pOut->PrintMessage("TestMove: Click on the target cell ..."); targetCell = pIn->GetCellClicked(); // Clear messages pOut->ClearStatusBar(); } void TestMove::Execute() { // The first line of any Action Execution is to read its parameter first // and hence initializes its data members ReadActionParameters(); Grid* pGrid = pManager->GetGrid(); // We get a pointer to the Grid from the ApplicationManager // Move the player pGrid->UpdatePlayerCell(pPlayer, targetCell); // Here, the player is moved and we completed the TestMove Action }
Leave a Comment