#include #include "MapT.h" #include "PlayerT.h" #include "CoordT.h" using namespace std; void DisplayMap(const MapT & map); void TakeTurn(MapT & map, int time); void FreeMap(MapT & map); int main() { MapT map(10,20); CoordT place(0,0); map.Add(place, new WizardT); place.x++; map.Add(place, new FighterT); for(int i = 0; i < 50; ++i) { DisplayMap(map); TakeTurn(map, i); cout << endl; cout << "Continue? " << endl; string junk; getline(cin, junk); } DisplayMap(map); FreeMap(map); return 0; } void FreeMap(MapT & map){ CoordT pos{0,0}; for( pos.x = 0; pos.x < map.Rows(); ++pos.x) { for( pos.y = 0; pos.y < map.Cols(); ++pos.y) { PlayerT * player = map.At(pos); if (player != nullptr) { delete player; } } } } void TakeTurn(MapT & map, int time){ CoordT pos{0,0}; for( pos.x = 0; pos.x < map.Rows(); ++pos.x) { for( pos.y = 0; pos.y < map.Cols(); ++pos.y) { PlayerT * player = map.At(pos); if (player != nullptr) { player->Move(map, pos, time); } } } cout << "Turn Done" << endl; } void DisplayMap(const MapT & map) { CoordT pos{0,0}; for( pos.x = 0; pos.x < map.Rows(); ++pos.x) { for( pos.y = 0; pos.y < map.Cols(); ++pos.y) { PlayerT * player = map.At(pos); if (player == nullptr) { cout << "."; } else { cout << player->MapSymbol(); } } cout << endl; } }