package de.miaurizius.jgame2d.entity.monster;

import de.miaurizius.jgame2d.core.GamePanel;
import de.miaurizius.jgame2d.core.enums.EntityType;
import de.miaurizius.jgame2d.entity.Entity;
import de.miaurizius.jgame2d.entity.item.CoinObj;
import de.miaurizius.jgame2d.entity.item.HeartObj;
import de.miaurizius.jgame2d.entity.item.PotionObj;

import java.util.Random;

public class BatMON extends Entity {

    public BatMON(GamePanel panel) {
        super(panel);
        type = EntityType.MONSTER;
        name = "bat";
        defaultSpeed = 4;
        speed = defaultSpeed;
        maxLife = 4;
        life = maxLife;
        attack = 1;
        defense = 0;
        exp = 2;

        knockbackVal = 5;

        solidArea.x = 3;
        solidArea.y = 15;
        solidArea.width = 42;
        solidArea.height = 21;
        solidAreaDefaultX = solidArea.x;
        solidAreaDefaultY = solidArea.y;

        getImage();
    }

    // INTERACTION
    public void setAction() {
        setRandomDirection(10);
    }
    public void damageReaction() {
        actionLock = 0;
        //onPath = true;
    }
    public void checkDrop() {
        int i = new Random().nextInt(100)+1;
        if(i < 50) dropItem(new CoinObj(panel));
        if(i >= 50 && i < 75) dropItem(new HeartObj(panel));
        if(i >= 75 && i < 100) dropItem(new PotionObj(panel));
    }

    // SETTING THINGS UP
    public void getImage() {
        up1 = initEntitySprites("monster/bat_down_1");
        up2 = initEntitySprites("monster/bat_down_2");
        down1 = initEntitySprites("monster/bat_down_1");
        down2 = initEntitySprites("monster/bat_down_2");
        left1 = initEntitySprites("monster/bat_down_1");
        left2 = initEntitySprites("monster/bat_down_2");
        right1 = initEntitySprites("monster/bat_down_1");
        right2 = initEntitySprites("monster/bat_down_2");
    }

}
