-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMunchkinCharacter.java
More file actions
151 lines (129 loc) · 3.57 KB
/
MunchkinCharacter.java
File metadata and controls
151 lines (129 loc) · 3.57 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
package MunchkinGame;
/** A class that holds and manipulates data
* for a single Munchkin player.
* @author Patrick Morgan
* @version 09 September 2019
*/
public class MunchkinCharacter {
private int level = 1;
private String playerName;
private int powerLevel = 1;
//private String gender;
private int money;
/*******************************************************************/
/** Default constructor for a MunchkinCharacter object.
* @param playerName The name of the player
* @param tempGender The gender of the character
*/
public MunchkinCharacter(String name)//, String tempGender)
{
playerName = name;
//gender = tempGender;
money = 0;
}
/*******************************************************************/
/** A method to return the current level of the character.
* @return the level of the character
*/
public int getCharacterLevel()
{
return level;
}
/** A method that adds one to the character's level.
*/
public void incrementCharacterLevel()
{
level++;
powerLevel++;
}
/** A method that subtracts one from the character's level.
*/
public void decrementCharacterLevel()
{
// a character's level can not go below 1
if (level > 1){
level--;
powerLevel--;
}
}
/*******************************************************************/
/** A method to return the power level of the character.
* @return the power level of the character
*/
public int getPowerLevel()
{
return powerLevel;
}
/** A method that adds one to the character's power level.
*/
public void incrementPowerLevel()
{
powerLevel++;
}
/** A method that subtracts one from the character's power level.
*/
public void decrementPowerLevel()
{
// a character's power level can not go below its actual level
if (powerLevel > level){
powerLevel--;
}
}
/*******************************************************************/
/** A method to return the name of the player.
* @return the name of the player
*/
public String getPlayerName()
{
return playerName;
}
/*******************************************************************/
/** A method to return the character's current amount of money.
* @return the ammount of money carried by the character.
*/
public int getMoney()
{
return money;
}
/** A method that increments the character's
* current amount of money by 100
*/
public void addGold(int gold)
{
money += gold;
/* increase the character's level and
* power level if their gold exceeds 1000 */
if (money >= 1000){
level++;
powerLevel++;
money = money - 1000;
}
}
/** A method that decrements the character's
* current amount of money by 100
*/
public void subtractGold(int gold)
{
// make sure the subtraction won't go below 0
if ((money - gold) >= 0){
money -= gold;
}
}
/*******************************************************************/
/** A method to return the gender of the character.
* @return the gender of the character
*/
/*public String getGender()
{
return gender;
}*/
/** A method to switch the gender of the character.
*/
/*public void genderSwap()
{*/
/* If the character is currently male, switch them to female.
* If the character is currently female, switch them to male.
*/
//gender = (gender.equalsIgnoreCase("male")) ? "female" : "male";
//}
}