#include "spawner.hpp"
#include "block.hpp"
#include "entity/simplyEnemy.hpp"
#include "entity/shootingEnemy.hpp"
#include "entity/chaseEnemy.hpp"

namespace game {

int SimplyEnemySpawner::SpawnEnemies(Block *block, int difficult)
{
    int health = difficult / 30;

    if (health > 40) {
        health = 40;
    } else if (health < 1) {
        health = 1;
    }

    vec2f position = vec2f{(rand()%250) / 10.0 + 1, (rand()%150) / 15.0f + 1 } + block->GetPosition();

    new entity::SimplyEnemy(block, position, health);

    return health * 5;
}

int ChaseEnemySpawner::SpawnEnemies(Block *block, int difficult)
{
    int health = difficult / 30;

    if (health > 40) {
        health = 40;
    } else if (health < 1) {
        health = 1;
    }

    vec2f position = vec2f{(rand()%250) / 10.0 + 1, (rand()%150) / 15.0f + 1 } + block->GetPosition();

    new entity::ChaseEnemy(block, position, health);

    return health * 10;
}

int ShootingEnemySpawner::SpawnEnemies(Block *block, int difficult)
{
    int amount = rand() % (difficult / 10);
    int health = difficult / 10;

    if (health > 20) {
        health = 20;
    }

    if (amount > 2) {
        amount = 2;
    }

    vec2f position = vec2f{(rand()%150) / 10.0 + 1, (rand()%150) / 10.0f + 1 } + block->GetPosition();

    for (int i = 0; i < (1 + amount); i++) {
        new entity::ShootingEnemy(block, position, health);
        position.x += 1.2;
    }


    return amount * 40;
}

}

