-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSkullSpider.java
More file actions
62 lines (55 loc) · 1.4 KB
/
SkullSpider.java
File metadata and controls
62 lines (55 loc) · 1.4 KB
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
import greenfoot.*;
/**
* Write a description of class SkullSpider here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class SkullSpider extends Monster
{
public SkullSpider()
{
super();
GreenfootImage spider = new GreenfootImage("images/monsters/skull_spider.png");
spider.scale(75, 75);
setImage(spider);
health = 15;
strength = 2;
defense = 8;
piety = 1;
will = 3;
speed = 7;
}
/**
* 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)
{
int damage = 0;
int playMDef = player.getWill();
damage = (piety * 2) / playMDef;
if (damage == 0) damage = 1;
return damage;
}
/**
* Act - do whatever the SkullSpider 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.
}
}