tutorial_prototypes.py 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. """
  2. Prototypes
  3. A prototype is a simple way to create individualized instances of a
  4. given typeclass. It is dictionary with specific key names.
  5. For example, you might have a Sword typeclass that implements everything a
  6. Sword would need to do. The only difference between different individual Swords
  7. would be their key, description and some Attributes. The Prototype system
  8. allows to create a range of such Swords with only minor variations. Prototypes
  9. can also inherit and combine together to form entire hierarchies (such as
  10. giving all Sabres and all Broadswords some common properties). Note that bigger
  11. variations, such as custom commands or functionality belong in a hierarchy of
  12. typeclasses instead.
  13. A prototype can either be a dictionary placed into a global variable in a
  14. python module (a 'module-prototype') or stored in the database as a dict on a
  15. special Script (a db-prototype). The former can be created just by adding dicts
  16. to modules Evennia looks at for prototypes, the latter is easiest created
  17. in-game via the `olc` command/menu.
  18. Prototypes are read and used to create new objects with the `spawn` command
  19. or directly via `evennia.spawn` or the full path `evennia.prototypes.spawner.spawn`.
  20. A prototype dictionary have the following keywords:
  21. Possible keywords are:
  22. - `prototype_key` - the name of the prototype. This is required for db-prototypes,
  23. for module-prototypes, the global variable name of the dict is used instead
  24. - `prototype_parent` - string pointing to parent prototype if any. Prototype inherits
  25. in a similar way as classes, with children overriding values in their partents.
  26. - `key` - string, the main object identifier.
  27. - `typeclass` - string, if not set, will use `settings.BASE_OBJECT_TYPECLASS`.
  28. - `location` - this should be a valid object or #dbref.
  29. - `home` - valid object or #dbref.
  30. - `destination` - only valid for exits (object or #dbref).
  31. - `permissions` - string or list of permission strings.
  32. - `locks` - a lock-string to use for the spawned object.
  33. - `aliases` - string or list of strings.
  34. - `attrs` - Attributes, expressed as a list of tuples on the form `(attrname, value)`,
  35. `(attrname, value, category)`, or `(attrname, value, category, locks)`. If using one
  36. of the shorter forms, defaults are used for the rest.
  37. - `tags` - Tags, as a list of tuples `(tag,)`, `(tag, category)` or `(tag, category, data)`.
  38. - Any other keywords are interpreted as Attributes with no category or lock.
  39. These will internally be added to `attrs` (eqivalent to `(attrname, value)`.
  40. See the `spawn` command and `evennia.prototypes.spawner.spawn` for more info.
  41. """
  42. # ROOMS
  43. START_00 = {
  44. "prototype_parent": "ROOM",
  45. "prototype_tags": ["room"],
  46. "key": "ruined room",
  47. "aliases": "start_00",
  48. "desc": "This room, once royally adorned, now lies in ruins. |/"
  49. "A violent battle must have been fought in this place,"
  50. "mixed with the broken wood of the furniture stand out broken weapons"
  51. "and bodies devoured by the passage of time. "
  52. "The long oak table that once occupied the center of the room"
  53. " it's now overturned against the wall to create a makeshift barricade."
  54. }
  55. START_01 = {
  56. "prototype_parent": "ROOM",
  57. "prototype_tags": ["room"],
  58. "key": "long hall",
  59. "aliases": ["hall", "start_01"],
  60. "desc": "A long hall paved with large hewn stones, thick oak beams"
  61. "still hold up the ceiling frescoed with gilded symbols. Dust corpuscles swirl"
  62. "in the light, disturbed by your passage."
  63. }
  64. START_02 = {
  65. "prototype_parent": "ROOM",
  66. "prototype_tags": ["room"],
  67. "key": "old guardhouse",
  68. "aliases": ["guardhouse", "start_02"],
  69. "desc": "An old guardhouse devastated by the fighting that took place in these halls."
  70. "The only part that has been spared is the ceiling, completely covered with"
  71. "peeling frescoes depicting scenes of martial life."
  72. }
  73. START_03 = {
  74. "prototype_parent": "ROOM",
  75. "prototype_tags": ["room"],
  76. "key": "empty corridor",
  77. "aliases": ["corridor", "start_03"],
  78. "desc": "The sides of the corridor are lined with stone archways, each adorned by a"
  79. "stone statue. All the statues have been broken behind recognition."
  80. }
  81. START_04 = {
  82. "prototype_parent": "ROOM",
  83. "prototype_tags": ["room"],
  84. "key": "empty corridor",
  85. "aliases": ["corridor", "start_04"],
  86. "desc": "This building seems to have survived the ravages of time better than"
  87. "most of the others. Its arched roof and wide spaces suggests that"
  88. "this is a temple or church of some kind."
  89. }
  90. # EXITS
  91. START_DOOR_00 = {
  92. "prototype_parent": "EXIT",
  93. "prototype_tags": ["exit"],
  94. "key": "sculpted archway",
  95. "aliases": ["archway", "start_door_00"],
  96. "desc": "A beautifully sculpted arched entrance. Two figures are carved into the"
  97. "stone on either side of the door, on the right Its, the muse of Deception, on"
  98. "right Izzac, the muse of Authority."
  99. }
  100. START_DOOR_01 = {
  101. "prototype_parent": "EXIT",
  102. "prototype_tags": ["exit"],
  103. "key": "open doorway",
  104. "aliases": ["doorway", "start_door_01"],
  105. "desc": "A large doorway, with no door. The rune '|y◧|n' is engraved on the granite jamb."
  106. }
  107. START_DOOR_02 = {
  108. "prototype_parent": "EXIT",
  109. "prototype_tags": ["exit"],
  110. "key": "small doorway",
  111. "aliases": ["doorway", "start_door_02"],
  112. "desc": "A small doorway, with no door. The rune '|y◓|n' is engraved on the granite jamb."
  113. }
  114. START_DOOR_03 = {
  115. "prototype_parent": "EXIT",
  116. "prototype_tags": ["exit"],
  117. "key": "reinforced door",
  118. "aliases": ["door", "start_door_03"],
  119. "desc": "A big oak door, reinforced with iron bars across its frame."
  120. "It bears marks and burns all over its surface but hasn't been breached during the"
  121. "siege."
  122. }