source: lost-perception/main/Weapon.java@ a10d422

Last change on this file since a10d422 was ebd3538, checked in by Dmitry Portnoy <dmitry.portnoy@…>, 6 years ago

Initial commit. This codebase for the Lost Perception game was created by decompiling code from a jar file.

  • Property mode set to 100644
File size: 1.4 KB
RevLine 
[ebd3538]1package main;
2
3import java.awt.FontMetrics;
4import java.awt.Font;
5import java.awt.Graphics;
6import java.awt.Point;
7import utils.DynamicImage;
8
9public 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}
Note: See TracBrowser for help on using the repository browser.