source: lost-perception/main/Armor.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.6 KB
Line 
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 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}
Note: See TracBrowser for help on using the repository browser.