@camium/

DarkProudSpool

Python

No description

fork
loading
Files
  • main.py
main.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
import random
import sys
import time
import pickle
high_scores = {  }
import collections
User1pass =False
User1name=False
User2pass =False
User2name=False
linenumber=0

global u1cc
global u2cc
u1cc=0
u2cc=0

blacklist=[  ]
play1list=[  ]
play2list=[  ]
c2_c=[  ]
c1_c=[  ]
c2_n=[  ]
c1_n=[  ]


deck_c=["Red ","Yellow ","Black "]
deck_n=["1","2","3","4","5","6","7","8","9","10"]


def u1w():
                Score = collections.namedtuple("Score", [User1name,u1cc,play1list])
                new_score = Score(User1name,u1cc,play1list)
                with open("highscores.pkl","rb") as in_:
                                high_scores = pickle.load(in_)
                                if new_scores.name not in high_scores:
                                                high_scores[new_scores.name] = new_scores.score
                                                with open("highscores.pkl","wb") as out:
                                                                                pickle.dump(high_scores, out)
                                                                                print("{{TITLE:^{PAGE_WIDTH}}}".format(PAGE_WIDTH=80).format(TITLE="HIGH SCORES"))
                                                                                print("-" * 80)
                                                for name,score in high_scores.items():
                                                                                    print("{{name:>{col_width}}} | {{score:<{col_width}}}".format(col_width=(80-3)//2).format(name=name, score=score))



def u2w():
                Score = collections.namedtuple("Score", [User2name,u2cc,play2list])
                new_score = Score(User2name,u2cc,play2list)
                with open("highscores.pkl","rb") as in_:
                                high_scores = pickle.load(in_)
                                if new_scores.name not in high_scores:
                                                high_scores[new_scores.name] = new_scores.score
                                                with open("highscores.pkl","wb") as out:
                                                                                pickle.dump(high_scores, out)
                                                                                print("{{TITLE:^{PAGE_WIDTH}}}".format(PAGE_WIDTH=80).format(TITLE="HIGH SCORES"))
                                                                                print("-" * 80)
                                                for name,score in high_scores.items():
                                                                                    print("{{name:>{col_width}}} | {{score:<{col_width}}}".format(col_width=(80-3)//2).format(name=name, score=score))


                    
def cs1():
                card_c=random.choice(deck_c)
                card_n=random.choice(deck_n)
                card= card_c + card_n
                if card in blacklist:
                    cs1()
                else:
                    print("Player 1, your card is...")
                    time.sleep(1)
                    print(card)
                    time.sleep(1)
                    c1_c.append(card_c)
                    c1_n.append(card_n)
                    blacklist.append(card)
                    play1list.append(card)
def cs2():
                card_c=random.choice(deck_c)
                card_n=random.choice(deck_n)
                card= card_c + card_n
                if card in blacklist:
                    cs2()
                else:
                    print("Player 2, your card is...")
                    time.sleep(1)
                    print(card)
                    c2_c.append(card_c)
                    c2_n.append(card_n)
                    blacklist.append(card)
                    play2list.append(card)


def rw():
    global u1cc
    global u2cc
    if "Yellow " in c1_c and "Black " in c2_c :
        time.sleep(1)
        print("Player 2 wins")
        time.sleep(1)
        u2cc=u2cc+2
    if "Yellow " in c2_c and "Black " in c1_c :
        time.sleep(1)
        print("Player 1 wins")
        time.sleep(1)
        u1cc=u1cc+2
    if "Red " in c1_c and "Yellow " in c2_c :
        time.sleep(2)
        print("Player 2 wins")
        time.sleep(1)
        u2cc=u2cc+2
    if "Red " in c2_c and "Yellow " in c1_c :
        time.sleep(1)
        print("Player 1 wins")
        time.sleep(1)
        u1cc=u1cc+2
    if "Black " in c1_c and "Red " in c2_c :
        time.sleep(1)
        print("Player 2 wins")
        u2cc=u2cc+2
    if "Black " in c2_c and "Red " in c1_c :
        time.sleep(2)
        print("Player 1 wins")
        time.sleep(1)
        u1cc=u1cc+2
    if c1_c == c2_c:
        if c1_n > c2_n:
            print("Player 1 wins!")
            time.sleep(1)
            u1cc=u1cc+2
        else:
            print("Player 2 wins!")
            time.sleep(1)
            u2cc=u2cc+2
    c1_c.pop()
    c2_c.pop()
    c1_n.pop()
    c2_n.pop()


  


                

rules=input(" \n Do you want the instructions? \n Please indicate using a 'Y' or a 'N' \n ")

if rules == "Y" or rules == "y":
                                print("""At the start of every round, both users will draw a card, they will then see who has won the round;

                                                Black beats Yellow,
                                                Yellow beats Red,
                                                Red beats Black,
                                                If the cards are the same colour, the card with the highest colour will win!
                                                
At the end of every round, the winner claims both cards that had been played that round.
At the end of the game (after all cards have been played) the play who has the most cards wins.\n """)
elif rules =="N" or rules =="n":
                                print("ok, Starting Game. \n")
else:
                                while rule_check==False:
                                  if rules == "n" or rules == "N" or rules == "y" or rules == "Y":
                                            rule_check = True
                                    else:
                                            rules=input("\n Please indicate using a 'Y' or a 'N' \n ")
                                            
                count=0
                for x in range(15):
                    count=count+1
                    print("\n Are you ready to start round ",count,"?")
                    confirm=input("\n Please indicate using a 'Y' or a 'N' \n ")
                    confirm_check=False
                    if confirm == "Y" or confirm== "y":
                                    cs1()
                                    cs2()
                                    rw()
                    else:
                                    while confirm_check== False:
                                        if confirm == "y" or confirm == "Y":
                                           confirm_check=True
                                        else:
                                           confirm=input("Are you ready to start round 1? \n Please indicate using a 'Y' or a 'N' \n ")
                if u1cc > u2cc:
                   print(username1," wins the game with",u1cc," amount of cards against", username2,"'s",u2cc," amount of cards!")
                   list1_check=False
                   list2_check=False
                   list1=input("Do you want to see what cards player 1 has?  ")
                   if list1 == "Y" or list== "y":
                                    print(play1list)
                   else:
                                    while list1_check== False:
                                        if list1 == "y" or list1 == "Y":
                                           list1_check=True
                                           print(play1list)
                                           u1w()
                                        elif list1 == "n" or list1 == "N":
                                                        print("Sure thing!")
                                                        list1_check=True
                                        else:
                                                        while list1_check == False:
                                                                        if list1 != "Y" or list1!= "y" or list1 != "n" or list1 != "N":
                                                                                           list1=input("Do you want to see what cards player 1 has?  \n")
                                                                        else:
                                                                                        if list1=="y" or list1=="Y":
                                                                                                        print(play1list)
                                                                                                        u1w()
                                                                                        list1_check=True
                else:
                    print(username2," wins the game with",u2cc," amount of cards against", username1,"'s",u1cc," amount of cards!")
                    list2=input("Do you want to see what cards player 2 has?  ")
                    if list2 == "Y" or list== "y":
                                    print(play2list)
                                    u2w()
                    else:
                                    while list2_check== False:
                                        if list2 == "y" or list2 == "Y":
                                           list2_check=True
                                           print(play2list)
                                           u2w()
                                        elif list2 == "n" or list2 == "N":
                                                        print("Sure thing!")
                                                        list2_check=True
                                        else:
                                                        while list2_check == False:
                                                                        if list2 != "Y" or list2!= "y" or list2 != "n" or list2 != "N":
                                                                                           list2=input("Do you want to see what cards player 2 has?  \n")
                                                                        else:
                                                                                        if list2=="y" or list2=="Y":
                                                                                                        print(play2list)
                                                                                                        u2w()
                                                                                        list2_check=True