-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgame1.py
More file actions
76 lines (72 loc) · 3.5 KB
/
game1.py
File metadata and controls
76 lines (72 loc) · 3.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
import sendmsg
import guessnum
import change
import getdata
def game1(message,urlsss,group,qq):
location = urlsss
answer = [0 for x in range(0,5)]
key = [0 for x in range(0,5)]
history = ["" for x in range(0,10)]
hisans = ["" for x in range(0,10)]
samecheck = 0
numlocate = 0
numsame = 0
for x in range (4):
answer[x] = int(message[x])
for x in range (0,4):
for y in range (x+1,4):
print(answer[x],answer[y])
if answer[x] == answer[y]:
samecheck = samecheck + 1
if samecheck != 0:
sendmsg.send_msg({'msg_type':'group','number':group,'msg':'[CQ:at,qq='+str(qq)+']不可以输入相同的数字啦!这次就不算你机会吧orz'})
else :
with open(file=location, mode='r', encoding="utf-8") as data:
for x in range (4):
key[x] = int(data.readline())
if key[x] == answer[x]:
numlocate = numlocate + 1
chance = int(data.readline())
if numlocate != 4:
for x in range (8-chance):
history[x] = history[x] + data.readline()
hisans[x] = hisans[x] + data.readline()
if numlocate == 4:
money = float(getdata.getsd(qq,5))
add = float(chance) * 5
money = money + add
sendmsg.send_msg({'msg_type':'group','number':group,'msg':'[CQ:at,qq='+str(qq)+']恭喜你猜中啦!你tdllwsl!想玩还可以再找芙兰玩哦~(已获得积分' + str(add) + ")"})
change.changes(qq,money,5)
guessnum.gameend(qq)
else:
if chance == 1 :
output = '[CQ:at,qq='+str(qq)+']呜呜呜好可惜,机会用完啦!正确的答案是'
for x in range (4):
output = output + str(key[x])
output = output + ',下次再来试试吧!XD'
sendmsg.send_msg({'msg_type':'group','number':group,'msg':output})
guessnum.gameend(qq)
else:
for x in range (4):
for y in range (4):
if key[x] == answer[y]:
numsame = numsame + 1
numsame = numsame - numlocate
chance = chance - 1
output = '[CQ:at,qq='+str(qq)+']\n你本次的猜测的结果为:'+ str(numlocate) + "A"+ str(numsame) + "B。\n你还剩下" + str(chance) + "次机会,再试试看喵~\n历史猜测记录:"
for y in range (8 - chance - 1):
history[y] = history[y].strip()
hisans[y] = hisans[y].strip()
output = output + "\n" + history[y] + " " + hisans[y]
output = output + "\n" + message + " " + str(numlocate) + "A"+ str(numsame) + "B"
sendmsg.send_msg({'msg_type':'group','number':group,'msg': output})
with open(file=location, mode='w', encoding="utf-8") as data:
for x in range (4):
data.write(str(key[x])+"\n")
data.write(str(chance)+"\n")
for x in range ( 8 - chance - 1):
data.write(str(history[x])+"\n")
data.write(str(hisans[x])+"\n")
data.write(message + "\n")
data.write(str(numlocate) + "A"+ str(numsame) + "B\n")
data.close