From 7a1f4e0e013cbb221e7d147fd1d71296aee9eca1 Mon Sep 17 00:00:00 2001 From: dreamscached Date: Wed, 5 Jul 2023 16:29:07 +0200 Subject: [PATCH] Fixes of 'sober since when' picker call, fixes of reminders --- mod/checkup.rpy | 2 +- mod/header.rpy | 2 +- mod/questions.rpy | 46 +++++++++++++++++++++++++++++++++++++++++----- mod/update.rpy | 19 ++++++++++++++++++- 4 files changed, 61 insertions(+), 8 deletions(-) diff --git a/mod/checkup.rpy b/mod/checkup.rpy index 7ecf42e..ab3232f 100644 --- a/mod/checkup.rpy +++ b/mod/checkup.rpy @@ -43,7 +43,7 @@ label mshMod_checkup_intro: if not store._msh_reminder.is_reminder_queued("mshMod_checkup_reminder"): $ store._msh_reminder.queue_reminder( _msh_reminder.Reminder( - trigger_at=store._msh_reminder_utils.getWeeklyEveningDelay(), + trigger_at=datetime.datetime.now() + store._msh_reminder_utils.getWeeklyEveningDelay(), target_evl="mshMod_checkup_reminder", key="checkup_reminder", interval=store._msh_reminder_utils.INTERVAL_WEEKLY, diff --git a/mod/header.rpy b/mod/header.rpy index cdf45b6..26df2ce 100644 --- a/mod/header.rpy +++ b/mod/header.rpy @@ -35,7 +35,7 @@ init -990 python in mas_submod_utils: name="Self Harm Awareness Submod", description="Awareness about self-harm and support to self-harmers, with different " "techniques, milestones, checkups and new dialogue and spritepacks.", - version="2.0.1" + version="2.0.2" ) init -989 python: diff --git a/mod/questions.rpy b/mod/questions.rpy index 652559d..e204136 100644 --- a/mod/questions.rpy +++ b/mod/questions.rpy @@ -54,10 +54,47 @@ label mshMod_probing_questions_talk: "Yes!": show monika 5husdlb at t11 zorder MAS_MONIKA_Z with dissolve_monika m 5husdlb "Oh, yay!" - m 5esa "Can you tell me for how many days have you been sober?{nw}" - - call mshMod_sober_ask_since - $ since = _return + m 5esa "Can you tell me since when have you been sober?{nw}" + + label .select_since_date: + m 3hub "If you don't remember exactly, it's alright! Pick a day when you think you decided to quit it~" + call mas_start_calendar_select_date + $ since = _return + if not since: + jump .select_nothing + $ since = _return.date() + + $ today = datetime.date.today() + + if since > today: + m 1hksdla "[player]!" + m 3lksdlb "It's great that you plan on quitting it in future, but I asked you for a day in the past, ahaha!" + m 1hua "Try again!" + jump .select_since_date + + # We can do a simplified check for 'honest' date (actually just relying + # on player's conscience) that probably is less than 5 years + if (today - since).days // 365 > 5: + m 3wub "[mas_get_player_nickname(capitalize=True)], it's been a while since that day!" + m 2lksdla "But just to be completely sure...{w=0.3}{nw} " + extend 3wud "Are you absolutely sure you're sober for more than {i}five{/i} years now?{nw}" + + $ _history_list.pop() + menu: + m "But just to be completely sure... Are you absolutely sure you're sober for more than {i}five{/i} years now?{fast}" + + "Yes!": + m 3hub "Amazing! Alright, I'll write it down right away~" + jump mshMod_sober_promise_jump + + "Well, actually...": + m 2dka "It's okay, [mas_get_player_nickname()].{w=0.3} Don't worry!" + jump .select_since_date + + if persistent._mas_player_bday and since < persistent._mas_player_bday: + m 1rkb "[mas_get_player_nickname(capitalize=True)]...{w=0.3} The day you chose is before your birthday!" + m 3eka "Try again, please." + jump .select_since_date show monika 1sub at t11 zorder MAS_MONIKA_Z with dissolve_monika m 1sub "I'm so proud of you, [mas_get_player_nickname()]." @@ -74,7 +111,6 @@ label mshMod_probing_questions_talk: mas_showEVL("mshMod_sober_check", "EVE", unlock=True) mas_showEVL("mshMod_sober_relapse", "EVE", unlock=True) - "I don't know.": m 2eka "Aww, [player], that's okay!" m 7hub "If you ever want to keep track of it, you can tell me by promising you'll stay self-harm sober." diff --git a/mod/update.rpy b/mod/update.rpy index 23c08c1..dabb0b6 100644 --- a/mod/update.rpy +++ b/mod/update.rpy @@ -99,6 +99,16 @@ init 5 python: if not ev.unlocked and ev.last_seen is not None: ev.unlocked = True + def _mshMod_migrateBrokenReminder(key): + rem_idx = store._msh_reminder.get_reminder(key) + if rem_idx is None: + return + + rem = store._msh_reminder.queue[rem_idx] + if isinstance(rem.trigger_at, datetime.timedelta): + store._msh_reminder.pop_reminder(rem_idx, remove=True) + rem.trigger_at = datetime.datetime.now() + rem.trigger_at + store._msh_reminder.queue_reminder(rem) init 10 python: @@ -141,4 +151,11 @@ init 996 python: if not persistent._msh_mod_sha_migrated and persistent._msh_mod_was_installed: persistent._msh_mod_sha_migrated = True - _msh_mod_migrated_now = True \ No newline at end of file + _msh_mod_migrated_now = True + + +init 996 python: + + ## Fix reminder that was broken until 2.0.0 + + _mshMod_migrateBrokenReminder("checkup_reminder") \ No newline at end of file