1
0
mirror of synced 2024-11-24 06:20:12 +01:00

Older IIDX routing refactor. (#51)

* Older IIDX routing refactor.
* game_to_db_chart() pattern added
This commit is contained in:
Subject38 2022-08-17 17:16:47 -05:00 committed by GitHub
parent 99e60e6bbc
commit b2edbdce24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 3286 additions and 3259 deletions

View File

@ -500,6 +500,18 @@ class IIDXBase(CoreHandler, CardManagerHandler, PASELIHandler, Base):
"""
raise Exception('Implement in specific game class!')
def game_to_db_chart(self, game_chart: int) -> int:
"""
Given a game's chart for a song, return the chart as defined above.
"""
raise Exception('Implement in sub-class!')
def db_to_game_chart(self, db_chart: int) -> int:
"""
Given a chart as defined above, return the game's chart constant.
"""
raise Exception('Implement in sub-class!')
def make_score_struct(self, scores: List[Score], cltype: int, index: int) -> List[List[int]]:
scorestruct: Dict[int, List[int]] = {}

View File

@ -86,6 +86,14 @@ class IIDXCannonBallers(IIDXCourse, IIDXBase):
FAVORITE_LIST_LENGTH: Final[int] = 20
GAME_CHART_TYPE_N7: Final[int] = 0
GAME_CHART_TYPE_H7: Final[int] = 1
GAME_CHART_TYPE_A7: Final[int] = 2
GAME_CHART_TYPE_N14: Final[int] = 3
GAME_CHART_TYPE_H14: Final[int] = 4
GAME_CHART_TYPE_A14: Final[int] = 5
GAME_CHART_TYPE_B7: Final[int] = 6
requires_extended_regions: bool = True
def previous_version(self) -> Optional[IIDXBase]:
@ -290,6 +298,17 @@ class IIDXCannonBallers(IIDXCourse, IIDXBase):
else:
raise Exception('Invalid cltype!')
def game_to_db_chart(self, db_chart: int) -> int:
return {
self.GAME_CHART_TYPE_B7: self.CHART_TYPE_B7,
self.GAME_CHART_TYPE_N7: self.CHART_TYPE_N7,
self.GAME_CHART_TYPE_H7: self.CHART_TYPE_H7,
self.GAME_CHART_TYPE_A7: self.CHART_TYPE_A7,
self.GAME_CHART_TYPE_N14: self.CHART_TYPE_N14,
self.GAME_CHART_TYPE_H14: self.CHART_TYPE_H14,
self.GAME_CHART_TYPE_A14: self.CHART_TYPE_A14,
}[db_chart]
def handle_IIDX25shop_getname_request(self, request: Node) -> Node:
machine = self.data.local.machine.get_machine(self.config.machine.pcbid)
if machine is not None:
@ -367,7 +386,7 @@ class IIDXCannonBallers(IIDXCourse, IIDXBase):
def handle_IIDX25ranking_getranker_request(self, request: Node) -> Node:
root = Node.void('IIDX25ranking')
chart = int(request.attribute('clid'))
chart = self.game_to_db_chart(int(request.attribute('clid')))
if chart not in [
self.CHART_TYPE_N7,
self.CHART_TYPE_H7,
@ -461,7 +480,7 @@ class IIDXCannonBallers(IIDXCourse, IIDXBase):
def handle_IIDX25ranking_entry_request(self, request: Node) -> Node:
extid = int(request.attribute('iidxid'))
courseid = int(request.attribute('coid'))
chart = int(request.attribute('clid'))
chart = self.game_to_db_chart(int(request.attribute('clid')))
course_type = int(request.attribute('regist_type'))
clear_status = self.game_to_db_status(int(request.attribute('clr')))
pgreats = int(request.attribute('pgnum'))
@ -597,7 +616,7 @@ class IIDXCannonBallers(IIDXCourse, IIDXBase):
def handle_IIDX25music_appoint_request(self, request: Node) -> Node:
musicid = int(request.attribute('mid'))
chart = int(request.attribute('clid'))
chart = self.game_to_db_chart(int(request.attribute('clid')))
ghost_type = int(request.attribute('ctype'))
extid = int(request.attribute('iidxid'))
userid = self.data.remote.user.from_extid(self.game, self.version, extid)
@ -673,7 +692,7 @@ class IIDXCannonBallers(IIDXCourse, IIDXBase):
def handle_IIDX25music_reg_request(self, request: Node) -> Node:
extid = int(request.attribute('iidxid'))
musicid = int(request.attribute('mid'))
chart = int(request.attribute('clid'))
chart = self.game_to_db_chart(int(request.attribute('clid')))
userid = self.data.remote.user.from_extid(self.game, self.version, extid)
# See if we need to report global or shop scores
@ -840,7 +859,7 @@ class IIDXCannonBallers(IIDXCourse, IIDXBase):
def handle_IIDX25music_play_request(self, request: Node) -> Node:
musicid = int(request.attribute('mid'))
chart = int(request.attribute('clid'))
chart = self.game_to_db_chart(int(request.attribute('clid')))
clear_status = self.game_to_db_status(int(request.attribute('cflg')))
self.update_score(
@ -1377,7 +1396,7 @@ class IIDXCannonBallers(IIDXCourse, IIDXBase):
best_clear_string = clear_map.get(best_clear, 'NO PLAY')
now_clear_string = clear_map.get(now_clear, 'NO PLAY')
# let's get the song info first
song = self.data.local.music.get_song(self.game, self.music_version, music_id, class_id)
song = self.data.local.music.get_song(self.game, self.music_version, music_id, self.game_to_db_chart(class_id))
notecount = song.data.get('notecount', 0)
# Construct the dictionary for the broadcast
card_data = {

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -86,6 +86,14 @@ class IIDXRootage(IIDXCourse, IIDXBase):
FAVORITE_LIST_LENGTH: Final[int] = 20
GAME_CHART_TYPE_N7: Final[int] = 0
GAME_CHART_TYPE_H7: Final[int] = 1
GAME_CHART_TYPE_A7: Final[int] = 2
GAME_CHART_TYPE_N14: Final[int] = 3
GAME_CHART_TYPE_H14: Final[int] = 4
GAME_CHART_TYPE_A14: Final[int] = 5
GAME_CHART_TYPE_B7: Final[int] = 6
requires_extended_regions = True
def previous_version(self) -> Optional[IIDXBase]:
@ -291,6 +299,17 @@ class IIDXRootage(IIDXCourse, IIDXBase):
else:
raise Exception('Invalid cltype!')
def game_to_db_chart(self, db_chart: int) -> int:
return {
self.GAME_CHART_TYPE_B7: self.CHART_TYPE_B7,
self.GAME_CHART_TYPE_N7: self.CHART_TYPE_N7,
self.GAME_CHART_TYPE_H7: self.CHART_TYPE_H7,
self.GAME_CHART_TYPE_A7: self.CHART_TYPE_A7,
self.GAME_CHART_TYPE_N14: self.CHART_TYPE_N14,
self.GAME_CHART_TYPE_H14: self.CHART_TYPE_H14,
self.GAME_CHART_TYPE_A14: self.CHART_TYPE_A14,
}[db_chart]
def handle_IIDX26shop_getname_request(self, request: Node) -> Node:
machine = self.data.local.machine.get_machine(self.config.machine.pcbid)
if machine is not None:
@ -450,7 +469,7 @@ class IIDXRootage(IIDXCourse, IIDXBase):
def handle_IIDX26music_appoint_request(self, request: Node) -> Node:
musicid = int(request.attribute('mid'))
chart = int(request.attribute('clid'))
chart = self.game_to_db_chart(int(request.attribute('clid')))
ghost_type = int(request.attribute('ctype'))
extid = int(request.attribute('iidxid'))
userid = self.data.remote.user.from_extid(self.game, self.version, extid)
@ -526,7 +545,7 @@ class IIDXRootage(IIDXCourse, IIDXBase):
def handle_IIDX26music_reg_request(self, request: Node) -> Node:
extid = int(request.attribute('iidxid'))
musicid = int(request.attribute('mid'))
chart = int(request.attribute('clid'))
chart = self.game_to_db_chart(int(request.attribute('clid')))
userid = self.data.remote.user.from_extid(self.game, self.version, extid)
# See if we need to report global or shop scores
@ -693,7 +712,7 @@ class IIDXRootage(IIDXCourse, IIDXBase):
def handle_IIDX26music_play_request(self, request: Node) -> Node:
musicid = int(request.attribute('mid'))
chart = int(request.attribute('clid'))
chart = self.game_to_db_chart(int(request.attribute('clid')))
clear_status = self.game_to_db_status(int(request.attribute('cflg')))
self.update_score(
@ -1015,7 +1034,7 @@ class IIDXRootage(IIDXCourse, IIDXBase):
best_clear_string = clear_map.get(best_clear, 'NO PLAY')
now_clear_string = clear_map.get(now_clear, 'NO PLAY')
# let's get the song info first
song = self.data.local.music.get_song(self.game, self.music_version, music_id, class_id)
song = self.data.local.music.get_song(self.game, self.music_version, music_id, self.game_to_db_chart(class_id))
notecount = song.data.get('notecount', 0)
# Construct the dictionary for the broadcast
card_data = {

View File

@ -86,6 +86,14 @@ class IIDXSinobuz(IIDXCourse, IIDXBase):
FAVORITE_LIST_LENGTH: Final[int] = 20
GAME_CHART_TYPE_N7: Final[int] = 0
GAME_CHART_TYPE_H7: Final[int] = 1
GAME_CHART_TYPE_A7: Final[int] = 2
GAME_CHART_TYPE_N14: Final[int] = 3
GAME_CHART_TYPE_H14: Final[int] = 4
GAME_CHART_TYPE_A14: Final[int] = 5
GAME_CHART_TYPE_B7: Final[int] = 6
def previous_version(self) -> Optional[IIDXBase]:
return IIDXCopula(self.data, self.config, self.model)
@ -288,6 +296,17 @@ class IIDXSinobuz(IIDXCourse, IIDXBase):
else:
raise Exception('Invalid cltype!')
def game_to_db_chart(self, db_chart: int) -> int:
return {
self.GAME_CHART_TYPE_B7: self.CHART_TYPE_B7,
self.GAME_CHART_TYPE_N7: self.CHART_TYPE_N7,
self.GAME_CHART_TYPE_H7: self.CHART_TYPE_H7,
self.GAME_CHART_TYPE_A7: self.CHART_TYPE_A7,
self.GAME_CHART_TYPE_N14: self.CHART_TYPE_N14,
self.GAME_CHART_TYPE_H14: self.CHART_TYPE_H14,
self.GAME_CHART_TYPE_A14: self.CHART_TYPE_A14,
}[db_chart]
def handle_IIDX24shop_getname_request(self, request: Node) -> Node:
machine = self.data.local.machine.get_machine(self.config.machine.pcbid)
if machine is not None:
@ -365,7 +384,7 @@ class IIDXSinobuz(IIDXCourse, IIDXBase):
def handle_IIDX24ranking_getranker_request(self, request: Node) -> Node:
root = Node.void('IIDX24ranking')
chart = int(request.attribute('clid'))
chart = self.game_to_db_chart(int(request.attribute('clid')))
if chart not in [
self.CHART_TYPE_N7,
self.CHART_TYPE_H7,
@ -457,7 +476,7 @@ class IIDXSinobuz(IIDXCourse, IIDXBase):
def handle_IIDX24ranking_entry_request(self, request: Node) -> Node:
extid = int(request.attribute('iidxid'))
courseid = int(request.attribute('coid'))
chart = int(request.attribute('clid'))
chart = self.game_to_db_chart(int(request.attribute('clid')))
course_type = int(request.attribute('regist_type'))
clear_status = self.game_to_db_status(int(request.attribute('clr')))
pgreats = int(request.attribute('pgnum'))
@ -593,7 +612,7 @@ class IIDXSinobuz(IIDXCourse, IIDXBase):
def handle_IIDX24music_appoint_request(self, request: Node) -> Node:
musicid = int(request.attribute('mid'))
chart = int(request.attribute('clid'))
chart = self.game_to_db_chart(int(request.attribute('clid')))
ghost_type = int(request.attribute('ctype'))
extid = int(request.attribute('iidxid'))
userid = self.data.remote.user.from_extid(self.game, self.version, extid)
@ -669,7 +688,7 @@ class IIDXSinobuz(IIDXCourse, IIDXBase):
def handle_IIDX24music_reg_request(self, request: Node) -> Node:
extid = int(request.attribute('iidxid'))
musicid = int(request.attribute('mid'))
chart = int(request.attribute('clid'))
chart = self.game_to_db_chart(int(request.attribute('clid')))
userid = self.data.remote.user.from_extid(self.game, self.version, extid)
# See if we need to report global or shop scores
@ -837,7 +856,7 @@ class IIDXSinobuz(IIDXCourse, IIDXBase):
def handle_IIDX24music_play_request(self, request: Node) -> Node:
musicid = int(request.attribute('mid'))
chart = int(request.attribute('clid'))
chart = self.game_to_db_chart(int(request.attribute('clid')))
clear_status = self.game_to_db_status(int(request.attribute('cflg')))
self.update_score(
@ -1399,7 +1418,7 @@ class IIDXSinobuz(IIDXCourse, IIDXBase):
best_clear_string = clear_map.get(best_clear, 'NO PLAY')
now_clear_string = clear_map.get(now_clear, 'NO PLAY')
# let's get the song info first
song = self.data.local.music.get_song(self.game, self.music_version, music_id, class_id)
song = self.data.local.music.get_song(self.game, self.music_version, music_id, self.game_to_db_chart(class_id))
notecount = song.data.get('notecount', 0)
# Construct the dictionary for the broadcast
card_data = {

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff