More tests added

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
master
sigonasr2 2 years ago
parent 3d5d1a126e
commit ebbfafbebc
  1. BIN
      C++ProjectTemplate
  2. 16
      SeasonI.h
  3. 1
      battleproperty.h
  4. 9
      defines.h
  5. 11
      main.cpp
  6. 49
      test/test.cpp

Binary file not shown.

@ -9,7 +9,7 @@
using namespace olc; using namespace olc;
#define 시험 #define 됐어
class Map; class Map;
enum class ItemName; enum class ItemName;
@ -25,19 +25,19 @@ class SeasonI:public PixelGameEngine{
public: public:
SeasonI(){sAppName="Season I: Winters of Loneliness";} SeasonI(){sAppName="Season I: Winters of Loneliness";}
bool OnUserCreate()override; bool OnUserCreate()override;
void SetupMoveList(); void SetupMoveList();
void SetupItemList(); void SetupItemList();
void SetupPartyMemberStats(); void SetupPartyMemberStats();
void SetupAnimations(); void SetupAnimations();
void SetupObjectInfo(); void SetupObjectInfo();
void SetupEncounters(); void SetupEncounters();
void SetupBattleProperties(); void SetupBattleProperties();
void SetGameFlag(Flag flag,bool val); void SetGameFlag(Flag flag,bool val);
void LoadMap(Map*map); void LoadMap(Map*map);
void SaveMap(Map*map); void SaveMap(Map*map);
void AddItemToPlayerInventory(ItemName item); void AddItemToPlayerInventory(ItemName item);
Decal*CreateSprite(std::string spriteName); 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); vi2d grid(int x, int y);
bool GetGameFlag(int flag); bool GetGameFlag(int flag);
bool GetGameFlag(Flag flag); bool GetGameFlag(Flag flag);

@ -2,6 +2,7 @@
#define BATTLE_PROPERTY_H #define BATTLE_PROPERTY_H
#include "pixelGameEngine.h" #include "pixelGameEngine.h"
#include "entity.h" #include "entity.h"
#include "object.h"
using namespace olc; using namespace olc;

@ -49,5 +49,14 @@ enum class Property{
REVIVE REVIVE
}; };
enum:char{
ALPHA=α,
BETA=β,
GAMMA=γ,
OMEGA=Ω,
SIGMA=Σ,
};
extern vd2d cameraPos; extern vd2d cameraPos;
#endif #endif

