Rename "game" to "gamecode" in Model class, to be more accurate.
This commit is contained in:
parent
fa0b2bd6cd
commit
3dd3f9ab07
@ -157,15 +157,15 @@ class Base:
|
|||||||
this model. Its possible to return None from this function if a registered game has no way of
|
this model. Its possible to return None from this function if a registered game has no way of
|
||||||
handling this particular modelstring.
|
handling this particular modelstring.
|
||||||
"""
|
"""
|
||||||
if model.game not in cls.__registered_games:
|
if model.gamecode not in cls.__registered_games:
|
||||||
# Return just this base model, which will provide nothing
|
# Return just this base model, which will provide nothing
|
||||||
return Base(data, config, model)
|
return Base(data, config, model)
|
||||||
else:
|
else:
|
||||||
# Return the registered module providing this game
|
# Return the registered module providing this game
|
||||||
return cls.__registered_games[model.game].create(data, config, model, parentmodel=parentmodel)
|
return cls.__registered_games[model.gamecode].create(data, config, model, parentmodel=parentmodel)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def register(cls, game: str, handler: Type[Factory]) -> None:
|
def register(cls, gamecode: str, handler: Type[Factory]) -> None:
|
||||||
"""
|
"""
|
||||||
Register a factory to handle a game. Note that the game should be the game
|
Register a factory to handle a game. Note that the game should be the game
|
||||||
code as returned by a game, such as "LDJ" or "MDX".
|
code as returned by a game, such as "LDJ" or "MDX".
|
||||||
@ -174,7 +174,7 @@ class Base:
|
|||||||
game - 3-character string identifying a game
|
game - 3-character string identifying a game
|
||||||
handler - A factory which has a create() method that can spawn game classes.
|
handler - A factory which has a create() method that can spawn game classes.
|
||||||
"""
|
"""
|
||||||
cls.__registered_games[game] = handler
|
cls.__registered_games[gamecode] = handler
|
||||||
cls.__registered_handlers.add(handler)
|
cls.__registered_handlers.add(handler)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -14,13 +14,13 @@ class BishiBashiFactory(Factory):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def register_all(cls) -> None:
|
def register_all(cls) -> None:
|
||||||
for game in ['IBB']:
|
for gamecode in ['IBB']:
|
||||||
Base.register(game, BishiBashiFactory)
|
Base.register(gamecode, BishiBashiFactory)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create(cls, data: Data, config: Dict[str, Any], model: Model, parentmodel: Optional[Model]=None) -> Optional[Base]:
|
def create(cls, data: Data, config: Dict[str, Any], model: Model, parentmodel: Optional[Model]=None) -> Optional[Base]:
|
||||||
|
|
||||||
if model.game == 'IBB':
|
if model.gamecode == 'IBB':
|
||||||
return TheStarBishiBashi(data, config, model)
|
return TheStarBishiBashi(data, config, model)
|
||||||
|
|
||||||
# Unknown game version
|
# Unknown game version
|
||||||
|
@ -48,8 +48,8 @@ class DDRFactory(Factory):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def register_all(cls) -> None:
|
def register_all(cls) -> None:
|
||||||
for game in ['HDX', 'JDX', 'KDX', 'MDX']:
|
for gamecode in ['HDX', 'JDX', 'KDX', 'MDX']:
|
||||||
Base.register(game, DDRFactory)
|
Base.register(gamecode, DDRFactory)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create(cls, data: Data, config: Dict[str, Any], model: Model, parentmodel: Optional[Model]=None) -> Optional[Base]:
|
def create(cls, data: Data, config: Dict[str, Any], model: Model, parentmodel: Optional[Model]=None) -> Optional[Base]:
|
||||||
@ -65,20 +65,20 @@ class DDRFactory(Factory):
|
|||||||
return VersionConstants.DDR_A20
|
return VersionConstants.DDR_A20
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if model.game == 'HDX':
|
if model.gamecode == 'HDX':
|
||||||
return DDRX(data, config, model)
|
return DDRX(data, config, model)
|
||||||
if model.game == 'JDX':
|
if model.gamecode == 'JDX':
|
||||||
return DDRX2(data, config, model)
|
return DDRX2(data, config, model)
|
||||||
if model.game == 'KDX':
|
if model.gamecode == 'KDX':
|
||||||
return DDRX3(data, config, model)
|
return DDRX3(data, config, model)
|
||||||
if model.game == 'MDX':
|
if model.gamecode == 'MDX':
|
||||||
if model.version is None:
|
if model.version is None:
|
||||||
if parentmodel is None:
|
if parentmodel is None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# We have no way to tell apart newer versions. However, we can make
|
# We have no way to tell apart newer versions. However, we can make
|
||||||
# an educated guess if we happen to be summoned for old profile lookup.
|
# an educated guess if we happen to be summoned for old profile lookup.
|
||||||
if parentmodel.game not in ['HDX', 'JDX', 'KDX', 'MDX']:
|
if parentmodel.gamecode not in ['HDX', 'JDX', 'KDX', 'MDX']:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
parentversion = version_from_date(parentmodel.version)
|
parentversion = version_from_date(parentmodel.version)
|
||||||
|
@ -70,8 +70,8 @@ class IIDXFactory(Factory):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def register_all(cls) -> None:
|
def register_all(cls) -> None:
|
||||||
for game in ['JDJ', 'JDZ', 'KDZ', 'LDJ']:
|
for gamecode in ['JDJ', 'JDZ', 'KDZ', 'LDJ']:
|
||||||
Base.register(game, IIDXFactory)
|
Base.register(gamecode, IIDXFactory)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create(cls, data: Data, config: Dict[str, Any], model: Model, parentmodel: Optional[Model]=None) -> Optional[Base]:
|
def create(cls, data: Data, config: Dict[str, Any], model: Model, parentmodel: Optional[Model]=None) -> Optional[Base]:
|
||||||
@ -97,20 +97,20 @@ class IIDXFactory(Factory):
|
|||||||
return VersionConstants.IIDX_BISTROVER
|
return VersionConstants.IIDX_BISTROVER
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if model.game == 'JDJ':
|
if model.gamecode == 'JDJ':
|
||||||
return IIDXSirius(data, config, model)
|
return IIDXSirius(data, config, model)
|
||||||
if model.game == 'JDZ':
|
if model.gamecode == 'JDZ':
|
||||||
return IIDXResortAnthem(data, config, model)
|
return IIDXResortAnthem(data, config, model)
|
||||||
if model.game == 'KDZ':
|
if model.gamecode == 'KDZ':
|
||||||
return IIDXLincle(data, config, model)
|
return IIDXLincle(data, config, model)
|
||||||
if model.game == 'LDJ':
|
if model.gamecode == 'LDJ':
|
||||||
if model.version is None:
|
if model.version is None:
|
||||||
if parentmodel is None:
|
if parentmodel is None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# We have no way to tell apart newer versions. However, we can make
|
# We have no way to tell apart newer versions. However, we can make
|
||||||
# an educated guess if we happen to be summoned for old profile lookup.
|
# an educated guess if we happen to be summoned for old profile lookup.
|
||||||
if parentmodel.game not in ['JDJ', 'JDZ', 'KDZ', 'LDJ']:
|
if parentmodel.gamecode not in ['JDJ', 'JDZ', 'KDZ', 'LDJ']:
|
||||||
return None
|
return None
|
||||||
parentversion = version_from_date(parentmodel.version)
|
parentversion = version_from_date(parentmodel.version)
|
||||||
if parentversion == VersionConstants.IIDX_SPADA:
|
if parentversion == VersionConstants.IIDX_SPADA:
|
||||||
|
@ -40,29 +40,29 @@ class JubeatFactory(Factory):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def register_all(cls) -> None:
|
def register_all(cls) -> None:
|
||||||
for game in ['H44', 'I44', 'J44', 'K44', 'L44']:
|
for gamecode in ['H44', 'I44', 'J44', 'K44', 'L44']:
|
||||||
Base.register(game, JubeatFactory)
|
Base.register(gamecode, JubeatFactory)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create(cls, data: Data, config: Dict[str, Any], model: Model, parentmodel: Optional[Model]=None) -> Optional[Base]:
|
def create(cls, data: Data, config: Dict[str, Any], model: Model, parentmodel: Optional[Model]=None) -> Optional[Base]:
|
||||||
if model.game == 'H44':
|
if model.gamecode == 'H44':
|
||||||
return Jubeat(data, config, model)
|
return Jubeat(data, config, model)
|
||||||
if model.game == 'I44':
|
if model.gamecode == 'I44':
|
||||||
if model.version >= 2010031800:
|
if model.version >= 2010031800:
|
||||||
return JubeatRipplesAppend(data, config, model)
|
return JubeatRipplesAppend(data, config, model)
|
||||||
else:
|
else:
|
||||||
return JubeatRipples(data, config, model)
|
return JubeatRipples(data, config, model)
|
||||||
if model.game == 'J44':
|
if model.gamecode == 'J44':
|
||||||
if model.version >= 2011032300:
|
if model.version >= 2011032300:
|
||||||
return JubeatKnitAppend(data, config, model)
|
return JubeatKnitAppend(data, config, model)
|
||||||
else:
|
else:
|
||||||
return JubeatKnit(data, config, model)
|
return JubeatKnit(data, config, model)
|
||||||
if model.game == 'K44':
|
if model.gamecode == 'K44':
|
||||||
if model.version >= 2012031400:
|
if model.version >= 2012031400:
|
||||||
return JubeatCopiousAppend(data, config, model)
|
return JubeatCopiousAppend(data, config, model)
|
||||||
else:
|
else:
|
||||||
return JubeatCopious(data, config, model)
|
return JubeatCopious(data, config, model)
|
||||||
if model.game == 'L44':
|
if model.gamecode == 'L44':
|
||||||
if model.version <= 2014022400:
|
if model.version <= 2014022400:
|
||||||
return JubeatSaucer(data, config, model)
|
return JubeatSaucer(data, config, model)
|
||||||
if model.version >= 2014030300 and model.version < 2015022000:
|
if model.version >= 2014030300 and model.version < 2015022000:
|
||||||
|
@ -16,8 +16,8 @@ class MusecaFactory(Factory):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def register_all(cls) -> None:
|
def register_all(cls) -> None:
|
||||||
for game in ['PIX']:
|
for gamecode in ['PIX']:
|
||||||
Base.register(game, MusecaFactory)
|
Base.register(gamecode, MusecaFactory)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create(cls, data: Data, config: Dict[str, Any], model: Model, parentmodel: Optional[Model]=None) -> Optional[Base]:
|
def create(cls, data: Data, config: Dict[str, Any], model: Model, parentmodel: Optional[Model]=None) -> Optional[Base]:
|
||||||
@ -29,7 +29,7 @@ class MusecaFactory(Factory):
|
|||||||
return VersionConstants.MUSECA_1_PLUS
|
return VersionConstants.MUSECA_1_PLUS
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if model.game == 'PIX':
|
if model.gamecode == 'PIX':
|
||||||
version = version_from_date(model.version)
|
version = version_from_date(model.version)
|
||||||
if version == VersionConstants.MUSECA:
|
if version == VersionConstants.MUSECA:
|
||||||
return Museca1(data, config, model)
|
return Museca1(data, config, model)
|
||||||
|
@ -64,8 +64,8 @@ class PopnMusicFactory(Factory):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def register_all(cls) -> None:
|
def register_all(cls) -> None:
|
||||||
for game in ['G15', 'H16', 'I17', 'J39', 'K39', 'L39', 'M39']:
|
for gamecode in ['G15', 'H16', 'I17', 'J39', 'K39', 'L39', 'M39']:
|
||||||
Base.register(game, PopnMusicFactory)
|
Base.register(gamecode, PopnMusicFactory)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create(cls, data: Data, config: Dict[str, Any], model: Model, parentmodel: Optional[Model]=None) -> Optional[Base]:
|
def create(cls, data: Data, config: Dict[str, Any], model: Model, parentmodel: Optional[Model]=None) -> Optional[Base]:
|
||||||
@ -83,26 +83,26 @@ class PopnMusicFactory(Factory):
|
|||||||
return VersionConstants.POPN_MUSIC_PEACE
|
return VersionConstants.POPN_MUSIC_PEACE
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if model.game == 'G15':
|
if model.gamecode == 'G15':
|
||||||
return PopnMusicAdventure(data, config, model)
|
return PopnMusicAdventure(data, config, model)
|
||||||
if model.game == 'H16':
|
if model.gamecode == 'H16':
|
||||||
return PopnMusicParty(data, config, model)
|
return PopnMusicParty(data, config, model)
|
||||||
if model.game == 'I17':
|
if model.gamecode == 'I17':
|
||||||
return PopnMusicTheMovie(data, config, model)
|
return PopnMusicTheMovie(data, config, model)
|
||||||
if model.game == 'J39':
|
if model.gamecode == 'J39':
|
||||||
return PopnMusicSengokuRetsuden(data, config, model)
|
return PopnMusicSengokuRetsuden(data, config, model)
|
||||||
if model.game == 'K39':
|
if model.gamecode == 'K39':
|
||||||
return PopnMusicTuneStreet(data, config, model)
|
return PopnMusicTuneStreet(data, config, model)
|
||||||
if model.game == 'L39':
|
if model.gamecode == 'L39':
|
||||||
return PopnMusicFantasia(data, config, model)
|
return PopnMusicFantasia(data, config, model)
|
||||||
if model.game == 'M39':
|
if model.gamecode == 'M39':
|
||||||
if model.version is None:
|
if model.version is None:
|
||||||
if parentmodel is None:
|
if parentmodel is None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# We have no way to tell apart newer versions. However, we can make
|
# We have no way to tell apart newer versions. However, we can make
|
||||||
# an educated guess if we happen to be summoned for old profile lookup.
|
# an educated guess if we happen to be summoned for old profile lookup.
|
||||||
if parentmodel.game not in ['G15', 'H16', 'I17', 'J39', 'K39', 'L39', 'M39']:
|
if parentmodel.gamecode not in ['G15', 'H16', 'I17', 'J39', 'K39', 'L39', 'M39']:
|
||||||
return None
|
return None
|
||||||
parentversion = version_from_date(parentmodel.version)
|
parentversion = version_from_date(parentmodel.version)
|
||||||
if parentversion == VersionConstants.POPN_MUSIC_LAPISTORIA:
|
if parentversion == VersionConstants.POPN_MUSIC_LAPISTORIA:
|
||||||
|
@ -24,8 +24,8 @@ class ReflecBeatFactory(Factory):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def register_all(cls) -> None:
|
def register_all(cls) -> None:
|
||||||
for game in ['KBR', 'LBR', 'MBR']:
|
for gamecode in ['KBR', 'LBR', 'MBR']:
|
||||||
Base.register(game, ReflecBeatFactory)
|
Base.register(gamecode, ReflecBeatFactory)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create(cls, data: Data, config: Dict[str, Any], model: Model, parentmodel: Optional[Model]=None) -> Optional[Base]:
|
def create(cls, data: Data, config: Dict[str, Any], model: Model, parentmodel: Optional[Model]=None) -> Optional[Base]:
|
||||||
@ -43,16 +43,16 @@ class ReflecBeatFactory(Factory):
|
|||||||
return VersionConstants.REFLEC_BEAT_REFLESIA
|
return VersionConstants.REFLEC_BEAT_REFLESIA
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if model.game == 'KBR':
|
if model.gamecode == 'KBR':
|
||||||
return ReflecBeat(data, config, model)
|
return ReflecBeat(data, config, model)
|
||||||
if model.game == 'LBR':
|
if model.gamecode == 'LBR':
|
||||||
return ReflecBeatLimelight(data, config, model)
|
return ReflecBeatLimelight(data, config, model)
|
||||||
if model.game == 'MBR':
|
if model.gamecode == 'MBR':
|
||||||
if model.version is None:
|
if model.version is None:
|
||||||
if parentmodel is None:
|
if parentmodel is None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if parentmodel.game not in ['KBR', 'LBR', 'MBR']:
|
if parentmodel.gamecode not in ['KBR', 'LBR', 'MBR']:
|
||||||
return None
|
return None
|
||||||
parentversion = version_from_date(parentmodel.version)
|
parentversion = version_from_date(parentmodel.version)
|
||||||
if parentversion == VersionConstants.REFLEC_BEAT_COLETTE:
|
if parentversion == VersionConstants.REFLEC_BEAT_COLETTE:
|
||||||
|
@ -22,8 +22,8 @@ class SoundVoltexFactory(Factory):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def register_all(cls) -> None:
|
def register_all(cls) -> None:
|
||||||
for game in ['KFC']:
|
for gamecode in ['KFC']:
|
||||||
Base.register(game, SoundVoltexFactory)
|
Base.register(gamecode, SoundVoltexFactory)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create(cls, data: Data, config: Dict[str, Any], model: Model, parentmodel: Optional[Model]=None) -> Optional[Base]:
|
def create(cls, data: Data, config: Dict[str, Any], model: Model, parentmodel: Optional[Model]=None) -> Optional[Base]:
|
||||||
@ -39,14 +39,14 @@ class SoundVoltexFactory(Factory):
|
|||||||
return VersionConstants.SDVX_HEAVENLY_HAVEN
|
return VersionConstants.SDVX_HEAVENLY_HAVEN
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if model.game == 'KFC':
|
if model.gamecode == 'KFC':
|
||||||
if model.version is None:
|
if model.version is None:
|
||||||
if parentmodel is None:
|
if parentmodel is None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# We have no way to tell apart newer versions. However, we can make
|
# We have no way to tell apart newer versions. However, we can make
|
||||||
# an educated guess if we happen to be summoned for old profile lookup.
|
# an educated guess if we happen to be summoned for old profile lookup.
|
||||||
if parentmodel.game != 'KFC':
|
if parentmodel.gamecode != 'KFC':
|
||||||
return None
|
return None
|
||||||
|
|
||||||
parentversion = version_from_date(parentmodel.version)
|
parentversion = version_from_date(parentmodel.version)
|
||||||
|
@ -6,19 +6,19 @@ class Model:
|
|||||||
Object representing a parsed Model String.
|
Object representing a parsed Model String.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, game: str, dest: str, spec: str, rev: str, version: Optional[int]) -> None:
|
def __init__(self, gamecode: str, dest: str, spec: str, rev: str, version: Optional[int]) -> None:
|
||||||
"""
|
"""
|
||||||
Initialize a Model object.
|
Initialize a Model object.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
game - Game code (such as LDJ)
|
gamecode - Game code (such as LDJ)
|
||||||
dest - Destination region for the game (such as J)
|
dest - Destination region for the game (such as J)
|
||||||
spec - Spec for the game (such as A)
|
spec - Spec for the game (such as A)
|
||||||
rev - Revision of the game (such as A)
|
rev - Revision of the game (such as A)
|
||||||
version - Integer representing version, usually in the form of YYYYMMDDXX where
|
version - Integer representing version, usually in the form of YYYYMMDDXX where
|
||||||
YYYY is a year, MM is a month, DD is a day and XX is sub-day versioning.
|
YYYY is a year, MM is a month, DD is a day and XX is sub-day versioning.
|
||||||
"""
|
"""
|
||||||
self.game = game
|
self.gamecode = gamecode
|
||||||
self.dest = dest
|
self.dest = dest
|
||||||
self.spec = spec
|
self.spec = spec
|
||||||
self.rev = rev
|
self.rev = rev
|
||||||
@ -38,15 +38,15 @@ class Model:
|
|||||||
"""
|
"""
|
||||||
parts = model.split(':')
|
parts = model.split(':')
|
||||||
if len(parts) == 5:
|
if len(parts) == 5:
|
||||||
game, dest, spec, rev, version = parts
|
gamecode, dest, spec, rev, version = parts
|
||||||
return Model(game, dest, spec, rev, int(version))
|
return Model(gamecode, dest, spec, rev, int(version))
|
||||||
elif len(parts) == 4:
|
elif len(parts) == 4:
|
||||||
game, dest, spec, rev = parts
|
gamecode, dest, spec, rev = parts
|
||||||
return Model(game, dest, spec, rev, None)
|
return Model(gamecode, dest, spec, rev, None)
|
||||||
raise Exception(f'Couldn\'t parse model {model}')
|
raise Exception(f'Couldn\'t parse model {model}')
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
if self.version is None:
|
if self.version is None:
|
||||||
return f'{self.game}:{self.dest}:{self.spec}:{self.rev}'
|
return f'{self.gamecode}:{self.dest}:{self.spec}:{self.rev}'
|
||||||
else:
|
else:
|
||||||
return f'{self.game}:{self.dest}:{self.spec}:{self.rev}:{self.version}'
|
return f'{self.gamecode}:{self.dest}:{self.spec}:{self.rev}:{self.version}'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user