Exemplo n.º 1
0
 def handle_effect(self, camp, originator, pos, anims, delay=0):
     """Do whatever is required of effect; return list of child effects."""
     target = camp.scene.get_character_at_spot(pos)
     if target:
         if context.matches_description(target.TEMPLATES, self.pat):
             return self.on_true
         return self.on_false
     return self.on_false
Exemplo n.º 2
0
 def handle_effect( self, camp, originator, pos, anims, delay=0 ):
     """Do whatever is required of effect; return list of child effects."""
     target = camp.scene.get_character_at_spot( pos )
     if target:
         if context.matches_description( target.TEMPLATES, self.pat ):
             return self.on_true
         else:
             return self.on_false
     else:
         return self.on_false
Exemplo n.º 3
0
def choose_monster_type( min_rank, max_rank, habitat=() ):
    """Choose a random monster class as close to range as possible."""
    possible_list = list()
    backup_list = list()
    for m in MONSTER_LIST:
        if m.ENC_LEVEL <= max_rank:
            n = context.matches_description( m.HABITAT, habitat )
            if n:
                backup_list += (m,) * m.ENC_LEVEL
                if m.ENC_LEVEL >= min_rank:
                    possible_list += (m,) * max( n * 2 - 3, 1 )
    if possible_list:
        return random.choice( possible_list )
    elif backup_list:
        return random.choice( backup_list )
Exemplo n.º 4
0
    def handle_effect( self, camp, originator, pos, anims, delay=0 ):
        """Do whatever is required of effect; return list of child effects."""
        target = camp.scene.get_character_at_spot( pos )
        if target:
#            match = True
#            for k,v in self.pat.iteritems():
#                if v:
                    # This key must exist in target's templates.
#                    if k not in target.TEMPLATES:
#                        match = False
#                        break
#                else:
                    # This key must not exist in target's templates.
#                    if k in target.TEMPLATES:
#                        match = False
#                        break

            if context.matches_description( target.TEMPLATES, self.pat ):
                return self.on_true
            else:
                return self.on_false
        else:
            return self.on_false