-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
175 lines (125 loc) · 4.38 KB
/
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
## start
import os , random
def wait():
t=input()
def preface_statements():
print("\n\n\n\t\t\t Welcome to Our Bollywood Film Name Guessing Game!!!")
print("\n\n\n")
def choice_to_play_again():
print("Wow Youve Done it")
print("\nTo play again, Type '1' ...\nTo exit , type anything else...")
r = input("Type : ")
return 1 if r==str(1) else 0
def exit_line():
print("Press Enter to Exit for Sure ...")
def game_over_line():
print("OOps ! You lost the game. \n")
print("Press Enter to Exit...")
def play():
fptr = open("data.txt", "r")
l=fptr.readlines()
i = random.randint(0,len(l)-1)
while(len(l[i]) <=2):
i = random.randint(0,len(l)-1)
film = list(map(str,l[i].split(',')))
film_name = film[0]
actor_name = film[1]
j = random.randint(0,len(film_name)-2)
ch = [film_name[0],film_name[j],film_name[-1],film_name[(len(film_name)-1)//2]]
life = 3 # life
while True:
os.system("clear")
print("\n\n")
print("\t\t\t\t\tActor is ",actor_name,"\n\n")
op = []
for i in range(len(film_name)):
if film_name[i]==' ':
op.append("_")
elif film_name[i] in ch:
op.append(film_name[i])
else:
op.append("-")
print("\t\t\t\t\t",*op,"\n\n\n")
if op.count('-') > 0:
c = input("\t\tGuess a Character: ")
if c.upper() in film_name:
if c.upper() in ch:
print("nice Guess ...\n But That character is Already Done....")
life -= 1
print("\nLife is Decreased to ",life," ... \n")
else:
ch.append(c.upper())
print("nice Guess ...")
else:
life -= 1
print("Wrong guess ... \nLife is Decreased to ",life," ... \n")
if life > 0:
print("Press Enter to continue ...")
print("................................................................................................................................")
wait()
else:
game_over_line()
wait()
print("................................................................................................................................")
break
else:
if choice_to_play_again():
os.system('cls')
play()
exit_line()
wait()
print("................................................................................................................................")
break
os.system("exit")
def movie_added():
print("\n\n\t\tThanks for Contributing this...\n\n")
t = input("\n\n\t\t Press Enter to continue...")
main()
def login():
from authentication import Users
print("For Logging in ;")
uname = input("Type your Username : ")
if not uname in Users.keys():
i=input("Username error...,Try again...")
login()
passwd = input("Type your password : ")
t=3
while(t and passwd!=Users[uname][0]): # and (uname not in Users.keys())
t-=1
print("Only {} tries left .".format(t))
uname = input("Type correct Username : ")
passwd = input("Type Correct password : ")
if t:
print("Welcome ...")
return [uname]+Users[uname]
else:
print("Come After some time ...")
return None
def add_movie():
fptr = open("data.txt", "a")
print("\n\n")
film_name = input("\t\tEnter The Name of Film : ")
actor_name = input("\t\tEnter The Name of Actor : ")
fptr.write((film_name+','+actor_name).upper() + "\n")
fptr.close()
movie_added()
def main():
os.system("clear")
preface_statements()
user = login()
if user is None:
print("Error login ...")
exit()
print("\t\t Choose from Following Statements : ")
print("\n\t\t1. Play the Game.")
print("\n\t\t2. Contribute a Movie Name.\n\n\t\t")
choice = int(input("Type a Nummber for Your Choice: "))
if choice==1:
play()
elif choice==2:
add_movie()
else:
print("Wrong Option")
main()
if __name__ == '__main__':
main()