IsharMud / ishar-web

3 stars 1 forks source link

objectify `helptab` and make it classy #37

Closed ericoc closed 2 months ago

ericoc commented 2 months ago

Very much a work-in-progress:

(venv) ➜ eric@pro:~/code/ishar-web/ishar/apps/help/objs git:(help-objs) ✗ $ python3 test.py 2>&1  | tail -10
2024-08-24 21:10:23 -0400 (EDT) [INFO] test.py +19 <module>: HelpTopic: 'Stat Pairing' (Level 0) [0 aliases]
2024-08-24 21:10:23 -0400 (EDT) [INFO] test.py +19 <module>: HelpTopic: 'UDC' (Level 0) [1 alias]
2024-08-24 21:10:23 -0400 (EDT) [INFO] test.py +21 <module>:    ['Ultimate Death Challenge']
2024-08-24 21:10:23 -0400 (EDT) [INFO] test.py +19 <module>: HelpTopic: 'Gold Auras' (Level 0) [4 aliases]
2024-08-24 21:10:23 -0400 (EDT) [INFO] test.py +21 <module>:    ['Pale Green Auras', 'Bright Blue Auras', 'Blue Auras', 'Object Auras']
2024-08-24 21:10:23 -0400 (EDT) [INFO] test.py +19 <module>: HelpTopic: 'Birthdays' (Level 0) [0 aliases]
2024-08-24 21:10:23 -0400 (EDT) [INFO] test.py +19 <module>: HelpTopic: 'misc secrets' (Level 0) [0 aliases]
2024-08-24 21:10:23 -0400 (EDT) [INFO] test.py +23 <module>: HelpTab: 469 topics (/Users/eric/code/ishar-web/ishar/apps/help/objs/helptab)
2024-08-24 21:10:23 -0400 (EDT) [INFO] test.py +24 <module>: HelpTab: 469 topics (/Users/eric/code/ishar-web/ishar/apps/help/objs/helptab)
2024-08-24 21:10:23 -0400 (EDT) [INFO] test.py +25 <module>: 469 topics found.

Created a HelpTab class that interacts with the Ishar MUD "helptab" file. The HelpTab class parses sections from the "helptab" file creating a Python list of child HelpTopic objects.

Each HelpTopic object has level, name, aliases, and body attributes (so far). 🤷‍♂️

Like I said, work-in-progress.

ericoc commented 2 months ago
>>> from pprint import pprint
>>> from helptab import HelpTab
>>> pprint(vars(HelpTab().help_topics['Spell Scry']))

{'aliases': [],
 'body_html': '<br>\n'
              '   By invoking the divine assistance of their deity, clerics '
              'can reach<br>\n'
              "out and see afar. When casting Scry, the cleric's vision is "
              'drawn towards<br>\n'
              'a targeted player, mob or object, revealing their location and '
              'their condition.<br>\n'
              '<br>\n'
              '   When cast on an object, scry will always succeed unless the '
              'object is in<br>\n'
              'the possession of a living entity. In which case, it will act '
              'the same as if<br>\n'
              'you had targeted that entity.<br>\n'
              '<br>\n'
              '   Scry can be viewed as a non-aggressive action and not '
              'provoke hostility,<br>\n'
              'but the target may feel a slight chill upon a failed scrying '
              'attempt, alerting<br>\n'
              "them of the cleric's gaze. Be warned - some entities may not "
              'view this kindly.<br>\n'
              "It's a valuable tool for clerics who wish to keep a watchful "
              'eye on allies or<br>\n'
              'gather intelligence on potential threats.<br>\n',
 'body_text': '\n'
              '   By invoking the divine assistance of their deity, clerics '
              'can reach\n'
              "out and see afar. When casting Scry, the cleric's vision is "
              'drawn towards\n'
              'a targeted player, mob or object, revealing their location and '
              'their condition.\n'
              '\n'
              '   When cast on an object, scry will always succeed unless the '
              'object is in\n'
              'the possession of a living entity. In which case, it will act '
              'the same as if\n'
              'you had targeted that entity.\n'
              '\n'
              '   Scry can be viewed as a non-aggressive action and not '
              'provoke hostility,\n'
              'but the target may feel a slight chill upon a failed scrying '
              'attempt, alerting\n'
              "them of the cleric's gaze. Be warned - some entities may not "
              'view this kindly.\n'
              "It's a valuable tool for clerics who wish to keep a watchful "
              'eye on allies or\n'
              'gather intelligence on potential threats.\n',
 'components': 'Treasure worth 250 obsidian',
 'level': 0,
 'minimum': '',
 'name': 'Spell Scry',
 'player_class': 'Cleric',
 'player_level': '10',
 'saves': 'against resilience for no effect',
 'see_also': [],
 'stats': '',
 'syntax': 'cast scry &lt;victim&gt;',
 'topic': ''}