-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbomb.py
More file actions
77 lines (62 loc) · 2.43 KB
/
bomb.py
File metadata and controls
77 lines (62 loc) · 2.43 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
import random
import os
location = os.path.abspath(os.path.join(os.path.dirname(__file__), 'bomb', 'player.txt'))
num = os.path.abspath(os.path.join(os.path.dirname(__file__), 'bomb', 'num.txt'))
def checkingame(qq):
with open(file=num, mode='r', encoding="utf-8") as data:
people = int(data.readline())
print(people)
with open(file=location, mode='r', encoding="utf-8") as data:
for a in range(people+1):
x = data.readline()
x = x.strip()
if(int(x) == qq):
print("已找到该QQ号正在参与游戏2")
return 1
return 0
def joingame(qq):
with open(file=num, mode='r', encoding="utf-8") as data:
people = int(data.readline())
with open(file=location, mode='r', encoding="utf-8") as data:
number = int(data.readline())
if number == 0:
number = random.randint(1,100000)
with open(file=location, mode='w', encoding="utf-8") as data:
data.write(str(number)+"\n")
data.close()
with open(file=location, mode='a', encoding="utf-8") as data:
data.write(str(qq)+"\n")
data.close()
with open(file=num, mode='w', encoding="utf-8") as data:
data.write(str(people+1))
def exitgame(qq):
with open(file=num, mode='r', encoding="utf-8") as data:
people = int(data.readline())
with open(file=location, mode='r', encoding="utf-8") as data:
lists = [0 for x in range(50)]
qqlo = 0
for a in range(people + 1):
x = data.readline()
x = x.strip()
lists[a] = int(x)
if(lists[a] == qq):
qqlo = a
a = a + 1
with open(file=num, mode='w', encoding="utf-8") as data:
data.write(str(people-1))
with open(file=location, mode='w', encoding="utf-8") as data:
if people - 1 == 0:
data.write("0\n")
data.close()
else:
for i in range (a):
if i != qqlo:
data.write(str(lists[i])+"\n")
data.close()
def gameend():
with open(file=num, mode='w', encoding="utf-8") as data:
data.write("0\n")
data.close()
with open(file=location, mode='w', encoding="utf-8") as data:
data.write("0\n")
data.close()