internet_mobile.qsrc 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. # internet_mobile
  2. !! { Plans and Subscriptions
  3. subscription[<plan name>] The subscription itself that will be checked to see if Sveta can access the internet
  4. Possible values:
  5. Monthly subscriptions:
  6. 0: subscription is inactive, either never bought or expired.
  7. 1: subscription is active
  8. Metered plans:
  9. Any integer number, which means the available minutes left within the plan.
  10. This is how the old mobile minutes and internet time worked, but tracked in minutes,
  11. not hours for the internet.
  12. subscription[<plan name>-date] The day the subscription was bought for the home (or mobile), this will be the renewal day.
  13. automatically set to `day`.
  14. Possible values 0-31, 1-31 are renewal days, 0 means the plan never expires.
  15. subscription[<plan name>-price] The monthly fee of the subscription.
  16. subscription[<plan name>-discount] The discount on the plan - relevant if the original discount was greater than the monthly
  17. fee. If the value is higher than 0, payments come from this first until the value gets to
  18. 0.
  19. subscription[<plan nam>-type] The type of the subscription.
  20. Possible values:
  21. 1: Monthly subscription
  22. 2: Metered plan
  23. Plan Names
  24. free: A subscription that is freely available, libraries, friends and lovers apartment, etc. that has a computer.
  25. The value of this plan is always 1 and the subscription date is 0.
  26. mobile: Mobile telephone (only internet or calls too?) and laptop if taken somewhere else.
  27. If at a location where subscription['free'] is used, she has to ask first to be able to use her own laptop
  28. with the local internet, otherwise it will still use the mobile subscription - if there is none, it won''t work.
  29. metered_mobile Cheaper option for broke Svetas. When subscription['mobile'] = 0 check for this and if
  30. `subscription['metered_mobile'] > 0` then use it.
  31. <property code> This is a monthly subscription that can be used in a specific home owned/rented by Sveta.
  32. This is tracking the internet subscription per home. So if Sveta owns several places, she has a separate
  33. subscription for each of them.
  34. For allowed values see `homes_properties`.
  35. monthly_calls A monthly mobile subscription giving unlimited call minutes and text message
  36. metered_calls A mobile plan that gives a set amount of minutes that can be used.
  37. }
  38. if subscription['free'] = 0: subscription['free'] = 1
  39. !! Used for metered calls/texts/internet.
  40. !! $ARGS[1] = subscription name, i.e., 'metered_mobile' for mobile net or 'metered_calls' for phone calls and text messages
  41. !! ARGS[2] = the number of units purchased (minutes, calls, etc.) right now relevant for metered mobile internet
  42. !! ARGS[3] = the number of sms messages that can be sent with this top up - only for metered_calls
  43. !! NOTE: Putting this on top so if we decide not to use it, it is easy to find and delete
  44. if $ARGS[0] = 'top_up_metered':
  45. subscription[$ARGS[1]] += ARGS[2]
  46. subscription['<<$ARGS[1]>>-date'] = day
  47. if $ARGS[1] = 'metered_calls': subscription['sms_limit'] += ARGS[3]
  48. if subscription['<<$ARGS[1]>>-type'] = 0: subscription['<<$ARGS[1]>>-type'] = 2
  49. gs 'stat'
  50. end
  51. !! In case we decide that internet prices are different for different homes (mobile definitely should be)
  52. !! $ARGS[1] = The plan name - see on top, generally the name of a property or a mobile plan.
  53. !! ARGS[2] = Subscription fee - the price to be paid every month
  54. !! ARGS[3] = The remaining amount from the discount when it was more than the monthly fee. Optional value
  55. !! See valid values in set_home.qsrc
  56. if $ARGS[0] = 'buy_subscription':
  57. subscription[$ARGS[1]] = 1
  58. subscription['<<$ARGS[1]>>-date'] = day
  59. subscription['<<$ARGS[1]>>-price'] = ARGS[2]
  60. subscription['<<$ARGS[1]>>-discount'] = ARGS[3]
  61. if subscription['<<$ARGS[1]>>-type'] = 0: subscription['<<$ARGS[1]>>-type'] = 1
  62. gs 'stat'
  63. end
  64. !! Nightly check called from cikl - check for subscription renewal and suspension.
  65. if $ARGS[0] = 'check_subscription_actions':
  66. !! Get a list of the properties and their attributes that the player rented:
  67. !! $property_code[], $property_name[], $property_display[], $property_status_display[], $property_type[]
  68. !! property_status[], property_construction_status[], property_is_renovated[], property_sales_price[],
  69. !! property_renovation_value[]
  70. gs 'homes_properties', 'get_accessible_properties', 'home'
  71. count = ARRSIZE('$property_name')
  72. if count > 0:
  73. i = 0
  74. :home_internet_subscription_loop
  75. if (property_status[i] = 1 or property_status[i] = 2) and subscription[$property_code[i]] = 1:
  76. if subscription['<<$property_code[i]>>-date'] = day: gs 'internet_mobile', 'renew_subscription', $property_code[i]
  77. if subscription['<<$property_code[i]>>-suspension_month'] = month and subscription['<<$property_code[i]>>-suspension_day'] >= day: gs 'internet_mobile', 'renew_subscription', $property_code[i]
  78. if subscription['<<$property_code[i]>>-suspension_month'] <= month and subscription['<<$property_code[i]>>-suspension_day'] < day: gs 'internet_mobile', 'suspend_subscription', $property_code[i]
  79. $result[j] = 'Internet Subscription for <<$property_display[i]>>: <<subscription[''<<$property_code[i]>>-contract_message'']>>'
  80. j += 1
  81. end
  82. i += 1
  83. if i < count: jump 'home_internet_subscription_loop'
  84. end
  85. gs 'homes_properties', 'clean_up_property_data'
  86. if subscription['mobile'] = 1:
  87. if subscription['mobile-date'] = day: gs 'internet_mobile', 'renew_subscription', 'mobile'
  88. if subscription['mobile-suspension_month'] = month and subscription['mobile-suspension_day'] >= day: gs 'internet_mobile', 'renew_subscription', 'mobile'
  89. if subscription['mobile-suspension_month'] <= month and subscription['mobile-suspension_day'] < day: gs 'internet_mobile', 'suspend_subscription', 'mobile'
  90. $result[j] = 'You Mobile Internet Subscription: <<subscription[''mobile-contract_message'']>>'
  91. j += 1
  92. end
  93. if subscription['monthly_calls'] = 1:
  94. if subscription['monthly_calls-date'] = day: gs 'internet_mobile', 'renew_subscription', 'monthly_calls'
  95. if subscription['monthly_calls-suspension_month'] = month and subscription['monthly_calls-suspension_day'] >= day: gs 'internet_mobile', 'renew_subscription', 'monthly_calls'
  96. if subscription['monthly_calls-suspension_month'] <= month and subscription['monthly_calls-suspension_day'] < day: gs 'internet_mobile', 'suspend_subscription', 'monthly_calls'
  97. $result[j] = 'You mobile contract: <<subscription[''monthly_calls-contract_message'']>>'
  98. j += 1
  99. end
  100. killvar 'count' & killvar 'i' & killvar 'j'
  101. end
  102. !! Cancelling a subscription (currently uused only for metered_calls and metered_mobile to clean them up when a monthly subscription
  103. !! is bought to repplace them)
  104. !! $ARGS[1] - subscription name
  105. if $ARGS[0] = 'cancel_subscription':
  106. subscription[$ARGS[1]] = 0
  107. subscription['<<$ARGS[1]>>-date'] = 0
  108. subscription['sms_limit'] = 0
  109. subscription['<<$ARGS[1]>>-type'] = 0
  110. subscription['<<$ARGS[1]>>-price'] = 0
  111. subscription['<<$ARGS[1]>>-discount'] = 0
  112. end
  113. !! Renewing the subscription
  114. if $ARGS[0] = 'renew_subscription':
  115. renewfee = subscription['<<$ARGS[1]>>-price']
  116. acc_discount = subscription['<<$ARGS[1]>>-discount']
  117. app_discount = MIN(acc_discount,renewfee)
  118. finalfee = app_discount
  119. rem_discount = acc_discount-app_discount
  120. if karta+bankDebtLimit > finalfee:
  121. karta -= finalfee
  122. subscription['<<$ARGS[1]>>-discount'] = rem_discount
  123. if app_discount > 0: $discounttext = '<<renewfee>>₽ and you had <<acc_discount>><b>₽</b> left on your account. After applying <<app_discount>><b>₽</b> to your monthly fee, your final payable was <b><font color="green"><<finalfee>>₽</b></font> and you were left with <<rem_discount>><b>₽</b> on your account.'
  124. $subscription['<<$ARGS[1]>>-contract_message'] = 'Your monthly fee was' + iif(app_discount > 0, $discounttext, '<b><font color="green"><<renewfee>>₽</font></b> which was taken from your bank account.')
  125. if subscription['<<$ARGS[1]>>-suspension_month'] > 0: subscription['<<$ARGS[1]>>-suspension_month'] = 0
  126. if subscription['<<$ARGS[1]>>-suspension_day'] > 0: subscription['<<$ARGS[1]>>-suspension_day'] = 0
  127. else
  128. remainingday = 5
  129. if subscription['<<$ARGS[1]>>-suspension_day'] > 0: remainingday = subscription['<<$ARGS[1]>>-suspension_day'] - day
  130. if app_discount > 0: $discounttext = ' and you had <<acc_discount>><b>₽</b> left on your account. After applying <<app_discount>><b>₽</b> to your monthly fee, your final payable was <<finalfee>><b>₽</b> and you were left with <<rem_discount>><b>₽</b> on your account.'
  131. $subscription['<<$ARGS[1]>>-contract_message'] = 'Your monthly fee was <<renewfee>><b>₽</b>'+ iif(app_discount >0, $discounttext,', unfortunately your payment was declined. We will try to take the payment over the next <b><font color="red"><<remainingday>> days</font></b> before suspending services.')
  132. gs 'internet_mobile', 'set_suspension_date', $ARGS[1]
  133. end
  134. killvar 'renewfee'
  135. killvar 'acc_discount'
  136. killvar 'app_discount'
  137. killvar 'finalfee'
  138. killvar 'rem_discount'
  139. killvar '$discounttext'
  140. killvar 'remainingday'
  141. end
  142. !! Transfer existing subscription from one home to another if Sveta is moving.
  143. if $ARGS[0] = 'transfer_subscription':
  144. allowed = func('internet_mobile', 'check_allowed_location', $ARGS[1])
  145. allowed = allowed and func('internet_mobile', 'check_allowed_location', $ARGS[2])
  146. if allowed:
  147. subscription[$ARGS[2]] = subscription[$ARGS[1]]
  148. subscription['<<ARGS[2]>>-date'] = subscription['<<$ARGS[1]>>-date']
  149. subscription['<<ARGS[2]>>-price'] = subscription['<<$ARGS[1]>>-price']
  150. subscription['<<ARGS[2]>>-discount'] = subscription['<<$ARGS[1]>>-discount']
  151. !! This one is always 1 because only type 1 subscriptions can be transferred, but making it "future proof"
  152. subscription['<<ARGS[2]>>-type'] = subscription['<<$ARGS[1]>>-type']
  153. subscription[$ARGS[0]] = 0
  154. killvar 'allowed'
  155. end
  156. end
  157. !! This is a separate "function" because the check is a bit long, and can change if we realise it isn't the best way to do it.
  158. !! Spoiler alert: It is not, I'm pretty sure.
  159. !!
  160. if $ARGS[0] = 'check_allowed_location':
  161. gs 'homes_properties_attr', 'get_property_attr', $ARGS[1]
  162. result = property['internet_enabled'] = 1
  163. killvar 'property'
  164. end
  165. !! $ARGS[1] - this is expected only if the location allows the use of subscription['free'], otherwise pass ''
  166. !! $ARGS[2] - Limitation code: : 'noporn', 'nocamshow'
  167. !! and on...can be up to 10 arguments.
  168. if $ARGS[0] = 'get_access':
  169. killvar 'access'
  170. $subsname = iif($ARGS[1] = '', func('homes_properties', 'get_property_code'), func('homes_properties', 'get_property_code', $ARGS[1]))
  171. if func('homes_properties', 'free_internet_available', $subsname) ! 0:
  172. $access['subscription'] = 'free'
  173. elseif $ARGS[1] = 'free':
  174. $access['subscription'] = 'free'
  175. elseif subscription[$subsname] = 1:
  176. $access['subscription'] = $subsname
  177. elseif subscription['mobile'] = 1:
  178. $access['subscription'] = 'mobile'
  179. elseif subscription['metered_mobile'] > 0:
  180. $access['subscription'] = 'metered_mobile'
  181. else
  182. $access = 'denied'
  183. end
  184. if $access ! 'denied':
  185. if subscription['<<$access[''subscription'']>>-type'] = 2: access['metered'] = 1
  186. count = ARRSIZE('ARGS')
  187. if count > 2:
  188. k = 2
  189. :loop_args
  190. access[$ARGS[k]] = 1
  191. k += 1
  192. if k < count: jump 'loop_args'
  193. end
  194. if access['noporn'] = 1: $access['noporn'] = 'You can''t search for porn on this computer'
  195. if access['nocamshow'] = 1: $access['nocamshow'] = 'You can''t do a cam show in this place'
  196. killvar 'count' & killvar 'k'
  197. end
  198. killvar 'subsname'
  199. end
  200. !! Adds a new limiation with a custom message
  201. !! If the limitation is already set, the existing message will be overwritten by the one passed here.
  202. !!
  203. !! $ARGS[1] - Limitation code: : 'noporn', 'nocamshow'
  204. !! $ARGS[2] - Custom message - optional
  205. if $ARGS[0] = 'add_limitation':
  206. access[$ARGS[1]] = 1
  207. $access[$ARGS[1]] = $ARGS[2]
  208. end
  209. !!Remove the limiation passed in $ARGS[1] and set's it's custom message to ''
  210. !!
  211. !! $ARGS[1] - Limitation code: : 'noporn', 'nocamshow'
  212. if $ARGS[0] = 'remove_limitation':
  213. access[$ARGS[1]] = 0
  214. $access[$ARGS[1]] = ''
  215. end
  216. !! Sets the message to limitation passed in $ARGS[1] if the limitation is active
  217. !!
  218. !! $ARGS[1] - Limitation code: : 'noporn', 'nocamshow'
  219. !! $ARGS[2] - Custom message
  220. if $ARGS[0] = 'set_limitation_message':
  221. if access[$ARGS[1]] = 1: $access[$ARGS[1]] = $ARGS[2]
  222. end
  223. !! Sets the date when the subscription will be cancelled if not paid.
  224. !!
  225. !! $ARGS[1] - the subscription name
  226. if ARGS[0] = 'set_suspension_date':
  227. temp_month = month
  228. if month = 2:
  229. if ((year mod 4 = 0) and (year mod 100 ! 0)) or (year mod 400 = 0):
  230. switchday = 29
  231. else
  232. switchday = 28
  233. end
  234. elseif month = 4 or month = 6 or month = 9 or month = 11:
  235. switchday = 30
  236. else
  237. switchday = 31
  238. end
  239. temp_day = day + 5
  240. if temp_day > switchday:
  241. temp_day -= switchday
  242. temp_month += 1
  243. end
  244. subscription[$ARGS[1]+'suspension_day'] = temp_day
  245. subscription[$ARGS[1]+'suspension_month'] = temp_month
  246. killvar 'temp_month'
  247. killvar 'temp_day'
  248. end
  249. !! Sending an sms on a metered contract
  250. if $ARGS[0] = 'send_sms':
  251. if subscription['metered_calls'] = 1: subscription['sms_limit'] -= 1
  252. end
  253. !! Using the internet - if metered, it lowers the minutes left
  254. !! $ARGS[1] - the name of the subscription used (this could be completely unnecessary, at this point there is an active
  255. !! $access which holds the subscription used.)
  256. !! ARGS[2] - the number of minutes used
  257. if $ARGS[0] = 'use_internet':
  258. if $subscription['<<$ARGS[1]>>-type'] = 'metered':
  259. subscription[$ARGS[1]] -= ARGS[2]
  260. if subscription[$ARGS[1]] < 0: subscription[$ARGS[1]] = 0
  261. end
  262. end
  263. !! Checks if Sveta still has access to the internet - use it while she is on the computer, mostly relevant for metered net,
  264. !! but monthly subscription can end abruptly too if she did not pay.
  265. !! Use it as a func() returns 1 or 0 based on the subscription[$ARGS[1]] value
  266. !!
  267. !! $ARGS[1] - the name of the subscription (this could be completely unnecessary, at this point there is an active
  268. !! $access which holds the subscription used.)
  269. if $ARGS[0] = 'check_internet_access':
  270. if subscription[$ARGS[1]] > 0: result = 1
  271. end
  272. --- internet_mobile ---------------------------------