forked from TechHead27/EW
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Slime.java
58 lines (52 loc) · 1.26 KB
/
Slime.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
import greenfoot.*;
/**
* Write a description of class Slime here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Slime extends Monster
{
public Slime()
{
super();
GreenfootImage slime = new GreenfootImage("images/monsters/Slime.png");
slime.scale(75, 75);
setImage(slime);
health = 20;
strength = 3;
defense = 2;
piety = 0;
will = 1;
speed = 4;
}
/**
* Attack with a physical attack
* @return the amount of damage dealt
*/
public int attack(Character player)
{
int damage = 0;
int playDef = player.getDefense();
damage = (strength * 2) / (playDef * 3);
if (damage == 0) damage = 1;
return damage;
}
/**
* Attack with a magical attack
* @return the amount of damage dealt
*/
public int cast(Character player)
{
// Do nothing if Monster has no magic attacks
return 0;
}
/**
* Act - do whatever the Slime wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
// Add your action code here.
}
}