-
Notifications
You must be signed in to change notification settings - Fork 10
/
effects.pas
399 lines (369 loc) · 13.1 KB
/
effects.pas
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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
unit Effects;
interface
uses
types,
sysutils,
outputcolor;
function Affect(var hero: THero; var antiHero: THero; effect: TEffect): Boolean;
function Affect(var hero: THero; var antiHero: THero; effects: TEffects): Boolean;
function Damage(var hero: THero; effect: TEffect): Boolean;
function Heal(var hero: THero; effect: TEffect): Boolean;
function Boost(var hero: THero; effect: TEffect): Boolean;
function Decrease(var hero: THero; effect: TEffect): Boolean;
function TakeToDrink(var hero: THero; effect: TEffect): Boolean;
function Sober(var hero: THero; effect: TEffect): Boolean;
function PumpUp(var hero: THero; effect: TEffect): Boolean;
function PumpDown(var hero: THero; effect: TEffect): Boolean;
function ReduceIntelligence(var hero: THero; effect: TEffect): Boolean;
function IncreaseIntelligence(var hero: THero; effect: TEffect): Boolean;
function Luckly(var hero: THero; effect: TEffect): Boolean;
function Luckless(var hero: THero; effect: TEffect): Boolean;
function InLove(var hero: THero; effect: TEffect): Boolean;
function Lonely(var hero: THero; effect: TEffect): Boolean;
function Happiness(var hero: THero; effect: TEffect): Boolean;
function Misfortune(var hero: THero; effect: TEffect): Boolean;
function Tuning(var hero: THero; effect: TEffect): Boolean;
function TakeToVape(var hero: THero; effect: TEffect): Boolean;
function UpReputationInGroup(var hero: THero; effect: TEffect): Boolean;
function DownReputationInGroup(var hero: THero; effect: TEffect): Boolean;
function UpReputationInUniversity(var hero: THero; effect: TEffect): Boolean;
function DownReputationInUniversity(var hero: THero; effect: TEffect): Boolean;
implementation
function Damage(var hero: THero; effect: TEffect): Boolean;
begin
hero.health.value := hero.health.value - effect.value;
hero.health.changed := hero.health.changed - effect.value;
if hero.health.value < 0 then
hero.health.value := 0;
if hero.health.value = 0 then
Exit(False);
Exit(True);
end;
function Heal(var hero: THero; effect: TEffect): Boolean;
begin
hero.health.value := hero.health.value + effect.value;
hero.health.changed := effect.value;
if hero.health.value > 10 then
hero.health.value := 10;
if hero.health.value = 10 then
Exit(True);
Exit(True);
end;
function Boost(var hero: THero; effect: TEffect): Boolean;
begin
hero.energy.value := hero.energy.value + effect.value;
hero.energy.changed := effect.value;
if hero.energy.value > 10 then
hero.energy.value := 10;
if hero.energy.value = 10 then
Exit(True);
Exit(True);
end;
function Decrease(var hero: THero; effect: TEffect): Boolean;
begin
hero.energy.value := hero.energy.value - effect.value;
hero.energy.changed := hero.energy.changed - effect.value;
if hero.energy.value < 0 then
hero.energy.value := 0;
if hero.energy.value = 0 then
Exit(False);
Exit(True);
end;
function TakeToDrink(var hero: THero; effect: TEffect): Boolean;
begin
hero.alchohol.value := hero.alchohol.value + effect.value;
hero.alchohol.changed := hero.alchohol.changed + effect.value;
if hero.alchohol.value > 10 then
hero.alchohol.value := 10;
if hero.alchohol.value = 10 then
Exit(True);
Exit(True);
end;
function Sober(var hero: THero; effect: TEffect): Boolean;
begin
hero.alchohol.value := hero.alchohol.value - effect.value;
hero.alchohol.changed := hero.alchohol.changed - effect.value;
if hero.alchohol.value < 0 then
hero.alchohol.value := 0;
if hero.alchohol.value = 0 then
Exit(True);
Exit(True);
end;
function PumpUp(var hero: THero; effect: TEffect): Boolean;
begin
hero.strength.value := hero.strength.value + effect.value;
hero.strength.changed := hero.strength.changed + effect.value;
if hero.strength.value > 10 then
hero.strength.value := 10;
if hero.strength.value = 10 then
Exit(True);
Exit(True);
end;
function PumpDown(var hero: THero; effect: TEffect): Boolean;
begin
hero.strength.value := hero.strength.value - effect.value;
hero.strength.changed := hero.strength.changed - effect.value;
if hero.strength.value < 0 then
hero.strength.value := 0;
if hero.strength.value = 0 then
Exit(True);
Exit(True);
end;
function ReduceIntelligence(var hero: THero; effect: TEffect): Boolean;
begin
hero.intelligence.value := hero.intelligence.value - effect.value;
hero.intelligence.changed := hero.intelligence.changed - effect.value;
if hero.intelligence.value < 0 then
hero.intelligence.value := 0;
if hero.intelligence.value = 0 then
Exit(True);
Exit(True);
end;
function IncreaseIntelligence(var hero: THero; effect: TEffect): Boolean;
begin
hero.intelligence.value := hero.intelligence.value + effect.value;
hero.intelligence.changed := hero.intelligence.changed + effect.value;
if hero.intelligence.value > 10 then
hero.intelligence.value := 10;
if hero.intelligence.value = 10 then
Exit(True);
Exit(True);
end;
function Luckly(var hero: THero; effect: TEffect): Boolean;
begin
hero.fortune.value := hero.fortune.value + effect.value;
hero.fortune.changed := hero.fortune.changed + effect.value;
if hero.fortune.value > 10 then
hero.fortune.value := 10;
if hero.fortune.value = 10 then
Exit(True);
Exit(True);
end;
function Luckless(var hero: THero; effect: TEffect): Boolean;
begin
hero.fortune.value := hero.fortune.value - effect.value;
hero.fortune.changed := hero.fortune.changed - effect.value;
if hero.fortune.value < 0 then
hero.fortune.value := 0;
if hero.fortune.value = 0 then
Exit(True);
Exit(True);
end;
function Lonely(var hero: THero; effect: TEffect): Boolean;
begin
hero.love.value := hero.love.value - effect.value;
hero.love.changed := hero.love.changed - effect.value;
if hero.love.value < 0 then
hero.love.value := 0;
if hero.love.value = 0 then
Exit(True);
Exit(True);
end;
function InLove(var hero: THero; effect: TEffect): Boolean;
begin
hero.love.value := hero.love.value + effect.value;
hero.love.changed := hero.love.changed + effect.value;
if hero.love.value > 10 then
hero.love.value := 10;
if hero.love.value = 10 then
Exit(True);
Exit(True);
end;
function Happiness(var hero: THero; effect: TEffect): Boolean;
begin
hero.happy.value := hero.happy.value + effect.value;
hero.happy.changed := hero.happy.changed + effect.value;
if hero.happy.value > 10 then
hero.happy.value := 10;
if hero.happy.value = 10 then
Exit(True);
Exit(True);
end;
function Misfortune(var hero: THero; effect: TEffect): Boolean;
begin
hero.happy.value := hero.happy.value - effect.value;
hero.happy.changed := hero.happy.changed - effect.value;
if hero.happy.value < 0 then
hero.happy.value := 0;
if hero.happy.value = 0 then
Exit(True);
Exit(True);
end;
function Tuning(var hero: THero; effect: TEffect): Boolean;
begin
hero.tune.value := hero.tune.value + effect.value;
hero.tune.changed := hero.tune.changed + effect.value;
Exit(True);
end;
function TakeToVape(var hero: THero; effect: TEffect): Boolean;
begin
hero.vape.value := hero.vape.value + effect.value;
hero.vape.changed := hero.vape.changed + effect.value;
if hero.vape.value > 10 then
hero.vape.value := 10;
if hero.vape.value = 10 then
Exit(True);
end;
function UpReputationInGroup(var hero: THero; effect: TEffect): Boolean;
begin
hero.reputationInGroup.value := hero.reputationInGroup.value + effect.value;
hero.reputationInGroup.changed := hero.reputationInGroup.changed + effect.value;
if hero.reputationInGroup.value > 10 then
hero.reputationInGroup.value := 10;
if hero.reputationInGroup.value = 10 then
Exit(True);
Exit(True);
end;
function DownReputationInGroup(var hero: THero; effect: TEffect): Boolean;
begin
hero.reputationInGroup.value := hero.reputationInGroup.value - effect.value;
hero.reputationInGroup.changed := hero.reputationInGroup.changed - effect.value;
if hero.reputationInGroup.value < 0 then
hero.reputationInGroup.value := 0;
if hero.reputationInGroup.value = 0 then
Exit(True);
Exit(True);
end;
function UpReputationInUniversity(var hero: THero; effect: TEffect): Boolean;
begin
hero.reputationInUnderworld.value := hero.reputationInUnderworld.value + effect.value;
hero.reputationInUnderworld.changed := hero.reputationInGroup.changed + effect.value;
if hero.reputationInUnderworld.value > 10 then
hero.reputationInUnderworld.value := 10;
if hero.reputationInUnderworld.value = 10 then
Exit(True);
Exit(True);
end;
function DownReputationInUniversity(var hero: THero; effect: TEffect): Boolean;
begin
hero.reputationInUnderworld.value := hero.reputationInUnderworld.value - effect.value;
hero.reputationInUnderworld.changed := hero.reputationInUnderworld.changed - effect.value;
if hero.reputationInUnderworld.value < 0 then
hero.reputationInUnderworld.value := 0;
if hero.reputationInUnderworld.value = 0 then
Exit(True);
Exit(True);
end;
function Affect(var hero: THero; var antiHero: THero; effect: TEffect): Boolean;
begin
if effect.name = 'damage' then
if not Damage(hero, effect) then
Exit(False);
if effect.name = 'damageAnti' then
if not Damage(antiHero, effect) then
Exit(False);
if effect.name = 'heal' then
if not Heal(hero, effect) then
Exit(False);
if effect.name = 'healAnti' then
if not Heal(antiHero, effect) then
Exit(False);
if effect.name = 'boost' then
if not Boost(hero, effect) then
Exit(False);
if effect.name = 'boostAnti' then
if not Boost(antiHero, effect) then
Exit(False);
if effect.name = 'decrease' then
if not Decrease(hero, effect) then
Exit(False);
if effect.name = 'decreaseAnti' then
if not Decrease(antiHero, effect) then
Exit(False);
if effect.name = 'takeToDrink' then
if not TakeToDrink(hero, effect) then
Exit(False);
if effect.name = 'takeToDrinkAnti' then
if not TakeToDrink(antiHero, effect) then
Exit(False);
if effect.name = 'sober' then
if not Sober(hero, effect) then
Exit(False);
if effect.name = 'soberAnti' then
if not Sober(antiHero, effect) then
Exit(False);
if effect.name = 'pumpUp' then
if not PumpUp(hero, effect) then
Exit(False);
if effect.name = 'pumpUpAnti' then
if not PumpUp(antiHero, effect) then
Exit(False);
if effect.name = 'pumpDown' then
if not PumpDown(hero, effect) then
Exit(False);
if effect.name = 'pumpDownAnti' then
if not PumpDown(antiHero, effect) then
Exit(False);
if effect.name = 'reduceIntelligence' then
if not ReduceIntelligence(hero, effect) then
Exit(False);
if effect.name = 'increaseIntelligence' then
if not IncreaseIntelligence(hero, effect) then
Exit(False);
if effect.name = 'luckly' then
if not Luckly(hero, effect) then
Exit(False);
if effect.name = 'luckless' then
if not Luckless(hero, effect) then
Exit(False);
if effect.name = 'happiness' then
if not Happiness(hero, effect) then
Exit(False);
if effect.name = 'happinessAnti' then
if not Happiness(antiHero, effect) then
Exit(False);
if effect.name = 'misfortune' then
if not Misfortune(hero, effect) then
Exit(False);
if effect.name = 'misfortuneAnti' then
if not Misfortune(antiHero, effect) then
Exit(False);
if effect.name = 'tuning' then
if not Tuning(hero, effect) then
Exit(False);
if effect.name = 'takeToVape' then
if not TakeToVape(hero, effect) then
Exit(False);
if effect.name = 'inLove' then
if not InLove(hero, effect) then
Exit(False);
if effect.name = 'lonely' then
if not Lonely(hero, effect) then
Exit(False);
if effect.name = 'upReputationInGroup' then
if not UpReputationInGroup(hero, effect) then
Exit(False);
if effect.name = 'upReputationInGroupAnti' then
if not UpReputationInGroup(antiHero, effect) then
Exit(False);
if effect.name = 'downReputationInGroup' then
if not DownReputationInGroup(hero, effect) then
Exit(False);
if effect.name = 'downReputationInGroupAnti' then
if not DownReputationInGroup(antiHero, effect) then
Exit(False);
if effect.name = 'upReputationInUniversity' then
if not UpReputationInUniversity(hero, effect) then
Exit(False);
if effect.name = 'upReputationInUniversityAnti' then
if not UpReputationInUniversity(antiHero, effect) then
Exit(False);
if effect.name = 'downReputationInUniversity' then
if not DownReputationInUniversity(hero, effect) then
Exit(False);
if effect.name = 'downReputationInUniversityAnti' then
if not DownReputationInUniversity(antiHero, effect) then
Exit(False);
Exit(True);
end;
function Affect(var hero: THero; var antiHero: THero; effects: TEffects): Boolean;
var
I: Integer;
begin
// TODO: console output
for I := 0 to Length(effects) - 1 do
if not Affect(hero, antiHero, effects[I]) then
Exit(False);
Exit(True);
end;
end.