-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRogue.java
More file actions
89 lines (75 loc) · 2.66 KB
/
Rogue.java
File metadata and controls
89 lines (75 loc) · 2.66 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
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
/*=============================================
class Rogue -- protagonist of Ye Olde RPG
=============================================*/
public class Rogue extends Character {
// ~~~~~~~~~~~ INSTANCE VARIABLES ~~~~~~~~~~~
// inherited from superclass
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/*=============================================
default constructor
pre: instance vars are declared
post: initializes instance vars.
=============================================*/
public Rogue() {
super();
_hitPts = 50;
_strength = 100;
_defense = 30;
_attack = 0.9;
}
/*=============================================
overloaded constructor
pre: instance vars are declared
post: initializes instance vars. _name is set to input String.
=============================================*/
public Rogue( String name ) {
this();
if (!name.equals("")) {
_name = name;
}
}
/*=============================================
void specialize() -- prepares character for special attack
pre:
post: Attack of character is increased, defense is decreased
=============================================*/
public void specialize() {
_attack = 1;
_defense = 25;
}
/*=============================================
void normalize() -- revert stats back to normal
pre:
post: Attack and defense of character is de-specialized
=============================================*/
public void normalize() {
_attack = .9;
_defense = 30;
}
/*=============================================
String about() -- returns descriptions character type
pre:
post: Info is returned
=============================================*/
public String about() {
return "Rogues are sneaky, fast, and elusive, but aren't very sturdy.";
}
/*==========================
String heroSpecial()
pre:
post: executes a character's special move, for example, a priest would heal itself, and
returns a string summarizing what happened.
========================*/
public String heroSpecial(){
if (((int) (Math.random()*99)) >= 50){
this._hitPts -=5;
this._defense -=5;
this._strength +=20;
return "your rogue sacrifices HP and Defence for its strength to increase to " + this._strength + "but it now has " + this._hitPts + " HP " + this._defense + " defence";
}
else {
this._hitPts-=-15;
return "your rogue messes up the sacrifice, lowering HP by 15";
}
}
}//end class Rogue