-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCheck_Com3_Card_Played.py
More file actions
443 lines (326 loc) · 14.5 KB
/
Check_Com3_Card_Played.py
File metadata and controls
443 lines (326 loc) · 14.5 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
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
import Com3_Behavior as C3B
import time
from tkinter import messagebox
import Game_REWRITE
import random
import Check_Card_Played as CCP
import Deal_To_Com_Players as DTCP
import Check_Card_Drawn as CCD
import Check_Com2_Card_Played as CC2CP
# Function draws a card for com 3
def draw_card():
# Checks if DTCP.com3_card1 is equal to ""
if DTCP.com3_card1 == "":
# Checks if com 1, com 2 or the player has played a see the future
if CCP.first_card != " ":
# Adds the cards to com 2's hand
DTCP.com3_card1 = CCP.first_card
DTCP.com3_cards[0] = DTCP.com3_card1
CCD.check_card(DTCP.com3_card1)
CCP.first_card = " "
elif CCP.second_card != " ":
# Adds the cards to com 2's hand
DTCP.com3_card1 = CCP.first_card
DTCP.com3_cards[0] = DTCP.com3_card1
CCD.check_card(DTCP.com3_card1)
CCP.second_card = " "
elif CCP.third_card != " ":
# Adds the cards to com 2's hand
DTCP.com3_card1 = CCP.first_card
DTCP.com3_cards[0] = DTCP.com3_card1
CCD.check_card(DTCP.com3_card1)
CCP.third_card = " "
else:
# Draws card from draw pile then adds to com 2's hand
DTCP.com3_card1 = random.choice(Game_REWRITE.cards)
DTCP.com3_cards[0] = DTCP.com3_card1
CCD.check_card(DTCP.com3_card1)
# Checks if DTCP.com3_card2 is equal to ""
elif DTCP.com3_card2 == "":
# Checks if com 1, com 2 or the player has played a see the future
if CCP.first_card != " ":
# Adds the cards to com 2's hand
DTCP.com3_card2 = CCP.first_card
DTCP.com3_cards[1] = DTCP.com3_card2
CCD.check_card(DTCP.com3_card2)
CCP.first_card = " "
elif CCP.second_card != " ":
# Adds the cards to com 2's hand
DTCP.com3_card2 = CCP.first_card
DTCP.com3_cards[1] = DTCP.com3_card2
CCD.check_card(DTCP.com1_card2)
CCP.second_card = " "
elif CCP.third_card != " ":
# Adds the cards to com 2's hand
DTCP.com3_card2 = CCP.first_card
DTCP.com3_cards[1] = DTCP.com3_card2
CCD.check_card(DTCP.com1_card2)
CCP.third_card = " "
else:
# Draws card from draw pile then adds to com 2's hand
DTCP.com3_card2 = random.choice(Game_REWRITE.cards)
DTCP.com3_cards[1] = DTCP.com3_card2
CCD.check_card(DTCP.com3_card2)
# Checks if DTCP.com3_card3 is equal to ""
elif DTCP.com3_card3 == "":
# Checks if com 1, com 2 or the player has played a see the future
if CCP.first_card != " ":
# Adds the cards to com 2's hand
DTCP.com3_card1 = CCP.first_card
DTCP.com3_cards[0] = DTCP.com3_card1
CCD.check_card(DTCP.com1_card1)
CCP.first_card = " "
elif CCP.second_card != " ":
# Adds the cards to com 2's hand
DTCP.com3_card1 = CCP.first_card
DTCP.com3_cards[0] = DTCP.com3_card1
CCD.check_card(DTCP.com1_card1)
CCP.second_card = " "
elif CCP.third_card != " ":
# Adds the cards to com 2's hand
DTCP.com3_card1 = CCP.first_card
DTCP.com3_cards[0] = DTCP.com3_card1
CCD.check_card(DTCP.com1_card1)
CCP.third_card = " "
else:
# Draws card from draw pile then adds to com 2's hand
DTCP.com3_card1 = random.choice(Game_REWRITE.cards)
DTCP.com3_cards[0] = DTCP.com3_card1
CCD.check_card(DTCP.com3_card1)
# Checks if DTCP.com3_card4 is equal to ""
elif DTCP.com3_card4 == "":
# Checks if com 1, com 2 or the player has played a see the future
if CCP.first_card != " ":
# Adds the cards to com 2's hand
DTCP.com3_card4 = CCP.first_card
DTCP.com3_cards[3] = DTCP.com3_card4
CCD.check_card(DTCP.com1_card4)
CCP.first_card = " "
elif CCP.second_card != " ":
# Adds the cards to com 2's hand
DTCP.com3_card4 = CCP.first_card
DTCP.com3_cards[3] = DTCP.com3_card4
CCD.check_card(DTCP.com1_card4)
CCP.second_card = " "
elif CCP.third_card != " ":
# Adds the cards to com 2's hand
DTCP.com3_card4 = CCP.first_card
DTCP.com3_cards[3] = DTCP.com3_card4
CCD.check_card(DTCP.com1_card4)
CCP.third_card = " "
else:
# Draws card from draw pile then adds to com 2's hand
DTCP.com3_card4 = random.choice(Game_REWRITE.cards)
DTCP.com3_cards[3] = DTCP.com3_card4
CCD.check_card(DTCP.com3_card4)
# Checks if DTCP.com3_card5 is equal to ""
elif DTCP.com3_card5 == "":
# Checks if com 1, com 2 or the player has played a see the future
if CCP.first_card != " ":
# Adds the cards to com 2's hand
DTCP.com3_card5 = CCP.first_card
DTCP.com3_cards[4] = DTCP.com3_card5
CCD.check_card(DTCP.com1_card5)
CCP.first_card = " "
elif CCP.second_card != " ":
# Adds the cards to com 2's hand
DTCP.com3_card6 = CCP.first_card
DTCP.com3_cards[4] = DTCP.com3_card5
CCD.check_card(DTCP.com1_card4)
CCP.second_card = " "
elif CCP.third_card != " ":
# Adds the cards to com 2's hand
DTCP.com3_card5 = CCP.first_card
DTCP.com3_cards[4] = DTCP.com3_card5
CCD.check_card(DTCP.com1_card5)
CCP.third_card = " "
else:
# Draws card from draw pile then adds to com 2's hand
DTCP.com3_card5 = random.choice(Game_REWRITE.cards)
DTCP.com3_cards[4] = DTCP.com3_card5
CCD.check_card(DTCP.com3_card5)
# Checks if DTCP.com3_card6 is equal to ""
elif DTCP.com3_card6 == "":
# Checks if com 1, com 2 or the player has played a see the future
if CCP.first_card != " ":
# Adds the cards to com 2's hand
DTCP.com3_card6 = CCP.first_card
DTCP.com3_cards[5] = DTCP.com3_card6
CCD.check_card(DTCP.com1_card4)
CCP.first_card = " "
elif CCP.second_card != " ":
# Adds the cards to com 2's hand
DTCP.com3_card6 = CCP.first_card
DTCP.com3_cards[5] = DTCP.com3_card6
CCD.check_card(DTCP.com1_card4)
CCP.second_card = " "
elif CCP.third_card != " ":
# Adds the cards to com 2's hand
DTCP.com3_card6 = CCP.first_card
DTCP.com3_cards[5] = DTCP.com3_card6
CCD.check_card(DTCP.com1_card4)
CCP.third_card = " "
else:
# Draws card from draw pile then adds to com 2's hand
DTCP.com3_card6 = random.choice(Game_REWRITE.cards)
DTCP.com3_cards[5] = DTCP.com3_card6
CCD.check_card(DTCP.com3_card6)
# Checks if DTCP.com3_card7 is equal to ""
elif DTCP.com3_card7 == "":
# Checks if com 1, com 2 or the player has played a see the future
if CCP.first_card != " ":
# Adds the cards to com 2's hand
DTCP.com3_card7 = CCP.first_card
DTCP.com3_cards[6] = DTCP.com3_card7
CCD.check_card(DTCP.com1_card4)
CCP.first_card = " "
elif CCP.second_card != " ":
# Adds the cards to com 2's hand
DTCP.com3_card7 = CCP.first_card
DTCP.com3_cards[6] = DTCP.com3_card7
CCD.check_card(DTCP.com1_card4)
CCP.second_card = " "
elif CCP.third_card != " ":
# Adds the cards to com 2's hand
DTCP.com3_card7 = CCP.first_card
DTCP.com3_cards[6] = DTCP.com3_card7
CCD.check_card(DTCP.com1_card4)
CCP.third_card = " "
else:
# Draws card from draw pile then adds to com 2's hand
DTCP.com3_card7 = random.choice(Game_REWRITE.cards)
DTCP.com3_cards[6] = DTCP.com3_card7
CCD.check_card(DTCP.com3_card7)
if CC2CP.com2_played_attack == True:
messagebox.showinfo("Exploding Kittens Game", "It's com 3's turn again because com 2 has played an attack card")
CC2CP.com2_played_attack = False
C3B.decied_card_to_play()
else:
messagebox.showinfo("Exploding Kittens Game", "Com 3 has drawn, it's now your turn")
Game_REWRITE.com1_turn = False
Game_REWRITE.com2_turn = False
Game_REWRITE.com3_turn = False
Game_REWRITE.player_turn = True
# Add cards gotten from favor or cat cards to com 3's hand
def add_card_to_hand(card_to_add_to_hand):
# Adds the card to there 1st card slot
if DTCP.com3_card1 == "":
DTCP.com3_card1 = card_to_add_to_hand
DTCP.com3_cards[0] = DTCP.com3_card1
# Adds the card to there 2st card slot
elif DTCP.com3_card2 == "":
DTCP.com3_card2 = card_to_add_to_hand
DTCP.com3_cards[0] = DTCP.com3_card2
# Adds the card to there 3st card slot
elif DTCP.com3_card3 == "":
DTCP.com3_card3 = card_to_add_to_hand
DTCP.com3_cards[0] = DTCP.com3_card3
# Adds the card to there 4st card slot
elif DTCP.com3_card4 == "":
DTCP.com3_card4 = card_to_add_to_hand
DTCP.com3_cards[0] = DTCP.com3_card4
# Adds the card to there 5st card slot
elif DTCP.com3_card5 == "":
DTCP.com3_card5 = card_to_add_to_hand
DTCP.com3_cards[0] = DTCP.com3_card5
# Adds the card to there 6st card slot
elif DTCP.com3_card6 == "":
DTCP.com3_card6 = card_to_add_to_hand
DTCP.com3_cards[0] = DTCP.com3_card6
# Adds the card to there 7st card slot
elif DTCP.com3_card7 == "":
DTCP.com3_card7 = card_to_add_to_hand
DTCP.com3_cards[0] = DTCP.com3_card7
else:
print("An error has been encountered.")
# Steals card from player when com 3 plays a cat
def steal_cat_card(cat_card):
looped_on_card = ""
# Loops through com 3's hand for matching card
for cards_in_com3_hand in DTCP.com3_cards:
looped_on_card = cards_in_com3_hand
# Checks if the looped on card match the played card
if cards_in_com3_hand == cat_card:
print("Com 3 has played 2 " + cat_card + " cards")
messagebox.showinfo("Exploding Kittens Game", "Com 3 has played 2 matching " + cat_card + " cards")
steal_card = random.choice(Game_REWRITE.player_cards) # Gets a card from the player that com 3 is going to steal
while steal_card == "":
steal_card = random.choice(Game_REWRITE.player_cards) # Gets a card from the player that com 3 is going to steal
print(steal_card)
messagebox.showinfo("Exploding Kittens Game", "Com 3 has stolen your " + steal_card + " card")
add_card_to_hand(steal_card)
break
else:
print("Com 3 hasn't played 2 " + cat_card + "cards")
print("Looped card is " + looped_on_card)
if looped_on_card != cat_card:
messagebox.showerror("Exploding Kittens Game", 'Com 3 has not successfully played 2 cat cards')
def check_card_played():
# Checks if com 3 has played an skip card
if C3B.card_to_play == "skip":
time.sleep(1)
print("Com 3 has played a skip card")
messagebox.showinfo("Exploding Kittens Game", "Com 3 has skiped there turn, it's now currently your turn")
Game_REWRITE.discard_pile_text.set(C3B.card_to_play + "\n\n\n")
Game_REWRITE.com3_turn = False
Game_REWRITE.com3_turn = False
Game_REWRITE.com1_turn = False
Game_REWRITE.player_turn = True
# Checks if com 3 has played an attack card
elif C3B.card_to_play == "attack":
time.sleep(1)
print("Com 3 has played a attack card")
messagebox.showinfo("Exploding Kittens Game", "Com 3 has played an attack and make you have 2 turns")
Game_REWRITE.discard_pile_text.set(C3B.card_to_play + "\n\n\n")
Game_REWRITE.com3_turn = False
Game_REWRITE.com3_turn = False
Game_REWRITE.com1_turn = False
Game_REWRITE.player_turn = True
# Checks if com 3 has played an favor card
elif C3B.card_to_play == "favor":
time.sleep(1)
print("Com 3 has played a favor card")
messagebox.showinfo("Exploding Kittens Game", "Com 3 has played a favor card, it's now currently your turn.")
Game_REWRITE.discard_pile_text.set(C3B.card_to_play + "\n\n\n")
Game_REWRITE.com3_turn = False
Game_REWRITE.com3_turn = False
Game_REWRITE.com1_turn = False
Game_REWRITE.player_turn = True
# Checks if com 3 has played an shuffle card
elif C3B.card_to_play == "shuffle":
time.sleep(1)
print("Com 3 has played a shuffle card")
random.shuffle(Game_REWRITE.cards)
random.shuffle(Game_REWRITE.cards)
random.shuffle(Game_REWRITE.cards)
random.shuffle(Game_REWRITE.cards)
random.shuffle(Game_REWRITE.cards)
random.shuffle(Game_REWRITE.cards)
random.shuffle(Game_REWRITE.cards)
draw_card()
# Checks if com 3 has played an see the future card
elif C3B.card_to_play == "see the future":
time.sleep(1)
print("Com 3 has played a see the future card")
# Assigns the top 3 cards to a random choice, this will be used to be find the top 3 cards
CCP.first_card = random.choice(Game_REWRITE.cards)
CCP.second_card = random.choice(Game_REWRITE.cards)
CCP.third_card = random.choice(Game_REWRITE.cards)
# Prints the top 3 card assigned above
print("--------------")
print(CCP.first_card)
print(CCP.second_card)
print(CCP.third_card)
print("--------------")
messagebox.showinfo("Exploding Kittens Game", "Com 3 has played a see the future")
Game_REWRITE.discard_pile_text.set(C3B.card_to_play + "\n \n \n")
draw_card()
elif C3B.card_to_play == 'potato cat' or 'taco cat' or 'rainbow ralphing cat' or 'beard cat' or 'cattermellon':
time.sleep(1)
print("Com 3 has played a " + C3B.card_to_play + " card")
steal_cat_card(C3B.card_to_play)
draw_card()
Game_REWRITE.com1_turn = False
Game_REWRITE.com3_turn = False
Game_REWRITE.com3_turn = False
Game_REWRITE.player_turn = True