Beispiel #1
0
 async def deathrattle(self):
     hears_rattle = all_in_submap(self.get_position(),
                                  5,
                                  npc_exclusions=[self.id])
     for entity in hears_rattle:
         await entity.send_message(
             f"ENTITY **{self.name().upper()}** HAS DIED", "captain")
Beispiel #2
0
 def move_towards_sub(self, dist: int) -> bool:
     """
     Looks for the closest sub in range, and moves towards it.
     """
     nearby_entities: List[Entity] = all_in_submap(self.get_position(),
                                                   dist)
     closest: Tuple[Optional[Submarine], int] = (None, 0)
     for entity in nearby_entities:
         if isinstance(entity, Submarine):
             sub: Submarine = entity
             this_dist = diagonal_distance(self.get_position(),
                                           sub.get_position())
             if (closest[0] is None) or this_dist < closest[1]:
                 closest = (entity, this_dist)
     if closest[0] is not None:
         direction = determine_direction(self.get_position(),
                                         closest[0].get_position())
         if direction is not None:
             rotated = rotate_direction(direction)
             directions = [direction]
             if rotated is not None:
                 directions.append(rotated[0])
                 directions.append(rotated[1])
             for possible_direction in directions:
                 if self.move(*go_in_direction(possible_direction)):
                     return True
     return False
Beispiel #3
0
 async def deathrattle(self):
     hears_rattle = all_in_submap(self.sub.movement.get_position(),
                                  5,
                                  sub_exclusions=[self.sub._name])
     for entity in hears_rattle:
         await entity.send_message(
             f"SUBMARINE **{self.sub.name().upper()}** ({self.sub.movement.x}, {self.sub.movement.y}) HAS DIED",
             "captain")
Beispiel #4
0
 async def deathrattle(self):
     hears_rattle = all_in_submap(self.get_position(), 5, npc_exclusions=[self.id])
     for entity in hears_rattle:
         await entity.send_message(f"Turtle at ({self.x}, {self.y}) was killed. The Turtle Revenge Squad hears its cry!", "captain")
     # Then summon four eel as a "f**k you".
     locations = [(0,1), (1,0), (-1,0), (0,-1)]
     locations = list(map(lambda p: (self.x+p[0], self.y+p[1]), locations))
     for location in locations:
         add_npc("squid", location[0], location[1], None)
Beispiel #5
0
 async def attack(self):
     parent = self.get_parent()
     if parent is None:
         return
     scanned = all_in_submap(self.get_position(), 1, [parent._name], [self.id])
     message = ""
     if len(scanned) == 0:
         return
     for entity in scanned:
         message += f"**{entity.name()}** at ({entity.x}, {entity.y})\n"
     await parent.send_message(f"**{self.typename}** (#{self.id}) scanned this turn:\n{message}", "scientist")