package main;

import java.awt.FontMetrics;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Point;
import utils.DynamicImage;

public class Weapon extends Item
{
    private int damage;
    private double attackSpeed;
    
    public Weapon(final String name, final DynamicImage img, final int damage, final double attackSpeed) {
        super(name, img, 2, 3);
        this.damage = damage;
        this.attackSpeed = attackSpeed;
        this.extraLines = 4;
    }
    
    protected Weapon(final Weapon o, final int x, final int y, final int z) {
        super(o, x, y, z);
        this.damage = o.damage;
        this.attackSpeed = o.attackSpeed;
    }
    
    @Override
    public Weapon copy(final Point newLoc) {
        return new Weapon(this, newLoc.x, newLoc.y, 0);
    }
    
    public int getDamage() {
        return this.damage;
    }
    
    public double getAttackSpeed() {
        return this.attackSpeed;
    }
    
    @Override
    public void addInfo(final Graphics g, final int x, final int y, final int width, final Font f, final FontMetrics m) {
        g.drawString("Weapon", x + (width - m.stringWidth("Weapon")) / 2, y + 2 * m.getHeight());
        g.drawString("Damage: " + this.damage, x + (width - m.stringWidth("Damage: " + this.damage)) / 2, y + 4 * m.getHeight());
        g.drawString("Speed: " + this.attackSpeed, x + (width - m.stringWidth("Speed: " + this.attackSpeed)) / 2, y + 5 * m.getHeight());
    }
}