@ -16,7 +16,7 @@
#include "map.h" #include "map.h"
#include "SeasonI.h" #include "SeasonI.h"
//#include "test/test.h" #include "test/test.h"
#ifndef TEST_SUITE #ifndef TEST_SUITE
#define OLC_PGE_APPLICATION #define OLC_PGE_APPLICATION
@ -37,15 +37,6 @@ vd2d cameraPos={0,0};
std::vector<Item*> PARTY_INVENTORY; std::vector<Item*> PARTY_INVENTORY;
enum{
ALPHA=α,
BETA=β,
GAMMA=γ,
OMEGA=Ω,
SIGMA=Σ,
};
class DamageNumber{ class DamageNumber{
public: public:

@ -30,6 +30,7 @@ extern std::array<Object*,4> PARTY_MEMBER_OBJ;
extern std::map<int,Object*> OBJ_INFO; extern std::map<int,Object*> OBJ_INFO;
extern std::map<BattleMoveName,Battle::Move*>MOVELIST; extern std::map<BattleMoveName,Battle::Move*>MOVELIST;
extern std::vector<Encounter*>ENCOUNTER_LIST; extern std::vector<Encounter*>ENCOUNTER_LIST;
extern std::map<Property,BattleProperty*> BATTLE_PROPERTIES;
int testCount=0; int testCount=0;
@ -135,13 +136,13 @@ bool SeasonI::OnUserCreate(){
testEncounter->playerPos==std::array<vd2d,4>{vd2d{grid(1,2)},{grid(2,2)},{grid(3,2)},{grid(4,2)}}); testEncounter->playerPos==std::array<vd2d,4>{vd2d{grid(1,2)},{grid(2,2)},{grid(3,2)},{grid(4,2)}});
Test("Test encounter grid positions are correct", Test("Test encounter grid positions are correct",
testEncounter->playerPos==std::array<vd2d,4>{vd2d{grid(1,2)},{grid(2,2)},{grid(3,2)},{grid(4,2)}}); testEncounter->playerPos==std::array<vd2d,4>{vd2d{grid(1,2)},{grid(2,2)},{grid(3,2)},{grid(4,2)}});
Test("Enemy 1 has 3 battle moves.", Test("Enemy 1 has 3 battle moves",
testEncounter->objs[0]->moveSet==std::vector<Battle::Move*>{ testEncounter->objs[0]->moveSet==std::vector<Battle::Move*>{
MOVELIST[BattleMoveName::TESTMOVE1], MOVELIST[BattleMoveName::TESTMOVE1],
MOVELIST[BattleMoveName::TESTMOVE2], MOVELIST[BattleMoveName::TESTMOVE2],
MOVELIST[BattleMoveName::TESTMOVE3], MOVELIST[BattleMoveName::TESTMOVE3],
}); });
Test("Enemy 1 has a cookie as a drop.", Test("Enemy 1 has a cookie as a drop",
testEncounter->objs[0]->inventory==std::vector<Item*>{ITEMLIST[ItemName::COOKIE]}); testEncounter->objs[0]->inventory==std::vector<Item*>{ITEMLIST[ItemName::COOKIE]});
Test("Enemy 1 gives 20 money.", Test("Enemy 1 gives 20 money.",
testEncounter->objs[0]->money==20); testEncounter->objs[0]->money==20);
@ -150,7 +151,7 @@ bool SeasonI::OnUserCreate(){
MOVELIST[BattleMoveName::TESTMOVE1], MOVELIST[BattleMoveName::TESTMOVE1],
MOVELIST[BattleMoveName::TESTMOVE2], MOVELIST[BattleMoveName::TESTMOVE2],
}); });
Test("Enemy 2 has a pizza as a drop.", Test("Enemy 2 has a pizza as a drop",
testEncounter->objs[1]->inventory==std::vector<Item*>{ITEMLIST[ItemName::PIZZA]}); testEncounter->objs[1]->inventory==std::vector<Item*>{ITEMLIST[ItemName::PIZZA]});
Test("Enemy 2 gives 0 money.", Test("Enemy 2 gives 0 money.",
testEncounter->objs[1]->money==0); testEncounter->objs[1]->money==0);
@ -158,10 +159,50 @@ bool SeasonI::OnUserCreate(){
testEncounter->objs[2]->moveSet==std::vector<Battle::Move*>{ testEncounter->objs[2]->moveSet==std::vector<Battle::Move*>{
MOVELIST[BattleMoveName::TESTMOVE1], MOVELIST[BattleMoveName::TESTMOVE1],
}); });
Test("Enemy 3 has no items to drop.", Test("Enemy 3 has no items to drop",
testEncounter->objs[2]->inventory==std::vector<Item*>{}); testEncounter->objs[2]->inventory==std::vector<Item*>{});
Test("Enemy 3 gives 0 money.", Test("Enemy 3 gives 0 money.",
testEncounter->objs[2]->money==0); testEncounter->objs[2]->money==0);
Test("There are no battle properties",
BATTLE_PROPERTIES.size()==0);
SetupBattleProperties();
Test("Battle Properties populated",
BATTLE_PROPERTIES.size()>0);
Test("Test Move 1 exists in the map.",
MOVELIST.count(BattleMoveName::TESTMOVE1));
Test("Test Move 1 is undefined",
MOVELIST[BattleMoveName::TESTMOVE1]==nullptr);
MOVELIST[BattleMoveName::TESTMOVE1]=new Battle::Move{"Test Move 1","An attack",baseDmg:30,randomDmg:5,range:6,channelTime:27,friendly:false};
Test("Verify Test Move 1's now set properly",
MOVELIST[BattleMoveName::TESTMOVE1]!=nullptr);
Test("Verify Test Move 1's Power Name shows up correctly",
MOVELIST[BattleMoveName::TESTMOVE1]->GetPowerName()=="Test Move 1");
MOVELIST[BattleMoveName::TESTMOVE1]->grade=GAMMA;
Test("Verify Test Move 1's Power Name shows up correctly with a grade",
MOVELIST[BattleMoveName::TESTMOVE1]->GetPowerName()=="Test Move 1 "+std::string(1,(char)GAMMA));
Test("Cookie is undefined",
ITEMLIST[ItemName::COOKIE]==nullptr);
SetupItemList();
Test("Cookie is defined",
ITEMLIST[ItemName::COOKIE]!=nullptr);
delete ITEMLIST[ItemName::COOKIE];
ITEMLIST.erase(ItemName::COOKIE);
ITEMLIST[ItemName::COOKIE]=new Item("Cookie","A delightful little treat. Restores 40 HP.",2,{hpRecovery:40,consumable:Consumable::FRIENDLY,sellPrice:2});
Test("Cookie name is set properly",
ITEMLIST[ItemName::COOKIE]->name=="Cookie");
Test("Cookie description is set properly",
ITEMLIST[ItemName::COOKIE]->description=="A delightful little treat. Restores 40 HP.");
Test("Cookie drop chance is set properly",
ITEMLIST[ItemName::COOKIE]->dropChance==2);
delete ITEMLIST[ItemName::FREEZE_PACKET];
ITEMLIST.erase(ItemName::FREEZE_PACKET);
ITEMLIST[ItemName::FREEZE_PACKET]=new Item("Freeze Packet","Lets out some blistering cold weather.",256,{consumable:Consumable::ENEMY,sellPrice:36},MOVELIST[BattleMoveName::FREEZE_PACKET]);
Test("Freeze Packet name is set properly",
ITEMLIST[ItemName::FREEZE_PACKET]->name=="Freeze Packet");
Test("Freeze Packet description is set properly",
ITEMLIST[ItemName::FREEZE_PACKET]->description=="Lets out some blistering cold weather.");
Test("Freeze Packet drop chance is set properly",
ITEMLIST[ItemName::FREEZE_PACKET]->dropChance==2);
return true; return true;
} }

Loading…
Cancel
Save