package org.project.item.consumables;

import org.project.Colors;
import org.project.entity.Entity;
import org.project.entity.enemies.Dragon;
import org.project.entity.enemies.Enemy;

import java.util.Collections;
import java.util.Random;

public class CursedDagger extends Consumable{

    public CursedDagger() {
        super("Cursed Dagger", 80, "Enemy");
    }

    @Override
    public void use(Entity entity) {
        Enemy e = (Enemy) entity;
        if(!(entity instanceof Dragon))
        {
            if (new Random().nextInt(100) < 30) {
                System.out.println("Cursed Dagger strikes true!");
                System.out.println("Enemy " + Colors.RED + "died" + Colors.RESET + "instantly.");
                e.setHp(0);
            } else {
                System.out.println("Cursed dagger fails.");
                e.takeDamage(10);
            }
        }
        else
        {
            System.out.println("Cursed Dagger has no effect on Dragon");
        }
    }

    @Override
    public String toString() {
        return "Cursed Dagger:\n" + Colors.COIN + "80 coins" +Colors.RESET +"\n30% chance to instantly kill a enemy(do not work for dragon). if it fails, deals 10 damage.";
    }
}
