Skip to content

Commit 47026be

Browse files
committed
Add config: wiki categories, filter out NPC inventory junk
1 parent 27f53b3 commit 47026be

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

config.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,16 @@ Templates:
2323
# If the image for an object was uploaded under a different name than in the
2424
# game data, override it here:
2525
Asphodel: Earl_asphodel.png
26+
27+
Wiki:
28+
Categories:
29+
Items: [Item]
30+
Weapons: [MeleeWeapon, MissileWeapon]
31+
Equipment: [Armor, Shield]
32+
Energy cells: [Energy Cell]
33+
Thrown weapons: [BaseThrownWeapon]
34+
Plants: [Plant]
35+
Creatures: [Creature]
36+
Characters: [Phinae Hoshaiah, Barathrumite, Argyve, ElderBob, Mehmet, Warden Ualraig, Warden Esthers,
37+
Eskhind, Meyehind, Liihart, Isahind, Neelahind, Keh, Kesehind, Angohind, Lulihart, AgateSeveranceStar,
38+
Mayor Nuntu, Oboroqoru, Asphodel, Yurl, Euclid]

qud_object.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from anytree import NodeMixin
88

99
from config import config
10-
from helpers import cp437_to_unicode
10+
from helpers import cp437_to_unicode, parse_svalue
1111

1212
IMAGE_OVERRIDES = config['Templates']['Image overrides']
1313

@@ -86,7 +86,9 @@ def ui_inheritance_path(self) -> str:
8686
return text
8787

8888
def inherits_from(self, name: str):
89-
"""Returns True if this object inherits from the object named 'name', False otherwise."""
89+
"""Returns True if this object is 'name' or inherits from 'name', False otherwise."""
90+
if self.name == name:
91+
return True
9092
if self.is_root:
9193
return False
9294
if self.parent.name == name:
@@ -180,8 +182,19 @@ def wikify(self):
180182
if getattr(self, stat) is not None:
181183
output += f"| {stat} = {getattr(self, stat)}\n"
182184
output += "}}\n"
185+
category = self.wiki_category()
186+
if category:
187+
output += "[[Category:" + category + "]]\n"
183188
return output
184189

190+
def wiki_category(self):
191+
cat = None
192+
for config_cat, names in config['Wiki']['Categories'].items():
193+
for name in names:
194+
if self.inherits_from(name):
195+
cat = config_cat
196+
return cat
197+
185198
def __str__(self):
186199
return self.name + ' ' + str(self.attributes)
187200

@@ -237,6 +250,9 @@ def av(self):
237250
if self.inventoryobject:
238251
# might be wearing armor
239252
for name in list(self.inventoryobject.keys()):
253+
if name[0] in '*#@':
254+
# special values like '*Junk 1'
255+
continue
240256
item = qindex[name]
241257
if item.av:
242258
av += int(item.av)

0 commit comments

Comments
 (0)