1   import java.awt.*;
2   import javax.swing.*;
3   import java.applet.*;
4   import java.awt.image.*;
5   import java.awt.geom.*;
6   import java.net.*;
7   import java.util.*;
8   /**
9    * Simple class to associate an Image with a Name.
10   * 
11   * @see Game
12   * @see Battle
13   * @see Monster
14   */
15  public class ImageMap
16  {
17      /**
18       * The name of this
19       */
20      String name;
21      /**
22       * The image of this
23       */
24      Image img;
25      /**
26       * Construct a new ImageMap with the name and Image specified.
27       * 
28       * @param name the name for the Image
29       * @param img the Image for this.
30       */
31      public ImageMap(String name, Image img)
32      {
33          this.name=name;
34          this.img = img;
35      }
36  
37      /**
38       * Gets the Image of this
39       * 
40       * @return the Image of this
41       */
42      public Image getImage() { return img; }
43      /**
44       * Gets the name of this Image
45       * 
46       * @return the name of this Image
47       */
48      public String getName() { return name; }
49      /**
50       * Determine Equality of this and the Object o.
51       * 
52       * @param o the Object to compare
53       * @return true iff equivalant
54       */
55      public boolean equals(Object o)
56      {
57          if(o instanceof ImageMap)
58              return equals((ImageMap)o);
59          return false;
60      }
61      /**
62       * Determine Equality of this and the ImageMap im.
63       * 
64       * @param o the Object to compare
65       * @return true iff equivalant, ie have the same name and Image
66       */
67      public boolean equals(ImageMap im)
68      {
69          return this.name.equalsIgnoreCase(im.getName()) && img.equals(im.getImage());
70      }
71      /**
72       * Determine Equality of this and the String specified.
73       * 
74       * @param s the String to compare with this name, should not specify th -B or -F, only should be the name to search for
75       * @param front true if opponent
76       * @return true iff equivalant
77       */
78      public boolean equals(String s, boolean front)
79      {
80          if(front)
81          {
82              return this.name.equalsIgnoreCase(s + "-B");
83          }
84          else
85          {
86              return this.name.equalsIgnoreCase(s + "-F");
87          }
88      }
89  }