177 lines
5.0 KiB
Python
177 lines
5.0 KiB
Python
import json
|
|
import pytz
|
|
import time
|
|
from sdgb import sdgb_api
|
|
from datetime import datetime, timedelta
|
|
|
|
from settings import regionId, clientId, placeId
|
|
|
|
from logout import logout
|
|
from login import login
|
|
|
|
def find_map(mapId, user_map_data):
|
|
for single in user_map_data:
|
|
if single["mapId"] == mapId:
|
|
return single
|
|
else:
|
|
continue
|
|
|
|
def isNewMapList(mapId, user_map_data):
|
|
if ('{"mapId": ' + str(mapId)) in user_map_data:
|
|
return 0
|
|
else:
|
|
return 1
|
|
|
|
def item(item_data, user_character_list):
|
|
item_list = []
|
|
character_list = []
|
|
for single in item_data:
|
|
if single['kind'] == 9:
|
|
if ('{"characterId": ' + str(single['id'])) in user_character_list:
|
|
pass
|
|
else:
|
|
data = ({
|
|
"characterId":single['id'],
|
|
"level":1,
|
|
"awakening":0,
|
|
"useCount": 0
|
|
})
|
|
character_list.append(data)
|
|
else:
|
|
data = ({
|
|
"itemKind": single['kind'],
|
|
"itemId": single['id'],
|
|
"stock": 1,
|
|
"isValid": True
|
|
})
|
|
item_list.append(data)
|
|
return item_list, character_list, item_data[-1]['distance']
|
|
|
|
|
|
def bonus_list_gen(userId):
|
|
with open('login_bonus.json') as file:
|
|
cache = json.load(file)
|
|
bonus_data = []
|
|
for item in cache:
|
|
bonus_data.append(item['id'])
|
|
cache = []
|
|
data = json.dumps({
|
|
"userId": int(userId),
|
|
"nextIndex":0,
|
|
"maxCount":2000
|
|
})
|
|
user_bonus = json.loads(sdgb_api(data, "GetUserLoginBonusApi", userId))['userLoginBonusList']
|
|
for item in user_bonus:
|
|
cache.append(item['bonusId'])
|
|
bonus_list_unexist = list(set(bonus_data) - set(cache))
|
|
bonus_list = []
|
|
for item in user_bonus:
|
|
if item['isComplete'] == False:
|
|
if item['bonusId'] in [12, 29, 30, 38, 43, 604]:
|
|
data = ({
|
|
"bonusId": item['bonusId'],
|
|
"point": 4,
|
|
"isCurrent": item['isCurrent'],
|
|
"isComplete": False
|
|
})
|
|
else:
|
|
data = ({
|
|
"bonusId": item['bonusId'],
|
|
"point": 9,
|
|
"isCurrent": item['isCurrent'],
|
|
"isComplete": False
|
|
})
|
|
bonus_list.append(data)
|
|
elif item['bonusId'] == 999:
|
|
data = ({
|
|
"bonusId": 999,
|
|
"point": item['point'] // 10 * 10 + 9,
|
|
"isCurrent": item['isCurrent'],
|
|
"isComplete": False
|
|
})
|
|
bonus_list.append(data)
|
|
else:
|
|
pass
|
|
for item in bonus_list_unexist:
|
|
if item in [12, 29, 30, 38, 43, 604]:
|
|
data = ({
|
|
"bonusId": item,
|
|
"point": 4,
|
|
"isCurrent": False,
|
|
"isComplete": False
|
|
})
|
|
else:
|
|
data = ({
|
|
"bonusId": item,
|
|
"point": 9,
|
|
"isCurrent": False,
|
|
"isComplete": False
|
|
})
|
|
bonus_list.append(data)
|
|
return bonus_list
|
|
|
|
|
|
def map(userId):
|
|
data = json.dumps({
|
|
"userId": int(userId),
|
|
"nextIndex": 0,
|
|
"maxCount": 600
|
|
})
|
|
|
|
map_result = json.loads(sdgb_api(data, "GetUserMapApi", userId))
|
|
|
|
return map_result
|
|
|
|
def character(userId):
|
|
data = json.dumps({
|
|
"userId": int(userId),
|
|
"nextIndex":10000000000,
|
|
"maxCount":1000000000
|
|
})
|
|
|
|
character_result = json.loads(sdgb_api(data, "GetUserCharacterApi", userId))
|
|
|
|
return character_result
|
|
|
|
|
|
def userdata(userId):
|
|
data = json.dumps({
|
|
"userId": int(userId)
|
|
})
|
|
|
|
userdata_result = json.loads(sdgb_api(data, "GetUserDataApi", userId))
|
|
|
|
return userdata_result
|
|
|
|
|
|
def charge(userId):
|
|
data = json.dumps({
|
|
"userId": userId,
|
|
})
|
|
|
|
charge_result = json.loads(sdgb_api(data, "GetUserChargeApi", userId))
|
|
|
|
return charge_result
|
|
|
|
def get_ticket(userId):
|
|
data = json.dumps({
|
|
"userId": userId,
|
|
"userCharge": {
|
|
"chargeId": 6,
|
|
"stock": 1,
|
|
"purchaseDate": (datetime.now(pytz.timezone('Asia/Shanghai')) - timedelta(hours=1)).strftime("%Y-%m-%d %H:%M:%S.0"),
|
|
"validDate": (datetime.now(pytz.timezone('Asia/Shanghai')) - timedelta(hours=1) + timedelta(days=90)).replace(hour=4, minute=0, second=0).strftime("%Y-%m-%d %H:%M:%S")
|
|
},
|
|
"userChargelog": {
|
|
"chargeId": 6,
|
|
"price": 4,
|
|
"purchaseDate": (datetime.now(pytz.timezone('Asia/Shanghai')) - timedelta(hours=1)).strftime("%Y-%m-%d %H:%M:%S.0"),
|
|
"placeId": placeId,
|
|
"regionId": regionId,
|
|
"clientId": clientId
|
|
}
|
|
})
|
|
|
|
ticket_result = json.loads(sdgb_api(data, "UpsertUserChargelogApi", userId))
|
|
|
|
return ticket_result |