示例#1
0
    def get_priority(cls, actor):
        """
        Priority is based on health but adjusted when corpses are close
        """
        if actor.hp >= actor.max_hp:
            return Priority.Never

        corpses = actor.level.get_actors_by_team(Team.Corpse)
        if not corpses:
            return Priority.Never

        if not actor.level.get_actors_by_team(Team.Goblin):
            return Priority.High

        closest_corpse = utils.get_closest_actor(actor, corpses)
        dist = utils.get_distance(actor, closest_corpse)

        hp = actor.hp
        quarter_hp = actor.max_hp / 4
        if hp >= quarter_hp * 3:
            if dist <= 1:
                return Priority.High
            else:
                return Priority.VeryLow
        elif hp >= quarter_hp * 2:
            if dist <= 1:
                return Priority.High
            elif dist <= 3:
                return Priority.Medium
            else:
                return Priority.Low
        else:
            return Priority.High
示例#2
0
    def _get_target(cls, actor):
        goblins = actor.level.get_actors_by_team(Team.Goblin)
        if not goblins:
            return None

        goblin = utils.get_closest_actor(actor, goblins)

        return goblin
示例#3
0
    def _get_target(cls, actor):
        corpses = actor.level.get_actors_by_team(Team.Corpse)
        if not corpses:
            return None

        target = utils.get_closest_actor(actor, corpses)

        return target
示例#4
0
def test_get_closest_actor_returns_closest_actor():
    actor = actors.Egg(None, 0, 0)
    closest = actors.Cocoon(None, 1, 0)
    all_objects = [
        closest, actors.Goblin(None, 2, 2),
        actors.Goblin(None, 1, 1)
    ]

    result = utils.get_closest_actor(actor, all_objects)
    assert result is closest
示例#5
0
    def act(self):
        if self.stunned > 0:
            self.stunned -= 1
            return

        if not self.dead:
            spiders = self.level.get_actors_by_team(Team.SpiderQueen)
            if spiders:
                closest_spider = utils.get_closest_actor(self, spiders)
                return movement.step_to_target(self, closest_spider)
示例#6
0
    def _get_target(cls, actor):
        spiders = actor.level.get_actors_by_team(Team.SpiderQueen)
        cocoons = [
            c for c in spiders
            if c.actor_type == ActorTypes.Cocoon and c.burrowed is False
        ]
        if not cocoons:
            return None

        cocoon = utils.get_closest_actor(actor, cocoons)

        return cocoon
示例#7
0
    def get_priority(cls, actor):
        goblins = actor.level.get_actors_by_team(Team.Goblin)
        if not goblins:
            return Priority.Never

        goblin = utils.get_closest_actor(actor, goblins)
        dist = utils.get_distance(actor, goblin)
        if dist <= 1:
            return Priority.Extreme
        elif dist == 2:
            return Priority.Medium
        else:
            return Priority.Low
示例#8
0
    def get_priority(cls, actor):
        if actor.cooldowns.get("lay_egg"):
            return Priority.Never

        enemies = actor.level.get_actors_by_team(Team.Goblin)
        if enemies:
            closest_enemy = utils.get_closest_actor(actor, enemies)
            dist = utils.get_distance(actor, closest_enemy)
            if dist >= 10:
                return Priority.High
            elif dist >= 5:
                return Priority.Medium
            else:
                return Priority.Never

        return Priority.High