1
0
mirror of synced 2025-02-16 10:52:34 +01:00

Fix core state machine for cards so Fantasia will present a profile migration.

This commit is contained in:
Jennifer Taylor 2021-09-03 04:34:51 +00:00
parent b58f356479
commit 4f64cc7e08
2 changed files with 21 additions and 11 deletions

View File

@ -35,29 +35,39 @@ class CardManagerHandler(Base):
root.set_attribute('status', str(Status.NOT_REGISTERED))
return root
# Special handling for looking up whether the previous game's profile existed
# Special handling for looking up whether the previous game's profile existed. If we
# don't do this then some games won't present the user with a migration.
bound = self.has_profile(userid)
expired = False
if bound is False:
if modelstring is not None:
model = Model.from_modelstring(modelstring)
oldgame = Base.create(self.data, self.config, model, self.model)
if oldgame is None:
bound = False
else:
if oldgame is not None:
bound = oldgame.has_profile(userid)
expired = True
refid = self.data.local.user.get_refid(self.game, self.version, userid)
paseli_enabled = self.supports_paseli() and self.config.paseli.enabled
newflag = self.data.remote.user.get_any_profile(self.game, self.version, userid) is None
root = Node.void('cardmng')
root.set_attribute('refid', refid)
root.set_attribute('dataid', refid)
root.set_attribute('newflag', '1') # Always seems to be set to 1
root.set_attribute('binded', '1' if bound else '0') # Whether we've bound to this version of the game or not
root.set_attribute('expired', '1' if expired else '0') # Whether we're expired
root.set_attribute('ecflag', '1' if paseli_enabled else '0') # Whether to allow paseli
# Unsure what this does, but it appears not to matter so we set it to my best guess.
root.set_attribute('newflag', '1' if newflag else '0')
# Whether we've bound a profile to this refid/dataid or not. This includes current profiles and any
# older game profiles that might exist that we should do a conversion from.
root.set_attribute('binded', '1' if bound else '0')
# Whether this version of the profile is expired (was converted to newer version). We support forwards
# and backwards compatibility so we always set this to 0.
root.set_attribute('expired', '0')
# Whether to allow paseli, as enabled by the operator and arcade owner.
root.set_attribute('ecflag', '1' if paseli_enabled else '0')
# I have absolutely no idea what these do.
root.set_attribute('useridflag', '1')
root.set_attribute('extidflag', '1')
return root

View File

@ -294,7 +294,7 @@ class BaseClient:
if binded != 1:
raise Exception(f'Card \'{card_id}\' returned invalid binded value \'{binded}\'')
if newflag != 1:
if newflag != 0:
raise Exception(f'Card \'{card_id}\' returned invalid newflag value \'{newflag}\'')
if ecflag != (1 if paseli_enabled else 0):
raise Exception(f'Card \'{card_id}\' returned invalid ecflag value \'{newflag}\'')