예제 #1
0
파일: components.py 프로젝트: olivmaurel/ag
    def do_eat(self, item: Entity):
        if not self.same_position(item):
            logging.error(
                '{}({}) is not located in {}, impossible to drink it {}'.
                format(self.entity.name, self.entity.pos, item.pos, item.name))
            return False

        raise NotImplementedError('Add this component : hunger')
예제 #2
0
파일: components.py 프로젝트: olivmaurel/ag
    def remove(self, item: Entity):

        if item not in self.content:
            logging.error('{} is not in {} inventory'.format(
                item.name, self.entity.name))
            return False
        else:
            self.content.remove(item)
            self.filled -= item.size
            return True
예제 #3
0
파일: components.py 프로젝트: olivmaurel/ag
    def enter_area(self, area: Entity, pos: Tuple[int, int]):

        if not area:
            logging.error('{} mov component cannot enter area {}'.format(
                self, area))
            return KeyError('error')

        self.leave_area(pos)
        self.entity.area = area
        self.moveto(pos)
        area.map[pos].entities.append(self.entity)
예제 #4
0
파일: components.py 프로젝트: olivmaurel/ag
    def drop(self, item: Entity):

        if not item.carriable:
            logging.error('{} cannot be dropped, not a carriable item.'.format(
                item.name))
            return False
        if item not in self.content:
            logging.error('{} is not in {} inventory'.format(
                item.name, self.entity.name))
            return False
        else:
            self.remove(item)
            item.dropped()
            return True
예제 #5
0
파일: components.py 프로젝트: olivmaurel/ag
    def pickup(self, item: Entity):

        if not self.same_position(item):
            logging.error(
                '{}({}) is not located in {}, impossible to pickup {}'.format(
                    self.entity.name, self.entity.pos, item.pos, item.name))
            return False
        elif not item.carriable:
            logging.error(
                '{} cannot be picked up, it is not a carriable item'.format(
                    item.name))
            return False
        elif item.size > self.space_left:
            logging.error(
                'Not enough space left in {} inventory. '
                'The item is {} units big, and there is only {} space left.'.
                format(self.entity.name, item.size, self.space_left))
            return False
        else:
            self.add(item)
            item.carriedby(self.owner)
            return True