package org.project.item.weapons;

import org.project.entity.Entity;
import org.project.item.Item;

/**
 * Base class shared by every weapon. It holds the numbers common to all weapons
 * (damage, the mana it takes to swing hard with it, and its shop price) so the
 * concrete weapons only have to fill in those values in their constructor.
 */
public abstract class Weapon implements Item {

    private final String name;
    private final int damage;
    private final int manaCost;
    private final int price;

    protected Weapon(String name, int damage, int manaCost, int price) {
        this.name = name;
        this.damage = damage;
        this.manaCost = manaCost;
        this.price = price;
    }

    /** Default weapon use = strike the target for the weapon's damage. */
    @Override
    public void use(Entity target) {
        target.takeDamage(damage);
    }

    @Override
    public String getName() {
        return name;
    }

    @Override
    public int getPrice() {
        return price;
    }

    public int getDamage() {
        return damage;
    }

    public int getManaCost() {
        return manaCost;
    }
}
