Changeset 161:9b4213f6ea7f


Ignore:
Timestamp:
Sep 3, 2009, 10:16:09 PM (11 years ago)
Author:
Adrianna Pińska <adrianna.pinska@…>
Branch:
default
Convert:
svn:b4e93282-eac8-4b8b-b765-0f5d36de2b68@162
Message:

improved equipment layers; unequip method on animal

Location:
gamelib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • gamelib/animal.py

    r158 r161  
    6262    def equip(self, item):
    6363        self.equipment.append(item)
    64         self.draw_equipment(item)
    65         if not equipment.is_weapon(item):
    66             # redraw weapons on top
    67             for weapon in self.weapons():
    68                 self.draw_equipment(weapon)
     64        self.redraw_equipment()
     65
     66    def unequip(self, item):
     67        self.equipment = [e for e in self.equipment if e != item]
     68        self.redraw_equipment()
     69
     70    def redraw_equipment(self):
     71        self.equipment.sort(key=lambda x: x.DRAW_LAYER)
     72        for item in self.equipment:
     73            self.draw_equipment(item)
    6974
    7075    def draw_equipment(self, item):
  • gamelib/equipment.py

    r158 r161  
    66class Equipment(object):
    77    IS_EQUIPMENT = True
     8    DRAW_LAYER = 0
    89
    910    def __init__(self):
     
    2324class Weapon(Equipment):
    2425    IS_WEAPON = True
     26    DRAW_LAYER = 10
    2527
    2628    def in_range(self, gameboard, wielder, target):
     
    6567
    6668class Armour(Equipment):
     69    DRAW_LAYER = 5
    6770
    6871    def place(self, animal):
Note: See TracChangeset for help on using the changeset viewer.