forked from binux/libMA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
_libMA.py
202 lines (166 loc) · 5.43 KB
/
_libMA.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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from HttpUtils import App, buildOpener
class Device(object):
def __init__(self, token):
self.token = token
self.app = App()
def check_inspection(self):
data = self.app.check__inspection()
return data
def notification_postDevicetoken(self, loginId, password,
token=None, S="nosessionid"):
if token == None:
token = self.token
params = {
"S": S, # magic,don't touch
"login_id": loginId,
"password": password,
"token": token.encode("base64")
}
data = self.app.notification_post__devicetoken(params)
return data
def newUser(self, loginId, password):
# self.notification_postDevicetoken(loginId, password)
return User(self.app, loginId, password)
class User(object):
def __init__(self, app, loginId, password):
self.login_id = loginId
self.password = password
self.app = app
self.session = None
self.userId = None
self.menu = Menu(self.app)
self.roundtable = RoundTable(self.app)
self.exploration = Exploration(self.app)
def login(self):
params = {
"login_id": self.login_id,
"password": self.password,
}
data = self.app.login(params)
self.session = data.response.header.session_id
self.userId = data.response.body.login.user_id
self.cardList = data.response.header.your_data.owner_card_list.user_card
return data
def mainmenu(self):
data = self.app.mainmenu()
return data
def endTutorial(self):
params = {
"S": self.session,
"step": '8000',
}
data = self.app.tutorial_next(params)
return data
class RoundTable(object):
def __init__(self, app):
self.app = app
def edit(self):
params = {
"move": "1",
}
data = self.app.roundtable_edit(params)
return data
def save(self, cards, leader):
'7803549,15208758,17258743,empty,empty,empty,empty,empty,empty,empty,empty,empty'
'17258743'
cards = cards + ["empty"]*(12-len(cards))
params = {
"C": ",".join(cards),
"lr": leader,
}
data = self.app.cardselect_savedeckcard(params)
return data
class Menu(object):
def __init__(self, app):
self.app = app
def menulist(self):
data = self.app.menu_menulist()
return data
def fairyselect(self):
data = self.app.menu_fairyselect()
return data
def friendlist(self, move = "0"):
params = {
"move": "0",
}
data = self.app.menu_friendlist(params)
return data
def likeUser(self, users, dialog = "1"):
users = ",".join(map(lambda x:str(x),users))
params = {
"dialog": dialog,
"user_id": users,
}
data = self.app.friend_like__user(params)
return data
class Exploration(object):
def __init__(self, app):
self.app = app
def getAreaList(self):
data = self.app.exploration_area()
return data
def getFloorList(self, areaId):
params = {
"area_id": areaId,
}
data = self.app.exploration_floor(params)
return data
def getFloorStatus(self, areaID, floorId, check="1"):
params = {
"area_id": areaID,
"floor_id": floorId,
"check": check, # magic,don't touch
}
data = self.app.exploration_get__floor(params)
return data
def explore(self, areaId, floorId, autoBuild="1"):
params = {
"area_id": areaId,
"floor_id": floorId,
"auto_build": autoBuild,
}
data = self.app.exploration_explore(params)
return data
def fairyFloor(self, serialId, userId, check="1"):
params = {
"serial_id": serialId,
"user_id": userId,
"check": check, # magic,don't touch
}
data = self.app.exploration_fairy__floor(params)
return data
def fairybattle(self, serialId, userId):
params = {
"serial_id": serialId,
"user_id": userId,
}
data = self.app.exploration_fairybattle(params)
return data
def fairyhistory(self, serialId, userId):
params = {
"serial_id": serialId,
"user_id": userId,
}
data = self.app.exploration_fairyhistory(params)
return data
def fairyLose(self, serialId, userId):
params = {
"serial_id": serialId,
"user_id": userId,
}
data = self.app.exploration_fairy__lose(params)
return data
def faityWin(self, serialId, userId):
params = {
"serial_id": serialId,
"user_id": userId,
}
data = self.app.exploration_fairy__win(params)
return data
if __name__ == "__main__":
from config import deviceToken, loginId, password
device = Device(token=deviceToken)
user = device.newUser(loginId=loginId, password=password)
loginData = user.login()