Copy over entire map functions

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
master
sigonasr2 2 years ago
parent 974b60fd22
commit f975a30925
  1. BIN
      C++ProjectTemplate
  2. 4
      SeasonI.h
  3. 48
      test/test.cpp
  4. 8
      tiles.h

Binary file not shown.

@ -33,8 +33,8 @@ class SeasonI:public PixelGameEngine{
void SetupObjectInfo();
void SetupEncounters();
void SetupBattleProperties();
void SetupCutscenes();
void SetupMapList();
void SetupCutscenes();
void SetupMapList();
void SetGameFlag(Flag flag,bool val);
void LoadMap(Map*map);
void SaveMap(Map*map);

@ -44,7 +44,12 @@ extern std::vector<Encounter*>ENCOUNTER_LIST;
extern std::map<Property,BattleProperty*> BATTLE_PROPERTIES;
extern std::map<MapName::Map,Map*> MAPS;
extern std::vector<CutsceneAction*>CUTSCENE_QUEUE;
extern std::vector<std::vector<TILE*>> MAP;
extern std::vector<std::vector<TILE*>> MAP2;
extern std::vector<std::vector<TILE*>> MAP3;
extern std::vector<std::vector<TILE*>> MAP4;
extern std::vector<std::vector<TILE*>> MAP5;
extern std::vector<std::vector<TILE*>> MAP6;
int testCount=0;
int MAX_ITERATIONS=1000;
@ -95,6 +100,30 @@ namespace key{
TestKey NP2{Key::NP2,"NP2",KeyIdentifier::DOWN};
}
void CopyMapContents(std::vector<std::vector<TILE*>>&from,std::vector<std::vector<TILE>>&to) {
for (int x=0;x<from.size();x++) {
std::vector<TILE> tiles;
for (int y=0;y<from[x].size();y++) {
tiles.push_back(TILE(from[x][y]->tileX,from[x][y]->tileY,from[x][y]->tileDegree));
}
to.push_back(tiles);
}
}
bool ValidateEntireMap(std::vector<std::vector<TILE*>>&mapref1,std::vector<std::vector<TILE>>&mapref2) {
for (int x=0;x<mapref1.size();x++) {
for (int y=0;y<mapref1[x].size();y++) {
if (mapref2[x][y]!=mapref1[x][y]) {
std::cout<<x<<","<<y<<" failed:"<<std::endl;
std::cout<<" "<<mapref2[x][y].tileX<<"|"<<mapref2[x][y].tileY<<"|"<<std::to_string(mapref2[x][y].tileDegree)<<std::endl;
std::cout<<" "<<mapref1[x][y]->tileX<<"|"<<mapref1[x][y]->tileY<<"|"<<std::to_string(mapref1[x][y]->tileDegree)<<std::endl;
return false;
}
}
}
return true;
}
bool GetKeyPressed(SeasonI&instance,TestKey&k) {
if (k==key::UP) {
return instance.UpPressed();
@ -681,6 +710,25 @@ bool SeasonI::OnUserCreate(){
endOfScreenCheck:
Test("Entire screen should be wiped to magenta before drawing anything",
isAllMagenta);
std::vector<std::vector<TILE>> TEMPMAP;
std::vector<std::vector<TILE>> TEMPMAP2;
std::vector<std::vector<TILE>> TEMPMAP3;
std::vector<std::vector<TILE>> TEMPMAP4;
std::vector<std::vector<TILE>> TEMPMAP5;
std::vector<std::vector<TILE>> TEMPMAP6;
CopyMapContents(MAP,TEMPMAP);
CopyMapContents(MAP2,TEMPMAP2);
CopyMapContents(MAP3,TEMPMAP3);
CopyMapContents(MAP4,TEMPMAP4);
CopyMapContents(MAP5,TEMPMAP5);
CopyMapContents(MAP6,TEMPMAP6);
Test("Entire map should be copied over properly for testing",
ValidateEntireMap(MAP,TEMPMAP)&&
ValidateEntireMap(MAP2,TEMPMAP2)&&
ValidateEntireMap(MAP3,TEMPMAP3)&&
ValidateEntireMap(MAP4,TEMPMAP4)&&
ValidateEntireMap(MAP5,TEMPMAP5)&&
ValidateEntireMap(MAP6,TEMPMAP6));
return true;
}

@ -26,5 +26,13 @@ class TILE{
}
return 0;
}
bool operator==(const TILE* rhs) {
return tileX==rhs->tileX&&
tileY==rhs->tileY&&
tileDegree==rhs->tileDegree;
}
bool operator!=(const TILE*t) {
return !(*this==t);
}
};
#endif
Loading…
Cancel
Save