1 | package main;
|
---|
2 |
|
---|
3 | import java.awt.FontMetrics;
|
---|
4 | import java.awt.Font;
|
---|
5 | import java.awt.Graphics;
|
---|
6 | import java.awt.Point;
|
---|
7 | import utils.DynamicImage;
|
---|
8 |
|
---|
9 | public class Weapon extends Item
|
---|
10 | {
|
---|
11 | private int damage;
|
---|
12 | private double attackSpeed;
|
---|
13 |
|
---|
14 | public Weapon(final String name, final DynamicImage img, final int damage, final double attackSpeed) {
|
---|
15 | super(name, img, 2, 3);
|
---|
16 | this.damage = damage;
|
---|
17 | this.attackSpeed = attackSpeed;
|
---|
18 | this.extraLines = 4;
|
---|
19 | }
|
---|
20 |
|
---|
21 | protected Weapon(final Weapon o, final int x, final int y, final int z) {
|
---|
22 | super(o, x, y, z);
|
---|
23 | this.damage = o.damage;
|
---|
24 | this.attackSpeed = o.attackSpeed;
|
---|
25 | }
|
---|
26 |
|
---|
27 | @Override
|
---|
28 | public Weapon copy(final Point newLoc) {
|
---|
29 | return new Weapon(this, newLoc.x, newLoc.y, 0);
|
---|
30 | }
|
---|
31 |
|
---|
32 | public int getDamage() {
|
---|
33 | return this.damage;
|
---|
34 | }
|
---|
35 |
|
---|
36 | public double getAttackSpeed() {
|
---|
37 | return this.attackSpeed;
|
---|
38 | }
|
---|
39 |
|
---|
40 | @Override
|
---|
41 | public void addInfo(final Graphics g, final int x, final int y, final int width, final Font f, final FontMetrics m) {
|
---|
42 | g.drawString("Weapon", x + (width - m.stringWidth("Weapon")) / 2, y + 2 * m.getHeight());
|
---|
43 | g.drawString("Damage: " + this.damage, x + (width - m.stringWidth("Damage: " + this.damage)) / 2, y + 4 * m.getHeight());
|
---|
44 | g.drawString("Speed: " + this.attackSpeed, x + (width - m.stringWidth("Speed: " + this.attackSpeed)) / 2, y + 5 * m.getHeight());
|
---|
45 | }
|
---|
46 | }
|
---|