Skip to content
This repository has been archived by the owner on Jul 28, 2019. It is now read-only.

Commit

Permalink
SMART character placement.
Browse files Browse the repository at this point in the history
  • Loading branch information
juanibiapina committed Jun 13, 2012
1 parent 68f9b65 commit 1ecd1c1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions domb/area.py
Expand Up @@ -41,6 +41,9 @@ def __init__(self, mapdata):
def get_random_position(self):
return Vec2d(choice([pos for pos, spot in self._data.iteritems() if spot.is_walkable()]))

def get_position_in_room(self, name):
return Vec2d(choice([pos for pos, spot in self._data.iteritems() if spot.is_walkable() and spot.get_room_name() == name]))

def draw(self, screen, camera):
for pos, spot in self._data.iteritems():
spot.draw(screen, pos, camera)
Expand Down
5 changes: 4 additions & 1 deletion domb/character/character.py
Expand Up @@ -41,14 +41,17 @@ class Character(object):

def __init__(self, area):
self.area = area
self.pos = area.get_random_position()
self.area.add_character(self)
self.inventory = Inventory()
self.set_attributes(self.attributes)
self.hp = HP(self)
self.ac = AC(self)
self.attack = Attack(self)
self.damage = Damage(self)
self.place_in_area()

def place_in_area(self):
self.pos = self.area.get_random_position()

def set_attributes(self, attributes):
broken_attrs = attributes.split(",")
Expand Down
3 changes: 3 additions & 0 deletions domb/hero.py
Expand Up @@ -35,3 +35,6 @@ def resolve_xp(self, target):

def get_xp(self):
return self.xp.xp

def place_in_area(self):
self.pos = self.area.get_position_in_room("initial room")

0 comments on commit 1ecd1c1

Please sign in to comment.