2024-02-28 17:50:57 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include "cutest-1.5/CuTest.h"
|
|
|
|
|
|
|
|
#include "movement.h"
|
|
|
|
#include "game.h"
|
|
|
|
#include "spawn.h"
|
|
|
|
#include "movement.h"
|
|
|
|
|
|
|
|
// testing these private methods, i know
|
|
|
|
void selectEnemySpawnLocation(
|
|
|
|
struct EnemySpawningDetails *spawnDetails,
|
|
|
|
struct RabbitPosition *rabbitPosition
|
|
|
|
);
|
|
|
|
int determineEnemyHitPointCalculation(int difficulty, int pcnt);
|
|
|
|
int spawnEnemy(struct EnemySpawningDetails*, struct GlobalGameState*);
|
|
|
|
|
|
|
|
struct EnemySpawningDetails spawnDetails;
|
|
|
|
struct RabbitPosition rabbitPosition;
|
|
|
|
struct GlobalGameState globalGameState;
|
|
|
|
struct EnemyPosition enemyPosition;
|
|
|
|
|
|
|
|
void TestSelectEnemySpawnLocation(CuTest *tc) {
|
|
|
|
srand(1);
|
|
|
|
|
|
|
|
spawnDetails.gate = -1;
|
|
|
|
spawnDetails.spawnX = -1;
|
|
|
|
spawnDetails.spawnY = -1;
|
|
|
|
|
|
|
|
rabbitPosition.mouseAngle = 30;
|
|
|
|
|
|
|
|
selectEnemySpawnLocation(
|
|
|
|
&spawnDetails,
|
|
|
|
&rabbitPosition
|
|
|
|
);
|
|
|
|
|
|
|
|
// built from setting seed to 1
|
|
|
|
CuAssertIntEquals(tc, 3, spawnDetails.gate);
|
|
|
|
CuAssertIntEquals(tc, 27, spawnDetails.spawnX);
|
|
|
|
CuAssertIntEquals(tc, 91, spawnDetails.spawnY);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestSpawnEnemy(CuTest *tc) {
|
|
|
|
srand(1);
|
|
|
|
|
|
|
|
spawnDetails.gate = 1;
|
|
|
|
spawnDetails.spawnX = 100;
|
|
|
|
spawnDetails.spawnY = 50;
|
|
|
|
spawnDetails.enemyPosition = &enemyPosition;
|
|
|
|
globalGameState.difficulty = 4;
|
|
|
|
|
|
|
|
spawnEnemy(&spawnDetails, &globalGameState);
|
|
|
|
|
|
|
|
// randomized values
|
2024-03-02 22:05:30 +00:00
|
|
|
CuAssertIntEquals(tc, 1, enemyPosition.hitPoints);
|
2024-03-04 22:38:03 +00:00
|
|
|
CuAssertIntEquals(tc, 108, enemyPosition.enemyFireDelayStep);
|
2024-02-28 17:50:57 +00:00
|
|
|
|
|
|
|
// from spawndetails
|
|
|
|
CuAssertIntEquals(tc, 1, enemyPosition.gateExitedFrom);
|
|
|
|
CuAssertIntEquals(tc, 100, enemyPosition.enemyPosition[0]);
|
|
|
|
CuAssertIntEquals(tc, 50, enemyPosition.enemyPosition[1]);
|
|
|
|
CuAssertIntEquals(tc, 100, enemyPosition.oldEnemyPosition[0]);
|
|
|
|
CuAssertIntEquals(tc, 50, enemyPosition.oldEnemyPosition[1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
CuSuite *SpawnGetSuite() {
|
|
|
|
CuSuite *suite = CuSuiteNew();
|
|
|
|
SUITE_ADD_TEST(suite, TestSelectEnemySpawnLocation);
|
|
|
|
SUITE_ADD_TEST(suite, TestSpawnEnemy);
|
|
|
|
return suite;
|
|
|
|
}
|