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
18 public class WaterMon extends Monster
19 {
20
23 protected static final int START = 10;
24
27 protected static final int MAX_EARN_ATTACK_LEVEL = 41;
28
29
32 protected static final String A1 = "Quick";
33
36 protected static final String A2 = "Water-Gun";
37
40 protected static final String A3 = "Tidal-Wave";
41
44 protected static final String A4 = "Tsunami";
45
48 protected static final String A5 = "Raging-Torrent";
49
52 protected static final String A6 = "Mega-Blast";
53
54
57 protected int lastAttack = 2;
58
59
64 public WaterMon()
65 {
66 type = MapObject.MONSTER;
67 attacks = new Vector();
68 maxLevel = START;
69 name = "Alligatrix";
70 kind = WATER;
71 enterable = true;
72
73 level = 2;
74 int lev6 = 6*level;
75 int lev7 = 7*level;
76 int lev10 = 10*level;
77 hp = lev6;
78 defp = lev10;
79 attp = lev7;
80 maxHP = lev6;
81 maxDef = lev10;
82 maxAtt = lev7;
83 exp = 0;
84 maxExp = lev10;
85 addAttack(A1);
86 addAttack(A2);
87 }
88
94 public WaterMon(String name)
95 {
96 type = MapObject.MONSTER;
97 attacks = new Vector();
98 maxLevel = START;
99 enterable = true;
100 if(name != null)
101 this.name = name;
102 else
103 name = "Alligatrix";
104 kind = WATER;
105 enterable = true;
106
107 level = 2;
108 int lev6 = 6*level;
109 int lev7 = 7*level;
110 int lev10 = 10*level;
111 hp = lev6;
112 defp = lev10;
113 attp = lev7;
114 maxHP = lev6;
115 maxDef = lev10;
116 maxAtt = lev7;
117 exp = 0;
118 maxExp = lev10;
119 addAttack(A1);
120 addAttack(A2);
121 }
122
123
127 public void setImage(Image[] img) { }
134 protected void setMaxLevel(byte nml)
135 {
136 if(nml > maxLevel && nml < MAX_EARN_ATTACK_LEVEL)
137 maxLevel = nml;
138 }
139
147 protected void levelUp() throws AttacksFullException
148 {
149 super.levelUp();
150
151 if(level >= maxLevel && level < MAX_EARN_ATTACK_LEVEL)
152 {
153 setMaxLevel((byte)(maxLevel+START));
154 try
155 {
156 Attack a;
157 switch(lastAttack)
158 {
159 case 2:
160 {
161 a = new Attack(A3, Attack.DAMAGE3);
162 lastAttack++;
163 break;
164 }
165 case 3:
166 {
167 a = new Attack(A4, Attack.DAMAGE4);
168 lastAttack++;
169 break;
170 }
171 case 4:
172 {
173 a = new Attack(A5, Attack.DAMAGE5);
174 lastAttack++;
175 break;
176 }
177 case 5:
178 {
179 a = new Attack(A6, Attack.DAMAGE6);
180 lastAttack++;
181 }
182 default:
183 return;
184 }
185 if(attacks.size() < MAXATTACKS)
186 {
187 attacks.add(a);
188 }
189 else
190 throw new AttacksFullException("Attacks are full to the brim remove one to add a new one", a);
191 }
192 catch(InvalidPowerException e) { } }
194 }
195
196
203 public void addAttack(String att) {
205 if(!(getNumberOfAttacks() < Monster.MAXATTACKS))
206 return;
207 Attack at;
208 for(int i = 0; i < attacks.size(); i++)
209 {
210 at = (Attack)attacks.get(i);
211 if(at.getName().equalsIgnoreCase(att))
212 return;
213 }
214 try
215 {
216 if(att.equalsIgnoreCase(A1))
217 {
218 attacks.add(new Attack(A1, Attack.DAMAGE1));
219 lastAttack = 1;
220 }
221 else if(att.equalsIgnoreCase(A2))
222 {
223 attacks.add(new Attack(A2, Attack.DAMAGE2));
224 lastAttack = 2;
225 }
226 else if(att.equalsIgnoreCase(A3))
227 {
228 attacks.add(new Attack(A3, Attack.DAMAGE3));
229 lastAttack = 3;
230 }
231 else if(att.equalsIgnoreCase(A4))
232 {
233 attacks.add(new Attack(A4, Attack.DAMAGE4));
234 lastAttack = 4;
235 }
236 else if(att.equalsIgnoreCase(A5))
237 {
238 attacks.add(new Attack(A5, Attack.DAMAGE5));
239 lastAttack = 5;
240 }
241 else if(att.equalsIgnoreCase(A6))
242 {
243 attacks.add(new Attack(A6, Attack.DAMAGE6));
244 lastAttack = 6;
245 }
246 }
247 catch(InvalidPowerException e) { } }
249
256 public boolean substituteAttack(Attack removed, Attack added)
257 {
258 if(attacks.remove(removed))
259 {
260 attacks.add(added);
261 return true;
262 }
263 else
264 return false;
265 }
266
271 public String getA1() { return A1; }
272
277 public String getA2() { return A2; }
278
283 public String getA3() { return A3; }
284
289 public String getA4() { return A4; }
290
295 public String getA5() { return A5; }
296
301 public String getA6() { return A6; }
302
306 public MapObject getClone() { return new WaterMon(name); }
307 }