1
0
mirror of synced 2024-11-13 17:40:47 +01:00

Rename "game" to "gamecode" in Model class, to be more accurate.

This commit is contained in:
Jennifer Taylor 2021-08-19 19:20:31 +00:00
parent fa0b2bd6cd
commit 3dd3f9ab07
10 changed files with 60 additions and 60 deletions

View File

@ -157,15 +157,15 @@ class Base:
this model. Its possible to return None from this function if a registered game has no way of
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 Base(data, config, model)
else:
# 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
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
code as returned by a game, such as "LDJ" or "MDX".
@ -174,7 +174,7 @@ class Base:
game - 3-character string identifying a game
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)
@classmethod

View File

@ -14,13 +14,13 @@ class BishiBashiFactory(Factory):
@classmethod
def register_all(cls) -> None:
for game in ['IBB']:
Base.register(game, BishiBashiFactory)
for gamecode in ['IBB']:
Base.register(gamecode, BishiBashiFactory)
@classmethod
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)
# Unknown game version

View File

@ -48,8 +48,8 @@ class DDRFactory(Factory):
@classmethod
def register_all(cls) -> None:
for game in ['HDX', 'JDX', 'KDX', 'MDX']:
Base.register(game, DDRFactory)
for gamecode in ['HDX', 'JDX', 'KDX', 'MDX']:
Base.register(gamecode, DDRFactory)
@classmethod
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 None
if model.game == 'HDX':
if model.gamecode == 'HDX':
return DDRX(data, config, model)
if model.game == 'JDX':
if model.gamecode == 'JDX':
return DDRX2(data, config, model)
if model.game == 'KDX':
if model.gamecode == 'KDX':
return DDRX3(data, config, model)
if model.game == 'MDX':
if model.gamecode == 'MDX':
if model.version is None:
if parentmodel is None:
return None
# 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.
if parentmodel.game not in ['HDX', 'JDX', 'KDX', 'MDX']:
if parentmodel.gamecode not in ['HDX', 'JDX', 'KDX', 'MDX']:
return None
parentversion = version_from_date(parentmodel.version)

View File

@ -70,8 +70,8 @@ class IIDXFactory(Factory):
@classmethod
def register_all(cls) -> None:
for game in ['JDJ', 'JDZ', 'KDZ', 'LDJ']:
Base.register(game, IIDXFactory)
for gamecode in ['JDJ', 'JDZ', 'KDZ', 'LDJ']:
Base.register(gamecode, IIDXFactory)
@classmethod
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 None
if model.game == 'JDJ':
if model.gamecode == 'JDJ':
return IIDXSirius(data, config, model)
if model.game == 'JDZ':
if model.gamecode == 'JDZ':
return IIDXResortAnthem(data, config, model)
if model.game == 'KDZ':
if model.gamecode == 'KDZ':
return IIDXLincle(data, config, model)
if model.game == 'LDJ':
if model.gamecode == 'LDJ':
if model.version is None:
if parentmodel is None:
return None
# 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.
if parentmodel.game not in ['JDJ', 'JDZ', 'KDZ', 'LDJ']:
if parentmodel.gamecode not in ['JDJ', 'JDZ', 'KDZ', 'LDJ']:
return None
parentversion = version_from_date(parentmodel.version)
if parentversion == VersionConstants.IIDX_SPADA:

View File

@ -40,29 +40,29 @@ class JubeatFactory(Factory):
@classmethod
def register_all(cls) -> None:
for game in ['H44', 'I44', 'J44', 'K44', 'L44']:
Base.register(game, JubeatFactory)
for gamecode in ['H44', 'I44', 'J44', 'K44', 'L44']:
Base.register(gamecode, JubeatFactory)
@classmethod
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)
if model.game == 'I44':
if model.gamecode == 'I44':
if model.version >= 2010031800:
return JubeatRipplesAppend(data, config, model)
else:
return JubeatRipples(data, config, model)
if model.game == 'J44':
if model.gamecode == 'J44':
if model.version >= 2011032300:
return JubeatKnitAppend(data, config, model)
else:
return JubeatKnit(data, config, model)
if model.game == 'K44':
if model.gamecode == 'K44':
if model.version >= 2012031400:
return JubeatCopiousAppend(data, config, model)
else:
return JubeatCopious(data, config, model)
if model.game == 'L44':
if model.gamecode == 'L44':
if model.version <= 2014022400:
return JubeatSaucer(data, config, model)
if model.version >= 2014030300 and model.version < 2015022000:

View File

