[ebd3538] | 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 Armor extends Item
|
---|
| 10 | {
|
---|
| 11 | private int armorRating;
|
---|
| 12 | private ArmorType type;
|
---|
| 13 |
|
---|
| 14 | public Armor(final String name, final DynamicImage img, final ArmorType type, final int armorRating) {
|
---|
| 15 | super(name, img, 2, 2);
|
---|
| 16 | if (type == ArmorType.Body) {
|
---|
| 17 | this.imgHeight = 3;
|
---|
| 18 | }
|
---|
| 19 | this.armorRating = armorRating;
|
---|
| 20 | this.type = type;
|
---|
| 21 | this.extraLines = 3;
|
---|
| 22 | }
|
---|
| 23 |
|
---|
| 24 | protected Armor(final Armor o, final int x, final int y, final int z) {
|
---|
| 25 | super(o, x, y, z);
|
---|
| 26 | this.armorRating = o.armorRating;
|
---|
| 27 | this.type = o.type;
|
---|
| 28 | }
|
---|
| 29 |
|
---|
| 30 | @Override
|
---|
| 31 | public Armor copy(final Point newLoc) {
|
---|
| 32 | return new Armor(this, newLoc.x, newLoc.y, 0);
|
---|
| 33 | }
|
---|
| 34 |
|
---|
| 35 | public int getArmorRating() {
|
---|
| 36 | return this.armorRating;
|
---|
| 37 | }
|
---|
| 38 |
|
---|
| 39 | public ArmorType getType() {
|
---|
| 40 | return this.type;
|
---|
| 41 | }
|
---|
| 42 |
|
---|
| 43 | @Override
|
---|
| 44 | public void addInfo(final Graphics g, final int x, final int y, final int width, final Font f, final FontMetrics m) {
|
---|
| 45 | g.drawString("Armor - " + this.type.name(), x + (width - m.stringWidth("Armor - " + this.type.name())) / 2, y + 2 * m.getHeight());
|
---|
| 46 | g.drawString("Armor Rating: " + this.armorRating, x + (width - m.stringWidth("Armor Rating: " + this.armorRating)) / 2, y + 4 * m.getHeight());
|
---|
| 47 | }
|
---|
| 48 |
|
---|
| 49 | public enum ArmorType {
|
---|
| 50 | Head("Head", 0),
|
---|
| 51 | Hands("Hands", 1),
|
---|
| 52 | Body("Body", 2),
|
---|
| 53 | Feet("Feet", 3);
|
---|
| 54 |
|
---|
| 55 | private ArmorType(final String s, final int n) {
|
---|
| 56 | }
|
---|
| 57 | }
|
---|
| 58 | }
|
---|