emp_functions.qsrc 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. # emp_functions
  2. !! Employmnent and Event Systems
  3. !! 2022-09-30
  4. !! Author: Hooded Silence
  5. !!
  6. !! v.01 - Initial code base
  7. !! v.02 - Event generator partially integrated
  8. !! v.03 - Job management system integrated
  9. !!
  10. !! --------------------- UI Interface for Journal
  11. if $ARGS[0] = 'gen_schedule':
  12. *clr & cla
  13. if night_mode = 1 or night_mode = 2:
  14. $header_theme = '#91B0B4'
  15. $body_theme = '#303030'
  16. $body_theme_alt = '#474747'
  17. $font_theme = '#000000'
  18. else
  19. $header_theme = '#e27c00'
  20. $body_theme = '#E0DED4'
  21. $body_theme_alt = '#D58B32'
  22. $font_theme = '#FFFFFF'
  23. end
  24. if function_sw = 1: '<center><h2>' + $npc_firstname['A<<mod_npc_id>>'] + ' ' + $npc_lastname['A<<mod_npc_id>>'] + '</h2></center>'
  25. if function_sw = 2:
  26. gs 'journal', 'journalmenu'
  27. '<center><h2>Work</h2></center>'
  28. end
  29. !! Enable selector if attending school or Uni by NPC group type or by character and set default to School
  30. if (npc_grupTipe['A<<mod_npc_id>>']>= 1 and npc_grupTipe['A<<mod_npc_id>>']<= 5) or mod_npc_id = 34 and function_sw <= 1:
  31. if flag_schedule = 0: flag_schedule = 1
  32. school_group = 1
  33. '<center>Change to: <a href="exec: flag_schedule = 1 & gs ''emp_functions'', ''gen_schedule''">School</a> | <a href="exec: flag_schedule = 2 & gs ''emp_functions'', ''gen_schedule''">University</a> | <a href="exec: flag_schedule = 3 & gs ''emp_functions'', ''gen_schedule''">Holiday</a> </center>'
  34. else
  35. !! Set schedule to holiday / non-edu NPCs
  36. flag_schedule = 3
  37. end
  38. !! Initiate loop variables
  39. i_day = 1
  40. mod_max_day = 7
  41. i_hour = ARGS[1]
  42. mod_max_hour = ARGS[1] + 8
  43. header_switch = 1
  44. killvar '$tablebody'
  45. killvar '$tableheader'
  46. !! create header, using header switch to fill in :00 or :30 automatically using mod to determine odd/even and set display hour automatically.
  47. $tableheader = '<tr border="1" align="center" bgcolor="<<$header_theme>>"><th style="padding: 10px;"></th>'
  48. :jmp_header_create
  49. if (i_hour mod 2) = 0:
  50. display_hour = i_hour/ 2
  51. end
  52. if display_hour = 24: Display_hour = 0
  53. if header_switch = 1:
  54. header_switch += 1
  55. $tableheader += '<th style="padding: 10px;"><font color="<<$font_theme>>">' + iif(display_hour < 10, '0<<display_hour >>', display_hour) + ':00</font></th>'
  56. elseif header_switch=2:
  57. header_switch = 1
  58. $tableheader += '<th style="padding: 10px;"><font color="<<$font_theme>>">' + iif(display_hour < 10, '0<< display_hour>>', display_hour) + ':30</font></th>'
  59. end
  60. i_hour += 1
  61. if i_hour <= mod_max_hour: jump 'jmp_header_create'
  62. ! Reset i_hour for next loop
  63. killvar 'display_hour'
  64. killvar 'header_switch'
  65. i_hour = ARGS[1]
  66. header_switch = 1
  67. !! Close out table header
  68. $tableheader += '</tr>'
  69. !! Create table body, with alternating colour rows for legibility
  70. :jmp_day_create
  71. !Set day
  72. if i_day = 1 or i_day = 3 or i_day = 5 or i_day = 7:
  73. $tablebody += '<tr><td style="padding: 10px;" bgcolor="<<$header_theme>>"><b><font color="<<$font_theme>>">' + $week[i_day] + '</font></b></td>'
  74. else
  75. $tablebody += '<tr bgcolor="<<$body_theme_alt>>"><td style="padding: 10px;" bgcolor="<<$header_theme>>"><b><font color="<<$font_theme>>">' + $week[i_day] + '</font></b></td>'
  76. end
  77. !! fill the slots from the NPC schedule
  78. :jmp_hour_create
  79. if i_day >= 1:
  80. !! Create function switcher:
  81. !! 1: NPC tracker
  82. !! 2: Job tracker
  83. !! 3: Event Tracker
  84. if function_sw = 1 or function_sw = 0:
  85. dynamic $schedule_tracker
  86. elseif function_sw = 2:
  87. flag_active = 1
  88. j_id = emp_rota_week[i_day + '_' + i_hour]
  89. if emp_rota_week[i_day + '_' + i_hour] ! 0:
  90. $transient_tb = '<a href="exec:gs ''emp_functions'', ''job_info'', <<j_id>>">' + $emp_job_title[j_id] + '</a>'
  91. else
  92. $transient_tb = 'Free'
  93. end
  94. elseif function_sw = 3:
  95. else
  96. msg 'Error - Failed to create body. Please set content switch.'
  97. end
  98. if flag_active = 0:
  99. $tablebody += '<td style="padding: 10px;">Slot: ' + i_hour +'</td>'
  100. else
  101. $tablebody += '<td style="padding: 10px;">' + $transient_tb +'</td>'
  102. flag_active = 0
  103. killvar '$transient_tb'
  104. end
  105. else
  106. i_day += 1
  107. jump 'jmp_day_create'
  108. end
  109. i_hour += 1
  110. if i_hour <= mod_max_hour: jump 'jmp_hour_create'
  111. $tablebody +='</tr>'
  112. i_day += 1
  113. i_hour = ARGS[1]
  114. if i_day <= mod_max_day: jump 'jmp_day_create'
  115. !! Create navigaton bars
  116. if (mod_max_hour + 8) <= 48:
  117. set_hour = ARGS[1] + 8
  118. $msg_forward = '<a href="exec:gs ''emp_functions'', ''gen_schedule'', <<set_hour>>"><b>Forward 4 hours</b></a>'
  119. else
  120. $msg_forward = 'End of Day'
  121. end
  122. if (mod_max_hour - 8) >0 :
  123. set_hour = ARGS[1] - 8
  124. $msg_back = '<a href="exec:gs ''emp_functions'', ''gen_schedule'', <<set_hour>>"><b>Back 4 hours</b></a>'
  125. else
  126. $msg_back = 'Start of day'
  127. end
  128. !! Start the table constuction
  129. '<center><table border=0 cellpadding=1 bgcolor="<<$body_theme>>" width="95%" align="center"><<$tableheader>><<$tablebody>></table>'
  130. '<<$msg_back>> | <<$msg_forward>>'
  131. *nl
  132. if function_sw = 1:
  133. '<b>Note:</b> Times are approximate, some characters will appear at quarter past or quarter to the hour.</center>'
  134. end
  135. if function_sw = 2:
  136. '<b>Note:</b> Times are approximate, some jobs may extend past the allotted time or have flexi-starts.</center>'
  137. end
  138. act 'Back':
  139. killvar 'flag_schedule'
  140. killvar 'school_group'
  141. killvar 'j_id'
  142. gt $loc, $loc_arg
  143. end
  144. end
  145. !! Job Info popup
  146. if $ARGS[0] = 'job_info':
  147. j_id = ARGS[1]
  148. killvar '$msg_body'
  149. $msg_body += '<p>Job Title: ' + $emp_job_title[j_id] + '</p>'
  150. $msg_body += '<p>Location: ' + $emp_job_loc[j_id] + '</p>'
  151. $msg_body += '<p>Notes: ' + $emp_job_notes[j_id]+ '</p>'
  152. $msg_body += '<p>Wages: ' +emp_job_wages[j_id] + '<b>₽</b></p>'
  153. msg '<<$msg_body>>'
  154. end
  155. !! Removed event generation for initial code review and to make job integration easier.
  156. !! --------------------- Event Generator
  157. !! Author - Hooded Silence
  158. !! Date created - 26 Aug 22
  159. !! Event Generator - filler content only for one off events or recurring work from NPCs
  160. !!
  161. !! v. 01 - Initial code base
  162. !! v. 02 - UI improvements and feature feedback
  163. !! --------------------- Job management system
  164. !! book role, creates a time slot for emp_rota_week in format day_hour to be used in schedule mode.
  165. if $ARGS[0] = 'emp_booking':
  166. gs 'emp_functions', 'emp_chk_clk'
  167. if emp_rota_fail = 0:
  168. gs 'emp_functions', 'loop_configure'
  169. j_finish = emp_job_end[j_id]
  170. :jmp_daily_book
  171. j_idx = emp_job_start[j_id]
  172. :jmp_hour_book
  173. emp_rota_week[d_idx + '_' + j_idx] = j_id
  174. j_idx += 1
  175. if j_idx <= j_finish: jump 'jmp_hour_book'
  176. d_idx += 1
  177. if d_idx <= d_end: jump 'jmp_daily_book'
  178. emp_job_status[j_id] = 1
  179. emp_job[active] += 1
  180. killvar 'j_idx'
  181. killvar 'j_finish'
  182. killvar 'd_idx'
  183. killvar 'd_end'
  184. else
  185. msg 'Sorry, you''ve already got a job for this time period.'
  186. end
  187. killvar 'emp_rota_fail'
  188. end
  189. !! check if time slots are avaialble for this role.
  190. if $ARGS[0] = 'emp_chk_clk':
  191. gs 'emp_functions', 'loop_configure'
  192. j_finish = emp_job_end[j_id]
  193. :jmp_daily_chk
  194. j_idx = emp_job_start[j_id]
  195. :jmp_job_chk
  196. if emp_rota_week[d_idx + '_' + j_idx] > 0:
  197. !! booking failed
  198. emp_rota_fail = 1
  199. else
  200. !! booking passed
  201. emp_rota_fail = 0
  202. end
  203. j_idx +=1
  204. if j_idx <= j_finish and emp_rota_fail = 0: jump 'jmp_job_chk'
  205. d_idx += 1
  206. if d_idx <= d_end and emp_rota_fail = 0: jump 'jmp_daily_chk'
  207. end
  208. if $ARGS[0] = 'emp_terminate':
  209. if ARGS[1] >= 4:
  210. gs 'emp_functions', 'loop_configure'
  211. j_finish = emp_job_end[j_id]
  212. :jmp_daily_book
  213. j_idx = emp_job_start[j_id]
  214. :jmp_hour_book
  215. emp_rota_week[d_idx + '_' + j_idx] = 0
  216. j_idx += 1
  217. if j_idx <= j_finish: jump 'jmp_hour_book'
  218. d_idx += 1
  219. if d_idx <= d_end: jump 'jmp_daily_book'
  220. !! Set the termination value
  221. emp_job_status[j_id] = ARGS[1]
  222. emp_job[active] -= 1
  223. else
  224. msg 'Job termination failed. Please ensure you set to 4 - Terminated or 5 - Fired'
  225. end
  226. killvar 'j_idx'
  227. killvar 'j_finish'
  228. killvar 'd_idx'
  229. killvar 'd_end'
  230. end
  231. if $ARGS[0] = 'loop_configure':
  232. if j_day= 0 or j_day = 1 or j_day = 2:
  233. d_idx = 1
  234. else
  235. d_idx= 6
  236. end
  237. if j_day <= 1:
  238. d_end = 5
  239. else
  240. d_end= 7
  241. end
  242. end
  243. --- emp_functions ---------------------------------