diff --git a/C++ProjectTemplate b/C++ProjectTemplate index d0b7dfd..42015d3 100755 Binary files a/C++ProjectTemplate and b/C++ProjectTemplate differ diff --git a/SeasonI.h b/SeasonI.h index 6434ed8..995a51f 100644 --- a/SeasonI.h +++ b/SeasonI.h @@ -9,6 +9,7 @@ using namespace olc; +#define 시험 class Map; enum class ItemName; @@ -26,17 +27,17 @@ class SeasonI:public PixelGameEngine{ bool OnUserCreate()override; void SetupMoveList(); void SetupItemList(); - void SetupPartyMemberStats(); - void SetupAnimations(); - void SetupObjectInfo(); - void SetupEncounters(); + void SetupPartyMemberStats(); 시험 + void SetupAnimations(); 시험 + void SetupObjectInfo(); 시험 + void SetupEncounters(); 시험 void SetupBattleProperties(); void SetGameFlag(Flag flag,bool val); void LoadMap(Map*map); void SaveMap(Map*map); void AddItemToPlayerInventory(ItemName item); Decal*CreateSprite(std::string spriteName); - Object*CreateObjectInfo(Object*obj,std::string spriteFileName,int sprWidth,Flag enableFlag=Flag::NONE,Flag disableFlag=Flag::NONE); + Object*CreateObjectInfo(Object*obj,std::string spriteFileName,int sprWidth,Flag enableFlag=Flag::NONE,Flag disableFlag=Flag::NONE); 시험 vi2d grid(int x, int y); bool GetGameFlag(int flag); bool GetGameFlag(Flag flag); diff --git a/test/test.cpp b/test/test.cpp index b0dd6e3..b6b0ad3 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -28,6 +28,8 @@ extern std::map SPRITES; extern std::map ANIMATIONS; extern std::array PARTY_MEMBER_OBJ; extern std::map OBJ_INFO; +extern std::mapMOVELIST; +extern std::vectorENCOUNTER_LIST; int testCount=0; @@ -58,7 +60,11 @@ bool SeasonI::OnUserCreate(){ Test("Party Member stats should not be initialized", PARTY_MEMBER_STATS[i]==nullptr); } + Test("No battle moves are loaded", + MOVELIST.size()==0); SetupPartyMemberStats(); + Test("Battle moves now exist (still not defined)", + MOVELIST.size()>0); for (int i=0;istats==partyMemberDefaultStats); @@ -88,6 +94,74 @@ bool SeasonI::OnUserCreate(){ SetupObjectInfo(); Test("Using the same sprite definition does not cause memory leak", playerAnimPointer==OBJ_INFO[0]->spr->spr); + Test("No encounters are loaded", + ENCOUNTER_LIST.size()==0); + SetupEncounters(); + Test("SetupEncounters() loads up new encounters", + ENCOUNTER_LIST.size()>0); + Encounter*testEncounter=new Encounter(encounter::ENCOUNTER_1,{0,0},std::array{vd2d + {grid(1,2)},{grid(2,2)},{grid(3,2)},{grid(4,2)}}, + std::vector{ + new Entity(new Standard_Obj( + NPC1_4,"Test Obj",3,2,ANIMATIONS["player.png"]), + {HP:70,maxHP:70,PP:10,maxPP:10,baseAtk:14,speed:5,resistances:{0,0,0,0}},std::vector{ + MOVELIST[BattleMoveName::TESTMOVE1], + MOVELIST[BattleMoveName::TESTMOVE2], + MOVELIST[BattleMoveName::TESTMOVE3], + }, + {ITEMLIST[ItemName::COOKIE]}, + 돈 20), + new Entity(new Standard_Obj( + NPC1_4,"Test Obj 2",1,3,ANIMATIONS["player.png"]), + {HP:70,maxHP:70,PP:10,maxPP:10,baseAtk:14,speed:5,resistances:{0,0,0,0}},std::vector{ + MOVELIST[BattleMoveName::TESTMOVE1], + MOVELIST[BattleMoveName::TESTMOVE2], + }, + {ITEMLIST[ItemName::PIZZA]}), + new Entity(new Standard_Obj( + NPC1_4,"Test Obj 3",2,2,ANIMATIONS["player.png"]), + {HP:70,maxHP:70,PP:10,maxPP:10,baseAtk:14,speed:5,resistances:{0,0,0,0}},std::vector{ + MOVELIST[BattleMoveName::TESTMOVE1], + }), + }); + Test("Test encounter has three entities", + testEncounter->objs.size()==3); + Test("Test encounter uses ID ENCOUNTER_1", + testEncounter->id==encounter::ENCOUNTER_1); + testPos={0,0}; + Test("Test encounter uses position ("+std::to_string(testPos.x)+","+std::to_string(testPos.y)+")", + testEncounter->pos==testPos); + Test("Test encounter player positions are correct", + testEncounter->playerPos==std::array{vd2d{grid(1,2)},{grid(2,2)},{grid(3,2)},{grid(4,2)}}); + Test("Test encounter grid positions are correct", + testEncounter->playerPos==std::array{vd2d{grid(1,2)},{grid(2,2)},{grid(3,2)},{grid(4,2)}}); + Test("Enemy 1 has 3 battle moves.", + testEncounter->objs[0]->moveSet==std::vector{ + MOVELIST[BattleMoveName::TESTMOVE1], + MOVELIST[BattleMoveName::TESTMOVE2], + MOVELIST[BattleMoveName::TESTMOVE3], + }); + Test("Enemy 1 has a cookie as a drop.", + testEncounter->objs[0]->inventory==std::vector{ITEMLIST[ItemName::COOKIE]}); + Test("Enemy 1 gives 20 money.", + testEncounter->objs[0]->money==20); + Test("Enemy 2 has 2 battle moves.", + testEncounter->objs[1]->moveSet==std::vector{ + MOVELIST[BattleMoveName::TESTMOVE1], + MOVELIST[BattleMoveName::TESTMOVE2], + }); + Test("Enemy 2 has a pizza as a drop.", + testEncounter->objs[1]->inventory==std::vector{ITEMLIST[ItemName::PIZZA]}); + Test("Enemy 2 gives 0 money.", + testEncounter->objs[1]->money==0); + Test("Enemy 3 has 1 battle move.", + testEncounter->objs[2]->moveSet==std::vector{ + MOVELIST[BattleMoveName::TESTMOVE1], + }); + Test("Enemy 3 has no items to drop.", + testEncounter->objs[2]->inventory==std::vector{}); + Test("Enemy 3 gives 0 money.", + testEncounter->objs[2]->money==0); return true; }