homes_properties.qsrc 50 KB

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