dynamicHousing.tw 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. :: dynamicHousing[include]
  2. <<set _housingData = $location_var[$here][0]>>
  3. <<set _currentRoom ??= ($dynamicHousingRoom ?? _housingData.entry)>>
  4. <<set $dynamicHousingRoom = _currentRoom>>
  5. <<set _currentRoomData = _housingData.room(_currentRoom)>>
  6. <<gs 'dynamicHousingEventHandling'>>
  7. <<if !_eventStopsRendering>>
  8. <h2>_currentRoomData.title</h2>
  9. <<image _currentRoomData.image>>
  10. <p>_currentRoomData.description</p>
  11. <<for _connection range _currentRoomData.connections ?? []>>
  12. <<if typeof _connection === 'string'>>
  13. <<if _connection.first() == '#'>>
  14. <<set _connection = _housingData.connections[_connection.substring(1)]>>
  15. <<set _flags = setup.mergeDeep({capture:['_connection']},_connection.flags??{})>>
  16. <<ConnectedLocation _connection.label _connection.destination '' _connection.image _connection.time _flags>>
  17. <<elseif _housingData.roomExists(_connection)>>
  18. <<set _destination = _housingData.room(_connection)>>
  19. <<ConnectedLocationCode _destination.title _destination.image 1 `{capture:['_connection']}`>>
  20. <<set $dynamicHousingRoom = _connection>>
  21. <<travel _housingData.passage>>
  22. <</ConnectedLocationCode>>
  23. <</if>>
  24. <<else>>
  25. <<ConnectedLocation _connection.label _connection.destination '' _connection.image _connection.time _connection.flags>>
  26. <</if>>
  27. <</for>>
  28. <<for _tag range _currentRoomData.tags ?? []>>
  29. <<run _tags.push(_tag)>>
  30. <</for>>
  31. <<if _currentRoomData.passage>>
  32. <<gs _currentRoomData.passage>>
  33. <</if>>
  34. <</if>>
  35. :: dynamicHousingEventHandling[event]
  36. <<set $eventReturnLocation = new LocationIdentifier(passage())>>
  37. <<set _temporaryEvents = {}>>
  38. <<set _eventPassages = Story.lookup("tags", $eventReturnLocation.passage+'_events')>>
  39. <<for _eventPassage range _eventPassages>>
  40. <<gs _eventPassage.title>>
  41. <</for>>
  42. <<set _eventsRegisteredForPassageAndTags = $events.registeredByPassage($eventReturnLocation.passage)>>
  43. <<set _targetPassageTags = $eventReturnLocation.tags>>
  44. <<run _targetPassageTags = _targetPassageTags.concatUnique(_currentRoomData.tags ?? [])>>
  45. <<for _targetPassageTag range _targetPassageTags>>
  46. <<set _eventsRegisteredForPassageAndTags = _eventsRegisteredForPassageAndTags.concat($events.registeredByTag(_targetPassageTag))>>
  47. <<set _eventPassages = Story.lookup("tags", _targetPassageTag+'_events')>>
  48. <<for _eventPassage range _eventPassages>>
  49. <<gs _eventPassage.title>>
  50. <</for>>
  51. <</for>>
  52. <!--<<set _allEvents = _eventsRegisteredForPassageAndTags.concat(_temporaryEvents).sortByPriority();>>-->
  53. <<set _allEvents = setup.mergeDeep({},_eventsRegisteredForPassageAndTags,_temporaryEvents)>>
  54. <<include 'eventsExecute'>>
  55. :: dynamicHousingWidgets[widget]
  56. <<widget 'dynamicHousing'>>
  57. /*
  58. Args
  59. 0 Data (Object: use the object, string: look up data in $housing)
  60. */
  61. <<set _housingData = $housing.house(_args[0])>>
  62. <<gs 'dynamicHousing' _housingData>>
  63. <</widget>>