@ -16,8 +16,8 @@ class MusecaFactory(Factory):
@classmethod
def register_all(cls) -> None:
for game in ['PIX']:
Base.register(game, MusecaFactory)
for gamecode in ['PIX']:
Base.register(gamecode, MusecaFactory)
@classmethod
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 None
if model.game == 'PIX':
if model.gamecode == 'PIX':
version = version_from_date(model.version)
if version == VersionConstants.MUSECA:
return Museca1(data, config, model)

View File

@ -64,8 +64,8 @@ class PopnMusicFactory(Factory):
@classmethod
def register_all(cls) -> None:
for game in ['G15', 'H16', 'I17', 'J39', 'K39', 'L39', 'M39']:
Base.register(game, PopnMusicFactory)
for gamecode in ['G15', 'H16', 'I17', 'J39', 'K39', 'L39', 'M39']:
Base.register(gamecode, PopnMusicFactory)
@classmethod
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 None
if model.game == 'G15':
if model.gamecode == 'G15':
return PopnMusicAdventure(data, config, model)
if model.game == 'H16':
if model.gamecode == 'H16':
return PopnMusicParty(data, config, model)
if model.game == 'I17':
if model.gamecode == 'I17':
return PopnMusicTheMovie(data, config, model)
if model.game == 'J39':
if model.gamecode == 'J39':
return PopnMusicSengokuRetsuden(data, config, model)
if model.game == 'K39':
if model.gamecode == 'K39':
return PopnMusicTuneStreet(data, config, model)
if model.game == 'L39':
if model.gamecode == 'L39':
return PopnMusicFantasia(data, config, model)
if model.game == 'M39':
if model.gamecode == 'M39':
if model.version is None:
if parentmodel is None:
return None
# 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.
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
parentversion = version_from_date(parentmodel.version)
if parentversion == VersionConstants.POPN_MUSIC_LAPISTORIA:

View File

@ -24,8 +24,8 @@ class ReflecBeatFactory(Factory):
@classmethod
def register_all(cls) -> None:
for game in ['KBR', 'LBR', 'MBR']:
Base.register(game, ReflecBeatFactory)
for gamecode in ['KBR', 'LBR', 'MBR']:
Base.register(gamecode, ReflecBeatFactory)
@classmethod
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 None
if model.game == 'KBR':
if model.gamecode == 'KBR':
return ReflecBeat(data, config, model)
if model.game == 'LBR':
if model.gamecode == 'LBR':
return ReflecBeatLimelight(data, config, model)
if model.game == 'MBR':
if model.gamecode == 'MBR':
if model.version is None:
if parentmodel is None:
return None
if parentmodel.game not in ['KBR', 'LBR', 'MBR']:
if parentmodel.gamecode not in ['KBR', 'LBR', 'MBR']:
return None
parentversion = version_from_date(parentmodel.version)
if parentversion == VersionConstants.REFLEC_BEAT_COLETTE:

View File

@ -22,8 +22,8 @@ class SoundVoltexFactory(Factory):
@classmethod
def register_all(cls) -> None:
for game in ['KFC']:
Base.register(game, SoundVoltexFactory)
for gamecode in ['KFC']:
Base.register(gamecode, SoundVoltexFactory)
@classmethod
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 None
if model.game == 'KFC':
if model.gamecode == 'KFC':
if model.version is None:
if parentmodel is None:
return None
# 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.
if parentmodel.game != 'KFC':
if parentmodel.gamecode != 'KFC':
return None
parentversion = version_from_date(parentmodel.version)

View File

@ -6,19 +6,19 @@ class Model:
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.
Parameters:
game - Game code (such as LDJ)
gamecode - Game code (such as LDJ)
dest - Destination region for the game (such as J)
spec - Spec for the game (such as A)
rev - Revision of the game (such as A)
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.
"""
self.game = game
self.gamecode = gamecode
self.dest = dest
self.spec = spec
self.rev = rev
@ -38,15 +38,15 @@ class Model:
"""
parts = model.split(':')
if len(parts) == 5:
game, dest, spec, rev, version = parts
return Model(game, dest, spec, rev, int(version))
gamecode, dest, spec, rev, version = parts
return Model(gamecode, dest, spec, rev, int(version))
elif len(parts) == 4:
game, dest, spec, rev = parts
return Model(game, dest, spec, rev, None)
gamecode, dest, spec, rev = parts
return Model(gamecode, dest, spec, rev, None)
raise Exception(f'Couldn\'t parse model {model}')
def __str__(self) -> str:
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:
return f'{self.game}:{self.dest}:{self.spec}:{self.rev}:{self.version}'
return f'{self.gamecode}:{self.dest}:{self.spec}:{self.rev}:{self.version}'