More cutscene test conditions

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
master
sigonasr2 2 years ago
parent 570d2ac5a1
commit 7a9ca378ea
  1. BIN
      C++ProjectTemplate
  2. 6
      SeasonI.h
  3. 74
      main.cpp
  4. 21
      test/test.cpp

Binary file not shown.

@ -144,6 +144,12 @@ class SeasonI:public PixelGameEngine{
int GetPointQuadrantRelativeToLine(vi2d x1y1,vi2d x2y2,vi2d point);
TILE GetSafeTileData(std::vector<std::vector<TILE*>>&data);
char GetTileDegreeSafely(std::vector<std::vector<TILE*>>&data);
//When using for testing, make sure you RELEASE the key when you are done!
void PressTestKey(Key k);
//When using for testing, make sure you RELEASE the key when you are done!
void HoldTestKey(Key k);
void ReleaseTestKey(Key k);
void ResetTestKeys();
};
extern SeasonI*GAME;
#endif

@ -177,6 +177,7 @@ int SAVE_FILE_CURSOR=0;
std::string CUTSCENE_DISPLAY_TEXT="";
int CUTSCENE_DISPLAY_TEXT_DELAY_TIME=0;
int TILEMAP_EDITOR_OFFSET=0;
HWButton TESTKEYS[128]={{false,false,false}};
/*
[Choice1,Choice2,Choice3]
@ -1552,6 +1553,10 @@ void SeasonI::updateGame(){
//CAMERA UPDATES MUST BE LAST!!! COLLISIONS RELY ON THE GAME POSITION STATES REMAINING THE SAME!
cameraUpdate();
for (int i=0;i<128;i++) {
TESTKEYS[i].bPressed=TESTKEYS[i].bReleased=false;
}
}
void SeasonI::keyUpdates() {
@ -4077,52 +4082,68 @@ void SeasonI::HandleCutscenes() {
}
bool SeasonI::TabHeld(){
return GetKey(TAB).bHeld;
return GetKey(TAB).bHeld||
TESTKEYS[TAB].bHeld;
}
bool SeasonI::UpPressed(){
return GetKey(W).bPressed||GetKey(UP).bPressed||GetKey(NP8).bPressed||MOUSE_PRESSED_DOWN&&GetMouseY()<=HEIGHT-128+32&&GetMouseY()>=HEIGHT-128&&GetMouseX()<=HEIGHT-128||KeyRepeat(UP);
return GetKey(W).bPressed||GetKey(UP).bPressed||GetKey(NP8).bPressed||MOUSE_PRESSED_DOWN&&GetMouseY()<=HEIGHT-128+32&&GetMouseY()>=HEIGHT-128&&GetMouseX()<=HEIGHT-128||KeyRepeat(UP)||
TESTKEYS[W].bPressed||TESTKEYS[UP].bPressed||TESTKEYS[NP8].bPressed;
}
bool SeasonI::DownPressed(){
return GetKey(S).bPressed||GetKey(DOWN).bPressed||GetKey(NP5).bPressed||GetKey(NP2).bPressed||MOUSE_PRESSED_DOWN&&GetMouseY()<=HEIGHT&&GetMouseY()>=HEIGHT-32&&GetMouseX()<=HEIGHT-128||KeyRepeat(DOWN);
return GetKey(S).bPressed||GetKey(DOWN).bPressed||GetKey(NP5).bPressed||GetKey(NP2).bPressed||MOUSE_PRESSED_DOWN&&GetMouseY()<=HEIGHT&&GetMouseY()>=HEIGHT-32&&GetMouseX()<=HEIGHT-128||KeyRepeat(DOWN)||TESTKEYS[DOWN].bPressed||
TESTKEYS[S].bPressed||TESTKEYS[DOWN].bPressed||TESTKEYS[NP5].bPressed||TESTKEYS[NP2].bPressed;
}
bool SeasonI::LeftPressed(){
return GetKey(A).bPressed||GetKey(LEFT).bPressed||GetKey(NP4).bPressed||MOUSE_PRESSED_DOWN&&GetMouseX()<=32&&GetMouseX()>=0&&GetMouseY()>=HEIGHT-128||KeyRepeat(LEFT);
return GetKey(A).bPressed||GetKey(LEFT).bPressed||GetKey(NP4).bPressed||MOUSE_PRESSED_DOWN&&GetMouseX()<=32&&GetMouseX()>=0&&GetMouseY()>=HEIGHT-128||KeyRepeat(LEFT)||
TESTKEYS[A].bPressed||TESTKEYS[LEFT].bPressed||TESTKEYS[NP4].bPressed;
}
bool SeasonI::RightPressed(){
return GetKey(D).bPressed||GetKey(RIGHT).bPressed||GetKey(NP6).bPressed||MOUSE_PRESSED_DOWN&&GetMouseX()<=128&&GetMouseX()>=96&&GetMouseY()>=HEIGHT-128||KeyRepeat(RIGHT);
return GetKey(D).bPressed||GetKey(RIGHT).bPressed||GetKey(NP6).bPressed||MOUSE_PRESSED_DOWN&&GetMouseX()<=128&&GetMouseX()>=96&&GetMouseY()>=HEIGHT-128||KeyRepeat(RIGHT)||
TESTKEYS[D].bPressed||TESTKEYS[RIGHT].bPressed||TESTKEYS[NP6].bPressed;
}
bool SeasonI::BackPressed(){
return GetKey(BACK).bPressed||GetKey(ESCAPE).bPressed||GetKey(X).bPressed||GetKey(CTRL).bPressed||GetKey(DEL).bPressed||GetKey(END).bPressed||GetKey(NP_DECIMAL).bPressed||GetKey(NP_SUB).bPressed||GetKey(MINUS).bPressed||GetKey(PAUSE).bPressed||GetKey(TAB).bPressed;
return GetKey(BACK).bPressed||GetKey(ESCAPE).bPressed||GetKey(X).bPressed||GetKey(CTRL).bPressed||GetKey(DEL).bPressed||GetKey(END).bPressed||GetKey(NP_DECIMAL).bPressed||GetKey(NP_SUB).bPressed||GetKey(MINUS).bPressed||GetKey(PAUSE).bPressed||GetKey(TAB).bPressed||
TESTKEYS[BACK].bPressed||TESTKEYS[ESCAPE].bPressed||TESTKEYS[X].bPressed||TESTKEYS[CTRL].bPressed||TESTKEYS[DEL].bPressed||TESTKEYS[END].bPressed||TESTKEYS[NP_DECIMAL].bPressed||TESTKEYS[NP_SUB].bPressed||TESTKEYS[MINUS].bPressed||TESTKEYS[PAUSE].bPressed||TESTKEYS[TAB].bPressed;
}
bool SeasonI::UpHeld(){
return GetKey(W).bHeld||GetKey(UP).bHeld||GetKey(NP8).bHeld||MOUSE_DOWN&&GetMouseY()<=HEIGHT-128+32&&GetMouseY()>=HEIGHT-128&&GetMouseX()<=HEIGHT-128;
return GetKey(W).bHeld||GetKey(UP).bHeld||GetKey(NP8).bHeld||MOUSE_DOWN&&GetMouseY()<=HEIGHT-128+32&&GetMouseY()>=HEIGHT-128&&GetMouseX()<=HEIGHT-128||
TESTKEYS[W].bHeld||TESTKEYS[UP].bHeld||TESTKEYS[NP8].bHeld;
}
bool SeasonI::DownHeld(){
return GetKey(S).bHeld||GetKey(DOWN).bHeld||GetKey(NP5).bHeld||GetKey(NP2).bHeld||MOUSE_DOWN&&GetMouseY()<=HEIGHT&&GetMouseY()>=HEIGHT-32&&GetMouseX()<=HEIGHT-128;
return GetKey(S).bHeld||GetKey(DOWN).bHeld||GetKey(NP5).bHeld||GetKey(NP2).bHeld||MOUSE_DOWN&&GetMouseY()<=HEIGHT&&GetMouseY()>=HEIGHT-32&&GetMouseX()<=HEIGHT-128||
TESTKEYS[S].bHeld||TESTKEYS[DOWN].bHeld||TESTKEYS[NP5].bHeld;
}
bool SeasonI::LeftHeld(){
return GetKey(A).bHeld||GetKey(LEFT).bHeld||GetKey(NP4).bHeld||MOUSE_DOWN&&GetMouseX()<=32&&GetMouseX()>=0&&GetMouseY()>=HEIGHT-128;
return GetKey(A).bHeld||GetKey(LEFT).bHeld||GetKey(NP4).bHeld||MOUSE_DOWN&&GetMouseX()<=32&&GetMouseX()>=0&&GetMouseY()>=HEIGHT-128||
TESTKEYS[A].bHeld||TESTKEYS[LEFT].bHeld||TESTKEYS[NP4].bHeld;
}
bool SeasonI::RightHeld(){
return GetKey(D).bHeld||GetKey(RIGHT).bHeld||GetKey(NP6).bHeld||MOUSE_DOWN&&GetMouseX()<=128&&GetMouseX()>=96&&GetMouseY()>=HEIGHT-128;
return GetKey(D).bHeld||GetKey(RIGHT).bHeld||GetKey(NP6).bHeld||MOUSE_DOWN&&GetMouseX()<=128&&GetMouseX()>=96&&GetMouseY()>=HEIGHT-128||
TESTKEYS[D].bHeld||TESTKEYS[RIGHT].bHeld||TESTKEYS[NP6].bHeld;
}
bool SeasonI::BackHeld(){
return GetKey(BACK).bHeld||GetKey(ESCAPE).bHeld||GetKey(X).bHeld||GetKey(CTRL).bHeld||GetKey(DEL).bHeld||GetKey(END).bHeld||GetKey(NP_DECIMAL).bHeld||GetKey(NP_SUB).bHeld||GetKey(MINUS).bHeld||GetKey(PAUSE).bHeld||GetKey(TAB).bHeld;
return GetKey(BACK).bHeld||GetKey(ESCAPE).bHeld||GetKey(X).bHeld||GetKey(CTRL).bHeld||GetKey(DEL).bHeld||GetKey(END).bHeld||GetKey(NP_DECIMAL).bHeld||GetKey(NP_SUB).bHeld||GetKey(MINUS).bHeld||GetKey(PAUSE).bHeld||GetKey(TAB).bHeld||
TESTKEYS[BACK].bHeld||TESTKEYS[ESCAPE].bHeld||TESTKEYS[X].bHeld||TESTKEYS[CTRL].bHeld||TESTKEYS[DEL].bHeld||TESTKEYS[END].bHeld||TESTKEYS[NP_DECIMAL].bHeld||TESTKEYS[NP_SUB].bHeld||TESTKEYS[MINUS].bHeld||TESTKEYS[PAUSE].bHeld||TESTKEYS[TAB].bHeld;
}
bool SeasonI::UpReleased(){
return GetKey(W).bReleased||GetKey(UP).bReleased||GetKey(NP8).bReleased||MOUSE_RELEASED&&GetMouseY()<=HEIGHT-128+32&&GetMouseY()>=HEIGHT-128&&GetMouseX()<=HEIGHT-128;
return GetKey(W).bReleased||GetKey(UP).bReleased||GetKey(NP8).bReleased||MOUSE_RELEASED&&GetMouseY()<=HEIGHT-128+32&&GetMouseY()>=HEIGHT-128&&GetMouseX()<=HEIGHT-128||
TESTKEYS[W].bReleased||TESTKEYS[UP].bReleased||TESTKEYS[NP8].bReleased;
}
bool SeasonI::DownReleased(){
return GetKey(S).bReleased||GetKey(DOWN).bReleased||GetKey(NP5).bReleased||GetKey(NP2).bReleased||MOUSE_RELEASED&&GetMouseY()<=HEIGHT&&GetMouseY()>=HEIGHT-32&&GetMouseX()<=HEIGHT-128;
return GetKey(S).bReleased||GetKey(DOWN).bReleased||GetKey(NP5).bReleased||GetKey(NP2).bReleased||MOUSE_RELEASED&&GetMouseY()<=HEIGHT&&GetMouseY()>=HEIGHT-32&&GetMouseX()<=HEIGHT-128||
TESTKEYS[S].bReleased||TESTKEYS[DOWN].bReleased||TESTKEYS[NP5].bReleased||TESTKEYS[NP2].bReleased;
}
bool SeasonI::LeftReleased(){
return GetKey(A).bReleased||GetKey(LEFT).bReleased||GetKey(NP4).bReleased||MOUSE_RELEASED&&GetMouseX()<=32&&GetMouseX()>=0&&GetMouseY()>=HEIGHT-128;
return GetKey(A).bReleased||GetKey(LEFT).bReleased||GetKey(NP4).bReleased||MOUSE_RELEASED&&GetMouseX()<=32&&GetMouseX()>=0&&GetMouseY()>=HEIGHT-128||
TESTKEYS[A].bReleased||TESTKEYS[LEFT].bReleased||TESTKEYS[NP4].bReleased;
}
bool SeasonI::RightReleased(){
return GetKey(D).bReleased||GetKey(RIGHT).bReleased||GetKey(NP6).bReleased||MOUSE_RELEASED&&GetMouseX()<=128&&GetMouseX()>=96&&GetMouseY()>=HEIGHT-128;
return GetKey(D).bReleased||GetKey(RIGHT).bReleased||GetKey(NP6).bReleased||MOUSE_RELEASED&&GetMouseX()<=128&&GetMouseX()>=96&&GetMouseY()>=HEIGHT-128||
TESTKEYS[D].bReleased||TESTKEYS[RIGHT].bReleased||TESTKEYS[NP6].bReleased;
}
bool SeasonI::BackReleased(){
return GetKey(BACK).bReleased||GetKey(ESCAPE).bReleased||GetKey(X).bReleased||GetKey(CTRL).bReleased||GetKey(DEL).bReleased||GetKey(END).bReleased||GetKey(NP_DECIMAL).bReleased||GetKey(NP_SUB).bReleased||GetKey(MINUS).bReleased||GetKey(PAUSE).bReleased||GetKey(TAB).bReleased;
return GetKey(BACK).bReleased||GetKey(ESCAPE).bReleased||GetKey(X).bReleased||GetKey(CTRL).bReleased||GetKey(DEL).bReleased||GetKey(END).bReleased||GetKey(NP_DECIMAL).bReleased||GetKey(NP_SUB).bReleased||GetKey(MINUS).bReleased||GetKey(PAUSE).bReleased||GetKey(TAB).bReleased||
TESTKEYS[BACK].bReleased||TESTKEYS[ESCAPE].bReleased||TESTKEYS[X].bReleased||TESTKEYS[CTRL].bReleased||TESTKEYS[DEL].bReleased||TESTKEYS[END].bReleased||TESTKEYS[NP_DECIMAL].bReleased||TESTKEYS[NP_SUB].bReleased||TESTKEYS[MINUS].bReleased||TESTKEYS[PAUSE].bReleased||TESTKEYS[TAB].bReleased;
}
bool SeasonI::PlayerCanMove(){
@ -5578,6 +5599,27 @@ char SeasonI::GetTileDegreeSafely(std::vector<std::vector<TILE*>>&data){
return GetSafeTileData(data).tileDegree;
}
void SeasonI::PressTestKey(Key k) {
TESTKEYS[k].bPressed=true;
TESTKEYS[k].bReleased=false;
}
void SeasonI::HoldTestKey(Key k) {
TESTKEYS[k].bHeld=true;
}
void SeasonI::ReleaseTestKey(Key k) {
TESTKEYS[k].bPressed=false;
TESTKEYS[k].bReleased=true;
TESTKEYS[k].bHeld=false;
}
void SeasonI::ResetTestKeys() {
for (int i=0;i<128;i++) {
TESTKEYS[i].bPressed=TESTKEYS[i].bHeld=TESTKEYS[i].bReleased=false;
}
}
#ifndef TEST_SUITE
int main()
{

@ -31,6 +31,7 @@ extern double CUTSCENE_FADE_VALUE;
extern Cutscene*CurrentCutscene;
extern ActionType CurrentAction;
extern vd2d cameraPos;
extern bool messageBoxVisible;
extern std::array<Entity*,7> PARTY_MEMBER_STATS;
extern Entity::pstats_t partyMemberDefaultStats;
extern std::map<std::string,Decal*> SPRITES;
@ -41,6 +42,7 @@ extern std::map<BattleMoveName,Battle::Move*>MOVELIST;
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;
int testCount=0;
int MAX_ITERATIONS=1000;
@ -376,6 +378,25 @@ bool SeasonI::OnUserCreate(){
prevCameraPos.x>cameraPos.x&&prevCameraPos.y>cameraPos.y);
Test("Due to async actions, next cutscene action should be Dialog Box Async",
CurrentAction==ActionType::DIALOG_ASYNC);
Test("A message box should be on-screen",
messageBoxVisible);
GetAnyKeyPress(H);
GetAnyKeyPress(H);
Test("Pressing any key that is a valid action key twice should close the message box",
!messageBoxVisible);
updateGame();
Test("Next cutscene action should be Modify Object 0",
CurrentAction==ActionType::MODIFY_OBJECT);
Test("Cutscene Object 0 is now size {5,5}",
CurrentCutscene->GetCutsceneObjects()[0]->GetScale().x==5&&CurrentCutscene->GetCutsceneObjects()[0]->GetScale().y==5);
updateGame();
Test("Next cutscene action should be Move Cutscene Object 1",
CurrentAction==ActionType::MOVE_CUTSCENE_OBJ);
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);
return true;
}

Loading…
Cancel
Save