Skip to content

Commit

Permalink
tweak when autosave happens
Browse files Browse the repository at this point in the history
  • Loading branch information
JarbasAl committed Dec 18, 2024
1 parent 8035186 commit b641df9
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions ovos_workshop/skills/game_skill.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,10 @@ def on_game_command(self, utterance: str, lang: str):

@abc.abstractmethod
def on_abandon_game(self):
"""user abandoned game mid interaction, good place to auto-save
"""user abandoned game mid interaction
auto-save is done before this method is called
(if enabled in self.settings)
on_game_stop will be called after this handler"""

Expand Down Expand Up @@ -213,10 +216,10 @@ def _autosave(self):
def converse(self, message: Message):
try:
if self.is_paused:
self._autosave()
# let ocp_pipeline unpause as appropriate
return False

self._autosave()
utterance = message.data["utterances"][0]
lang = get_message_lang(message)
# let the user implemented intents do the job if they can handle the utterance
Expand All @@ -238,11 +241,11 @@ def handle_deactivate(self, message: Message):
means the user didn't interact with the game for a long time and intent parser will be released
"""
try:
self._autosave()
if self.is_paused:
self.log.info("Game is paused, keeping it active")
self.activate() # keep the game in active skills list so it can still converse
elif self.is_playing:
self._autosave()
self.log.info("Game abandoned due to inactivity")
self.on_abandon_game()
self.on_stop_game()
Expand Down

0 comments on commit b641df9

Please sign in to comment.