mirror of
https://github.com/drmext/MonkeyBusiness.git
synced 2025-02-15 18:12:32 +01:00
Implement DDR rivals
This commit is contained in:
parent
a91b442eb9
commit
9309edde2b
@ -29,9 +29,12 @@ def get_game_profile(cid, game_version):
|
|||||||
|
|
||||||
def get_common(ddr_id, game_version, idx):
|
def get_common(ddr_id, game_version, idx):
|
||||||
profile = get_db().table('ddr_profile').get(
|
profile = get_db().table('ddr_profile').get(
|
||||||
where('ddr_id') == ddr_id
|
where('ddr_id') == int(ddr_id)
|
||||||
)
|
)
|
||||||
|
if profile is not None:
|
||||||
return profile['version'].get(str(game_version), None)['common'].split(',')[idx]
|
return profile['version'].get(str(game_version), None)['common'].split(',')[idx]
|
||||||
|
else:
|
||||||
|
return 0
|
||||||
|
|
||||||
@router.post('/{gameinfo}/playerdata/usergamedata_advanced')
|
@router.post('/{gameinfo}/playerdata/usergamedata_advanced')
|
||||||
async def usergamedata_advanced(request: Request):
|
async def usergamedata_advanced(request: Request):
|
||||||
@ -62,6 +65,9 @@ async def usergamedata_advanced(request: Request):
|
|||||||
'guideline': "Center",
|
'guideline': "Center",
|
||||||
'priority': "Judgment",
|
'priority': "Judgment",
|
||||||
'timing_disp': "On",
|
'timing_disp': "On",
|
||||||
|
'rival_1_ddr_id': 0,
|
||||||
|
'rival_2_ddr_id': 0,
|
||||||
|
'rival_3_ddr_id': 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
db.table('ddr_profile').upsert(all_profiles_for_card, where('card') == refid)
|
db.table('ddr_profile').upsert(all_profiles_for_card, where('card') == refid)
|
||||||
@ -334,11 +340,16 @@ async def usergamedata_advanced(request: Request):
|
|||||||
ddrcode = int(request_info['root'][0].find('data/ddrcode').text)
|
ddrcode = int(request_info['root'][0].find('data/ddrcode').text)
|
||||||
pcbid = request_info['root'][0].find('data/pcbid').text
|
pcbid = request_info['root'][0].find('data/pcbid').text
|
||||||
|
|
||||||
world_record = []
|
|
||||||
for record in db.table('ddr_scores_wr'):
|
|
||||||
world_record.append(record)
|
|
||||||
|
|
||||||
if loadflag in (1, 2, 4):
|
if loadflag in (1, 2, 4):
|
||||||
|
scores = []
|
||||||
|
for s in db.table('ddr_scores_wr'):
|
||||||
|
scores.append(s)
|
||||||
|
|
||||||
|
elif loadflag in (8, 16, 32):
|
||||||
|
scores = []
|
||||||
|
for s in db.table('ddr_scores_best').search(where('ddr_id') == ddrcode):
|
||||||
|
scores.append(s)
|
||||||
|
|
||||||
response = E.response(
|
response = E.response(
|
||||||
E.playerdata(
|
E.playerdata(
|
||||||
E.result(0, __type="s32"),
|
E.result(0, __type="s32"),
|
||||||
@ -355,18 +366,11 @@ async def usergamedata_advanced(request: Request):
|
|||||||
E.code(s['ddr_id'], __type="s32"),
|
E.code(s['ddr_id'], __type="s32"),
|
||||||
E.score(s['score'], __type="s32"),
|
E.score(s['score'], __type="s32"),
|
||||||
E.ghostid(s['ghostid'], __type="s32"),
|
E.ghostid(s['ghostid'], __type="s32"),
|
||||||
)for s in world_record]
|
)for s in scores]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
else:
|
|
||||||
response = E.response(
|
|
||||||
E.playerdata(
|
|
||||||
E.result(0, __type="s32"),
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
if mode == 'ghostload':
|
if mode == 'ghostload':
|
||||||
ghostid = int(request_info['root'][0].find('data/ghostid').text)
|
ghostid = int(request_info['root'][0].find('data/ghostid').text)
|
||||||
record = db.table('ddr_scores').get(doc_id=ghostid)
|
record = db.table('ddr_scores').get(doc_id=ghostid)
|
||||||
@ -430,11 +434,19 @@ async def usergamedata_recv(request: Request):
|
|||||||
option[18] = timing_disp.index(profile['timing_disp'])
|
option[18] = timing_disp.index(profile['timing_disp'])
|
||||||
option_load = ",".join([str(i) for i in option])
|
option_load = ",".join([str(i) for i in option])
|
||||||
|
|
||||||
|
rival = profile['rival'].split(',')
|
||||||
|
rival_ids = [profile.get('rival_1_ddr_id', 0), profile.get('rival_2_ddr_id', 0), profile.get('rival_3_ddr_id', 0)]
|
||||||
|
for idx, r in enumerate(rival_ids, start=3):
|
||||||
|
if r != 0:
|
||||||
|
rival[idx] = idx - 2
|
||||||
|
rival[idx + 8] = get_common(r, game_version, 4)
|
||||||
|
rival_load = ",".join([str(i) for i in rival])
|
||||||
|
|
||||||
load = [
|
load = [
|
||||||
b64encode(str.encode(common_load.split('ffffffff,COMMON,')[1])).decode(),
|
b64encode(str.encode(common_load.split('ffffffff,COMMON,')[1])).decode(),
|
||||||
b64encode(str.encode(option_load.split('ffffffff,OPTION,')[1])).decode(),
|
b64encode(str.encode(option_load.split('ffffffff,OPTION,')[1])).decode(),
|
||||||
b64encode(str.encode(profile['last'].split('ffffffff,LAST,')[1])).decode(),
|
b64encode(str.encode(profile['last'].split('ffffffff,LAST,')[1])).decode(),
|
||||||
b64encode(str.encode(profile['rival'].split('ffffffff,RIVAL,')[1])).decode()
|
b64encode(str.encode(rival_load.split('ffffffff,RIVAL,')[1])).decode()
|
||||||
]
|
]
|
||||||
|
|
||||||
response = E.response(
|
response = E.response(
|
||||||
@ -473,6 +485,9 @@ async def usergamedata_send(request: Request):
|
|||||||
game_profile['option'] = b64decode(data.find('record')[1].text.split('<bin1')[0]).decode(encoding='utf-8', errors='ignore')
|
game_profile['option'] = b64decode(data.find('record')[1].text.split('<bin1')[0]).decode(encoding='utf-8', errors='ignore')
|
||||||
game_profile['last'] = b64decode(data.find('record')[2].text.split('<bin1')[0]).decode(encoding='utf-8', errors='ignore')
|
game_profile['last'] = b64decode(data.find('record')[2].text.split('<bin1')[0]).decode(encoding='utf-8', errors='ignore')
|
||||||
game_profile['rival'] = b64decode(data.find('record')[3].text.split('<bin1')[0]).decode(encoding='utf-8', errors='ignore')
|
game_profile['rival'] = b64decode(data.find('record')[3].text.split('<bin1')[0]).decode(encoding='utf-8', errors='ignore')
|
||||||
|
for r in ('rival_1_ddr_id', 'rival_2_ddr_id', 'rival_3_ddr_id'):
|
||||||
|
if r not in game_profile:
|
||||||
|
game_profile[r] = 0
|
||||||
|
|
||||||
profile['version'][str(game_version)] = game_profile
|
profile['version'][str(game_version)] = game_profile
|
||||||
|
|
||||||
|
@ -29,9 +29,12 @@ def get_game_profile(cid, game_version):
|
|||||||
|
|
||||||
def get_common(ddr_id, game_version, idx):
|
def get_common(ddr_id, game_version, idx):
|
||||||
profile = get_db().table('ddr_profile').get(
|
profile = get_db().table('ddr_profile').get(
|
||||||
where('ddr_id') == ddr_id
|
where('ddr_id') == int(ddr_id)
|
||||||
)
|
)
|
||||||
|
if profile is not None:
|
||||||
return profile['version'].get(str(game_version), None)['common'].split(',')[idx]
|
return profile['version'].get(str(game_version), None)['common'].split(',')[idx]
|
||||||
|
else:
|
||||||
|
return 0
|
||||||
|
|
||||||
@router.post('/{gameinfo}/playerdata_2/usergamedata_advanced')
|
@router.post('/{gameinfo}/playerdata_2/usergamedata_advanced')
|
||||||
async def usergamedata_advanced(request: Request):
|
async def usergamedata_advanced(request: Request):
|
||||||
@ -62,6 +65,9 @@ async def usergamedata_advanced(request: Request):
|
|||||||
'guideline': "Center",
|
'guideline': "Center",
|
||||||
'priority': "Judgment",
|
'priority': "Judgment",
|
||||||
'timing_disp': "On",
|
'timing_disp': "On",
|
||||||
|
'rival_1_ddr_id': 0,
|
||||||
|
'rival_2_ddr_id': 0,
|
||||||
|
'rival_3_ddr_id': 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
db.table('ddr_profile').upsert(all_profiles_for_card, where('card') == refid)
|
db.table('ddr_profile').upsert(all_profiles_for_card, where('card') == refid)
|
||||||
@ -334,14 +340,19 @@ async def usergamedata_advanced(request: Request):
|
|||||||
ddrcode = int(request_info['root'][0].find('data/ddrcode').text)
|
ddrcode = int(request_info['root'][0].find('data/ddrcode').text)
|
||||||
pcbid = request_info['root'][0].find('data/pcbid').text
|
pcbid = request_info['root'][0].find('data/pcbid').text
|
||||||
|
|
||||||
world_record = []
|
|
||||||
for record in db.table('ddr_scores_wr'):
|
|
||||||
world_record.append(record)
|
|
||||||
|
|
||||||
if loadflag in (1, 2, 4):
|
if loadflag in (1, 2, 4):
|
||||||
|
scores = []
|
||||||
|
for s in db.table('ddr_scores_wr'):
|
||||||
|
scores.append(s)
|
||||||
|
|
||||||
|
elif loadflag in (8, 16, 32):
|
||||||
|
scores = []
|
||||||
|
for s in db.table('ddr_scores_best').search(where('ddr_id') == ddrcode):
|
||||||
|
scores.append(s)
|
||||||
|
|
||||||
load = []
|
load = []
|
||||||
for r in world_record:
|
for r in scores:
|
||||||
record = [
|
s = [
|
||||||
r['mcode'],
|
r['mcode'],
|
||||||
r['difficulty'],
|
r['difficulty'],
|
||||||
r['rank'],
|
r['rank'],
|
||||||
@ -352,7 +363,7 @@ async def usergamedata_advanced(request: Request):
|
|||||||
r['score'],
|
r['score'],
|
||||||
r['ghostid'],
|
r['ghostid'],
|
||||||
]
|
]
|
||||||
load.append(b64encode(str.encode(','.join(str(x) for x in record))).decode())
|
load.append(b64encode(str.encode(','.join(str(x) for x in s))).decode())
|
||||||
|
|
||||||
response = E.response(
|
response = E.response(
|
||||||
E.playerdata_2(
|
E.playerdata_2(
|
||||||
@ -365,13 +376,6 @@ async def usergamedata_advanced(request: Request):
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
else:
|
|
||||||
response = E.response(
|
|
||||||
E.playerdata_2(
|
|
||||||
E.result(0, __type="s32"),
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
if mode == 'ghostload':
|
if mode == 'ghostload':
|
||||||
ghostid = int(request_info['root'][0].find('data/ghostid').text)
|
ghostid = int(request_info['root'][0].find('data/ghostid').text)
|
||||||
record = db.table('ddr_scores').get(doc_id=ghostid)
|
record = db.table('ddr_scores').get(doc_id=ghostid)
|
||||||
@ -435,11 +439,19 @@ async def usergamedata_recv(request: Request):
|
|||||||
option[18] = timing_disp.index(profile['timing_disp'])
|
option[18] = timing_disp.index(profile['timing_disp'])
|
||||||
option_load = ",".join([str(i) for i in option])
|
option_load = ",".join([str(i) for i in option])
|
||||||
|
|
||||||
|
rival = profile['rival'].split(',')
|
||||||
|
rival_ids = [profile.get('rival_1_ddr_id', 0), profile.get('rival_2_ddr_id', 0), profile.get('rival_3_ddr_id', 0)]
|
||||||
|
for idx, r in enumerate(rival_ids, start=3):
|
||||||
|
if r != 0:
|
||||||
|
rival[idx] = idx - 2
|
||||||
|
rival[idx + 8] = get_common(r, game_version, 4)
|
||||||
|
rival_load = ",".join([str(i) for i in rival])
|
||||||
|
|
||||||
load = [
|
load = [
|
||||||
b64encode(str.encode(common_load.split('ffffffff,COMMON,')[1])).decode(),
|
b64encode(str.encode(common_load.split('ffffffff,COMMON,')[1])).decode(),
|
||||||
b64encode(str.encode(option_load.split('ffffffff,OPTION,')[1])).decode(),
|
b64encode(str.encode(option_load.split('ffffffff,OPTION,')[1])).decode(),
|
||||||
b64encode(str.encode(profile['last'].split('ffffffff,LAST,')[1])).decode(),
|
b64encode(str.encode(profile['last'].split('ffffffff,LAST,')[1])).decode(),
|
||||||
b64encode(str.encode(profile['rival'].split('ffffffff,RIVAL,')[1])).decode()
|
b64encode(str.encode(rival_load.split('ffffffff,RIVAL,')[1])).decode()
|
||||||
]
|
]
|
||||||
|
|
||||||
response = E.response(
|
response = E.response(
|
||||||
@ -478,6 +490,9 @@ async def usergamedata_send(request: Request):
|
|||||||
game_profile['option'] = b64decode(data.find('record')[1].text.split('<bin1')[0]).decode(encoding='utf-8', errors='ignore')
|
game_profile['option'] = b64decode(data.find('record')[1].text.split('<bin1')[0]).decode(encoding='utf-8', errors='ignore')
|
||||||
game_profile['last'] = b64decode(data.find('record')[2].text.split('<bin1')[0]).decode(encoding='utf-8', errors='ignore')
|
game_profile['last'] = b64decode(data.find('record')[2].text.split('<bin1')[0]).decode(encoding='utf-8', errors='ignore')
|
||||||
game_profile['rival'] = b64decode(data.find('record')[3].text.split('<bin1')[0]).decode(encoding='utf-8', errors='ignore')
|
game_profile['rival'] = b64decode(data.find('record')[3].text.split('<bin1')[0]).decode(encoding='utf-8', errors='ignore')
|
||||||
|
for r in ('rival_1_ddr_id', 'rival_2_ddr_id', 'rival_3_ddr_id'):
|
||||||
|
if r not in game_profile:
|
||||||
|
game_profile[r] = 0
|
||||||
|
|
||||||
profile['version'][str(game_version)] = game_profile
|
profile['version'][str(game_version)] = game_profile
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user