forked from Peashooter101/CSULB_CECS-277_Pokemon_Project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Grass.java
99 lines (91 loc) · 2.79 KB
/
Grass.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import java.util.Random;
/**
* Grass Type Pokemon Class
*/
public class Grass extends Pokemon {
/**
* Constructor for Pokemon of this Type
* @param n Name of Pokemon
* @param h Current HP of Pokemon (New Pokemon should have max HP)
* @param m Max HP of Pokemon
*/
public Grass(String n, int h, int m) {
super(n,h,m);
}
/**
* Returns a string representing the menu.
* @param atkType Attack Type represented as int.
* @return Menu for Attack Type, otherwise "INVALID MENU".
*/
@Override
public String getAttackMenu(int atkType) {
if (atkType == 1) { return super.getAttackMenu(atkType); }
if (atkType == 2) { return "1.Vine Whip\n2.Razor Leaf\n3.Solar Beam"; }
return "[FATAL ERROR] INVALID ATTACK MENU in " + this.getClass().getName();
}
/**
* Returns the number of items in the menu.
* @param atkType Attack Type represented as int.
* @return Number representing the attack menu items, invalid atkType returns -1.
*/
@Override
public int getNumAttackMenuItems(int atkType) {
if (atkType == 2) { return 3; }
return super.getNumAttackMenuItems(atkType);
}
/**
* Returns the partial string for the attack.
* @param atkType Attack Type represented as int.
* @param move Move represented as int.
* @return Verb of the attack, partial string for the full attack string, [Error] if invalid atkType.
*/
@Override
public String getAttackString(int atkType, int move) {
if (atkType == 2) {
switch(move) {
case 1:
return "WHIPPED WITH A VINE";
case 2:
return "CUT BY LEAVES";
case 3:
return "BEAMED BY THE SUN";
default:
return "[ERROR ATK MOVE]";
}
}
return super.getAttackString(atkType, move);
}
/**
* Returns the attack damage.
* @param atkType Attack Type represented as int.
* @param move Move represented as int.
* @return Damage value to be used, -1 if invalid atkType / move.
*/
@Override
public int getAttackDamage(int atkType, int move) {
if (atkType == 2) {
Random random = new Random();
switch (move) {
case 1:
return random.nextInt(3) + 1 + getAttackBonus(atkType);
case 2:
return random.nextInt(3) + 2 + getAttackBonus(atkType);
case 3:
return random.nextInt(6) + getAttackBonus(atkType);
default:
return -1;
}
}
return super.getAttackDamage(atkType, move);
}
/**
* Returns the attack multiplier based on the battle table.
* @param p Pokemon
* @param atkType Attack Type represented by int.
* @return Multiplier depending on types, 1.0 if atkType is 1 (Basic).
*/
@Override
public double getAttackMultiplier(Pokemon p, int atkType) {
return super.getAttackMultiplier(p, atkType);
}
}