User Tools

Site Tools


tasks:buy_tasks_lib
Title:buy_tasks_lib
Sex: Female T Male T Trans T
Require:
Limits:
; just for testing:
assign:taskName:'task2'
;
;================================================================
;================================================================
;==================== TODO: move to global lib ==================
;================================================================
;================================================================
;
call:check_bought_tasks_and_deadlines
;----------------------------------------------------------------
function:check_bought_tasks_and_deadlines
  ;----------------------------------------------------------------
  ; Part 1: check global bought tasks and write them to todo tasks of the user:
  ; TASKS_TODO_BY_ME contains: <task name>,<deadline>,<optional from user>;..
  loadtemp1:TASKS_TODO_BY_ME
  assign:globalTasksTodoByMe:'TEMP1'
  if: '$taskName' != 'buy_tasks'
    ; GLOBAL_BOUGHT_TASKS contains: <to user>,<task name>,<from user>;..
    loadgtemp1:GLOBAL_BOUGHT_TASKS
    assign:globalBoughtTasks:'TEMP1'
    if: '$globalBoughtTasks'.includes('SNAME,')
      assign:globalNoOfBoughtTasks:'$globalBoughtTasks'.split(';').length-1
      assign:globalTodoCounter:0
      label:startOfCheckBoughtTasksLoop
      assign:globalBoughtTaskTo:'$globalBoughtTasks'.split(';')[$globalTodoCounter].split(',')[0]
      assign:globalBoughtTaskTaskName:'$globalBoughtTasks'.split(';')[$globalTodoCounter].split(',')[1]
      assign:globalBoughtTaskFrom:'$globalBoughtTasks'.split(';')[$globalTodoCounter].split(',')[2]
      if: 'SNAME' == '$globalBoughtTaskTo'
        image:taskimg/assistant_at_desk2.jpg
        show:<b>$globalBoughtTaskFrom</b> has bought the task <b>$globalBoughtTaskTaskName</b> for you. I've added it to your 'Tasks ToDo' list, you'll have to do it within 30 days.
        ; dtask:0:$globalBoughtTaskFrom:$globalBoughtTaskTaskName:720
        ; msg:$globalBoughtTaskFrom:SNAME was now informed that you've bought the task $globalBoughtTaskTaskName for them. They have to do it within 30 days.
        settemp1:(TIMENOW+(30*24*60*60*1000))
        assign:globalTasksTodoByMe:'$globalTasksTodoByMe$globalBoughtTaskTaskName,TEMP1,$globalBoughtTaskFrom;'
        assign:globalBoughtTasks:'$globalBoughtTasks'.replace('$globalBoughtTaskTo,$globalBoughtTaskTaskName,$globalBoughtTaskFrom;','')
        assign:globalNoOfBoughtTasks:$globalNoOfBoughtTasks-1
        assign:globalTodoCounter:$globalTodoCounter-1;
        button:I understand, Miss Claire
      fi:
      assign:globalTodoCounter:$globalTodoCounter+1;
      if: $globalTodoCounter < $globalNoOfBoughtTasks
        goto:startOfCheckBoughtTasksLoop
      fi:
      settemp1:'$globalBoughtTasks'
      savegtemp1:GLOBAL_BOUGHT_TASKS
    fi:
  fi:
  ; -----------
  ; Part 2: check dtask deadlines
  assign:globalAlreadyRemovedThisTask:false
  assign:globalNoOfTodoTasks:'$globalTasksTodoByMe'.split(';').length-1
  assign:globalTodoCounter:0
  if: $globalNoOfTodoTasks > 0
    label:startOfCheckTodoTasksLoop
    assign:globalTodoTaskName:'$globalTasksTodoByMe'.split(';')[$globalTodoCounter].split(',')[0]
    assign:globalTodoTaskDeadline:'$globalTasksTodoByMe'.split(';')[$globalTodoCounter].split(',')[1]
    assign:globalTodoTaskOptionalFrom:'$globalTasksTodoByMe'.split(';')[$globalTodoCounter].split(',')[2]
    if: TIMENOW > $globalTodoTaskDeadline
      image:taskimg/assistant_at_desk2.jpg
      if: '$globalTodoTaskOptionalFrom' != 'undefined'
        settemp1:' that <b>$globalTodoTaskOptionalFrom</b> has bought for you'
      else:
        settemp1:''
      fi:
      show:You've missed the deadline of the task <b>$globalTodoTaskName</b>TEMP1. I'm really sorry but I had to remove 5 mood for that.
      button:I'm sorry, Miss Claire
      if: '$globalTodoTaskOptionalFrom' != 'undefined'
        ;
        settemp1:'$taskName'
        if: '$taskName' != '$taskName' && '$globalTodoTaskName' == 'TEMP1'
          ;msg:$globalTodoTaskOptionalFrom:SNAME just started the task $taskName that you bought for them. They started it after the deadline of 30 days though, so they also lost 5 mood.
        else:
          ;msg:$globalTodoTaskOptionalFrom:SNAME did not do the task $taskName that you bought for them within 30 days. Thus they've lost 5 mood, and don't have to do the task anymore.
        fi:
        settemp1:',$globalTodoTaskOptionalFrom'
      else:
        settemp1:''
      fi:
      assign:globalTasksTodoByMe:'$globalTasksTodoByMe'.replace('$globalTodoTaskName,$globalTodoTaskDeadlineTEMP1;','')
      assign:globalNoOfTodoTasks:$globalNoOfTodoTasks-1
      assign:globalTodoCounter:$globalTodoCounter-1;
    else:
      settemp1:'$taskName'
      if: '$taskName' != '$taskName' && '$globalTodoTaskName' == 'TEMP1'
        if: !$globalAlreadyRemovedThisTask
          if: '$globalTodoTaskOptionalFrom' != 'undefined'
            ;msg:$globalTodoTaskOptionalFrom:SNAME just started the task $taskName that you bought for them
            settemp1:',$globalTodoTaskOptionalFrom'
          else:
            settemp1:''
          fi:
          assign:globalTasksTodoByMe:'$globalTasksTodoByMe'.replace('$globalTodoTaskName,$globalTodoTaskDeadlineTEMP1;','')
          assign:globalNoOfTodoTasks:$globalNoOfTodoTasks-1
          assign:globalTodoCounter:$globalTodoCounter-1;
          assign:globalAlreadyRemovedThisTask:true
        else:
          ; due to a current bug in the system all todo tasks with the same name will be removed, thus add it again
          ; dtask:1:Miss Claire:$taskName:720
        fi:
      fi:
    fi:
    assign:globalTodoCounter:$globalTodoCounter+1;
    if: $globalTodoCounter < $globalNoOfTodoTasks
      goto:startOfCheckTodoTasksLoop
    fi:
    settemp1:'$globalTasksTodoByMe'
    button:saving (TEMP1)
    savetemp1:TASKS_TODO_BY_ME
  fi:
end:
;
;================================================================
;================================================================
;================================================================
;================================================================
;================================================================

</code>

tasks/buy_tasks_lib.txt · Last modified: 2024/07/13 19:55 (external edit)