homes_properties.qsrc 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054
  1. # homes_properties
  2. if ARRSIZE('home_name') < 4:
  3. gs 'homes_properties_attr', ''
  4. end
  5. !! NOTE: The code will set the value to -1 if now property of correct type is found.
  6. !! The reason for this is to make sure that it will not run more than once because there are no properties of that type - like business properties right now -,
  7. !! but to also make it sure that if we add one or more, either in the main game, or via some mod, we won't have to worry about this, as it will calculate correctly.
  8. if accessible_property['available_for_rent_home_count'] = 0 or accessible_property['available_for_rent_business_count']:
  9. gs 'homes_properties', 'get_rentable_property_count'
  10. end
  11. !!-----------------------------------------------------------------------------------------------------
  12. !!
  13. !! General calls
  14. !!
  15. !!-----------------------------------------------------------------------------------------------------
  16. !! Call: `gs 'homes_properties', 'calculate_available_for_rent_property_count'`
  17. !! This calculate the value of accessible_property['available_for_rent_home_count'] and accessible_property['available_for_rent_business_count']
  18. !! Right now it is called once when the first call to this location finds that the value for these are 0.
  19. !! However, I added it as a named thing in case a mod adds new properties, especially business type properties, in which the mod should call this
  20. !! to recalculate the values to include the newly added properties.
  21. !!
  22. !! NOTE: The code will set the value to -1 if now property of correct type is found.
  23. !! The reason for this is to make sure that it will not run more than once because there are no properties of that type - like business properties right now -,
  24. !! but to also make it sure that if we add one or more, either in the main game, or via some mod, we won't have to worry about this, as it will calculate correctly.
  25. !!
  26. !! ARGS[1] - property type filter: 'home', 'business', 'all' or '' or missing
  27. if $ARGS[0] = 'calculate_rentable_property_count':
  28. count = ARRSIZE('$home_name')
  29. if count > 0:
  30. :get_rentable_property_count_loop
  31. gs 'homes_properties_attr', 'get_property_attr', $home_name[i]
  32. if ($ARGS[1] ! 'home' and INSTR($property['type'], 'residence') = 0) and property['rental']:
  33. accessible_property['rentable_business_count'] += 1
  34. elseif ($ARGS[1] ! 'business' and INSTR($property['type'], 'business') = 0) and property['rental']:
  35. accessible_property['rentable_rent_home_count'] += 1
  36. end
  37. i += 1
  38. if i < count: jump 'get_rentable_property_count_loop'
  39. end
  40. if accessible_property['rentable_business_count'] = 0: accessible_property['rentable_business_count'] = -1
  41. if accessible_property['rentable_home_count'] = 0: accessible_property['rentable_home_count'] = -1
  42. accessible_property['available_for_rent_home_count'] = accessible_property['rentable_home_count']
  43. accessible_property['available_for_rent_business_count'] = accessible_property['rentable_business_count']
  44. killvar 'count' & killvar 'i'
  45. end
  46. !! Set the current home for Sveta based on either the property code or the id - for backward compatibility or some mods
  47. !! $ARGS[1] - a string to identify the property.
  48. !! Possible values:
  49. !! A property code - 'city_apartment', 'village_cottage', etc.
  50. !! A location name - $loc passed
  51. !! An empty string - in this case ARGS[2] is mandatory
  52. !! A number as str - really should remove this
  53. !!
  54. if $ARGS[0] = 'set_home':
  55. $homepropcode = iif($ARGS[1] = '', $home_name[$loc], $home_name[$ARGS[1]])
  56. if $homepropcode ! '':
  57. killvar 'home'
  58. gs 'homes_properties_attr', 'get_property_attr', $homepropcode
  59. if INSTR($property['type'], 'residence') > 0:
  60. COPYARR 'home','property'
  61. $home['current'] = $property['code']
  62. if accessible_property[$home['current']] = 0: gs 'homes_properties', 'set_access', $home['current'], 1
  63. killvar 'property'
  64. end
  65. end
  66. end
  67. !! Call: `gs 'homes_properties', 'set_access', $ARGS[1], ARGS[2], ARGS[3]. ARGS[4]
  68. !!
  69. !! $ARGS[1]: the location for which the access is set
  70. !! Accepted values
  71. !! - property code -> 'city_apartment', 'parents_home'
  72. !! - a location -> 'bedrPar', 'koo2x' - A value that can shop up in $loc
  73. !! - empty strying -> '' - will work as if a location was passed, but will use the actual value of $loc
  74. !! - A number as str -> '1', '2' - this should be the id of the property
  75. !! NOTE: only added in case someone really want to use the old ids
  76. !! ARGS[2]: ownership type
  77. !! 0: no acces -> 'no access'
  78. !! 1: not owned but can live her - a rented property or living at some else''s place
  79. !! 2: owned -> 'owned'
  80. !! 3: owned and rented out -> 'tenants'
  81. !! ARGS[3]: construction status - optional
  82. !! 0: land only
  83. !! 1: foundation, frames built, utilities are connected
  84. !! 2: fully built
  85. !! ARGS[4]:renovation status - optional
  86. !! 0: not renovated
  87. !! 1: fully renovated
  88. if $ARGS[0] = 'set_access':
  89. $propcode = iif($ARGS[1] = '', $home_name[$loc], $home_name[$ARGS[1]])
  90. orig_status_code = accessible_property[$propcode]
  91. new_status_code = ARGS[2]
  92. if orig_status_code ! new_status_code:
  93. if $accessible_property[$propcode] = '' or accessible_property['<<$propcode>>-display'] = '' or accessible_property['<<$propcode>>-name'] = '':
  94. if $property['code'] ! $propcode:
  95. gs 'homes_properties_attr', 'get_property_attr', $propcode
  96. else
  97. nokill = 1
  98. end
  99. if ARGS[2] = 1 and property['rental'] = 0: new_status_code = 4
  100. accessible_property[$propcode] = new_status_code
  101. $accessible_property[$propcode] = $propcode
  102. $accessible_property['<<$propcode>>-name'] = $property['name']
  103. $accessible_property['<<$propcode>>-type'] = $property['type']
  104. if property['construction_needed'] = 1:
  105. accessible_property['<<$propcode>>-construction-status'] = ARGS[3]
  106. $accessible_property['<<$propcode>>-display'] = $property['display_<<ARGS[3]>>']
  107. else
  108. accessible_property['<<$propcode>>-construction-status'] = 2
  109. $accessible_property['<<$propcode>>-display'] = $property['display']
  110. end
  111. if INSTR($property['type'], 'residence') > 0: accessible_property['<<$propcode>>-is-home'] = 1
  112. accessible_property['<<$propcode>>-rental'] = property['rental']
  113. accessible_property['<<$propcode>>-renovated'] = ARGS[4]
  114. accessible_property['<<$propcode>>-sales-price'] = property['price']
  115. accessible_property['<<$propcode>>-rent'] = property['rent']
  116. end
  117. if accessible_property[$propcode] = 0:
  118. !! If this was the current home then killing it
  119. if $home['current'] = $propcode: killvar '$home'
  120. !! Updating home counts
  121. !! NOTE: Valid transitions: 1 -> 0, 2 -> 0, 4 -> 0
  122. if accessible_property['<<$propcode>>-is-home'] = 1:
  123. if orig_status_code = 1:
  124. accessible_property['rental_home_count'] -= 1
  125. accessible_property['available_for_rent_home_count'] += 1
  126. end
  127. if orig_status_code = 2: accessible_property['owned_home_count'] -= 1
  128. if accessible_property['<<$propcode>>-construction-status'] = 2: accessible_property['furnishable_home_count'] -= 1
  129. accessible_property['accessible_home_count'] -= 1
  130. end
  131. if accessible_property['accessible_home_count'] = 1:
  132. gs 'homes_properties', 'get_accessible_properties', 'home'
  133. if accessible_property['<<$ARGS[1]>>-is-home'] = 1: gs 'homes_properties', 'set_home', $property_code
  134. gs 'homes_properties', 'clean_up_property_data'
  135. end
  136. !! Property is rented
  137. elseif accessible_property[$propcode] = 1:
  138. !! Updating home counts
  139. !! NOTE: Only valid transition is 0 -> 1
  140. if accessible_property['<<$propcode>>-is-home'] = 1:
  141. accessible_property['rental_home_count'] += 1
  142. accessible_property['accessible_home_count'] += 1
  143. accessible_property['available_for_rent_home_count'] -= 1
  144. if accessible_property['<<$propcode>>-construction-status'] = 2: accessible_property['furnishable_home_count'] +=1
  145. end
  146. !! Property is owned
  147. elseif accessible_property[$propcode] = 2:
  148. !! Updating home counts
  149. !! NOTE: Valid transitions: 0 -> 2, 1 -> 2, 3-> 2
  150. if accessible_property['<<$propcode>>-is-home'] = 1:
  151. if orig_status_code = 0:
  152. accessible_property['accessible_home_count'] += 1
  153. elseif orig_status_code = 1:
  154. accessible_property['rental_home_count'] -= 1
  155. accessible_property['available_for_rent_home_count'] += 1
  156. elseif orig_status_code = 3:
  157. accessible_property['tenant_home_count'] -= 1
  158. accessible_property['<<$propcode>>-tenant-day'] = -1
  159. accessible_property['<<$propcode>>-tenant-month'] = -1
  160. if accessible_property['<<$propcode>>-construction-status'] = 2: accessible_property['furnishable_home_count'] += 1
  161. end
  162. if accessible_property['<<$propcode>>-construction-status'] = 2 and orig_status_code ! 1: accessible_property['furnishable_home_count'] += 1
  163. accessible_property['owned_home_count'] += 1
  164. end
  165. !! Property has tenants
  166. elseif accessible_property[$propcode] = 3:
  167. !! Updating home counts
  168. !! NOTE: Valid transitions: 2 -> 3
  169. if accessible_property['<<$propcode>>-is-home'] = 1:
  170. if $home['current'] = $propcode: killvar '$home'
  171. accessible_property['tenant_home_count'] += 1
  172. accessible_property['owned_home_count'] -= 1
  173. accessible_property['accessible_home_count'] -= 1
  174. if accessible_property['<<$propcode>>-construction-status'] = 2: accessible_property['furnishable_home_count'] -= 1
  175. end
  176. !! Property is just accessible
  177. elseif accessible_property[$propcode] = 4:
  178. !! Updating home counts
  179. !! NOTE: Valid transitions: 0 -> 4
  180. if accessible_property['<<$propcode>>-is-home'] = 1:
  181. accessible_property['accessible_home_count'] += 1
  182. end
  183. end
  184. if nokill = 0 : killvar 'property'
  185. end
  186. killvar 'propcode' & killvar 'orig_status_code' & killvar 'new_status_code' & killvar 'nokill'
  187. end
  188. !! Call: `func('homes_properties', 'can_live_here', $ARGS[1])`
  189. !! Return -1 if the location/property is a place where Sveta can live, whether he owns or rents the place,
  190. !! she is just allowed to live there: university dorm, parents home, the Meynold Household, etc.
  191. !!
  192. !! $ARGS[1]: the location for which the access is set
  193. !! Accepted values
  194. !! - property code -> 'city_apartment', 'parents_home'
  195. !! - a location -> 'bedrPar', 'koo2x' - A value that can shop up in $loc
  196. !! - empty strying -> '' - will work as if a location was passed, but will use the actual value of $loc
  197. !! - A number as str -> '1', '2' - this should be the id of the property
  198. !! NOTE: only added in case someone really want to use the old ids
  199. if $ARGS[0] = 'can_live_here':
  200. $canlivecode = iif($ARGS[1] = '', $home_name[$loc], $home_name[$ARGS[1]])
  201. result = accessible_property[$canlivecode] > 0 and accessible_property[$canlivecode] ! 3 and func('homes_properties', 'get_property_construction_status', $canlivecode) = 2
  202. killvar 'canlivecode'
  203. end
  204. !! Call: `func('homes_properties', 'is_current_home', $ARGS[1])`
  205. !! Returns 0 if the location/property is not the current home, otherwise -1.
  206. !!
  207. !! $ARGS[1]: the location for which the access is set
  208. !! Accepted values
  209. !! - property code -> 'city_apartment', 'parents_home'
  210. !! - a location -> 'bedrPar', 'koo2x' - A value that can shop up in $loc
  211. !! - empty strying -> '' - will work as if a location was passed, but will use the actual value of $loc
  212. !! - A number as str -> '1', '2' - this should be the id of the property
  213. !! NOTE: only added in case someone really want to use the old ids
  214. if $ARGS[0] = 'is_current_home':
  215. $currenthomecode = iif($ARGS[1] = '', $home_name[$loc], $home_name[$ARGS[1]])
  216. result = $home['current'] = $currenthomecode
  217. killvar 'currenthomecode'
  218. end
  219. !! Call: `func('homes_properties', 'is_at_a_home', $ARGS[1])`
  220. !! Tells if the location passed in $ARGS[1] or if empty the $loc is a home or not.
  221. !! If true then returns -1, if false 0.
  222. !!
  223. !! $ARGS[1]: the location for which the access is set
  224. !! Accepted values
  225. !! - property code -> 'city_apartment', 'parents_home'
  226. !! - a location -> 'bedrPar', 'koo2x' - A value that can shop up in $loc
  227. !! - empty strying -> '' - will work as if a location was passed, but will use the actual value of $loc
  228. !! - A number as str -> '1', '2' - this should be the id of the property
  229. !! NOTE: only added in case someone really want to use the old ids
  230. if $ARGS[0] = 'is_at_a_home':
  231. $isathomecode = iif($ARGS[1] = '', $home_name[$loc], $home_name[$ARGS[1]])
  232. result = accessible_property['<<$isathomecode>>-is-home'] = 1
  233. killvar 'isathomecode'
  234. end
  235. !! Call: `func('homes_properties', 'is_property_of_status', $ARGS[1])`
  236. !! Tells if the location passed in $ARGS[1] or if empty the $loc is of the queried status.
  237. !! If true then returns -1, if false 0.
  238. !!
  239. !! $ARGS[1]: the status that is checked
  240. !! Accepted values
  241. !! 'rented' -> is the property rented?
  242. !! 'owned' -> is the property is owned (bought by Sveta) ?
  243. !! 'tenants' -> are there tenants in the property?
  244. !! 'purchased' -> both 'owned' and 'tenants'
  245. !! 'blocked' -> is the property blocked?
  246. !! 'hasaccess' -> can Sveta use the property (without owning or renting it)?
  247. !!
  248. !! $ARGS[2]: the location for which the access is set
  249. !! Accepted values
  250. !! - property code -> 'city_apartment', 'parents_home'
  251. !! - a location -> 'bedrPar', 'koo2x' - A value that can shop up in $loc
  252. !! - empty strying -> '' - will work as if a location was passed, but will use the actual value of $loc
  253. !! - A number as str -> '1', '2' - this should be the id of the property
  254. !! NOTE: only added in case someone really want to use the old ids
  255. if $ARGS[0] = 'is_property_of_status':
  256. $propstatcode = iif($ARGS[2] = '', $home_name[$loc], $home_name[$ARGS[2]])
  257. if $ARGS[1] = 'rented':
  258. result = accessible_property[$propstatcode] = 1
  259. elseif $ARGS[1] = 'owned':
  260. result = accessible_property[$propstatcode] = 2
  261. elseif $ARGS[1] = 'tenants':
  262. result = accessible_property[$propstatcode] = 3
  263. elseif $ARGS[1] = 'blocked':
  264. result = accessible_property[$propstatcode] = 0
  265. elseif $ARGS[1] = 'hasacces':
  266. result = accessible_property[$propstatcode] = 4
  267. elseif $ARGS[1] = 'purchased':
  268. result = accessible_property[$propstatcode] = 2 or accessible_property[$propstatcode] = 3
  269. else
  270. result = 0
  271. end
  272. killvar 'propstatcode'
  273. end
  274. !! Call `func('homes_properties', 'get_property_code', $ARGS[1])
  275. !! Returns
  276. !!
  277. !! $ARGS[1]: the location for which the access is set
  278. !! Accepted values
  279. !! - property code -> 'city_apartment', 'parents_home'
  280. !! - a location -> 'bedrPar', 'koo2x' - A value that can shop up in $loc
  281. !! - empty strying -> '' - will work as if a location was passed, but will use the actual value of $loc
  282. !! - A number as str -> '1', '2' - this should be the id of the property
  283. !! NOTE: only added in case someone really want to use the old ids
  284. if $ARGS[0] = 'get_property_code':
  285. $result = iif($ARGS[1] = '', $home_name[$loc], $home_name[$ARGS[1]])
  286. end
  287. !!---------------------------------------------------------
  288. !! Home and Property Counts - FUNC()
  289. !!---------------------------------------------------------
  290. !! Call: `func('homes_properties', 'get_rented_property_count', $ARGS[1])`
  291. !! Returns the count of rented properties
  292. !!
  293. !! ARGS[1] - property type filter: 'home', 'business', 'all' or '' or missing
  294. if $ARGS[0] = 'get_rented_property_count':
  295. if $ARGS[1] = 'home':
  296. result = accessible_property['rental_home_count']
  297. elseif $ARGS[1] = 'business':
  298. result = accessible_property['rental_business_count']
  299. elseif $ARGS[1] = 'all' or $ARGS[1] = '':
  300. result = accessible_property['rental_home_count'] + accessible_property['rental_business_count']
  301. end
  302. end
  303. !! Call: `func('homes_properties', 'get_accessible_property_count', $ARGS[1])`
  304. !! Returns the count of accessible properties
  305. !!
  306. !! ARGS[1] - property type filter: 'home', 'business', 'all' or '' or missing
  307. if $ARGS[0] = 'get_accessible_property_count':
  308. if $ARGS[1] = 'home':
  309. result = accessible_property['accessible_home_count']
  310. elseif $ARGS[1] = 'business':
  311. result = accessible_property['accessible_business_count']
  312. elseif $ARGS[1] = 'all' or $ARGS[1] = '':
  313. result = accessible_property['accessible_home_count'] + accessible_property['accessible_business_count']
  314. end
  315. end
  316. !! Call: `func('homes_properties', 'get_rentable_property_count', $ARGS[1])`
  317. !! Returns the count of properties that can be rented (all properties with where property['rental'] = 1)
  318. !!
  319. !! ARGS[1] - property type filter: 'home', 'business', 'all' or '' or missing
  320. if $ARGS[0] = 'get_rentable_property_count':
  321. if $ARGS[1] = 'home':
  322. result = accessible_property['rentable_home_count']
  323. elseif $ARGS[1] = 'business':
  324. result = accessible_property['rentable_business_count']
  325. elseif $ARGS[1] = 'all' or $ARGS[1] = '':
  326. result = accessible_property['rentable_home_count'] + accessible_property['rentable_business_count']
  327. end
  328. end
  329. !! Call: `func('homes_properties', 'get_available_for_rent_property_count', $ARGS[1])`
  330. !! Returns the number of properties that are avaiable for rent - rentable properties that are not rented.
  331. !! ARGS[1] - property type filter: 'home', 'business', 'all' or '' or missing
  332. if $ARGS[0] = 'get_available_for_rent_property_count':
  333. if $ARGS[1] = 'home':
  334. result = accessible_property['available_for_rent_home_count']
  335. elseif $ARGS[1] = 'business':
  336. result = accessible_property['available_for_rent_business_count']
  337. elseif $ARGS[1] = 'all' or $ARGS[1] = '':
  338. result = accessible_property['available_for_rent_home_count'] + accessible_property['available_for_rent_business_count']
  339. end
  340. end
  341. !! Call: `func('homes_properties', 'furnishable_home_count', $ARGS[1])`
  342. !! Returns the count of furnishable properties (for shops)
  343. !!
  344. !! ARGS[1] - property type filter: 'home', 'business', 'all' or '' or missing
  345. if $ARGS[0] = 'get_furnishable_property_count':
  346. if $ARGS[1] = 'home':
  347. result = accessible_property['furnishable_home_count']
  348. elseif $ARGS[1] = 'business':
  349. result = accessible_property['furnishable_business_count']
  350. elseif $ARGS[1] = 'all' or $ARGS[1] = '':
  351. result = accessible_property['furnishable_home_count'] + accessible_property['furnishable_business_count']
  352. end
  353. end
  354. !!---------------------------------------------------------
  355. !! Get Properties and their values
  356. !!---------------------------------------------------------
  357. !! Use it as `gs`, creates a set of arrays that contains the relevant info for
  358. !! rented properties
  359. !!
  360. !! Returns: property_rent, property_days, $property_name, $property_display, $property_code
  361. !! $ARGS[1] - the property_type: 'home' - homes, 'business' - business properties, 'all' or '' - both types
  362. !! ARGS[2] - optional, if value is 1 then only $property_code[] is created.
  363. if $ARGS[0] = 'get_rented_properties':
  364. i = 0
  365. j = 0
  366. gs 'homes_properties', 'clean_up_property_data'
  367. count = ARRSIZE('accessible_property')
  368. if count > 0:
  369. :get_rented_properties_loop
  370. $getrentedpropcode = $accessible_property[i]
  371. if $home_name[$getrentedpropcode] ! '' and accessible_property[i] = 1:
  372. if ($ARGS[1] ! 'home' and accessible_property['<<$getrentedpropcode>>-is-home'] = 0) or ($ARGS[1] ! 'business' and accessible_property['<<$getrentedpropcode>>-is-home'] = 1):
  373. $property_code[j] = $getrentedpropcode
  374. if ARGS[2] = 0:
  375. $property_name[j] = $accessible_property['<<$getrentedpropcode>>-name']
  376. $property_display[j] = $accessible_property['<<$getrentedpropcode>>-display']
  377. property_days[j] = accessible_property['<<$getrentedpropcode>>-days-left']
  378. property_rent[j] = accessible_property['<<$getrentedpropcode>>-rent']
  379. end
  380. j += 1
  381. end
  382. end
  383. i += 1
  384. if i < count: jump 'get_rented_properties_loop'
  385. end
  386. killvar 'count' & killvar 'i' & killvar 'j' & killvar '$getrentedpropcode'
  387. end
  388. !! Use it as `gs`, creates a set of arrays that contains the relevant info for
  389. !! all owned (bought) properties.
  390. !!
  391. !! "Returns":
  392. !! $property_code[], $property_name[], $property_display[], $property_status_display[], $property_type[]
  393. !! property_status[], property_construction_status, property_is_renovated[], property_sales_price[],
  394. !! property_renovation_value[]
  395. !!
  396. !! $ARGS[1] - the class of the property: 'home' - returns only homes; 'business' - returns only business properties;
  397. !! 'all' or '' (or $ARGS[1] not passed) - returns both types
  398. !! IMPORTANT: If $ARGS[2] is passed, the $ARGS[1] will be ignored and will be treated as if it was 'all'/''.
  399. !! $ARGS[2] - optional, a property code or a location. If $ARGS[2] passed, only one property will be checked and returned.
  400. !!
  401. if $ARGS[0] = 'get_owned_properties':
  402. i = 0
  403. j = 0
  404. gs 'homes_properties', 'clean_up_property_data'
  405. $type = iif($ARGS[2] = '', $ARGS[1], 'all')
  406. count = iif($ARGS[2] = '', ARRSIZE('accessible_property'), 1)
  407. if count > 0:
  408. !!'<h3>Building Owned Properties List</h3>'
  409. !!'Count: <b><<count>></b>'
  410. :get_owned_properties_loop
  411. $getownedpropcode = iif( $ARGS[2] = '', $accessible_property[i], $ARGS[2] )
  412. !!' Index: <b><<i>></b> Code: <b><<$getownedpropcode>></b> Status: <b><<accessible_property[i]>></b>'
  413. if $home_name[$getownedpropcode] ! '' and (accessible_property[$getownedpropcode] = 2 or accessible_property[$getownedpropcode] = 3):
  414. !!' $ARGS[1]: <b><<$ARGS[i]>></b> Is home: <b><<accessible_property[''<<$getownedpropcode>>-is-home'']>></b>'
  415. if ($type ! 'home' and accessible_property['<<$getownedpropcode>>-is-home'] = 0) or ($type ! 'business' and accessible_property['<<$getownedpropcode>>-is-home'] = 1):
  416. $property_code[j] = $getownedpropcode
  417. $property_name[j] = $accessible_property['<<$getownedpropcode>>-name']
  418. if property['construction_needed'] = 1:
  419. $property_display[j] = iif($accessible_property[$getownedpropcode] = '', $property['display_0'], $accessible_property['<<$getownedpropcode>>-display'])
  420. else
  421. $property_display[j] = iif($accessible_property[$getownedpropcode] = '', $property['display'], $accessible_property['<<$getownedpropcode>>-display'])
  422. end
  423. $property_type[j] = $accessible_property['<<$getownedpropcode>>-type']
  424. if accessible_property[$getownedpropcode] = 3:
  425. $property_status_display[j] = 'A(n) <<$property_display[j]>> which is currently occupied by your tenants'
  426. else
  427. $property_status_display[j] = 'A(n) <<$property_display[j]>> ' + iif($accessible_property[$getownedpropcode] = $home['current'], 'where you currently live.', 'which is currently empty.')
  428. end
  429. property_status[j] = accessible_property[$getownedpropcode]
  430. property_construction_status[j] = accessible_property['<<$getownedpropcode>>-construction-status']
  431. property_is_renovated[j] = accessible_property['<<$getownedpropcode>>-renovated']
  432. property_sales_price[j] = accessible_property['<<$getownedpropcode>>-sales-price']
  433. property_renovation_value[j] = accessible_property['<<$getownedpropcode>>-renovation-value']
  434. j += 1
  435. end
  436. end
  437. i += 1
  438. if i < count: jump 'get_owned_properties_loop'
  439. end
  440. killvar 'count' & killvar 'i' & killvar 'j' & killvar 'getownedpropcode'
  441. end
  442. !! Use it as `gs`, creates a set of arrays that contains the relevant info for
  443. !! all accessible (rented, bought or just allowed to stay) properties.
  444. !!
  445. !! "Returns":
  446. !! $property_code[], $property_name[], $property_display[], $property_status_display[], $property_type[]
  447. !! property_status[], property_construction_status[], property_is_renovated[], property_renovation_value[]
  448. !!
  449. !! $ARGS[1] - the class of the property: 'home' - returns only homes; 'business' - returns only business properties; '' - returns both types
  450. if $ARGS[0] = 'get_accessible_properties':
  451. i = 0
  452. j = 0
  453. gs 'homes_properties', 'clean_up_property_data'
  454. count = ARRSIZE('accessible_property')
  455. if count > 0:
  456. :get_accessible_properties_loop
  457. $getaccessiblepropcode = $accessible_property[i]
  458. if $home_name[$getaccessiblepropcode] ! '' and accessible_property[$getaccessiblepropcode] > 0:
  459. if ($ARGS[1] ! 'home' and accessible_property['<<$getaccessiblepropcode>>-is-home'] = 0) or ($ARGS[1] ! 'business' and accessible_property['<<$getaccessiblepropcode>>-is-home'] = 1):
  460. $property_code[j] = $getaccessiblepropcode
  461. $property_name[j] = $accessible_property['<<$getaccessiblepropcode>>-name']
  462. if property['construction_needed'] = 1:
  463. $property_display[j] = iif($accessible_property[$getaccessiblepropcode] = '', $property['display_0'], $accessible_property['<<$getaccessiblepropcode>>-display'])
  464. else
  465. $property_display[j] = iif($accessible_property[$getaccessiblepropcode] = '', $property['display'], $accessible_property['<<$getaccessiblepropcode>>-display'])
  466. end
  467. if accessible_property[$getaccessiblepropcode] = 1:
  468. $property_status_display[j] = 'You rent the <<$property_display[j]>> '+iif($accessible_property[$getaccessiblepropcode] = $home['current'], 'where you currently live.', 'which is currently empty.')
  469. elseif accessible_property[$getaccessiblepropcode] = 2:
  470. $property_status_display[j] = 'You own the <<$property_display[j]>> ' + iif($accessible_property[$getaccessiblepropcode] = $home['current'], 'where you currently live.', 'which is currently empty.')
  471. elseif accessible_property[$getaccessiblepropcode] = 3:
  472. $property_status_display[j] = 'You own the <<$property_display[j]>> which is currently occupied by your tenants'
  473. else
  474. $property_status_display[j] = 'You can stay at the <<$property_display[j]>> which is currently occupied by your tenants'
  475. end
  476. property_status[j] = accessible_property[$getaccessiblepropcode]
  477. property_construction_status[j] = accessible_property['<<$getaccessiblepropcode>>-construction-status']
  478. property_is_renovated[j] = accessible_property['<<$getaccessiblepropcode>>-renovated']
  479. property_type[j] = accessible_property['<<$getaccessiblepropcode>>-type']
  480. j += 1
  481. end
  482. end
  483. i += 1
  484. if i < count: jump 'get_accessible_properties_loop'
  485. end
  486. killvar 'count' & killvar 'i' & killvar 'j' & killvar 'getaccessiblepropcode'
  487. end
  488. !! Use it as `gs`, creates a set of arrays that contains the relevant info for
  489. !! all properties that are for sale.
  490. !!
  491. !! "Returns":
  492. !! $property_code[], $property_name[], $property_display[], $property_type[]
  493. !! property_construction_status,property_is_renovated[], property_sales_price[], property_renovation_value[]
  494. !!
  495. !! $ARGS[1] - the class of the property: 'home' - returns only homes; 'business' - returns only business properties; '' - returns both types
  496. if $ARGS[0] = 'get_properties_for_sale':
  497. i = 0
  498. j = 0
  499. gs 'homes_properties', 'clean_up_property_data'
  500. count = ARRSIZE('home_name')
  501. if count > 0:
  502. :get_properties_for_sale_loop
  503. $getforsalespropcode = $home_name[i]
  504. if $getforsalespropcode ! '' and checked_homes[$getforsalespropcode] = 0 and accessible_property[$getforsalespropcode] < 2:
  505. checked_homes[$getforsalespropcode] = 1
  506. if accessible_property[$getforsalespropcode] = '':
  507. gs 'homes_properties_attr', 'get_property_attr', $getforsalespropcode
  508. end
  509. ishome = iif(accessible_property[$getforsalespropcode] = '', INSTR($property['type'], 'residence') > 0, INSTR($accessible_property['<<$getforsalespropcode>>-type'], 'residence') > 0 )
  510. hasprice = iif($accessible_property[$getforsalespropcode] = '', property['price'] > 0, accessible_property['<<$getforsalespropcode>>-sales-price'] > 0)
  511. if (($ARGS[1] ! 'home' and ishome = 0) or ($ARGS[1] ! 'business' and ishome)) and hasprice:
  512. $property_code[j] = $getforsalespropcode
  513. $property_name[j] = iif($accessible_property[$getforsalespropcode] = '', $property['name'], $accessible_property['<<$getforsalespropcode>>-name'])
  514. $property_type[j] = iif($accessible_property[$getforsalespropcode] = '', $property['type'], $accessible_property['<<$getforsalespropcode>>-type'])
  515. if property['construction_needed'] = 1:
  516. $property_display[j] = iif($accessible_property[$getforsalespropcode] = '', $property['display_0'], $accessible_property['<<$getforsalespropcode>>-display'])
  517. else
  518. $property_display[j] = iif($accessible_property[$getforsalespropcode] = '', $property['display'], $accessible_property['<<$getforsalespropcode>>-display'])
  519. end
  520. property_is_rented[j] = accessible_property[$getforsalespropcode] = 1
  521. property_construction_status[j] = iif($accessible_property[$getforsalespropcode] = '', 0, accessible_property['<<$getforsalespropcode>>-construction-status'])
  522. property_is_renovated[j] = iif($accessible_property[$getforsalespropcode] = '', 0, accessible_property['<<$getforsalespropcode>>-renovated'])
  523. property_sales_price[j] = iif($accessible_property[$getforsalespropcode] = '', property['price'], accessible_property['<<$getforsalespropcode>>-sales-price'])
  524. j += 1
  525. end
  526. killvar 'property'
  527. end
  528. i += 1
  529. if i < count: jump 'get_properties_for_sale_loop'
  530. end
  531. killvar 'count' & killvar 'i' & killvar 'j' & killvar 'propcode' & killvar 'checked_homes' & killvar 'ishome' & killvar 'hasprice'
  532. end
  533. !! Use it as `gs`, creates a set of arrays that contains the relevant info for
  534. !! all properties that the player can rent.
  535. !!
  536. !! "Returns":
  537. !! $property_code[], $property_name[], $property_display[]
  538. !! property_days[], property_rent[]
  539. !!
  540. !! $ARGS[1] - the class of the property: 'home' - returns only homes; 'business' - returns only business properties; '' - returns both types
  541. if $ARGS[0] = 'get_properties_for_rent':
  542. i = 0
  543. j = 0
  544. gs 'homes_properties', 'clean_up_property_data'
  545. count = ARRSIZE('home_name')
  546. if count > 0:
  547. :get_rented_properties_loop
  548. $getpropforrentcode = $home_name[i]
  549. if $getpropforrentcode ! '' and checked_homes[$getpropforrentcode] = 0 and accessible_property[$getpropforrentcode] = 0:
  550. checked_homes[$getpropforrentcode] = 1
  551. if accessible_property[$getpropforrentcode] = '': gs 'homes_properties_attr', 'get_property_attr', $getpropforrentcode
  552. ishome = iif($accessible_property[$getpropforrentcode] = '', INSTR($property['type'], 'residence') > 1, INSTR($accessible_property['<<$getpropforrentcode>>-type'], 'residence') > 1 )
  553. isrental = iif($accessible_property[$getpropforrentcode] = '', property['rental'] = 1, accessible_property['<<$getpropforrentcode>>-rental'] = 1 )
  554. if (($ARGS[1] ! 'home' and ishome = 0) or ($ARGS[1] ! 'business' and ishome)) and isrental:
  555. $property_code[j] = $getpropforrentcode
  556. $property_name[j] = iif($accessible_property[$getpropforrentcode] = '', $property['name'], $accessible_property['<<$getpropforrentcode>>-name'])
  557. if property['construction_needed'] = 1:
  558. $property_display[j] = iif($accessible_property[$getpropforrentcode] = '', $property['display_0'], $accessible_property['<<$getpropforrentcode>>-display'])
  559. else
  560. $property_display[j] = iif($accessible_property[$getpropforrentcode] = '', $property['display'], $accessible_property['<<$getpropforrentcode>>-display'])
  561. end
  562. property_days[j] = iif($accessible_property[$getpropforrentcode] = '', 0, accessible_property['<<$getpropforrentcode>>-days-left'])
  563. property_rent[j] = iif($accessible_property[$getpropforrentcode] = '', property['rent'], accessible_property['<<$getpropforrentcode>>-rent'])
  564. j += 1
  565. end
  566. killvar 'property'
  567. end
  568. i += 1
  569. if i < count: jump 'get_rented_properties_loop'
  570. end
  571. killvar 'checked_homes'
  572. killvar 'count' & killvar 'i' & killvar 'j' & killvar '$getpropforrentcode' & killvar 'ishome' & killvar 'isrental'
  573. end
  574. !! Use it as `gs`, creates a set of arrays that contains the relevant info for
  575. !! all properties for which the player can buy an internet subscription
  576. !!
  577. !! "Returns":
  578. !! $property_code[], $property_name[], $property_status[], property__is_current_home[]
  579. !! $property_stat values: 'rented', 'owned', 'tenants', 'no access'
  580. !!
  581. !! $ARGS[1] - the class of the property: 'home' - returns only homes; 'business' - returns only business properties; '' - returns both types
  582. !! $ARGS[2] - '' or 'hasaccess'. 'hasaccess' returns only those internet enabled properties that are purchased or rented by Sveta
  583. !! including ones with tenants.
  584. if $ARGS[0] = 'get_internet_enabled_properties':
  585. i = 0
  586. j = 0
  587. gs 'homes_properties', 'clean_up_property_data'
  588. count = ARRSIZE('home_name')
  589. if count > 0:
  590. :get_internet_enabled_properties_loop
  591. $getnetenabledprocode = $home_name[i]
  592. if checked_homes[$getnetenabledprocode] = 0:
  593. checked_homes[$getnetenabledprocode] = 1
  594. gs 'homes_properties_attr', 'get_property_attr', $getnetenabledprocode
  595. accesscheck = ($ARGS[2] = 'hasaccess' and accessible_property[$getnetenabledprocode] ! 0 and accessible_property[$getnetenabledprocode] ! 4) or $ARGS[2] = ''
  596. typecheck = (($ARGS[1] ! 'home' and INSTR($property['type'], 'residence') = 0) or ($ARGS[1] ! 'business' and INSTR($property['type'], 'residence') > 0))
  597. if accesscheck and typecheck and property['internet_enabled']:
  598. $property_name[j] = $property['name']
  599. $property_code[j] = $getnetenabledprocode
  600. if accessible_property[$getnetenabledprocode] = 0:
  601. $property_status[j] = 'no access'
  602. elseif accessible_property[$getnetenabledprocode] = 1:
  603. $property_status[j] = 'rented'
  604. elseif accessible_property[$getnetenabledprocode] = 2:
  605. $property_status[j] = 'owned'
  606. elseif accessible_property[$getnetenabledprocode] = 3:
  607. $property_status[j] = 'tenants'
  608. end
  609. property__is_current_home[j] = $home['current'] = $getnetenabledprocode
  610. j += 1
  611. killvar 'accesscheck' & killvar 'typecheck'
  612. end
  613. killvar 'property'
  614. end
  615. i += 1
  616. if i < count: jump 'get_internet_enabled_properties_loop'
  617. end
  618. killvar 'count' & killvar 'i' & killvar 'j' & killvar 'propcode'
  619. end
  620. !! Call after using any of the above calls to run killvar on all the temporary variables
  621. if $ARGS[0] = 'clean_up_property_data':
  622. killvar 'property_rent' & killvar 'property_days' & killvar 'property_code' & killvar 'property_status'
  623. killvar 'property_name' & killvar 'property_display' & killvar 'property_type' & killvar 'property_status_display'
  624. killvar 'property_is_rented' & killvar 'property_construction_status' & killvar 'property_is_renovated'
  625. killvar 'property_sales_price' & killvar 'property_renovation_value' & killvar 'property__is_current_home'
  626. end
  627. !!---------------------------------------------------------
  628. !! Give and block access to properties - use these if the
  629. !! property is not bought or rented.
  630. !! Parents home[], Meynold household, Grandparents house, etc.
  631. !!---------------------------------------------------------
  632. !! $ARGS[1]: the location for which the access is set
  633. !! Accepted values
  634. !! - property code -> 'city_apartment', 'parents_home'
  635. !! - a location -> 'bedrPar', 'koo2x' - A value that can shop up in $loc
  636. !! - empty strying -> '' - will work as if a location was passed, but will use the actual value of $loc
  637. !! - A number as str -> '1', '2' - this should be the id of the property
  638. !! NOTE: only added in case someone really want to use the old ids
  639. if $ARGS[0] = 'give_access':
  640. $accesscode = iif($ARGS[1] = '', $home_name[$loc], $ARGS[1])
  641. gs 'homes_properties', 'set_access', $accesscode, 1
  642. if accessible_property['accessible_home_count'] = 1 and accessible_property['<<$accesscode>>-is-home'] = 1 and $home['current'] = '': gs 'homes_properties', 'set_home', $accesscode
  643. killvar '$accesscode'
  644. end
  645. !! $ARGS[1]: the location for which the access is set
  646. !! Accepted values
  647. !! - property code -> 'city_apartment', 'parents_home'
  648. !! - a location -> 'bedrPar', 'koo2x' - A value that can shop up in $loc
  649. !! - empty strying -> '' - will work as if a location was passed, but will use the actual value of $loc
  650. !! - A number as str -> '1', '2' - this should be the id of the property
  651. !! NOTE: only added in case someone really want to use the old ids
  652. if $ARGS[0] = 'block_access':
  653. $blockcode = iif($ARGS[1] = '', $home_name[$loc], $ARGS[1])
  654. gs 'homes_properties', 'set_access', $blockcode, 0
  655. if accessible_property['accessible_home_count'] = 1 and $home['current'] = '':
  656. gs 'homes_properties', 'get_accessible_properties', 'home'
  657. if accessible_property['<<$property_code>>-is-home'] = 1: gs 'homes_properties', 'set_home', $property_code
  658. gs 'homes_properties', 'clean_up_property_data'
  659. end
  660. killvar 'blockcode'
  661. end
  662. !! Call: `func('homes_properties', 'has_access', $ARGS[1])`
  663. !! Returns 0 if Sveta has no access to the property and 1 or -1 if she has access, irrelecant of the type of access
  664. !! - owns the property, rents the property or allowed to stay at the property
  665. !!
  666. !! $ARGS[1]: the location for which the access is set
  667. !! Accepted values
  668. !! - property code -> 'city_apartment', 'parents_home'
  669. !! - a location -> 'bedrPar', 'koo2x' - A value that can shop up in $loc
  670. !! - empty strying -> '' - will work as if a location was passed, but will use the actual value of $loc
  671. !! - A number as str -> '1', '2' - this should be the id of the property
  672. !! NOTE: only added in case someone really want to use the old ids
  673. if $ARGS[0] = 'has_access':
  674. $hasaccesscode = iif($ARGS[1] = '', $home_name[$loc], $ARGS[1])
  675. result = accessible_property[$hasaccesscode] > 0 and accessible_property[$hasaccesscode] ! 3
  676. killvar 'hasaccesscode'
  677. end
  678. !!---------------------------------------------------------
  679. !! Buy, rent out and sell properties
  680. !!---------------------------------------------------------
  681. !! Call: `gs 'homes_properties', 'get_property_sales_info', $ARGS[1]
  682. !! Creates $property_display and property_sales_price for a specific property.
  683. !!
  684. !! $ARGS[1] = the code of the property, e.g. 'city_apartment'
  685. if $ARGS[0] = 'get_property_sales_info':
  686. if $accessible_property[$ARGS[1]] = '' : gs 'homes_properties_attr', 'get_property_attr', $ARGS[1]
  687. if property['construction_needed'] = 1:
  688. $property_display = iif($accessible_property[$ARGS[1]] = '', $property['display_0'], $accessible_property['<<$ARGS[1]>>-display'])
  689. else
  690. $property_display = iif($accessible_property[$ARGS[1]] = '', $property['display'], $accessible_property['<<$ARGS[1]>>-display'])
  691. end
  692. property_sales_price = iif($accessible_property[$ARGS[1]] = '', property['price'], accessible_property['<<$ARGS[1]>>-sales-price'])
  693. killvar 'property'
  694. end
  695. !! Call: `gs 'homes_properties', 'buy_property', $ARGS[1], ARGS[2]
  696. !! Makes all the necessary changes to the property status, access, etc.
  697. !! and stores the new sales value for future reference in case Sveta sells the property.
  698. !!
  699. !! $ARGS[1] = the code of the property, e.g. 'city_apartment'
  700. !! ARGS[2] = the final sales price in the transaction
  701. if $ARGS[0] = 'buy_property':
  702. gs 'homes_properties', 'set_access', $ARGS[1], 2
  703. accessible_property['<<$ARGS[1]>>-sales-price'] = ARGS[2]
  704. end
  705. !! Call: `gs 'homes_properties', 'sell_property', $ARGS[1], ARGS[2]
  706. !! Makes all the necessary changes to the property status, access, etc.
  707. !! and stores the new sales value for future reference in case Sveta buys the property back.
  708. !!
  709. !! $ARGS[1] = the code name of the property, e.g. 'city_apartment'
  710. !! ARGS[2] = the final sales price in the transaction
  711. if $ARGS[0] = 'sell_property':
  712. gs 'homes_properties', 'set_access',$ARGS[1], 0
  713. accessible_property['<<$ARGS[1]>>-sales-price'] = ARGS[2]
  714. end
  715. !! Call: gs 'homes_properties', 'tenants_move_in', $ARGS[1], ARGS[2], ARGS[3]
  716. !! Makes the necessary changes to the property to track the tenants.
  717. !!
  718. !! $ARGS[1] - the property code of the home that is rented to tenants
  719. !! ARGS[2] - the tenancy end day
  720. !! ARGS[3] - the tenancy end month
  721. if $ARGS[0] = 'tenants_move_in':
  722. gs 'homes_properties', 'set_access', $ARGS[1], 3
  723. accessible_property['<<$ARGS[1]>>-tenant-day'] = ARGS[2]
  724. accessible_property['<<$ARGS[1]>>-tenant-month'] = ARGS[3]
  725. if $home['current'] = '' and accessible_property['accessible_home_count'] = 1:
  726. gs 'homes_properties', 'get_accessible_properties', 'home'
  727. if accessible_property['<<$property_code>>-is-home']: gs 'homes_properties', 'set_home', $property_code
  728. gs 'homes_properties', 'clean_up_property_data'
  729. end
  730. end
  731. !! Call: gs 'homes_properties', 'tenants_move_out', $ARGS[1]
  732. !! Makes the necessary changes to the property to track the tenants.
  733. !!
  734. !! $ARGS[1] - the property code of the home that was rented to tenants
  735. if $ARGS[0] = 'tenants_move_out':
  736. if $ARGS[1] ! '':
  737. gs 'homes_properties', 'set_access', $ARGS[1], 2
  738. if $home['current'] = '' and accessible_property['<<$ARGS[1]>>-is-home'] = 1 and accessible_property['accessible_home_count'] = 1: gs 'homes_properties', 'set_home', $ARGS[1]
  739. end
  740. end
  741. !! Call: `func('homes_properties', 'tenant_move_out_check')`
  742. !! Returns an array of messages for the tenants that have moved out.
  743. !! Runs every night and sees if any tenants are moving out
  744. !! If the tenants are moving out, the property becomes accessible again
  745. !!
  746. if $ARGS[0] = 'tenant_move_out_check':
  747. count = ARRSIZE('accessible_property')
  748. i = 0
  749. j = 0
  750. if count > 0:
  751. :tenantloop
  752. $tenantcode = $accessible_property[i]
  753. if $home_name[$tenantcode] ! '' and accessible_property[$tenantcode] = 3:
  754. if accessible_property['<<$tenantcode>>-tenant-day'] = day and accessible_property['<<$tenantcode>>-tenant-month'] = month:
  755. gs 'homes_properties', 'set_access', $tenantcode, 2
  756. $result[j] = '<b><font color="red">Your tenants have moved out from your <<$accessible_property[''<<$tenantcode>>-display'']>> and your apartment is now vacant.</font></b>'
  757. j += 1
  758. end
  759. end
  760. i += 1
  761. killvar 'property'
  762. if i < count: jump 'tenantloop'
  763. end
  764. if accessible_property['accessible_home_count'] = 1 and $home['current'] = '':
  765. gs 'homes_properties', 'get_accessible_properties', 'home'
  766. if accessible_property['<<$property_code>>-is-home'] = 1: gs 'homes_properties', 'set_home', $property_code
  767. gs 'homes_properties', 'clean_up_property_data'
  768. end
  769. killvar 'i' && killvar 'j' && killvar 'count'
  770. end
  771. !! Call: `func('homes_properties', 'get_property_sales_price', $ARGS[1])`
  772. !! Returns the actual sales price of the property
  773. !!
  774. !! $ARGS[1] - property code
  775. if $ARGS[0] = 'get_property_sales_price':
  776. if accessible_property[$ARGS[1]] ! '':
  777. result = accessible_property['<<$ARGS[1]>>-sales-price']
  778. else
  779. gs 'homes_properties_attr', 'get_property_attr', $ARGS[1]
  780. result = property['price']
  781. killvar 'property'
  782. end
  783. end
  784. !!---------------------------------------------------------
  785. !! Create, Update and Cancel Rents and related values
  786. !!---------------------------------------------------------
  787. !! Call: `gs 'homes_properties', 'rent_property'`, $ARGS[1], ARGS[2]`
  788. !! Rents a property. For now with immediate effect.
  789. !!
  790. !! $ARGS[1] = the code name of the property, e.g. 'city_apartment'
  791. !! ARGS[2] = the number of days the rent is paid for, optional
  792. if $ARGS[0] = 'rent_property':
  793. gs 'homes_properties', 'set_access', $ARGS[1], 1
  794. gs 'homes_properties', 'set_rent_days', $ARGS[1], ARGS[2]
  795. end
  796. !! Call: `gs 'homes_properties', 'cancel_rent'`, $ARGS[1]`
  797. !! Cancels the rent. For now with immediate effect.
  798. !!
  799. !! $ARGS[1] = the code name of the property, e.g. 'city_apartment'
  800. if $ARGS[0] = 'cancel_rent':
  801. gs 'homes_properties', 'set_access', $ARGS[1], 0
  802. gs 'homes_properties', 'set_rent_days', $ARGS[1], -1
  803. if accessible_property['accessible_home_count'] = 1 and $home['current'] = '':
  804. gs 'homes_properties', 'get_accessible_properties', 'home'
  805. if accessible_property['<<$ARGS[1]>>-is-home'] = 1: gs 'homes_properties', 'set_home', $ARGS[1]
  806. gs 'homes_properties', 'clean_up_property_data'
  807. end
  808. end
  809. !! Call: `gs 'homes_properties', 'cancel_rent'`, $ARGS[1]`, $ARGS[2]
  810. !!
  811. !! $ARGS[1] - property code of the rental
  812. !! $ARGS[2] - payment method: 'card' or 'cash'
  813. if $ARGS[0] = 'pay_rent':
  814. if $ARGS[2] = 'card':
  815. karta -= accessible_property['<<$ARGS[1]>>-rent']
  816. elseif $ARGS[2] = 'cash':
  817. money -= accessible_property['<<$ARGS[1]>>-rent']
  818. end
  819. gs 'homes_properties', 'add_rent_days', $ARGS[1]
  820. end
  821. !! Call: `gs 'homes_properties', 'add_rent_days', $ARGS[1], ARGS[2]`
  822. !! Add the number of days passed to the remaining rental days.
  823. !!
  824. !! $ARGS[1] = the code name of the property, e.g. 'city_apartment'
  825. !! ARGS[2] - the number of days to add (can be negative).
  826. !! if the value is 0 then the code will add the number of days equal to the length of the month
  827. if $ARGS[0] = 'add_rent_days':
  828. if ARGS[2] = 0:
  829. accessible_property['<<$ARGS[1]>>-days-left'] += func( 'homes_properties', 'days_in_month')
  830. else
  831. accessible_property['<<$ARGS[1]>>-days-left'] += ARGS[2]
  832. end
  833. end
  834. !! Call: `gs 'homes_properties', 'set_rent_days', $ARGS[1], ARGS[2]`
  835. !! Sets the remaining rental days to a specific amount.
  836. !!
  837. !! $ARGS[1] - the code name of the property, e.g. 'city_apartment'
  838. !! ARGS[2] - the number of days to set to - it is an absolute value
  839. !! If the value is zero, it will be set to the length of the month (ie. 28,29,30 or 31 days)
  840. if $ARGS[0] = 'set_rent_days':
  841. if ARGS[2] = 0:
  842. accessible_property['<<$ARGS[1]>>-days-left'] = func( 'homes_properties', 'days_in_month')
  843. else
  844. accessible_property['<<$ARGS[1]>>-days-left'] = ARGS[2]
  845. end
  846. end
  847. !! Call: `gs 'homes_properties', 'set_rent_amount', $ARGS[1], ARGS[2]`
  848. !! Sets the monthly rent of the property
  849. !!
  850. !! $ARGS[1] - property code
  851. !! ARGS[2] - the new rent amount
  852. if $ARGS[0] = 'set_rent_amount':
  853. if accessible_property['<<$ARGS[1]>>-rental'] and ARGS[2] >= 0 : accessible_property['<<$ARGS[1]>>-rent'] = ARGS[2]
  854. end
  855. !! Call: `func('homes_properties', 'get_rent_days', $RGS{1])`
  856. !! Returns the remaining rent days for the property
  857. !!
  858. !! $ARGS[1] = the code name of the property, e.g. 'city_apartment'
  859. if $ARGS[0] = 'get_rent_days':
  860. result = accessible_property['<<$ARGS[1]>>-days-left']
  861. end
  862. !! Call: `func('homes_properties', 'get_rent_amount', $ARGS[1])`
  863. !! Returns the monthly rent of the property
  864. !!
  865. !! $ARGS[1] - property code
  866. if $ARGS[0] = 'get_rent_amount':
  867. if $ARGS[1] ! '':
  868. result = accessible_property['<<$ARGS[1]>>-rent']
  869. else
  870. gs 'homes_properties_attr', 'get_property_attr', $ARGS[1]
  871. result = property['rent']
  872. killvar 'property'
  873. end
  874. end
  875. !! Call: `gs 'homes_properties', 'progress_property_rent_time'`
  876. !! Decreases the number of days left on the lease.
  877. !!
  878. if $ARGS[0] = 'progress_property_rent_time':
  879. gs 'homes_properties', 'get_rented_properties', 1
  880. count = ARRSIZE('property_code')
  881. i = 0
  882. if count > 0:
  883. :progress_property_rent_time_loop
  884. gs 'homes_properties', 'add_rent_days', $property_code[i], -1
  885. i += 1
  886. if i < count: jump 'progress_property_rent_time_loop'
  887. end
  888. killvar 'property_code' & killvar 'count' & killvar 'i'
  889. end
  890. !! Call: `func('homes_properties', 'days_in_month'}`
  891. !! Returns the rent the number of days in a give month.
  892. !!
  893. if $ARGS[0] = 'days_in_month':
  894. if month = 1 or month = 3 or month = 5 or month = 7 or month = 8 or month = 10 or month = 12:
  895. result = 31
  896. elseif month = 2:
  897. if ((year mod 4 = 0) and (year mod 100 ! 0)) or (year mod 400 = 0):
  898. result = 29
  899. else
  900. result = 28
  901. end
  902. else
  903. result = 30
  904. end
  905. end
  906. !!---------------------------------------------------------
  907. !! Construction and Renovation of Properties
  908. !!---------------------------------------------------------
  909. !! Call: `func('homes_properties', 'get_property_construction_status', $ARGS[1])`
  910. !! $ARGS[1] - the property code or location, if empty it will use $loc
  911. if $ARGS[0] = 'get_property_construction_status':
  912. $constrstatcheckpropcode = iif($ARGS[1] = '', $home_name[$loc], $home_name[$ARGS[1]])
  913. result = accessible_property['<<$constrstatcheckpropcode>>-construction-status']
  914. killvar 'constrstatcheckpropcode'
  915. end
  916. !! Call: `func('homes_properties', 'progress_construction_status', $ARGS[1])`
  917. !! $ARGS[1] - the property code or location, if empty it will use $loc
  918. if $ARGS[0] = 'progress_construction_status':
  919. $constrstatpropcode = iif($ARGS[1] = '', $home_name[$loc], $home_name[$ARGS[1]])
  920. if accessible_property['<<$constrstatpropcode>>-construction-status'] < 2: accessible_property['<<$constrstatpropcode>>-construction-status'] += 1
  921. killvar 'constrstatpropcode'
  922. end
  923. !! Call: `func('homes_properties', 'is_property_renovated', $ARGS[1])`
  924. !! $ARGS[1] - the property code or location, if empty it will use $loc
  925. if $ARGS[0] = 'is_property_renovated':
  926. $checkrenpropcode = iif($ARGS[1] = '', $home_name[$loc], $home_name[$ARGS[1]])
  927. result = accessible_property['<<$checkrenpropcode>>-renovated']
  928. killvar 'checkrenpropcode'
  929. end
  930. !! Call: `gs 'homes_properties', 'renovate_property', $ARGS[1], ARGS[2], $ARGS[3]
  931. !!
  932. !! $ARGS[1] - the property code or location, if empty it will use $loc
  933. !! ARGS[2] - the value of the renovation
  934. !! $ARGS[3] - the part of the property that was renovated - 'bedroom', 'living room', etc. Optional
  935. if $ARGS[0] = 'renovate_property':
  936. $renovatepropcode = iif($ARGS[1] = '', $home_name[$loc], $home_name[$ARGS[1]])
  937. accessible_property['<<$renovatepropcode>>-renovated'] = 1
  938. accessible_property['<<$renovatepropcode>>-renovation-value'] += ARGS[2]
  939. if $ARGS[3] ! '' : $accessible_property['<<$renovatepropcode>>-renovations'] += ';<<$ARGS[3]>>'
  940. killvar '$renovatepropcode'
  941. end
  942. !!---------------------------------------------------------
  943. !! Go to properties, home, free internet checksm etc.
  944. !!---------------------------------------------------------
  945. !! Call: `gs 'homes_properties', 'go_home'
  946. !! Takes Sveta to the location where her home can be found
  947. if $ARGS[0] = 'go_home':
  948. gt $home['location'], $home['location_arg']
  949. end
  950. !! Call: `gs 'homes_properties', 'go_straight_home'
  951. !! Takes Sveta to the entracne of her home
  952. if $ARGS[0] = 'go_straight_home':
  953. gt $home['entrance'], $home['entrance_arg']
  954. end
  955. !! Returns 0 if the property doesn''t give free internet access, and 1 or -1 if it does
  956. !!
  957. !! Call: func('homes_properties', 'free_internet_available')
  958. !! $ARGS[1] The location to be checked
  959. !! Accepted values:
  960. !! - a property code - 'city_apartment', etc.
  961. !! - a location - a value that could show up in $loc, like 'bedr' or 'mey_home'
  962. !! - empty string - in this case the actual $loc value will be used
  963. if $ARGS[0] = 'free_internet_available':
  964. gs 'homes_properties_attr', 'get_property_attr', iif($ARGS[1] = '', $home_name[$loc], $home_name[$ARGS[1]])
  965. result = property['free_internet'] = 1
  966. killvar 'property'
  967. end
  968. --- homes_properties ---------------------------------