Title:Morning Ritual
Sex: Female T Male T Trans T
Require:
Limits:
; Morning Ritual by cmsrv
; Slave should start each day by typing in their slave mantra and reflect on their submissiveness.
;
; Saved variables:
;
; * morning_ritual_last_run:
;   - empty string if the task was never run (or if the slave can't commit to mantra)
;   - otherwise date that the morning mantra was last run
; * morning_mantra_run_count_with_no_mistakes:
;   - empty string if the task was never run
;   - number of times the slave has typed in his mantra without mistake
;
;-----------------
; Configuration
;-----------------
;
; /** The max amount of time that can go between ritual runs without punishment */
assign:maxRitualIntervalInSeconds:300
;
;-----------------
; Variables
;-----------------
;
; /** Whether to show the mantra prompt. */
assign:showMantraLinePrompt:true
;
; /** The number of typing mistakes that will be tolerated */
assign:allowedTypos:1
;
;----------
; Functions
;----------
;
; /**
;  * Reads the current task state from saved variables.
;  * After the function is called, the following variables are defined:
;  * - firstRun: Boolean
;  * - secondsSinceLastRun: Number (optional)
;  * - runCountWithSuccess: Number
;  */
function:ReadSavedState
  loadtemp1:morning_ritual_last_run
  if:('TEMP1' == '')
    assign:firstRun:true
    assign:runCountWithSuccess:0
  else:
    assign:firstRun:false
    assign:secondsSinceLastRun:(Math.round(Date.now() / 1000) - (parseInt('TEMP1') || 0))
    loadtemp1:morning_mantra_success_run_count
    assign:runCountWithSuccess:(parseInt('TEMP1') || 0)
  fi:
end:ReadSavedState
;
; /**
;  * Saves that the user has completed his ritual
;  */
function:MarkRitualCompletedToday
  settemp1:(Math.round(Date.now() / 1000))
  savetemp1:morning_ritual_last_run
  loadtemp1:morning_mantra_success_run_count
  settemp1:((parseInt('TEMP1') || 0) + 1)
  savetemp1:morning_mantra_success_run_count
end:MarkRitualCompletedToday
;
; /**
;  * Resets the ritual from 0
;  */
function:ResetRitual
  settemp1:''
  savetemp1:morning_ritual_last_run
  settemp1:'0'
  savetemp1:morning_mantra_success_run_count
end:ResetRitual
;
; /**
;  * Makes the user type in a line from their mantra.
;  * Param TEMP1: The mantra line the user needs to type in
;  */
function:MakeUserTypeMantraLine
  assign:typedInCorrectly:false
  while:(!$typedInCorrectly)
    if:($showMantraLinePrompt)
      show:Instruct user to type in mantra line <i>TEMP1</i>
      wait:5
    fi:
    asktext:[Instruct user to type in mantra line]
    if:('TEMP1' == 'LASTASK')
      assign:typedInCorrectly:true
    else:
      if:($allowedTypos <= 0)
        log: Slave made a typo when typing in his mantra and DTITLE is out of patience.
        show:[Tell user that was a mistake too many]
        button:OK
        goto:punishment
      else:
        log: Slave made a typo when typing in his mantra, but DTITLE is in a good mood today
        show:[Chastiste the user for their mistake]
        button:OK
        assign:allowedTypos:($allowedTypos - 1)
      fi:
    fi:
  endwhile:
end:MakeUserTypeMantraLine
;
; /**
;  * Makes the user wait for 2 minutes 30 seconds, taking a picture at a random time
;  */
function:MakeUserWait
  assign:waitBefore:(Math.floor((Math.random() * 90) + 10))
  assign:waitAfter:(150 - $waitBefore)
  if:(mode == 1)
    show:[Skipping wait time in test mode]
    wait:5
  else:
    wait:$waitBefore
    cam:temp
    wait:$waitAfter
  fi:
end:
;
;-----------------
; Main entry point
;-----------------
;
; Greet the user
show:[Greet the user]
wait:5
;
; Read saved state
call:ReadSavedState
;
; First run
if:($firstRun)
  log:Slave is not currently commited to the daily ritual task
  show:[Explain what the ritual task is, that it should be run first thing after waking up, etc]
  button:OK
  show:[Give the user a choice on whether to perfom a daily morning mantra]
  choice:Yes I will,No I can't
  if:(LASTASK == 1)
    log:Slave committed to the daily ritual task
  fi:
  if:(LASTASK == 2)
    show:[Push the user to reconsider]
    choice:OK I will commit, No I really can't
    if:(LASTASK == 1)
      log:Slave committed to the daily ritual task (after additional prodding)
      show:[Praise user for reconsidering]
      wait:5
    fi:
    if:(LASTASK == 2)
      log:Slave could not commit to the daily ritual task. 1 mood point was substracted. Please leave this task at 6.
      show:[Chastise the user for not committing and explain 1 mood point was removed]
      button:OK
      ; if:(mode != 1)
      ;   setmood:(MOOD - 3)
      ; fi:
      goto:endOfTask
    fi:
  fi:
fi:
;
; Explain more on the first run
if:($firstRun)
  show:[Explain more about mantra]
  button:OK
  show:[Transition to running first mantra]
fi:
;
; Show the mantra prompt only for the first few runs
; After that the slave should have it memorized
if:(!$firstRun)
  if:($runCountWithSuccess >= 5)
    assign:showMantraLinePrompt:false
  fi:
fi:
;
; Users in hardcore mode don't deserve any leeway
if:(HARDCORE)
  assign:allowedTypos:0
fi:
;
; Punish the user because if they haven't been following their ritual diligently
if:(!$firstRun)
  if:($secondsSinceLastRun > $maxRitualIntervalInSeconds)
    show:[Chastise the user because they have not been running their mantra regularly]
    button:OK
    goto:punishment
  fi:
fi:
;
; Ask the user to type in their mantra
show:[Prompt the user to type in their mantra, warn that any mistake will be costly]
button:Yes DTITLE
settemp1:'Line 1'
call:MakeUserTypeMantraLine
settemp1:'Line 2'
call:MakeUserTypeMantraLine
log:Slave completed typing in their mantra
show:[Praise the user for typing in their mantra]
button:Thank you, DTITLE
;
; Time to reflect
show:[Explain that user will take a moment to reflect on their submissiveness and their love for their dominant, on their knees eyes closed, with verification pictures at random times]
log:Slave will now spend 5 minutes reflecting on their submissiveness and their love for their dominant.
log:The next few pictures should show the slave on their knees and holding still. If their face is visible, they should have their eyes closed and head bowed.
button:Ready to start
show:[Remind user they should be on their knees, eyes closed]
call:MakeUserWait
call:MakeUserWait
;
;
show:[Explain the user will have to type in a daily report to describe their submissive state of mind that particular day and their hopes of serving the dominant well]
button:OK
asktext:[Instruct user to type in their daily report]
log:When asked to describe their state of mind, slave said LASTASK
;
; Wish the user a good day
show:[Wish the user a good day]
wait:5
;
; Mark the ritual as completed for today
call:MarkRitualCompletedToday
;
; Skip punishment
goto:endOfTask
;
;-----------
; Punishment
;-----------
label:punishment
call:ResetRitual
log:Slave was asked to report for punishment
show:[Ask the user to report for punishment]
button:OK
;
;------------
; End of task
;------------
label:endOfTask
;
;