-
Notifications
You must be signed in to change notification settings - Fork 0
/
Player.java
216 lines (175 loc) · 5.04 KB
/
Player.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
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
import java.util.Random;
public class Player {
final static int WRKENERGY = 10;
final static int EXENERGY = 30;
final static int HPFROMEX = 10;
final static int STUDYENERGY = 30;
final static int RKTENERGY = 30;
final static int RKTPTSTOWIN = 1;
final static int FOODMONEY = 10;
final static int FOODENG = 10;
final static int DRUGHEALTH = 10;
final static int DRUGENG = 20;
final static int DRUGMENTAL = 5;
final static int SLEEPDEPRIVED = 10;
final static int DAILYSORROW = 5;
final static int RENTNSTUFF = 10;
final static int FUNHEALTH = 10;
int physHealth = 80;
int mentalHealth = 80;
int money = 80;
int rocketPoints = 0;
int dailyTime;
boolean isAlive = true;
boolean deathMental = false;
boolean deathPhysical = false;
boolean isBroke = false;
boolean isWinning = false;
IO inputPrompt = new IO();
int energy;
int salary = 5;
void wakeUp() {
this.energy =(int)((this.physHealth * 0.7) + (this.mentalHealth *0.3));
dailyTime = 4;
}
void goToWork(int intensity) {
this.money += salary + intensity;
this.energy -= (WRKENERGY + intensity * 5);
//initiate a mini game, might get you extra bonus points
int extraSal = inputPrompt.miniGame();
//decide whether or not to work an extra shift
boolean extraWork = inputPrompt.extraShift();
if (extraWork) {
this.money += salary + intensity;
this.energy -= (WRKENERGY + intensity * 5);
dailyTime--;
}
inputPrompt.workIsOver(salary + intensity, WRKENERGY + intensity * 5, extraWork);
inputPrompt.mainInfo(energy, physHealth, mentalHealth, money);
}
void dailyLife() {
//get a request from player and return
String action = inputPrompt.dailyOptions(dailyTime).toLowerCase();
switch(action) {
case "exercise": this.exercise();
break;
case "study": this.study();
break;
case "rocket": this.buildRocket();
break;
case "eat": this.eat();
break;
case "meds": this.getEnergised();
break;
case "fun": this.haveFun();
break;
default: dailyLife();
}
}
void exercise() {
boolean success = false;
if (this.energy >= EXENERGY) {
this.physHealth += HPFROMEX;
this.energy -= EXENERGY;
success = true;
dailyTime--;
}
if(physHealth > 100) {
physHealth = 100;
}
//output a message depending on weather you have successfully completed the exercise
inputPrompt.excersiceRes(success);
inputPrompt.mainInfo(energy, physHealth, mentalHealth, money);
}
void study() {
boolean success = false;
if (this.energy >= STUDYENERGY) {
this.salary++;
this.energy -= STUDYENERGY;
success = true;
dailyTime--;
}
//output a message depending on weather you have successfully completed the exercise
inputPrompt.studyRes(success);
inputPrompt.mainInfo(energy, physHealth, mentalHealth, money);
}
void buildRocket() {
boolean success = false;
if (this.energy >= RKTENERGY) {
this.rocketPoints++;
if(this.rocketPoints == RKTPTSTOWIN) {
//this then ends the game in he mainGame loop
this.isWinning = true;
}
this.energy -= RKTENERGY;
success = true;
dailyTime--;
}
inputPrompt.rocketRes(success, RKTPTSTOWIN - rocketPoints);
inputPrompt.mainInfo(energy, physHealth, mentalHealth, money);
}
void eat() {
boolean success = false;
if (this.money >= FOODMONEY) {
this.money -= FOODMONEY;
this.energy += FOODENG;
success = true;
dailyTime--;
}
if(energy > 100) {
energy = 100;
}
inputPrompt.eatRes(success);
inputPrompt.mainInfo(energy, physHealth, mentalHealth, money);
}
public void maybeSleepLate() {
boolean stayingUp = inputPrompt.sleep();
if (stayingUp) {
this.physHealth -= SLEEPDEPRIVED;
this.dailyLife();
}
}
public void maintenace() {
this.mentalHealth -= DAILYSORROW;
this.money -= RENTNSTUFF;
inputPrompt.endDay();
}
private void getEnergised() {
boolean success = false;
if (this.physHealth >= DRUGHEALTH) {
this.physHealth -= DRUGHEALTH;
this.energy += DRUGENG;
this.mentalHealth -= DRUGMENTAL;
success = true;
dailyTime--;
}
if(energy > 100) {
energy = 100;
}
inputPrompt.drugRes(success);
inputPrompt.mainInfo(energy, physHealth, mentalHealth, money);
}
private void haveFun() {
// TODO Auto-generated method stub
int action = inputPrompt.funActivities(money);
this.money -= action;
//has better effect depending on how much money you have spent
this.mentalHealth += FUNHEALTH + action;
dailyTime--;
inputPrompt.mainInfo(energy, physHealth, mentalHealth, money);
}
public boolean checkLife() {
if(this.physHealth <= 0) {
deathPhysical = true;
}
if(this.mentalHealth <= 0) {
deathMental = true;
}
if(this.money <= 0) {
isBroke = true;
}
//if whichever of these is false, we have lost the game:
this.isAlive = !(deathPhysical || deathMental || isBroke);
return this.isAlive;
}
}