-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcards.py
539 lines (473 loc) · 16 KB
/
cards.py
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
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
#######################################################################################################################
# Code created by karri104
#######################################################################################################################
from random import randint
# Responsible for distributing cnts to players depending on strikes and replicates.
def give_cnts(game, player, cnts):
if not player.check_strike():
player.cnts += cnts
if len(game.replicates) != 0:
for replicate in game.replicates:
if not replicate.check_strike():
replicate.cnts += cnts
else:
replicate.cnts += int(cnts / 2)
else:
player.cnts += int(cnts / 2)
if len(game.replicates) != 0:
for replicate in game.replicates:
if not replicate.check_strike():
replicate.cnts += int(cnts / 2)
else:
replicate.cnts += int(cnts / 4)
game.replicates = []
# Randomly creates sustainability loops depending on current discard_pile size.
# Can currently only create one sustainability loop even though in the actual game you can create multiple
def sustainability_loop(player, game_type):
# Generate random number to be used in calculating successes
num = randint(1, 10000)
# If no sustainability loop exists yet
if len(player.discard_pile) >= 3 and len(player.sustainability_loop) == 0:
# Percent thresholds for success depending on pile_size. 100 = 1%
# e.g. 3500 means 35% of the time making a sustainability loop succeeds when discard_pile
# has exactly 3 cards
chances = [3500, 5000, 7500, 8750, 9375, 10000]
# Creating a sustainability loop always works when there are at least 8 cards in discard_pile
if len(player.discard_pile) >= 8:
probability = 10000
else:
probability = chances[len(player.discard_pile) - 3]
# If loop generation is successful, move a random amount of cards from discard_pile to sustainability_loop
# Skip a turn otherwise.
if num <= probability:
player.loop = False
used_cards = randint(3, len(player.discard_pile))
for used_card in range(0, used_cards - 1):
card_index = randint(0, len(player.discard_pile) - 1)
card = player.discard_pile[card_index]
player.sustainability_loop.append(card)
del player.discard_pile[card_index]
else:
if game_type == "M":
print("Didn't succeed in making a sustainability loops.\nYour turn is skipped. Try again next turn")
player.loop = True
# If a sustainability loop exists already. Works with same logic as normal creation. Just has different values.
elif len(player.discard_pile) >= 1 and len(player.sustainability_loop) >= 3:
chances = [50000, 7500, 8750, 9375, 10000]
if len(player.discard_pile) >= 5:
probability = 10000
else:
probability = chances[len(player.discard_pile)]
if num <= probability:
player.loop = False
used_cards = randint(1, len(player.discard_pile))
for used_card in range(0, used_cards - 1):
card_index = randint(0, len(player.discard_pile) - 1)
card = player.discard_pile[card_index]
player.sustainability_loop.append(card)
del player.discard_pile[card_index]
else:
if game_type == "M":
print("Didn't succeed in making a sustainability loops.\nYour turn is skipped. Try again next turn")
player.loop = True
else:
if game_type == "M":
print("Didn't succeed in making a sustainability loops.\nYour turn is skipped. Try again next turn")
player.loop = True
#################################
# Following functions contain the logic for different cards.
# These do not reflect current game balancing changes.
# Correct values and general functionality is outlined in Canva.
#################################
def diabetes(game, player):
choice = input("A or B?\n")
if choice == "A":
num = randint(1, 20)
if num >= 14:
give_cnts(game, player, 3)
else:
if not player.check_immunity():
player.cnts -= 3
if choice == "B":
if not player.check_immunity():
player.cnts -= 1
def union_strike(game, player):
choice = input("A or B?\n")
if choice == "A":
if not player.check_immunity():
player.cnts -= 3
for contestant in game.players:
if contestant != player:
contestant.strike += 2
else:
num = randint(1, 20)
if num >= 10:
pass
else:
if len(game.replicates) != 0:
for replicate in game.replicates:
replicate.cnts += 1
game.replicates = []
for contestant in game.players:
if contestant != player:
if not contestant.check_strike():
contestant.cnts += 1
else:
contestant.cnts += int(1 / 2)
def carcinogenicity(game, player):
choice = input("A or B?\n")
if choice == "A":
for contestant in game.players:
contestant.cnts -= 1
if player.check_immunity():
# NOTE: DO NOT ADD REPLICANT OR STRIKE TO THIS AS IT'S NOT ACTUALLY GIVING
# CNTS RATHER JUST GIVING BACK THE CNT TAKEN AWAY IN ABOVE FOR LOOP
player.cnts += 1
else:
num = randint(1, 20)
if num >= 19:
for contestant in game.players:
if contestant != player:
contestant.cnts -= 2
else:
if not player.check_immunity():
player.cnts -= 2
def bond(game, player):
choice = input("A or B?\n")
if choice == "A":
num = randint(1, 20)
if num >= 14:
bests = [0, 0]
ids = [0, 0]
for i, contestant in enumerate(game.players):
if contestant != player:
for j, best in enumerate(bests):
if contestant.cnts > best:
bests[j] = contestant.cnts
ids[j] = i
game.players[ids[0]].cnts -= 2
game.players[ids[1]].cnts -= 2
else:
pass
def ipr(game, player):
choice = input("A or B?\n")
if choice == "A":
num = randint(1, 20)
if num >= 10:
best = 0
index = 0
for i, contestant in enumerate(game.players):
if contestant != player:
if contestant.cnts > best:
best = contestant.cnts
index = i
game.players[index].cnts -= 2
give_cnts(game, player, 2)
else:
if not player.check_immunity():
player.cnts -= 1
else:
if not player.check_immunity():
player.cnts -= 1
def regulations(game, player):
choice = input("A or B?\n")
if choice == "A":
num = randint(1, 20)
if num >= 14:
give_cnts(game, player, 2)
else:
if not player.check_immunity():
player.cnts -= 2
else:
if not player.check_immunity():
player.cnts -= 1
def sweat_analysis(game, player):
choice = input("A or B?\n")
num = randint(1, 20)
if choice == "A":
if num >= 8:
give_cnts(game, player, 1)
else:
pass
else:
if num >= 15:
give_cnts(game, player, 4)
else:
if not player.check_immunity():
player.cnts -= 3
def critical_flaw(player):
choice = input("A or B?\n")
if choice == "A":
player.immune = True
else:
player.replicate = True
def terrorism(game, player):
choice = input("A or B?\n")
if choice == "A":
num = randint(1, 20)
if num >= 4:
give_cnts(game, player, 3)
else:
if not player.check_immunity():
player.cnts -= 4
player.skips += 2
else:
give_cnts(game, player, 1)
def structural_health_monitoring(game, player):
choice = input("A or B?\n")
num = randint(1, 20)
if choice == "A":
if num >= 10:
give_cnts(game, player, 2)
else:
if not player.check_immunity():
player.cnts -= 2
else:
if num >= 10:
for competitor in game.players:
if competitor != player:
competitor.cnts -= 2
else:
if len(game.replicates) != 0:
for replicate in game.replicates:
replicate.cnts += 1
game.replicates = []
for contestant in game.players:
if contestant != player:
if not contestant.check_strike():
contestant.cnts += 1
else:
contestant.cnts += int(1 / 2)
def student_recruitment(game, player):
choice = input("A or B?\n")
num = randint(1, 20)
if choice == "A":
if num >= 11:
give_cnts(game, player, 3)
else:
if not player.check_immunity():
player.cnts -= 2
else:
if num >= 5:
give_cnts(game, player, 2)
else:
if not player.check_immunity():
player.cnts -= 4
def recycling(player):
if not player.check_immunity():
player.cnts -= 1
def material_choices(player):
give_cnts(game, player, 1)
def twitter(game, player):
choice = input("A or B?\n")
if choice == "A":
num = randint(1, 20)
if num >= 10:
give_cnts(game, player, 3)
else:
if not player.check_immunity():
player.cnts -= 3
else:
pass
def greenwashing(game, player):
choice = input("A or B?\n")
if choice == "A":
num = randint(1, 20)
if num >= 10:
give_cnts(game, player, 3)
else:
if not player.check_immunity():
player.cnts -= 3
else:
if not player.check_immunity():
player.cnts -= 1
def temperature(game, player):
choice = input("A or B?\n")
num = randint(1, 20)
if choice == "A":
if num >= 10:
give_cnts(game, player, 1)
else:
if not player.check_immunity():
player.cnts -= 1
else:
if num >= 10:
for competitor in game.players:
if competitor != player:
competitor.cnts -= 1
else:
if len(game.replicates) != 0:
for replicate in game.replicates:
if not replicate.check_strike():
replicate.cnts += 1
else:
replicate.cnts += int(1 / 2)
game.replicates = []
for contestant in game.players:
if contestant != player:
if not contestant.check_strike():
contestant.cnts += 1
else:
contestant.cnts += int(1 / 2)
def increased_production(game, player):
choice = input("A or B?\n")
if choice == "A":
num = randint(1, 20)
if num >= 10:
give_cnts(game, player, 3)
else:
if not player.check_immunity():
player.cnts -= 3
else:
give_cnts(game, player, 1)
def water_pollution(game, player):
choice = input("A or B?\n")
if choice == "A":
num = randint(1, 20)
if num >= 10:
give_cnts(game, player, 5)
else:
if not player.check_immunity():
player.cnts -= 5
else:
pass
def cleaning(game, player):
choice = input("A or B?\n")
num = randint(1, 20)
if choice == "A":
if num < 10:
if not player.check_immunity():
player.cnts -= 1
else:
if num >= 19:
give_cnts(game, player, 5)
else:
if not player.check_immunity():
player.cnts -= 3
def aerosols(game, player):
choice = input("A or B?\n")
if choice == "A":
num = randint(1, 20)
if num >= 4:
give_cnts(game, player, 1)
else:
if not player.check_immunity():
player.cnts -= 1
else:
if not player.check_immunity():
player.cnts -= 1
def enzymes(game, player):
choice = input("A or B?\n")
if choice == "A":
num = randint(1, 20)
if num == 20:
give_cnts(game, player, 6)
else:
if not player.check_immunity():
player.cnts -= 2
else:
if not player.check_immunity():
player.cnts -= 1
def cnt_spray(game, player):
choice = input("A or B?\n")
if choice == "A":
num = randint(1, 20)
if num >= 10:
give_cnts(game, player, 2)
else:
if not player.check_immunity():
player.cnts -= 3
else:
give_cnts(game, player, 1)
def cnt_length(game, player):
choice = input("A or B?\n")
if choice == "A":
give_cnts(game, player, 2)
if not player.immune:
player.skips += 1
else:
if not player.check_immunity():
player.cnts -= 1
def mycotoxins(game, player):
choice = input("A or B?\n")
if choice == "A":
num = randint(1, 20)
if num >= 14:
give_cnts(game, player, 3)
else:
if not player.check_immunity():
player.cnts -= 2
else:
give_cnts(game, player, 1)
def customization(game, player):
choice = input("A or B?\n")
if choice == "A":
give_cnts(game, player, 2)
if not player.immune:
player.skips += 1
else:
if not player.check_immunity():
player.cnts -= 1
def gender_equality(game, player):
choice = input("A or B?\n")
if choice == "A":
num = randint(1, 20)
if num >= 10:
give_cnts(game, player, 2)
else:
if not player.check_immunity():
player.cnts -= 2
if choice == "B":
give_cnts(game, player, 1)
def bulletproof_vests(game, player):
choice = input("A or B?\n")
if choice == "A":
pass
else:
num = randint(1, 20)
if 1 <= num <= 5:
if not player.check_immunity():
player.cnts -= 2
elif 6 <= num <= 10:
if not player.check_immunity():
player.cnts -= 1
elif 11 <= num <= 15:
give_cnts(game, player, 1)
else:
give_cnts(game, player, 2)
def fossil_fuels(game, player):
give_cnts(game, player, 1)
def production_location(game, player):
choice = input("A or B?\n")
num = randint(1, 20)
if choice == "A":
if num >= 10:
give_cnts(game, player, 2)
else:
if not player.check_immunity():
player.cnts -= 2
else:
if num >= 10:
give_cnts(game, player, 3)
else:
if not player.check_immunity():
player.cnts -= 4
def budget(game, player):
choice = input("A or B?\n")
num = randint(1, 20)
if choice == "A":
if len(game.replicates) != 0:
for replicate in game.replicates:
replicate.cnts += 1
game.replicates = []
for contestant in game.players:
if not contestant.check_strike():
contestant.cnts += 1
else:
contestant.cnts += int(1 / 2)
else:
if num >= 17:
give_cnts(game, player, 3)
else:
if not player.check_immunity():
player.cnts -= int(player.cnts / 3)