forked from ebith/Switch-Fightstick
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreplay.py
121 lines (116 loc) · 3.63 KB
/
replay.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
import serial
import time
from time import sleep
import re
from tqdm import tqdm
# from controller_util import *
f = open("lvl_up.txt", "r")
"""
升级
初始条件:
精灵中心PC前
自动同步时间 关闭
放一批精灵出去打工
菜单图标放在地图上
"""
lines = f.readlines()
operations_list = []
f.close()
for line in lines:
cmd = line[line.find(":") + 1 : line.find(",")]
# print(cmd)
duration = float(line[line.find(":", line.find("duration")) + 1 : -1])
operations_list.append({"cmd": cmd, "duration": duration})
# f = open('next_box.txt', 'r')
# lines = f.readlines()
# change_box_list = []
# f.close()
# for line in lines:
# cmd = line[line.find(':') + 1:line.find(',')]
# # print(cmd)
# duration = float(line[line.find(':', line.find('duration')) + 1:-1])
# change_box_list.append({'cmd': cmd, 'duration': duration})
ser = serial.Serial("COM3", 38400)
# tmplist = []
# #free pokemon
# for j in tqdm(range(5)):
# for i in range(5):
# if i == 4:
# tmp_list = operations_list[:-1]
# else:
# tmp_list = operations_list
# for operation in tmp_list:
# msg = operation['cmd']
# ser.write(f'{msg}\r\n'.encode('utf-8'))
# sleep(operation['duration'])
# for operation in change_box_list:
# msg = operation['cmd']
# ser.write(f'{msg}\r\n'.encode('utf-8'))
# sleep(operation['duration'])
# lvl up
try:
msg = "0 4 8 128 128 128 128"
ser.write(f"{msg}\r\n".encode("utf-8"))
sleep(0.1)
msg = "0 0 8 128 128 128 128"
ser.write(f"{msg}\r\n".encode("utf-8"))
while True:
for operation in operations_list:
msg = operation["cmd"]
ser.write(f"{msg}\r\n".encode("utf-8"))
sleep(operation["duration"])
except KeyboardInterrupt:
print("exiting")
# msg = "0 8 8 128 128 128 128"
# ser.write(f'{msg}\r\n'.encode('utf-8'))
# sleep(0.12102365493774414)
# msg = "0 0 8 128 128 128 128"
# ser.write(f'{msg}\r\n'.encode('utf-8'))
# sleep(0.7474985122680664)
# msg = "0 4 8 128 128 128 128"
# ser.write(f'{msg}\r\n'.encode('utf-8'))
# sleep(0.10030198097229004)
# msg = "0 0 8 128 128 128 128"
# ser.write(f'{msg}\r\n'.encode('utf-8'))
# sleep(2.2908709049224854)
# msg = "0 0 8 128 1 128 128"
# ser.write(f'{msg}\r\n'.encode('utf-8'))
# sleep(0.23099207878112793)
# msg = "0 0 8 128 128 128 128"
# ser.write(f'{msg}\r\n'.encode('utf-8'))
# sleep(0.27367639541625977)
# msg = "0 4 8 128 128 128 128"
# ser.write(f'{msg}\r\n'.encode('utf-8'))
# sleep(0.11481761932373047)
# msg = "0 0 8 128 128 128 128"
# ser.write(f'{msg}\r\n'.encode('utf-8'))
# sleep(0.5575323104858398)
# msg = "0 4 8 128 128 128 128"
# ser.write(f'{msg}\r\n'.encode('utf-8'))
# sleep(0.10053300857543945)
# msg = "0 0 8 128 128 128 128"
# ser.write(f'{msg}\r\n'.encode('utf-8'))
# sleep(11.26662540435791)
# msg = "1 0 8 128 128 128 128"
# ser.write(f'{msg}\r\n'.encode('utf-8'))
# sleep(0.11900138854980469)
# msg = "0 0 8 128 128 128 128"
# ser.write(f'{msg}\r\n'.encode('utf-8'))
# sleep(0.442216157913208)
# msg = "0 0 8 128 1 128 128"
# ser.write(f'{msg}\r\n'.encode('utf-8'))
# sleep(1.8006880283355713)
# msg = "0 0 8 128 128 128 128"
# ser.write(f'{msg}\r\n'.encode('utf-8'))
# sleep(1.3317699432373047)
# msg = "0 0 8 128 1 128 128"
# ser.write(f'{msg}\r\n'.encode('utf-8'))
# sleep(0.940157413482666)
# msg = "0 0 8 128 128 128 128"
# ser.write(f'{msg}\r\n'.encode('utf-8'))
# sleep(0.23840808868408203)
# msg = "0 0 8 1 128 128 128"
# ser.write(f'{msg}\r\n'.encode('utf-8'))
# sleep(0.3774278163909912)
# msg = "0 0 8 128 128 128 128"
# ser.write(f'{msg}\r\n'.encode('utf-8'))