|
|
|
#include "../entity.h"
|
|
|
|
#include "../item.h"
|
|
|
|
#include "../layers.h"
|
|
|
|
#include <string>
|
|
|
|
#define OLC_PGE_APPLICATION
|
|
|
|
#include "../pixelGameEngine.h"
|
|
|
|
#define OLC_PGEX_SPLASHSCREEN
|
|
|
|
#include "../splash.h"
|
|
|
|
#define OLC_SOUNDWAVE
|
|
|
|
#include "../defines.h"
|
|
|
|
#include "../soundwaveEngine.h"
|
|
|
|
#include "../tiles.h"
|
|
|
|
#include "../references.h"
|
|
|
|
#include "../states.h"
|
|
|
|
#include "../flags.h"
|
|
|
|
#include <assert.h>
|
|
|
|
#include "../cutscene.h"
|
|
|
|
#include "../encounters.h"
|
|
|
|
#include "../particle.h"
|
|
|
|
#include "../effect.h"
|
|
|
|
#include "../battleproperty.h"
|
|
|
|
#include "test.h"
|
|
|
|
#include "../SeasonI.h"
|
|
|
|
|
|
|
|
extern std::array<Entity*,7> PARTY_MEMBER_STATS;
|
|
|
|
extern Entity::pstats_t partyMemberDefaultStats;
|
|
|
|
extern std::map<std::string,Decal*> SPRITES;
|
|
|
|
extern std::map<std::string,Animation*> ANIMATIONS;
|
|
|
|
extern std::array<Object*,4> PARTY_MEMBER_OBJ;
|
|
|
|
extern std::map<int,Object*> OBJ_INFO;
|
|
|
|
|
|
|
|
int testCount=0;
|
|
|
|
|
|
|
|
void Test(std::string name,bool success) {
|
|
|
|
testCount++;
|
|
|
|
std::cout<<"Test ("<<testCount<<") "<<name<<"..."<<std::endl;
|
|
|
|
assert(success);
|
|
|
|
std::cout<<" Passed"<<std::endl;
|
|
|
|
};
|
|
|
|
|
|
|
|
void TestSpriteUndefined(std::vector<std::string> sprList) {
|
|
|
|
for (int i=0;i<sprList.size();i++) {
|
|
|
|
Test("Sprite "+sprList[i]+" should not be initialized",
|
|
|
|
SPRITES[sprList[i]]==nullptr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void TestSpriteInitialized(std::vector<std::string> sprList) {
|
|
|
|
for (int i=0;i<sprList.size();i++) {
|
|
|
|
Test("Sprite "+sprList[i]+" should be initialized",
|
|
|
|
SPRITES[sprList[i]]!=nullptr);
|
|
|
|
Test("Sprite "+sprList[i]+" should have a non-zero width and height",
|
|
|
|
SPRITES[sprList[i]]->sprite->width!=0&&SPRITES["terrainmap.png"]->sprite->height!=0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SeasonI::OnUserCreate(){
|
|
|
|
for (int i=0;i<PARTY_MEMBER_STATS.size();i++) {
|
|
|
|
Test("Party Member stats should not be initialized",
|
|
|
|
PARTY_MEMBER_STATS[i]==nullptr);
|
|
|
|
}
|
|
|
|
SetupPartyMemberStats();
|
|
|
|
for (int i=0;i<PARTY_MEMBER_STATS.size();i++) {
|
|
|
|
Test("Party Members get initialized with correct defaults",
|
|
|
|
PARTY_MEMBER_STATS[i]->stats==partyMemberDefaultStats);
|
|
|
|
}
|
|
|
|
TestSpriteUndefined({"terrainmap.png","pixel.png","bufficons.png","rollingcounter.png","additionalFont.png"});
|
|
|
|
SetupAnimations();
|
|
|
|
TestSpriteInitialized({"terrainmap.png","pixel.png","bufficons.png","rollingcounter.png","additionalFont.png"});
|
|
|
|
Test("Player animation is undefined",
|
|
|
|
ANIMATIONS.count("player.png")==0);
|
|
|
|
Test("Party Member Object is not setup",
|
|
|
|
PARTY_MEMBER_OBJ[0]==nullptr);
|
|
|
|
vd2d testPos={0,0},testScale={2,2};
|
|
|
|
CreateObjectInfo(new Standard_Obj(PLAYER,"player",testPos,nullptr,testScale,MAGENTA,32),"player.png",32);
|
|
|
|
Test("Player animation is defined",
|
|
|
|
ANIMATIONS["player.png"]!=nullptr);
|
|
|
|
Decal*playerAnimPointer=ANIMATIONS["player.png"]->spr;
|
|
|
|
Test("Player animation is setup correctly",
|
|
|
|
ANIMATIONS["player.png"]->frames>0&&ANIMATIONS["player.png"]->spr!=nullptr);
|
|
|
|
Test("Object Info database now has 1 entry",
|
|
|
|
OBJ_INFO.size()==1);
|
|
|
|
Test("Object Info is correctly assigned",
|
|
|
|
OBJ_INFO[0]->name=="player"&&OBJ_INFO[0]->id==PLAYER&&OBJ_INFO[0]->GetPos()==testPos&&OBJ_INFO[0]->GetScale()==testScale&&OBJ_INFO[0]->color==MAGENTA&&OBJ_INFO[0]->spr->width==32);
|
|
|
|
delete OBJ_INFO[PLAYER];
|
|
|
|
OBJ_INFO.erase(PLAYER);
|
|
|
|
Test("Object Info is cleared",
|
|
|
|
OBJ_INFO.size()==0);
|
|
|
|
SetupObjectInfo();
|
|
|
|
Test("Using the same sprite definition does not cause memory leak",
|
|
|
|
playerAnimPointer==OBJ_INFO[0]->spr->spr);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SeasonI::OnUserUpdate(float fElapsedTime)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
SeasonI demo;
|
|
|
|
if (demo.Construct(WIDTH, HEIGHT, 4, 4))
|
|
|
|
demo.Start();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|