Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

Commit

Permalink
Add PlayerCharacter.items
Browse files Browse the repository at this point in the history
  • Loading branch information
jd28 committed Mar 30, 2022
1 parent 78be18c commit d50d3cb
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
26 changes: 25 additions & 1 deletion pynwn/player_character.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pynwn.file.gff import Gff, make_gff_property, make_gff_locstring_property
from pynwn.file.gff import GffInstance

from pynwn.item import ItemInstance
from pynwn.item import RepositoryItem, ItemInstance

__all__ = ['PlayerCharacter']

Expand Down Expand Up @@ -126,6 +126,30 @@ def equips(self):

return result

@property
def items(self):
"""Creature's inventory items.
:returns: List of tuples contiain repository position
and the :class:`pynwn.ItemInstance`.
"""

result = []
i = 0
# If the creature doesn't have inventory items they won't
# have an 'ItemList' field in their gff structure.
try:
for p in self.gff['ItemList']:
gff_inst = GffInstance(self.gff, 'ItemList', i)
st_inst = ItemInstance(gff_inst, self)
repo_pos = (p['Repos_PosX'], p['Repos_Posy'])
result.append((repo_pos, st_inst))
i += 1
except KeyError:
pass

return result

@property
def level_stats(self):
""" Player's level stat list.
Expand Down
10 changes: 5 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
setup(
name='PyNWN',
version='0.1dev',
packages = ['pynwn',
'pynwn.nwn',
'pynwn.file',
'pynwn.util',],
packages=['pynwn',
'pynwn.nwn',
'pynwn.file',
'pynwn.util', ],
license='GPL v2 and 2-Clause BSD License',
install_requires=[
'prettytable',
'pyyaml'
'PyYAML'
],
zip_safe=False
)

0 comments on commit d50d3cb

Please sign in to comment.