internet_mobile.qsrc 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  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['<<$ARGS[1]>>-sms_limit'] += ARGS[3]
  48. if subscription['<<$ARGS[1]>>-type'] = 0: subscription['<<$ARGS[1]>>-type'] = 2
  49. end
  50. !! In case we decide that internet prices are different for different homes (mobile definitely should be)
  51. !! $ARGS[1] = The plan name - see on top, generally the name of a property or a mobile plan.
  52. !! ARGS[2] = Subscription fee - the price to be paid every month
  53. !! ARGS[3] = The remaining amount from the discount when it was more than the monthly fee. Optional value
  54. !! See valid values in set_home.qsrc
  55. if $ARGS[0] = 'buy_subscription':
  56. subscription[$ARGS[1]] = 1
  57. subscription['<<$ARGS[1]>>-date'] = day
  58. subscription['<<$ARGS[1]>>-price'] = ARGS[2]
  59. subscription['<<$ARGS[1]>>-discount'] = ARGS[3]
  60. if subscription['<<$ARGS[1]>>-type'] = 0: subscription['<<$ARGS[1]>>-type'] = 1
  61. end
  62. !! Nightly check called from cikl - check for subscription renewal and suspension.
  63. if $ARGS[0] = 'check_subscription_actions':
  64. !! Get a list of the properties and their attributes that the player rented:
  65. !! $property_code[], $property_name[], $property_display[], $property_status_display[], $property_type[]
  66. !! property_status[], property_construction_status[], property_is_renovated[], property_sales_price[],
  67. !! property_renovation_value[]
  68. gs 'homes_properties', 'get_accessible_properties', 'home'
  69. count = ARRSIZE('$property_name')
  70. if count > 0:
  71. i = 0
  72. :home_internet_subscription_loop
  73. if (property_status[i] = 1 or property_status[i] = 2) and subscription[$property_code[i]] = 1:
  74. if subscription['<<$property_code[i]>>-date'] = day: gs 'internet_mobile', 'renew_subscription', $property_code[i]
  75. if subscription['<<$property_code[i]>>-suspension_month'] = month and subscription['<<$property_code[i]>>-suspension_day'] >= day: gs 'internet_mobile', 'renew_subscription', $property_code[i]
  76. if subscription['<<$property_code[i]>>-suspension_month'] <= month and subscription['<<$property_code[i]>>-suspension_day'] < day: gs 'internet_mobile', 'suspend_subscription', $property_code[i]
  77. $result[j] = 'Internet Subscription for <<$property_display[i]>>: <<subscription[''<<$property_code[i]>>-contract_message'']>>'
  78. j += 1
  79. end
  80. i += 1
  81. if i < count: jump 'home_internet_subscription_loop'
  82. end
  83. gs 'homes_properties', 'clean_up_property_data'
  84. if subscription['mobile'] = 1:
  85. if subscription['mobile-date'] = day: gs 'internet_mobile', 'renew_subscription', 'mobile'
  86. if subscription['mobile-suspension_month'] = month and subscription['mobile-suspension_day'] >= day: gs 'internet_mobile', 'renew_subscription', 'mobile'
  87. if subscription['mobile-suspension_month'] <= month and subscription['mobile-suspension_day'] < day: gs 'internet_mobile', 'suspend_subscription', 'mobile'
  88. $result[j] = 'You Mobile Internet Subscription: <<subscription[''mobile-contract_message'']>>'
  89. j += 1
  90. end
  91. if subscription['monthly_calls'] = 1:
  92. if subscription['monthly_calls-date'] = day: gs 'internet_mobile', 'renew_subscription', 'monthly_calls'
  93. if subscription['monthly_calls-suspension_month'] = month and subscription['monthly_calls-suspension_day'] >= day: gs 'internet_mobile', 'renew_subscription', 'monthly_calls'
  94. if subscription['monthly_calls-suspension_month'] <= month and subscription['monthly_calls-suspension_day'] < day: gs 'internet_mobile', 'suspend_subscription', 'monthly_calls'
  95. $result[j] = 'You mobile contract: <<subscription[''monthly_calls-contract_message'']>>'
  96. j += 1
  97. end
  98. killvar 'count' & killvar 'i' & killvar 'j'
  99. end
  100. !! Cancelling a subscription (currently uused only for metered_calls and metered_mobile to clean them up when a monthly subscription
  101. !! is bought to repplace them)
  102. !! $ARGS[1] - subscription name
  103. if $ARGS[0] = 'cancel_subscription':
  104. subscription[$ARGS[1]] = 0
  105. subscription['<<$ARGS[1]>>-date'] = 0
  106. subscription['<<$ARGS[1]>>-sms_limit'] = 0
  107. subscription['<<$ARGS[1]>>-type'] = 0
  108. subscription['<<$ARGS[1]>>-price'] = 0
  109. subscription['<<$ARGS[1]>>-discount'] = 0
  110. end
  111. !! Renewing the subscription
  112. if $ARGS[0] = 'renew_subscription':
  113. renewfee = subscription['<<$ARGS[1]>>-price']
  114. acc_discount = subscription['<<$ARGS[1]>>-discount']
  115. app_discount = MIN(acc_discount,renewfee)
  116. finalfee = app_discount
  117. rem_discount = acc_discount-app_discount
  118. if karta+bankDebtLimit > finalfee:
  119. karta -= finalfee
  120. subscription['<<$ARGS[1]>>-discount'] = rem_discount
  121. 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.'
  122. $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.')
  123. if subscription['<<$ARGS[1]>>-suspension_month'] > 0: subscription['<<$ARGS[1]>>-suspension_month'] = 0
  124. if subscription['<<$ARGS[1]>>-suspension_day'] > 0: subscription['<<$ARGS[1]>>-suspension_day'] = 0
  125. else
  126. remainingday = 5
  127. if subscription['<<$ARGS[1]>>-suspension_day'] > 0: remainingday = subscription['<<$ARGS[1]>>-suspension_day'] - day
  128. 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.'
  129. $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.')
  130. gs 'internet_mobile', 'set_suspension_date', $ARGS[1]
  131. end
  132. killvar 'renewfee'
  133. killvar 'acc_discount'
  134. killvar 'app_discount'
  135. killvar 'finalfee'
  136. killvar 'rem_discount'
  137. killvar '$discounttext'
  138. killvar 'remainingday'
  139. end
  140. !! Transfer existing subscription from one home to another if Sveta is moving.
  141. if $ARGS[0] = 'transfer_subscription':
  142. allowed = func('internet_mobile', 'check_allowed_location', $ARGS[1])
  143. allowed = allowed and func('internet_mobile', 'check_allowed_location', $ARGS[2])
  144. if allowed:
  145. subscription[$ARGS[2]] = subscription[$ARGS[1]]
  146. subscription['<<ARGS[2]>>-date'] = subscription['<<$ARGS[1]>>-date']
  147. subscription['<<ARGS[2]>>-price'] = subscription['<<$ARGS[1]>>-price']
  148. subscription['<<ARGS[2]>>-discount'] = subscription['<<$ARGS[1]>>-discount']
  149. !! This one is always 1 because only type 1 subscriptions can be transferred, but making it "future proof"
  150. subscription['<<ARGS[2]>>-type'] = subscription['<<$ARGS[1]>>-type']
  151. subscription[$ARGS[0]] = 0
  152. killvar 'allowed'
  153. end
  154. end
  155. !! 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.
  156. !! Spoiler alert: It is not, I'm pretty sure.
  157. !!
  158. if $ARGS[0] = 'check_allowed_location':
  159. gs 'homes_properties_attr', 'get_property_attr', $ARGS[1]
  160. result = property['internet_enabled'] = 1
  161. killvar 'property'
  162. end
  163. !! $ARGS[1] - this is expected only if the location allows the use of subscription['free'], otherwise pass ''
  164. !! $ARGS[2] - Limitation code: : 'noporn', 'nocamshow'
  165. !! and on...can be up to 10 arguments.
  166. if $ARGS[0] = 'get_access':
  167. killvar 'access'
  168. $subsname = iif($ARGS[1] = '', func('homes_properties', 'get_property_code'), func('homes_properties', 'get_property_code', $ARGS[1]))
  169. if func('homes_properties', 'free_internet_available', $subsname) ! 0:
  170. $access['subscription'] = 'free'
  171. elseif $ARGS[1] = 'free':
  172. $access['subscription'] = 'free'
  173. elseif subscription[$subsname] = 1:
  174. $access['subscription'] = $subsname
  175. elseif subscription['mobile'] = 1:
  176. $access['subscription'] = 'mobile'
  177. elseif subscription['metered_mobile'] > 0:
  178. $access['subscription'] = 'metered_mobile'
  179. else
  180. $access = 'denied'
  181. end
  182. if $access ! 'denied':
  183. if subscription['<<$access[''subscription'']>>-type'] = 2: access['metered'] = 1
  184. count = ARRSIZE('ARGS')
  185. if count > 2:
  186. k = 2
  187. :loop_args
  188. access[$ARGS[k]] = 1
  189. k += 1
  190. if k < count: jump 'loop_args'
  191. end
  192. if access['noporn'] = 1: $access['noporn'] = 'You can''t search for porn on this computer'
  193. if access['nocamshow'] = 1: $access['nocamshow'] = 'You can''t do a cam show in this place'
  194. killvar 'count' & killvar 'k'
  195. end
  196. killvar 'subsname'
  197. end
  198. !! Adds a new limiation with a custom message
  199. !! If the limitation is already set, the existing message will be overwritten by the one passed here.
  200. !!
  201. !! $ARGS[1] - Limitation code: : 'noporn', 'nocamshow'
  202. !! $ARGS[2] - Custom message - optional
  203. if $ARGS[0] = 'add_limitation':
  204. access[$ARGS[1]] = 1
  205. $access[$ARGS[1]] = $ARGS[2]
  206. end
  207. !!Remove the limiation passed in $ARGS[1] and set's it's custom message to ''
  208. !!
  209. !! $ARGS[1] - Limitation code: : 'noporn', 'nocamshow'
  210. if $ARGS[0] = 'remove_limitation':
  211. access[$ARGS[1]] = 0
  212. $access[$ARGS[1]] = ''
  213. end
  214. !! Sets the message to limitation passed in $ARGS[1] if the limitation is active
  215. !!
  216. !! $ARGS[1] - Limitation code: : 'noporn', 'nocamshow'
  217. !! $ARGS[2] - Custom message
  218. if $ARGS[0] = 'set_limitation_message':
  219. if access[$ARGS[1]] = 1: $access[$ARGS[1]] = $ARGS[2]
  220. end
  221. !! Sets the date when the subscription will be cancelled if not paid.
  222. !!
  223. !! $ARGS[1] - the subscription name
  224. if $ARGS[0] = 'set_suspension_date':
  225. temp_month = month
  226. if month = 2:
  227. if ((year mod 4 = 0) and (year mod 100 ! 0)) or (year mod 400 = 0):
  228. switchday = 29
  229. else
  230. switchday = 28
  231. end
  232. elseif month = 4 or month = 6 or month = 9 or month = 11:
  233. switchday = 30
  234. else
  235. switchday = 31
  236. end
  237. temp_day = day + 5
  238. if temp_day > switchday:
  239. temp_day -= switchday
  240. temp_month += 1
  241. end
  242. subscription[$ARGS[1]+'suspension_day'] = temp_day
  243. subscription[$ARGS[1]+'suspension_month'] = temp_month
  244. killvar 'temp_month'
  245. killvar 'temp_day'
  246. end
  247. !! Sending an sms on a metered contract
  248. if $ARGS[0] = 'send_sms':
  249. if subscription['metered_calls'] = 1: subscription['sms_limit'] -= 1
  250. end
  251. !! Using the internet - if metered, it lowers the minutes left
  252. !! $ARGS[1] - the name of the subscription used (this could be completely unnecessary, at this point there is an active
  253. !! $access which holds the subscription used.)
  254. !! ARGS[2] - the number of minutes used
  255. if $ARGS[0] = 'use_internet':
  256. if $subscription['<<$ARGS[1]>>-type'] = 'metered':
  257. subscription[$ARGS[1]] -= ARGS[2]
  258. if subscription[$ARGS[1]] < 0: subscription[$ARGS[1]] = 0
  259. end
  260. end
  261. !! Checks if Sveta still has access to the internet - use it while she is on the computer, mostly relevant for metered net,
  262. !! but monthly subscription can end abruptly too if she did not pay.
  263. !! Use it as a func() returns 1 or 0 based on the subscription[$ARGS[1]] value
  264. !!
  265. !! $ARGS[1] - the name of the subscription (this could be completely unnecessary, at this point there is an active
  266. !! $access which holds the subscription used.)
  267. if $ARGS[0] = 'check_internet_access':
  268. if subscription[$ARGS[1]] > 0: result = 1
  269. end
  270. --- internet_mobile ---------------------------------