-
Notifications
You must be signed in to change notification settings - Fork 2
/
monsterzoo.py
1248 lines (1127 loc) · 42.6 KB
/
monsterzoo.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
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import random
class Card(object):
def __init__(self, name="", description="", card_type="", card_family="",cost=0, food=0, image=""):
self.name = name
self.description = description
self.card_type = card_type
self.card_family = card_family
self.cost = cost
self.food = food
def __str__(self):
return self.name
def zoo_effect(self, player):
pass
def move_selected_card_to_zoo(self, player):
card = self.get_selected_card()
# Special rule for Ripli Oogly
if card.name == "Ripli Oogly":
player.food += len(player.zoo.cards)
# Special rule for Flo Boogly's Zoo Effect
flo = False
for zoocard in player.zoo.cards:
if isinstance(zoocard, FloBoogly) == True:
flo = True
if flo == True:
player.deal(1)
player.hand.remove_card(card)
player.zoo.add_to_bottom(card)
return card
def discard(self, player):
hand = player.hand
discard = player.played
#discard = player.discard
try:
print "Trying to remove card %r from hand" % self
hand.remove_card(self)
discard.add_to_bottom(self)
print "Cards in player.played %r" % player.played.cards
except:
print "Card is not in hand"
def put_back(self, player):
hand = player.hand
deck = player.deck
try:
hand.remove_card(self)
deck.add_to_top(self)
except:
print "Card is not in hand"
def select_cards(self, num, player, played_card_index):
self.socket.log('Getting Selected Card from Client')
self.socket.log('Data passed to select_cards %r %r %r' % (num, player, played_card_index))
card_index = [played_card_index]
self.socket.emit('select_cards', player.player_id, card_index)
self.socket.log('Sent emit selected_cards')
def select_only_monsters(self, num, player, played_card_index):
self.socket.log('Getting Selected Card from Client')
self.socket.log('Data passed to select_cards %r %r %r' % (num, player, played_card_index))
card_index = [played_card_index]
# ADD FOOD TO CARD INDEX
for card in player.hand.cards:
if card.card_type == "Food":
card_index.append(player.hand.cards.index(card))
print "Card index for selected_cards %r" % card_index
self.socket.emit('select_cards', player.player_id, card_index)
self.socket.log('Sent emit selected_cards')
def select_cards_wild(self, num, player):
self.socket.emit('select_card_from_wild', player.player_id)
def get_other_player(self, player):
# this is buggy
player_index = self.socket.game.players.index(player)
if player_index == 0:
return self.socket.players[1]
elif player_index == 1:
return self.socket.players[0]
else:
print "Something went wrong when getting the other player index"
def find_location(self, player):
hand = player.hand
deck = player.deck
zoo = player.zoo
if self in hand:
location = hand.index(self)
print "Card found in Hand"
return 'hand', location
elif self in deck:
location = deck.index(self)
print "Card found in Deck"
return 'deck', location
elif self in zoo:
location = zoo.index(self)
print "Card found in Zoo"
return 'zoo', location
else:
print "Card not found"
return False
def select_card_from_zoo(self, player, played_card_index):
self.socket.emit('select_card_from_zoo', player.player_id, played_card_index)
def select_card_from_wild(self, player):
self.socket.emit('select_card_from_wild', player.player_id)
def get_selected_card(self):
selected_cards = self.socket.selected_cards
card = selected_cards.pop(0)
return card
def get_selected_card_wild(self):
selected_cards = self.socket.selected_cards_wild
card = selected_cards.pop(0)
return card
def peak_at_play_stack(self):
try:
card = self.socket.play_stack[-1]
print "Card at the top of the stack is %r" % card
return card
except:
print "Peaking at Play Stack: Play Stack is Empty"
return False
def is_in_stack(self):
try:
card = self.socket.play_stack.index(self)
print "Card %r is in stack at location" % card
return True
except:
print "Card is not in the play stack"
return False
class ZooglyZoo(Card):
def __init__(self):
self.name = "Zoogly Zoo"
self.description = "+1 Food for Each Zoogly in Your Zoo"
self.card_type = "Event"
self.card_family = "Event"
self.cost = 0
self.remodel = False
self.remodel_card = None
self.food = 1
self.image = "/static/images/Visitor.png"
def play(self, player):
for card in player.zoo.cards:
if card.card_family == "Zoogly":
player.food += 1
print "Oogly Zoo - Event"
class OoglyZoo(Card):
def __init__(self):
self.name = "Oogly Zoo"
self.description = "+1 Food for Each Oogly in Your Zoo"
self.card_type = "Event"
self.card_family = "Event"
self.cost = 0
self.remodel = False
self.remodel_card = None
self.food = 1
self.image = "/static/images/Visitor.png"
def play(self, player):
for card in player.zoo.cards:
if card.card_family == "Oogly":
player.food += 1
print "Oogly Zoo - Event"
class BooglyZoo(Card):
def __init__(self):
self.name = "Boogly Zoo"
self.description = "Draw a Card for Each Boogly in Your Zoo"
self.card_type = "Event"
self.card_family = "Event"
self.cost = 0
self.remodel = False
self.remodel_card = None
self.food = 1
self.image = "/static/images/Visitor.png"
def play(self, player):
for card in player.zoo.cards:
if card.card_family == "Boogly":
player.deal(1)
print "Boogly Zoo - Event"
class DirtySocks(Card):
def __init__(self):
self.name = "Dirty Socks"
self.description = "1 Food"
self.card_type = "Food"
self.card_family = "Food"
self.cost = 0
self.remodel = False
self.remodel_card = None
self.food = 1
self.image = "/static/images/Food.png"
def play(self, player):
self.discard(player)
player.food += self.food
print "Played Dirty Socks"
self.socket.render_game()
class Cookies(Card):
def __init__(self):
self.name = "Cookies"
self.description = "3 Food"
self.card_type = "Food"
self.card_family = "Food"
self.cost = 3
self.remodel = False
self.remodel_card = None
self.food = 3
self.image = "/static/images/Food.png"
def play(self, player):
self.discard(player)
player.food += self.food
print "Played Cookies"
self.socket.render_game()
class YouYoogly(Card):
def __init__(self):
self.name = "You Yoogly"
self.description = "Force a Monster to Remodel"
self.card_type = "Monster"
self.card_family = "Yoogly"
self.cost = 3
self.remodel = False
self.remodel_card = None
self.food = 3
self.image = "/static/images/Oogly.png"
def play(self, player):
if self.socket.selected_cards:
card = self.get_selected_card()
self.socket.selected_cards = []
card.remodel = True
card.remodel_card = self
player.hand.remove_card(self)
self.socket.log('Played You Yoogly')
self.socket.play_stack.remove(self)
self.socket.render_game()
else:
self.socket.log('Getting card from other player zoo')
self.socket.play_stack.append(self)
self.socket.emit('select_card_from_other_zoo', player.player_id, 1)
class FumbleeBoogly(Card):
def __init__(self):
self.name = "Fumblee Boogly"
self.description = "Draw 4 Cards. Put 2 Cards Back."
self.card_type = "Monster"
self.card_family = "Boogly"
self.cost = 4
self.remodel = False
self.remodel_card = None
self.food = 0
self.image = "/static/images/Boogly.png"
def play(self, player):
if len(self.socket.selected_cards) == 2:
card = self.socket.selected_cards[1]
card.put_back(player) # put the second card back on deck
self.discard(player) # discard the fumblee boogly card
self.socket.log('Played: Fumblee Boogly')
self.socket.render_game()
self.socket.selected_cards = [] # reset the selected cards
elif len(self.socket.selected_cards) == 1:
self.socket.log('Discard first card')
card = self.socket.selected_cards[0]
card.put_back(player) # put the first card back on deck
self.socket.render_game()
self.socket.log('Grab another card')
try:
fumblee = player.hand.cards.index(self)
except:
fumblee = None
print "Fumblee is not in Hand"
self.select_cards(1, player, fumblee)
else:
player.deal(4)
self.socket.render_game()
self.socket.log('Going to select_cards function')
fumblee = player.hand.cards.index(self)
self.select_cards(1, player, fumblee)
class BooBoogly(Card):
def __init__(self):
self.name = 'Boo Boogly'
self.description = 'Draw 2 Cards'
self.card_type = "Monster"
self.card_family = "Boogly"
self.cost = 3
self.remodel = False
self.remodel_card = None
self.image = "/static/images/Boogly.png"
def play(self, player):
self.discard(player)
player.deal(2) # draw 3 cards
print "Played Boo Boogly"
self.socket.render_game()
class MeeraBoogly(Card):
def __init__(self):
self.name = 'Meera Boogly'
self.description = 'Play a card from your Zoo'
self.card_type = "Monster"
self.card_family = "Boogly"
self.cost = 3
self.remodel = False
self.remodel_card = None
self.image = "/static/images/Boogly.png"
def play(self, player):
if self.socket.selected_cards and self.peak_at_play_stack() == self:
# Meera is the top card in the stack and a selected card exists
card = self.get_selected_card()
self.socket.selected_cards = [] # reset the selected cards
print "Meera Loop: Playing %r" % card
card.play(player)
self.play(player)
elif self.socket.selected_cards and self.peak_at_play_stack() != self:
# Meera is not the top card, but there is already a selected card.
# Pass it back to the top card in the stack.
card = self.peak_at_play_stack()
print "Meera Loop: Selected Card Exists & Meera is not top of stack"
print "Try playing the top card on stack"
card.play(player)
self.play(player)
elif self.peak_at_play_stack() == self:
print "Meera Loop: Meera is the top card in stack"
self.discard(player)
print "Played Meera Boogly"
self.socket.render_game()
self.socket.play_stack.remove(self)
elif self.is_in_stack():
print "Meera is in the stack, but not at the top"
pass
else:
meera = player.hand.cards.index(self)
self.select_card_from_zoo(player, meera)
self.socket.play_stack.append(self)
print "Meera: Play stack is %r" % self.socket.play_stack
class WhompoBoogly(Card):
def __init__(self):
self.name = 'Whompo Boogly'
self.description = '+2 Food.<br/><br/><span class="text-primary"><b>Zoo Effect:</b></span> Draw a card.</span>'
self.card_type = "Monster"
self.card_family = "Boogly"
self.cost = 4
self.remodel = False
self.remodel_card = None
self.food = 2
self.image = "/static/images/Boogly.png"
def play(self, player):
self.discard(player)
player.food += 2
print "Played Whompo Boogly"
self.socket.render_game()
def zoo_effect(self, player):
player.deal(1)
print "Zoo Effect Whompo Boogly"
self.socket.render_game()
class BoomerBoogly(Card):
def __init__(self):
self.name = 'Boomer Boogly'
self.description = 'Draw 2 Cards for Every Boogly in Your Zoo'
self.card_type = "Monster"
self.card_family = "Boogly"
self.cost = 6
self.remodel = False
self.remodel_card = None
self.image = "/static/images/Boogly.png"
def play(self, player):
self.discard(player)
count = 0
for card in player.zoo.cards:
if card.card_family == "Boogly":
count += 1
if count > 0:
count = count * 2
player.deal(count)
else:
print "No Boogly in Zoo"
print "Played Whompo Boogly"
self.socket.render_game()
class FloBoogly(Card):
def __init__(self):
self.name = 'Flo Boogly'
self.description = '<span class="text-primary"><b>Zoo Effect:</b></span> Draw a card each time you put a Monster into your Zoo</span>'
self.card_type = "Monster"
self.card_family = "Boogly"
self.cost = 3
self.remodel = False
self.remodel_card = None
self.image = "/static/images/Boogly.png"
def play(self, player):
self.discard(player)
print "Played Flo Boogly"
self.socket.render_game()
class KoppiBoogly(Card):
def __init__(self):
self.name = 'Koppi Boogly'
self.description = 'Draw 2 Cards if you have a Boogly in your Zoo.'
self.card_type = "Monster"
self.card_family = "Boogly"
self.cost = 2
self.remodel = False
self.remodel_card = None
self.image = "/static/images/Boogly.png"
def play(self, player):
self.discard(player)
count = 0
for card in player.zoo.cards:
if card.card_family == "Boogly":
count += 1
if count > 0:
print "Found a Boogly in Zoo. Dealing 3 Cards."
player.deal(2)
else:
print "No Boogly in Zoo"
print "Played Koppi Boogly"
self.socket.render_game()
class LanzoBoogly(Card):
def __init__(self):
self.name = 'Lanzo Boogly'
self.description = "Take a random card from other player\'s hand. Put it in your hand."
self.card_type = "Monster"
self.card_family = "Boogly"
self.cost = 5
self.remodel = False
self.remodel_card = None
self.image = "/static/images/Boogly.png"
def play(self, player):
opponent = self.get_other_player(player)
opponent_hand = opponent.hand.cards
card = random.choice(opponent_hand)
card.discard(opponent)
player.hand.add_to_bottom(card)
print "Played Lanzo Boogly"
self.discard(player)
self.socket.render_game()
class LurtiBoogly(Card):
def __init__(self):
self.name = 'Lurti Boogly'
self.description = "Put the top card from other player's deck into your hand."
self.card_type = "Monster"
self.card_family = "Boogly"
self.cost = 4
self.remodel = False
self.remodel_card = None
self.image = "/static/images/Boogly.png"
def play(self, player):
opponent = self.get_other_player(player)
print "This is the opponent returned by Lurti: %r" % opponent
card = opponent.deck.draw_card()
print "This is the card returned by Lurti: %r" % card
if card:
player.hand.add_to_bottom(card)
else:
print "No card to add. Lurti Boogly did nothing"
print "Played Lurti Boogly"
self.discard(player)
self.socket.render_game()
class PortaBoogly(Card):
def __init__(self):
self.name = 'Porta Boogly'
self.description = "Swap a Monster card from your hand with a card in The Wild. Put the Monster card in your Discard."
self.card_type = "Monster"
self.card_family = "Boogly"
self.cost = 3
self.remodel = False
self.remodel_card = None
self.image = "/static/images/Boogly.png"
def play(self, player):
self.socket.log('In the Play Loop for Porta Boogly')
# First select a card from hand
# Then select a card in the wild
# Then move the wild card into hand
if self.socket.selected_cards and self.socket.selected_cards_wild:
card = self.get_selected_card()
wildcard = self.get_selected_card_wild()
wild = self.socket.game.wild
# swap card in wild and hand
player.hand.remove_card(card)
wild.hand.add_to_bottom(card)
wild.hand.remove_card(wildcard)
player.discard.add_to_bottom(wildcard)
self.discard(player)
self.socket.log('Played: Porta Boogly')
self.socket.selected_cards = [] # reset the selected cards
self.socket.selected_cards_wild = [] # reset the selected cards from wild
self.socket.render_game()
self.socket.play_stack.remove(self)
elif self.socket.selected_cards and not self.socket.selected_cards_wild:
self.socket.log('Going to select_cards_wild function')
self.select_cards_wild(1, player)
else:
self.socket.log('Going to select_cards function')
try:
porta = player.hand.cards.index(self)
except:
porta = None
print "Porta is not in hand."
self.select_only_monsters(1, player, porta) # issue with meera boogly, if this is run then meera is played before card can be selected
self.socket.play_stack.append(self)
print "Porta: Play stack is %r" % self.socket.play_stack
class MunchOogly(Card):
def __init__(self):
self.name = 'Munch Oogly'
self.description = 'Gain 1 Food.<br/><br/><span class="text-primary"><b>Zoo Effect:</b></span> Gain 1 Food for every Oogly in your Zoo.'
self.card_type = "Monster"
self.card_family = "Oogly"
self.cost = 3
self.remodel = False
self.remodel_card = None
self.image = "/static/images/Oogly.png"
def zoo_effect(self, player):
count = 0
for card in player.zoo.cards:
if card.card_family == "Oogly":
count += 1
if count > 0:
player.food += count
else:
print "No Oogly in Zoo"
print "Zoo Effect Munch Oogly"
def play(self, player):
player.food += 1
self.discard(player)
self.socket.render_game()
class HuntoOogly(Card):
def __init__(self):
self.name = 'Hunto Oogly'
self.description = "Move a card from The Wild to the top of your deck."
self.card_type = "Monster"
self.card_family = "Oogly"
self.cost = 5
self.remodel = False
self.remodel_card = None
self.image = "/static/images/Oogly.png"
def play(self, player):
self.socket.log('In the Play Loop for Hunto Oogly')
# select a card in the wild
# move card to top of deck
if self.socket.selected_cards_wild:
wildcard = self.get_selected_card_wild()
wild = self.socket.game.wild
wild.hand.remove_card(wildcard)
player.deck.add_to_top(wildcard)
wild.deal(1)
self.discard(player)
self.socket.log('Played: Hunto Oogly')
self.socket.selected_cards_wild = [] # reset the selected cards from wild
self.socket.render_game()
self.socket.play_stack.remove(self)
else:
self.socket.log('Going to select_cards function')
try:
hunto = player.hand.cards.index(self)
except:
hunto = None
print "Hunto is not in hand."
self.select_cards_wild(1, player) # issue with meera boogly, if this is run then meera is played before card can be selected
self.socket.play_stack.append(self)
print "Hunto: Play stack is %r" % self.socket.play_stack
class ChunkyOogly(Card):
def __init__(self):
self.name = 'Chunky Oogly'
self.description = '+2 Food. Draw a Card.'
self.card_type = "Monster"
self.card_family = "Oogly"
self.cost = 3
self.remodel = False
self.remodel_card = None
self.image = "/static/images/Oogly.png"
def play(self, player):
player.deal(1) # draw 3 cards
player.food += 2
print "Played Chunky Oogly"
self.discard(player)
self.socket.render_game()
class YummliOogly(Card):
def __init__(self):
self.name = 'Yummli Oogly'
self.description = 'Double all Food gained so far this turn.'
self.card_type = "Monster"
self.card_family = "Oogly"
self.cost = 6
self.remodel = False
self.remodel_card = None
self.image = "/static/images/Oogly.png"
def play(self, player):
player.food = player.food * 2
print "Played Yummli Oogly"
self.discard(player)
self.socket.render_game()
class RinkaOogly(Card):
def __init__(self):
self.name = 'Rinka Oogly'
self.description = '+Food equal to the number of Monsters in your Zoo'
self.card_type = "Monster"
self.card_family = "Oogly"
self.cost = 2
self.remodel = False
self.remodel_card = None
self.image = "/static/images/Oogly.png"
def play(self, player):
player.food += len(player.zoo.cards)
print "Played Rinka Oogly"
self.discard(player)
self.socket.render_game()
class RipliOogly(Card):
def __init__(self):
self.name = 'Ripli Oogly'
self.description = 'Gain Food equal to the number of cards in your Zoo when this card enters your Zoo.'
self.card_type = "Monster"
self.card_family = "Oogly"
self.cost = 3
self.remodel = False
self.remodel_card = None
self.image = "/static/images/Oogly.png"
def play(self, player):
print "Played Ripli Oogly"
self.discard(player)
self.socket.render_game()
class ParksOogly(Card):
def __init__(self):
self.name = 'Parks Oogly'
self.description = '+2 Food. Monsters cost 1 less food to catch this turn.'
self.card_type = "Monster"
self.card_family = "Oogly"
self.cost = 5
self.remodel = False
self.remodel_card = None
self.image = "/static/images/Oogly.png"
def play(self, player):
player.food += 2
player.food_discount += 1
print "Played Parks Oogly"
self.discard(player)
self.socket.render_game()
class FifiOogly(Card):
def __init__(self):
self.name = 'Fifi Oogly'
self.description = '+1 Food. Monsters cost 1 less food to catch this turn.<br/><br/><span class="text-primary"><b>Zoo Effect:</b></span> Monsters cost 1 less to catch this turn.</span>'
self.card_type = "Monster"
self.card_family = "Oogly"
self.cost = 5
self.remodel = False
self.remodel_card = None
self.image = "/static/images/Oogly.png"
def play(self, player):
player.food += 1
player.food_discount += 1
print "Played Fifi Oogly"
self.discard(player)
self.socket.render_game()
def zoo_effect(self, player):
player.food_discount += 1
class OoglyBoogly(Card):
def __init__(self):
self.name = 'Oogly Boogly'
self.description = 'Draw 3 Cards'
self.card_type = "Monster"
self.card_family = "Boogly"
self.cost = 3
self.remodel = False
self.remodel_card = None
self.image = "/static/images/Oogly.png"
def play(self, player):
player.deal(3) # draw 3 cards
print "Played Oogly Boogly"
self.discard(player)
self.socket.render_game()
class JusteeZoogly(Card):
def __init__(self):
self.name = 'Justee Zoogly'
self.description = 'Remove a card in your hand from the game. Draw 3 cards.'
self.card_type = "Monster"
self.card_family = "Zoogly"
self.cost = 2
self.remodel = False
self.remodel_card = None
self.image = "/static/images/Zoogly.png"
def play(self, player):
self.socket.log('In the Play Loop for Justee Zoogly')
if self.socket.selected_cards:
card = self.get_selected_card()
player.hand.remove_card(card)
player.deal(3)
self.discard(player)
self.socket.log('Played: Justee Zoogly')
self.socket.selected_cards = [] # reset the selected cards
self.socket.render_game()
self.socket.play_stack.remove(self)
else:
self.socket.log('Going to select_cards function')
try:
justee = player.hand.cards.index(self)
except:
justee = None
print "Justee is not in hand."
self.select_cards(1, player, justee) # issue with meera boogly, if this is run then meera is played before card can be selected
self.socket.play_stack.append(self)
print "Justee: Play stack is %r" % self.socket.play_stack
class OhnoZoogly(Card):
def __init__(self):
self.name = 'Ohno Zoogly'
self.description = 'Swap this card with a card in your Zoo.'
self.card_type = "Monster"
self.card_family = "Zoogly"
self.cost = 6
self.remodel = False
self.remodel_card = None
self.image = "/static/images/Zoogly.png"
def play(self, player):
if self.socket.selected_cards:
card = self.get_selected_card()
self.socket.selected_cards = [] # reset the selected cards
player.hand.remove_card(self)
player.zoo.remove_card(card)
player.hand.add_to_bottom(card)
player.zoo.add_to_bottom(self)
self.socket.log('Played Ohno Zoogly')
self.socket.render_game()
else:
ohno = player.hand.cards.index(self)
self.select_card_from_zoo(player, ohno)
class ViktorZoogly(Card):
def __init__(self):
self.name = 'Viktor Zoogly'
self.description = 'Gain food equal to the number of monsters in an opponents Zoo.'
self.card_type = "Monster"
self.card_family = "Zoogly"
self.cost = 2
self.remodel = False
self.remodel_card = None
self.image = "/static/images/Zoogly.png"
self.socket = '' # this will hold the socketio object
def play(self, player):
opponent = self.get_other_player(player)
player.food += len(opponent.zoo.cards)
self.discard(player)
self.socket.log('Played Viktor Zoogly')
self.socket.render_game()
class BossiZoogly(Card):
def __init__(self):
self.name = 'Bossi Zoogly'
self.description = '+2 Food. Force other player to discard a Monster from their Zoo.'
self.card_type = "Monster"
self.card_family = "Zoogly"
self.cost = 4
self.remodel = False
self.remodel_card = None
self.image = "/static/images/Zoogly.png"
self.socket = '' # this will hold the socketio object
def play(self, player):
if self.socket.selected_cards:
card = self.get_selected_card()
self.socket.selected_cards = []
opponent = self.get_other_player(player)
opponent.zoo.remove_card(card)
opponent.discard.add_to_bottom(card)
self.discard(player)
player.food += 2
self.socket.log('Played Bossi Zoogly')
self.socket.play_stack.remove(self)
self.socket.render_game()
else:
self.socket.log('Getting card from other player zoo')
self.socket.play_stack.append(self)
self.socket.emit('select_card_from_other_zoo', player.player_id, 1)
class SluggoZoogly(Card):
def __init__(self):
self.name = 'Sluggo Zoogly'
self.description = 'Move a Monster in opponents Zoo back to opponents hand'
self.card_type = "Monster"
self.card_family = "Zoogly"
self.cost = 3
self.remodel = False
self.remodel_card = None
self.image = "/static/images/Zoogly.png"
self.socket = '' # this will hold the socketio object
def play(self, player):
if self.socket.selected_cards:
card = self.get_selected_card()
self.socket.selected_cards = []
opponent = self.get_other_player(player)
opponent.zoo.remove_card(card)
opponent.hand.add_to_bottom(card)
self.discard(player)
self.socket.log('Played Sluggo Zoogly')
self.socket.play_stack.remove(self)
self.socket.render_game()
else:
self.socket.log('Getting card from other player zoo')
self.socket.play_stack.append(self)
self.socket.emit('select_card_from_other_zoo', player.player_id, 1)
class ZookeeZoogly(Card):
def __init__(self):
self.name = 'Zookee Zoogly'
self.description = 'Move a Monster to your Zoo'
self.card_type = "Monster"
self.card_family = "Zoogly"
self.cost = 3
self.remodel = False
self.remodel_card = None
self.image = "/static/images/Zoogly.png"
self.socket = '' # this will hold the socketio object
def play(self, player):
self.socket.log('In the Play Loop for Zookee Zoogly')
if self.socket.selected_cards:
self.move_selected_card_to_zoo(player)
#card = self.get_selected_card()
#player.hand.remove_card(card)
#player.zoo.add_to_bottom(card)
self.discard(player)
self.socket.log('Played: Zookee Zoogly')
self.socket.selected_cards = [] # reset the selected cards
self.socket.render_game()
self.socket.play_stack.remove(self)
else:
self.socket.log('Going to select_cards function')
try:
zookee = player.hand.cards.index(self)
except:
zookee = None
print "Zookee is not in hand."
self.select_only_monsters(1, player, zookee) # issue with meera boogly, if this is run then meera is played before card can be selected
self.socket.play_stack.append(self)
print "Zookee: Play stack is %r" % self.socket.play_stack
class ZoomiZoogly(Card):
def __init__(self):
self.name = 'Zoomi Zoogly'
self.description = 'Move a Monster to your Zoo. If you put an Oogly into your Zoo, draw 2 cards.'
self.card_type = "Monster"
self.card_family = "Zoogly"
self.cost = 5
self.remodel = False
self.remodel_card = None
self.image = "/static/images/Zoogly.png"
self.socket = '' # this will hold the socketio object
def play(self, player):
self.socket.log('In the Play Loop for Zoomi Zoogly')
if self.socket.selected_cards:
card = self.move_selected_card_to_zoo(player)
if card.card_family == "Oogly":
player.deal(2)
self.discard(player)
self.socket.log('Played: Zoomi Zoogly')
self.socket.selected_cards = [] # reset the selected cards
self.socket.render_game()
self.socket.play_stack.remove(self)
else:
self.socket.log('Going to select_cards function')
try:
zoomi = player.hand.cards.index(self)
except:
zoomi = None
print "Zoomi is not in hand."
self.select_only_monsters(1, player, zoomi) # issue with meera boogly, if this is run then meera is played before card can be selected
self.socket.play_stack.append(self)
print "Zoomi: Play stack is %r" % self.socket.play_stack
class Deck(object):
def __init__(self):
self.cards = []
def shuffle_cards(self):
random.shuffle(self.cards)
def show_cards(self):
for card in self.cards:
print card
def draw_card(self):
try:
card = self.cards.pop(0)
return card
except:
print "No more cards in deck"
return None
def is_empty(self):
return (len(self.cards) == 0)
def add_to_top(self, card):
self.cards.insert(0, card)
def add_to_bottom(self, card):
self.cards.append(card)
def remove_card(self, card):
self.cards.remove(card)
def deal(self, hand, num):
for i in range(num):
if self.is_empty():
break # need to add back discard and shuffle
card = self.draw_card()
hand.add_to_top(card)
class Hand(Deck):
def __init__(self, name=""):
self.cards = []
self.name = name
def play(self, card, players):
card.play(players)
class Player(object):
def __init__(self, player_id=""):
starter_deck = [ViktorZoogly(), LanzoBoogly(), SluggoZoogly(), ZookeeZoogly(), ZookeeZoogly(), ZookeeZoogly(), ZookeeZoogly(), DirtySocks(), DirtySocks(), DirtySocks(), DirtySocks(), DirtySocks(), DirtySocks()]
self.deck = Deck()
self.deck.cards = list(starter_deck)
self.hand = Hand()
self.discard = Deck()
self.played = Deck()
self.zoo = Hand()
self.food = 0
self.food_discount = 0
self.score = 0
self.player_id = player_id
self.turn = False
self.socket_id = None
def deal(self, num):
cards = []
for i in range(num):
if self.deck.is_empty():
print "Deck is EMPTY"
print "============="
print "Shuffling in Discard"
self.deck.cards = self.deck.cards + self.discard.cards
self.discard.cards = []