Test Suite first test in action

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
master
sigonasr2 2 years ago
parent 56ca9470ee
commit 88efa7764e
  1. BIN
      C++ProjectTemplate
  2. 14
      SeasonI.h
  3. 1
      defines.h
  4. 14
      entity.h
  5. 26
      main.cpp
  6. 2
      object.h
  7. 27
      test/test.cpp

Binary file not shown.

@ -3,12 +3,23 @@
#include "pixelGameEngine.h" #include "pixelGameEngine.h"
#include "splash.h" #include "splash.h"
#include "soundwaveEngine.h" #include "soundwaveEngine.h"
#include "defines.h"
#include "flags.h" #include "flags.h"
#include "map.h"
#include "cutscene.h" #include "cutscene.h"
using namespace olc; using namespace olc;
class Map;
enum class ItemName;
class Object;
enum class ActionType;
class Entity;
class Effect;
namespace Battle{
class Move;
}
class SeasonI:public PixelGameEngine{ class SeasonI:public PixelGameEngine{
public: public:
SeasonI(){sAppName="Season I: Winters of Loneliness";} SeasonI(){sAppName="Season I: Winters of Loneliness";}
@ -112,4 +123,5 @@ class SeasonI:public PixelGameEngine{
void GetAnyKeyPress(olc::Key keypress)override; void GetAnyKeyPress(olc::Key keypress)override;
bool Collision(vd2d pos); bool Collision(vd2d pos);
}; };
extern SeasonI*GAME;
#endif #endif

@ -49,6 +49,5 @@ enum class Property{
REVIVE REVIVE
}; };
extern PixelGameEngine*GAME;
extern vd2d cameraPos; extern vd2d cameraPos;
#endif #endif

@ -3,6 +3,7 @@
#include "pixelGameEngine.h" #include "pixelGameEngine.h"
#include "object.h" #include "object.h"
#include <cassert>
extern std::vector<Item*>PARTY_INVENTORY; extern std::vector<Item*>PARTY_INVENTORY;
@ -34,6 +35,7 @@ class Entity{
bool smart=false; bool smart=false;
bool dumb=false; bool dumb=false;
}; };
public:
struct stats_t{ struct stats_t{
private: private:
int HP=0; int HP=0;
@ -67,6 +69,18 @@ class Entity{
this->smart=stats.smart; this->smart=stats.smart;
this->dumb=stats.dumb; this->dumb=stats.dumb;
}; };
bool operator==(const stats_t&t)const{
return HP==t.HP&&
maxHP==t.maxHP&&
PP==t.PP&&
maxPP==t.maxPP&&
baseAtk==t.baseAtk&&
speed==t.speed&&
resistances==t.resistances&&
damageReduction==t.damageReduction&&
smart==t.smart&&
dumb==t.dumb;
}
//Get the HP that the rolling counter is moving towards. //Get the HP that the rolling counter is moving towards.
int GetTargetHP() { int GetTargetHP() {
return targetHP; return targetHP;

@ -2,12 +2,6 @@
#include "item.h" #include "item.h"
#include "layers.h" #include "layers.h"
#include <string> #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 "soundwaveEngine.h"
#include "tiles.h" #include "tiles.h"
#include "references.h" #include "references.h"
@ -19,14 +13,25 @@
#include "particle.h" #include "particle.h"
#include "effect.h" #include "effect.h"
#include "battleproperty.h" #include "battleproperty.h"
#include "map.h"
#include "SeasonI.h" #include "SeasonI.h"
//#include "test/test.h"
#include "test/test.h"
#ifndef TEST_SUITE
#define OLC_PGE_APPLICATION
#include "pixelGameEngine.h"
#define OLC_PGEX_SPLASHSCREEN
#include "splash.h"
#define OLC_SOUNDWAVE
#include "defines.h"
#endif
using namespace olc; using namespace olc;
std::vector<Object*> OBJECTS; std::vector<Object*> OBJECTS;
const vd2d NO_NEIGHBOR = {-999,-999}; const vd2d NO_NEIGHBOR = {-999,-999};
PixelGameEngine*GAME; SeasonI*GAME;
vd2d cameraPos={0,0}; vd2d cameraPos={0,0};
@ -209,6 +214,7 @@ FireFountainEffect*FIREFOUNTAIN_EFFECT=nullptr;
Effect*CURRENT_EFFECT=nullptr; Effect*CURRENT_EFFECT=nullptr;
#ifndef TEST_SUITE
bool SeasonI::OnUserCreate(){ bool SeasonI::OnUserCreate(){
srand(time(NULL)); srand(time(NULL));
GAME=this; GAME=this;
@ -318,6 +324,7 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
return true; return true;
} }
#endif
void SeasonI::SetupMoveList() { void SeasonI::SetupMoveList() {
MOVELIST[BattleMoveName::TESTMOVE1]=new Battle::Move{"Test Move 1","An attack",baseDmg:30,randomDmg:5,range:1,channelTime:0,friendly:false}; MOVELIST[BattleMoveName::TESTMOVE1]=new Battle::Move{"Test Move 1","An attack",baseDmg:30,randomDmg:5,range:1,channelTime:0,friendly:false};
@ -1094,6 +1101,7 @@ void SeasonI::LoadEncounter(Map*map,vd2d pos,int chance,int id,bool successful)
} }
} }
#ifndef TEST_SUITE
bool SeasonI::OnUserUpdate(float fElapsedTime) bool SeasonI::OnUserUpdate(float fElapsedTime)
{ {
elapsedTime+=fElapsedTime; elapsedTime+=fElapsedTime;
@ -1121,6 +1129,8 @@ bool SeasonI::OnUserUpdate(float fElapsedTime)
drawGame(); drawGame();
return true; return true;
} }
#endif
void SeasonI::updateGame(){ void SeasonI::updateGame(){
frameCount++; frameCount++;
for (auto obj:OBJECTS) { for (auto obj:OBJECTS) {

@ -7,6 +7,8 @@
#include "layers.h" #include "layers.h"
#include "item.h" #include "item.h"
#include "states.h" #include "states.h"
#include "SeasonI.h"
using namespace olc; using namespace olc;
struct Interaction{ struct Interaction{

@ -20,6 +20,33 @@
#include "../effect.h" #include "../effect.h"
#include "../battleproperty.h" #include "../battleproperty.h"
#include "test.h" #include "test.h"
#include "../SeasonI.h"
extern std::array<Entity*,7> PARTY_MEMBER_STATS;
extern std::map<BattleMoveName,Battle::Move*>MOVELIST;
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;
};
bool SeasonI::OnUserCreate(){
SetupPartyMemberStats();
Entity::stats_t defaults{{HP:120,maxHP:120,PP:30,maxPP:30,baseAtk:8,speed:8,resistances:{0,0,0,0}}};
Test("Party Members get initialized with correct defaults.",
PARTY_MEMBER_STATS[0]->stats==defaults);
return true;
}
bool SeasonI::OnUserUpdate(float fElapsedTime)
{
return true;
}
int main() { int main() {
SeasonI demo; SeasonI demo;

Loading…
Cancel
Save