|
|
|
@ -32,6 +32,7 @@ extern Cutscene*CurrentCutscene; |
|
|
|
|
extern ActionType CurrentAction; |
|
|
|
|
extern vd2d cameraPos; |
|
|
|
|
extern bool messageBoxVisible; |
|
|
|
|
extern std::string messageBoxText; |
|
|
|
|
extern std::array<Entity*,7> PARTY_MEMBER_STATS; |
|
|
|
|
extern Entity::pstats_t partyMemberDefaultStats; |
|
|
|
|
extern std::map<std::string,Decal*> SPRITES; |
|
|
|
@ -48,6 +49,111 @@ int testCount=0; |
|
|
|
|
int MAX_ITERATIONS=1000; |
|
|
|
|
int iterations=0; |
|
|
|
|
|
|
|
|
|
enum KeyIdentifier{ |
|
|
|
|
UP, |
|
|
|
|
RIGHT, |
|
|
|
|
DOWN, |
|
|
|
|
LEFT, |
|
|
|
|
BACK, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
struct TestKey{ |
|
|
|
|
Key k; |
|
|
|
|
std::string keyName; |
|
|
|
|
KeyIdentifier id; |
|
|
|
|
bool operator==(TestKey&other){ |
|
|
|
|
return id==other.id; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
namespace key{ |
|
|
|
|
TestKey UP{Key::UP,"UP",KeyIdentifier::UP}; |
|
|
|
|
TestKey DOWN{Key::DOWN,"DOWN",KeyIdentifier::DOWN}; |
|
|
|
|
TestKey LEFT{Key::LEFT,"LEFT",KeyIdentifier::LEFT}; |
|
|
|
|
TestKey RIGHT{Key::RIGHT,"RIGHT",KeyIdentifier::RIGHT}; |
|
|
|
|
TestKey BACK{Key::BACK,"BACKSPACE",KeyIdentifier::BACK}; |
|
|
|
|
TestKey ESCAPE{Key::ESCAPE,"ESCAPE",KeyIdentifier::BACK}; |
|
|
|
|
TestKey X{Key::X,"X",KeyIdentifier::BACK}; |
|
|
|
|
TestKey CTRL{Key::CTRL,"CTRL",KeyIdentifier::BACK}; |
|
|
|
|
TestKey DEL{Key::DEL,"DEL",KeyIdentifier::BACK}; |
|
|
|
|
TestKey END{Key::END,"END",KeyIdentifier::BACK}; |
|
|
|
|
TestKey NP_DECIMAL{Key::NP_DECIMAL,"Numpad Decimal",KeyIdentifier::BACK}; |
|
|
|
|
TestKey NP_SUB{Key::NP_SUB,"Numpad Subtract",KeyIdentifier::BACK}; |
|
|
|
|
TestKey MINUS{Key::MINUS,"MINUS",KeyIdentifier::BACK}; |
|
|
|
|
TestKey PAUSE{Key::PAUSE,"PAUSE",KeyIdentifier::BACK}; |
|
|
|
|
TestKey TAB{Key::TAB,"TAB",KeyIdentifier::BACK}; |
|
|
|
|
TestKey CAPS_LOCK{Key::CAPS_LOCK,"CAPS LOCK",KeyIdentifier::BACK}; |
|
|
|
|
TestKey W{Key::W,"W",KeyIdentifier::UP}; |
|
|
|
|
TestKey A{Key::A,"A",KeyIdentifier::LEFT}; |
|
|
|
|
TestKey S{Key::S,"S",KeyIdentifier::DOWN}; |
|
|
|
|
TestKey D{Key::D,"D",KeyIdentifier::RIGHT}; |
|
|
|
|
TestKey NP8{Key::NP8,"NP8",KeyIdentifier::UP}; |
|
|
|
|
TestKey NP4{Key::NP4,"NP4",KeyIdentifier::LEFT}; |
|
|
|
|
TestKey NP5{Key::NP5,"NP5",KeyIdentifier::DOWN}; |
|
|
|
|
TestKey NP6{Key::NP6,"NP6",KeyIdentifier::RIGHT}; |
|
|
|
|
TestKey NP2{Key::NP2,"NP2",KeyIdentifier::DOWN}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool GetKeyPressed(SeasonI&instance,TestKey&k) { |
|
|
|
|
if (k==key::UP) { |
|
|
|
|
return instance.UpPressed(); |
|
|
|
|
} |
|
|
|
|
if (k==key::DOWN) { |
|
|
|
|
return instance.DownPressed(); |
|
|
|
|
} |
|
|
|
|
if (k==key::RIGHT) { |
|
|
|
|
return instance.RightPressed(); |
|
|
|
|
} |
|
|
|
|
if (k==key::LEFT) { |
|
|
|
|
return instance.LeftPressed(); |
|
|
|
|
} |
|
|
|
|
if (k==key::BACK) { |
|
|
|
|
return instance.BackPressed(); |
|
|
|
|
} |
|
|
|
|
std::cerr<<"Something went terribly wrong! THIS SHOULD NOT BE HAPPENING!\n"; |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool GetKeyHeld(SeasonI&instance,TestKey&k) { |
|
|
|
|
if (k==key::UP) { |
|
|
|
|
return instance.UpHeld(); |
|
|
|
|
} |
|
|
|
|
if (k==key::DOWN) { |
|
|
|
|
return instance.DownHeld(); |
|
|
|
|
} |
|
|
|
|
if (k==key::RIGHT) { |
|
|
|
|
return instance.RightHeld(); |
|
|
|
|
} |
|
|
|
|
if (k==key::LEFT) { |
|
|
|
|
return instance.LeftHeld(); |
|
|
|
|
} |
|
|
|
|
if (k==key::BACK) { |
|
|
|
|
return instance.BackHeld(); |
|
|
|
|
} |
|
|
|
|
std::cerr<<"Something went terribly wrong! THIS SHOULD NOT BE HAPPENING!\n"; |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool GetKeyReleased(SeasonI&instance,TestKey&k) { |
|
|
|
|
if (k==key::UP) { |
|
|
|
|
return instance.UpReleased(); |
|
|
|
|
} |
|
|
|
|
if (k==key::DOWN) { |
|
|
|
|
return instance.DownReleased(); |
|
|
|
|
} |
|
|
|
|
if (k==key::RIGHT) { |
|
|
|
|
return instance.RightReleased(); |
|
|
|
|
} |
|
|
|
|
if (k==key::LEFT) { |
|
|
|
|
return instance.LeftReleased(); |
|
|
|
|
} |
|
|
|
|
if (k==key::BACK) { |
|
|
|
|
return instance.BackReleased(); |
|
|
|
|
} |
|
|
|
|
std::cerr<<"Something went terribly wrong! THIS SHOULD NOT BE HAPPENING!\n"; |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Test(std::string name,bool success) { |
|
|
|
|
testCount++; |
|
|
|
|
std::cout<<"Test ("<<testCount<<") "<<name<<"..."<<std::endl; |
|
|
|
@ -296,7 +402,7 @@ bool SeasonI::OnUserCreate(){ |
|
|
|
|
액션 SetFlagWhenCutsceneEnds(Flag::TEST_FLAG3), |
|
|
|
|
액션 SetFlag(Flag::TEST_FLAG2,true), |
|
|
|
|
액션 PanCamera({128,128},BOTH,1), |
|
|
|
|
액션 MoveCutsceneObjectAsync(1,{80,64},5), |
|
|
|
|
액션 MoveCutsceneObjectAsync(1,{80,64},50), |
|
|
|
|
액션 PanCameraAsync({64,0},BOTH), |
|
|
|
|
액션 DialogBoxAsync(R"(Hello! |
|
|
|
|
This is a test message that lets us trigger straight from a cutscene! Cool!)"), |
|
|
|
@ -382,7 +488,7 @@ bool SeasonI::OnUserCreate(){ |
|
|
|
|
messageBoxVisible); |
|
|
|
|
GetAnyKeyPress(H); |
|
|
|
|
GetAnyKeyPress(H); |
|
|
|
|
Test("Pressing any key that is a valid action key twice should close the message box", |
|
|
|
|
Test("Pressing any key should close the message box", |
|
|
|
|
!messageBoxVisible); |
|
|
|
|
updateGame(); |
|
|
|
|
Test("Next cutscene action should be Modify Object 0", |
|
|
|
@ -395,8 +501,68 @@ bool SeasonI::OnUserCreate(){ |
|
|
|
|
prevCutsceneObjPosition=CurrentCutscene->GetCutsceneObjects()[1]->GetPos(); |
|
|
|
|
updateGame(); |
|
|
|
|
Test("Cutscene Object 1 is moving towards position {320,64}", |
|
|
|
|
CurrentCutscene->GetCutsceneObjects()[1]->GetPos().x<prevCutsceneObjPosition.x&&CurrentCutscene->GetCutsceneObjects()[1]->GetPos().y<prevCutsceneObjPosition.y); |
|
|
|
|
|
|
|
|
|
CurrentCutscene->GetCutsceneObjects()[1]->GetPos().x>prevCutsceneObjPosition.x&&CurrentCutscene->GetCutsceneObjects()[1]->GetPos().y==prevCutsceneObjPosition.y); |
|
|
|
|
TestWhile("Move Cutscene Object should finish",CurrentAction==ActionType::MOVE_CUTSCENE_OBJ) { |
|
|
|
|
updateGame(); |
|
|
|
|
} |
|
|
|
|
Test("Cutscene Object 1 should be at position {320,64}", |
|
|
|
|
CurrentCutscene->GetCutsceneObjects()[1]->GetPos().x==320&&CurrentCutscene->GetCutsceneObjects()[1]->GetPos().y==64); |
|
|
|
|
Test("Next cutscene action is Dialog Box", |
|
|
|
|
CurrentAction==ActionType::DIALOG); |
|
|
|
|
Test("Dialog box should be visible", |
|
|
|
|
messageBoxVisible); |
|
|
|
|
GetAnyKeyPress(S); |
|
|
|
|
Test("Pressing a key should show the entire message", |
|
|
|
|
messageBoxText=="Hello!"); |
|
|
|
|
GetAnyKeyPress(S); |
|
|
|
|
Test("Pressing a key should close the message box", |
|
|
|
|
!messageBoxVisible); |
|
|
|
|
int prevDestructionCount=OBJECT_DESTRUCTION_COUNT; |
|
|
|
|
updateGame(); |
|
|
|
|
Test("Next cutscene action should be loading a map", |
|
|
|
|
CurrentAction==ActionType::LOAD_MAP); |
|
|
|
|
Test("Current Map should now be TWOSON", |
|
|
|
|
CURRENT_MAP==MAPS[MapName::TWOSON]); |
|
|
|
|
Test("All temporary objects should now be destroyed", |
|
|
|
|
OBJECT_DESTRUCTION_COUNT-3==prevDestructionCount); |
|
|
|
|
updateGame(); |
|
|
|
|
Test("Next action should be moving player objects", |
|
|
|
|
CurrentAction==ActionType::MOVE_PLAYER_OBJS); |
|
|
|
|
Test("All player objects should now be at position {16,16}", |
|
|
|
|
PARTY_MEMBER_OBJ[0]->GetPos().x==16&&PARTY_MEMBER_OBJ[0]->GetPos().y==16); |
|
|
|
|
Test("Next cutscene action should be cleanup", |
|
|
|
|
CurrentCutscene->CurrentAction()==ActionType::CLEANUP); |
|
|
|
|
updateGame(); |
|
|
|
|
Test("All cutscene and action variables should be cleaned up", |
|
|
|
|
CurrentCutscene==nullptr&& |
|
|
|
|
CurrentAction==ActionType::NONE); |
|
|
|
|
TestKey testkeys[] = {key::UP,key::DOWN,key::LEFT,key::RIGHT,key::W,key::A,key::S,key::D,key::NP8,key::NP4,key::NP5,key::NP6,key::NP2,key::BACK,key::ESCAPE,key::X,key::CTRL,key::DEL,key::END,key::NP_DECIMAL,key::NP_SUB,key::MINUS,key::PAUSE,key::TAB,key::CAPS_LOCK}; |
|
|
|
|
for (TestKey k : testkeys) { |
|
|
|
|
PressTestKey(k.k); |
|
|
|
|
Test(k.keyName+" key is pressed", |
|
|
|
|
GetKeyPressed(*this,k)); |
|
|
|
|
updateGame(); |
|
|
|
|
Test(k.keyName+" key is no longer pressed", |
|
|
|
|
!GetKeyPressed(*this,k)); |
|
|
|
|
Test(k.keyName+" key is held down", |
|
|
|
|
GetKeyHeld(*this,k)); |
|
|
|
|
updateGame(); |
|
|
|
|
Test(k.keyName+" key is still held down", |
|
|
|
|
GetKeyHeld(*this,k)); |
|
|
|
|
for (int i=0;i<50;i++) { |
|
|
|
|
updateGame(); |
|
|
|
|
} |
|
|
|
|
Test(k.keyName+" key is still held down after multiple updates", |
|
|
|
|
GetKeyHeld(*this,k)); |
|
|
|
|
ReleaseTestKey(k.k); |
|
|
|
|
Test(k.keyName+" key is no longer held down", |
|
|
|
|
!GetKeyHeld(*this,k)); |
|
|
|
|
Test(k.keyName+" key is released", |
|
|
|
|
GetKeyReleased(*this,k)); |
|
|
|
|
updateGame(); |
|
|
|
|
Test(k.keyName+" key is no longer released", |
|
|
|
|
!GetKeyReleased(*this,k)); |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|