1 import item_handler
, types
2 from item_groups
import item_groups
5 def __init__(self
, item_type
= None, group
= None, quality
= None, ethereal
= None, sockets
= None, level
= None):
6 quality
= item_rule
.listify(quality
)
7 sockets
= item_rule
.listify(sockets
)
8 self
.item_type
= item_type
10 self
.quality
= quality
11 self
.ethereal
= ethereal
12 self
.sockets
= sockets
15 self
.debug_mode
= False
19 if type(input) == types
.IntType
:
24 def debug(self
, text
):
28 def applies_to(self
, item
):
29 if self
.group
!= None:
31 item_types
= item_groups
[self
.group
]
33 print 'Unable to find item group "%s"' % self
.group
36 if item
.type not in item_types
:
37 self
.debug('Group rejection for %s: "%s" (%s)' % (item
.type, self
.group
, item_types
))
40 elif self
.item_type
!= None and self
.item_type
!= item
.type:
41 self
.debug('Type rejection: %s != %s' % (self
.item_type
, item
.type))
44 if self
.quality
!= None and item
.quality
not in self
.quality
:
45 self
.debug('Quality rejection: %s not in %s' % (item
.quality
, self
.quality
))
48 elif self
.ethereal
!= None and self
.ethereal
!= item
.ethereal
:
49 self
.debug('Ethereal rejection: %s != %s' % (self
.ethereal
, item
.ethereal
))
52 elif self
.sockets
!= None and item
.sockets
not in self
.sockets
:
53 self
.debug('Socket rejection: %d not in %s' % (item
.sockets
, self
.sockets
))
56 elif self
.level
!= None and item
.level
< self
.level
:
57 self
.debug('Level rejection: %d < %d' % (item
.level
, self
.level
))
60 self
.debug('Item rule success')