Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def cant_walk_through_closed_doors(event, door):
if not IOpenable(door.entity).open:
event.cancel()
def color(self):
# TODO what if it doesn't exist
if ILockable(self.entity).locked:
return self.locked[1]
# TODO what if it doesn't exist
elif IOpenable(self.entity).open:
return self.open[1]
else:
return self.closed[1]
def blocks(self, actor):
return not IOpenable(self.entity).open
def sprite(self):
# TODO what if it doesn't exist
if ILockable(self.entity).locked:
return self.locked[0]
# TODO what if it doesn't exist
elif IOpenable(self.entity).open:
return self.open[0]
else:
return self.closed[0]
new_pos = self.current_map.find(self.player).position + direction
if new_pos not in self.current_map:
return None
tile = self.current_map.tiles[new_pos]
if tile.creature:
return MeleeAttack(self.player, direction)
arch = tile.architecture
if ILockable in arch and ILockable(arch).locked:
key = next((item for item in IContainer(self.player).inventory if item.isa(Key)), None)
if key:
return Unlock(self.player, arch, key)
if IOpenable in arch and not IOpenable(arch).open:
return Open(self.player, arch)
return Walk(self.player, direction)