1 import java.awt.*;
2 import java.applet.*;
3 import javax.swing.*;
4 import java.awt.image.*;
5 import java.awt.geom.*;
6 import java.net.*;
7 import java.util.*;
8
14 public class MonsterBallItem extends Item
15 {
16
19 public static final int NORMAL = 1;
20
23 public static final int MASTER = 2;
24
25
28 private int subBrand;
29
30
36 public MonsterBallItem(String name, int subBrand)
37 {
38 brand = MONSTERBALL;
39 if(name != null)
40 this.name = name;
41 else
42 name = "Normal MonsterBall";
43 brand = MONSTERBALL;
44 if(subBrand == NORMAL || subBrand == MASTER)
45 this.subBrand = subBrand;
46 else
47 this.subBrand = NORMAL;
48 number = 1;
49 }
50
55 public int getSubBrand() { return subBrand; }
56
57
67 public boolean useItem(Monster m) {
69 double r = Math.random();
70 number--;
71 if(getSubBrand() == NORMAL)
72 {
73 if(m.getLevel() < 20)
74 {
75 if(r < .9) return true;
77 else
78 return false;
79 }
80 else
81 {
82 if(r < .2) return true;
84 else
85 return false;
86 }
87 }
88 else
89 {
90 if(r < 9) return true;
92 else
93 return false;
94 }
95 }
96 }