Guest account restarts completely

This commit is contained in:
Howard Abrams 2025-07-31 21:39:36 -07:00
parent 283f022108
commit 6870c9008e
2 changed files with 68 additions and 19 deletions

View file

@ -488,7 +488,7 @@ class CmdRead(Command):
self.show_file(reader, contents[5:], prefix, self.show_file(reader, contents[5:], prefix,
self.client_width(), reader.client_height()) self.client_width(), reader.client_height())
else: else:
reader.msg(prefix + contents) reader.msg((prefix or "") + contents)
def show_file(self, reader, filename, prefix, width, height): def show_file(self, reader, filename, prefix, width, height):
""" """

View file

@ -83,29 +83,78 @@ class Character(Object, GenderCharacter, ContribRPCharacter):
return False return False
def delete_inv(self, typeclass): def delete_inv(self, typeclass):
"""
Delete items from a character's inventory of typeclass.
"""
for obj in self.contents: for obj in self.contents:
if obj.is_typeclass(typeclass): if obj.is_typeclass(typeclass):
obj.delete() obj.delete()
def at_post_puppet(self, **kwargs): def new_account_setup(self):
if self.db.visited and not self.db.guest_account: """
self.msg(f"""\n“Welcome back, {self.key.capitalize()}.”\n""") New accounts should connect the tutorial.
if self.location.key == "Wyldwood Bar": """
self.msg("You wake up in a meadow with a strange dream of a bar...")
self.delete_inv("typeclasses.drinkables.Cocktail")
meadow = self.search("Frog Meadow", global_search=True, quiet=True)
if isinstance(meadow, list):
meadow = meadow[0]
self.move_to(meadow, quiet=True, use_destination=True)
else:
self.execute_cmd("look")
else:
self.db.visited = True
self.db.tutorstate = 0
TutorBird.do_start_tutorial(self)
self.msg(INTRO)
self.fix_letter() self.fix_letter()
self.db.visited = True
self.db.tutorstate = 0
TutorBird.do_start_tutorial(self)
self.msg(INTRO)
def guest_account_setup(self):
"""
Cleanup the guest account to start fresh for a new player.
What if there is a bug and they are able to "get" something
important, instead of berries?
"""
self.new_account_setup()
self.db.jumped_times = 0
# Remove all the tags that let them
for tag in self.tags.all():
if tag.startswith("hidden_"):
self.tags.remove(tag)
# Remove everything in their inventory
for obj in self.contents:
logger.warning(f"Guest account: deleting {obj.name}")
obj.delete()
# Move them to the Grove to begin their adventure:
grove = self.search("mp01", global_search=True, quiet=True)
if isinstance(grove, list):
grove = grove[0]
self.move_to(grove, quiet=True, use_destination=True)
def after_bar_setup(self):
"""
Users should not return to the bar.
And let's get rid of their cocktail glasses, too.
"""
self.msg("You wake up in a meadow with a strange dream of a bar...")
self.delete_inv("typeclasses.drinkables.Cocktail")
meadow = self.search("Frog Meadow", global_search=True, quiet=True)
if isinstance(meadow, list):
meadow = meadow[0]
self.move_to(meadow, quiet=True, use_destination=True)
def at_post_puppet(self, **kwargs):
"""
Setup the character based for _this world_.
New accounts, guest accounts, and those that woke up
with a hangover in the bar, need consideration.
"""
if self.db.guest_account:
self.guest_account_setup()
elif not self.db.visited:
self.new_account_setup()
elif self.location.key == "Wyldwood Bar":
self.after_bar_setup()
else:
self.msg(f"""\n“Welcome back, {self.key.capitalize()}.”\n""")
self.execute_cmd("look")
self.account.db._last_puppet = self self.account.db._last_puppet = self
def at_pre_unpuppet(self, **kwargs): def at_pre_unpuppet(self, **kwargs):