Exemple #1
0
 def perform(self) -> bool:
     components = ["pearl"]
     if self.crewman.cooldown > 0:
         raise Impossible(f"{self.crewman.name} is still on cooldown")
     for item in components:
         if not (item in self.entity.cargo.manifest.keys() and self.entity.cargo.manifest[item] > 0):
             raise Impossible(f"Cannot view without {item}")
     self.crewman.cooldown = self.crewman.cooldown_max
     if len(components) > 1:
         used = f"each of {components[0]}"
         for item in components[1:]:
             used = used + f", {item}"
     else:
         used = components[0]
     for item in components:
         self.entity.cargo.manifest[item] -= 1
     
     distance = view_port
     visible_tiles = self.entity.game_map.get_fov(distance,
                                                  self.entity.x,
                                                  self.entity.y,
                                                  elevation=Elevation.ALL,
                                                  mist_view=distance)
     for (x, y) in visible_tiles:
         entities = self.entity.game_map.get_targets_at_location(x, y)
         for entity in entities:
             if entity.is_alive:
                 self.entity.view.fov.add((x, y))
     
     self.engine.message_log.add_message(f"{self.crewman.name} connects with enemy minds!", text_color='yellow')
     self.engine.message_log.add_message(f"Used 1 {used}")
     return False
Exemple #2
0
 def perform(self) -> bool:
     components = ["bat wing"]
     if self.crewman.cooldown > 0:
         raise Impossible(f"{self.crewman.name} is still on cooldown")
     for item in components:
         if not (item in self.entity.cargo.manifest.keys()
                 and self.entity.cargo.manifest[item] > 0):
             raise Impossible(f"Cannot calm wind without {item}")
     if self.entity.game_map.weather.wind_direction is None:
         raise Impossible(f"Wind is not blowing")
     self.crewman.cooldown = self.crewman.cooldown_max
     if len(components) > 1:
         used = f"each of {components[0]}"
         for item in components[1:]:
             used = used + f", {item}"
     else:
         used = components[0]
     for item in components:
         self.entity.cargo.manifest[item] -= 1
     self.entity.game_map.weather.wind_direction = None
     self.entity.game_map.weather.wind_count = 0
     self.engine.message_log.add_message(
         f"{self.crewman.name} calms the wind!", text_color='yellow')
     self.engine.message_log.add_message(f"Used 1 {used}")
     return True
Exemple #3
0
 def perform(self) -> bool:
     components = ["wood", "tar"]
     if self.crewman.cooldown > 0:
         raise Impossible(f"{self.crewman.name} is still on cooldown")
     if self.entity.fighter.hp >= self.entity.fighter.max_hp:
         raise Impossible(
             f"{self.entity.fighter.name.capitalize()} is not in need of repairs"
         )
     for item in components:
         if not (item in self.entity.cargo.manifest.keys()
                 and self.entity.cargo.manifest[item] > 0):
             raise Impossible(f"Cannot repair without {item}")
     self.crewman.cooldown = self.crewman.cooldown_max
     if len(components) > 1:
         used = f"each of {components[0]}"
         for item in components[1:]:
             used = used + f", {item}"
     else:
         used = components[0]
     for item in components:
         self.entity.cargo.manifest[item] -= 1
     self.entity.fighter.hp += 1
     self.engine.message_log.add_message(
         f"{self.crewman.name} repaired {self.entity.fighter.name} for 1 point"
     )
     self.engine.message_log.add_message(f"Used 1 {used}")
     return True
 def perform(self) -> bool:
     components = ["wood", "leather"]
     if self.crewman.cooldown > 0:
         raise Impossible(f"{self.crewman.name} is still on cooldown")
     damaged_weapons = self.entity.broadsides.get_damaged_weapons()
     repair_list = [
         weapon for weapon in damaged_weapons
         if "ballista" in weapon.name.lower()
     ]
     if len(repair_list) < 1:
         raise Impossible(f"There are no damaged Ballista to repair")
     else:
         to_repair = choice(repair_list)
     for item in components:
         if not (item in self.entity.cargo.manifest.keys()
                 and self.entity.cargo.manifest[item] > 0):
             raise Impossible(f"Cannot repair without {item}")
     self.crewman.cooldown = self.crewman.cooldown_max
     if len(components) > 1:
         used = f"each of {components[0]}"
         for item in components[1:]:
             used = used + f", {item}"
     else:
         used = components[0]
     for item in components:
         self.entity.cargo.manifest[item] -= 1
     to_repair.hp += 1
     self.engine.message_log.add_message(
         f"{self.crewman.name} repaired {to_repair.name.capitalize()} for 1 point"
     )
     self.engine.message_log.add_message(f"Used 1 {used}")
     return True
    def __init__(self, entity: Entity, direction: Location):
        """
        Arrow action hits all adjacent targets as well as entities at the attacker's location
        This is a split damage attack action that divides total damage by number of targets hit
        :param entity: acting Entity
        :param direction: key pressed to make attack
        """
        self.entity = entity
        ammo = {'arrows': len(self.entity.crew.roster) // 4}
        enough_ammo = True
        for ammo_type in ammo.keys():
            if ammo_type not in self.entity.cargo.manifest.keys():
                enough_ammo = False
            elif self.entity.cargo.manifest[ammo_type] - ammo[ammo_type] < 0:
                enough_ammo = False
        if not enough_ammo:
            raise Impossible(f"Not enough arrows!")

        targets = []
        neighbor_tiles = self.engine.game_map.get_neighbors_at_elevations(
            self.entity.x, self.entity.y, elevations='all')
        neighbor_tiles.append((entity.x, entity.y))
        for tile_x, tile_y in neighbor_tiles:
            targets.extend(
                self.engine.game_map.get_targets_at_location(tile_x, tile_y))
        if self.entity in targets:
            targets.remove(self.entity)
        if len(targets) < 1:
            raise Impossible(f"No adjacent targets")
        damage = (len(self.entity.crew.roster) // 4) // len(targets)
        if self.entity.crew.has_occupation("archer"):
            damage += 1
        super().__init__(entity, targets, damage, direction, ammo)
 def perform(self) -> bool:
     components = ["pearl"]
     if self.crewman.cooldown > 0:
         raise Impossible(f"{self.crewman.name} is still on cooldown")
     for item in components:
         if not (item in self.entity.cargo.manifest.keys()
                 and self.entity.cargo.manifest[item] > 0):
             raise Impossible(f"Cannot change weather without {item}")
     if self.entity.game_map.weather.conditions == Conditions.STORMY:
         raise Impossible(f"Weather conditions cannot get worse")
     self.crewman.cooldown = self.crewman.cooldown_max
     if len(components) > 1:
         used = f"each of {components[0]}"
         for item in components[1:]:
             used = used + f", {item}"
     else:
         used = components[0]
     for item in components:
         self.entity.cargo.manifest[item] -= 1
     self.entity.game_map.weather.conditions = Conditions(
         self.entity.game_map.weather.conditions.value + 1)
     self.entity.game_map.weather.conditions_count = 0
     self.engine.message_log.add_message(
         f"{self.crewman.name} moves the heavens!", text_color='yellow')
     self.engine.message_log.add_message(f"Used 1 {used}")
     return True
Exemple #7
0
 def perform(self) -> bool:
     if self.entity.fighter.hp >= self.entity.fighter.max_hp:
         raise Impossible(f"Hull is already fully repaired")
     if self.entity.cargo.coins < 20:
         raise Impossible("Not enough coins")
     self.entity.cargo.coins -= 20
     self.entity.game_map.port.coins += 20
     self.entity.fighter.repair(1)
     self.engine.time.roll_hrs(2)
     self.engine.message_log.add_message(
         f"Repaired 1 Hull Point for 20 Coins (2 hours pass)")
     return True
Exemple #8
0
 def perform(self) -> bool:
     if not self.entity.cargo.item_type_in_manifest('mines'):
         raise Impossible("No mines in inventory!")
     self.engine.game_map.terrain[self.entity.x][
         self.entity.y].decoration = "minefield"
     self.entity.cargo.remove_items_from_manifest({'mines': 1})
     self.engine.message_log.add_message("Mines placed")
     return True
 def perform(self) -> bool:
     if self.event == "crew":
         raise Impossible("Not Anymore!")
     if self.event == "sails":
         return RepairSailsAction(self.entity).perform()
     if self.event == "shipyard":
         return RepairHullAction(self.entity).perform()
     if self.event == "engineer":
         return RepairWeaponsAction(self.entity).perform()
Exemple #10
0
    def __init__(self, entity: Entity, direction: Location):
        """
        Broadside action hits all targets in a cone in a particular side direction up to a certain range
        This is a split damage attack action that divides total damage by number of targets hit
        :param entity: acting Entity
        :param direction: key pressed to make attack
        """
        self.entity = entity

        distance = self.entity.broadsides.get_active_range(direction)
        if distance:
            damage = self.entity.broadsides.get_active_power(direction)
        else:
            raise Impossible(
                f"No active weapons to {direction.name.lower().capitalize()}")
        ammo = self.entity.broadsides.get_active_weapon_ammo_types(direction)
        enough_ammo = True
        for ammo_type in ammo.keys():
            if ammo_type not in self.entity.cargo.manifest.keys():
                enough_ammo = False
            elif self.entity.cargo.manifest[ammo_type] - ammo[ammo_type] < 0:
                enough_ammo = False
        if not enough_ammo:
            raise Impossible(
                f"Not enough ammo to fire {direction.name.lower().capitalize()} Broadsides"
            )
        targets = []
        hexes = get_cone_target_hexes_at_location(entity.x, entity.y,
                                                  entity.facing, direction,
                                                  distance)
        for x, y in hexes:
            if (x, y) in entity.view.fov:
                targets.extend(
                    self.engine.game_map.get_targets_at_location(x, y))
        if self.entity in targets:
            targets.remove(self.entity)
        if len(targets) < 1:
            raise Impossible(
                f"No targets to {direction.name.lower().capitalize()}")
        if self.entity.crew.has_occupation("sharpshooter"):
            damage += 1
        damage = damage // len(targets)
        super().__init__(entity, targets, damage, direction, ammo)
Exemple #11
0
 def perform(self) -> bool:
     action = None
     assigned = None
     for crewman in self.entity.crew.roster:
         if crewman.assignment and crewman.assignment == self.event:
             assigned = crewman
             action = action_lookup[crewman.occupation]
     if action and assigned:
         return action(self.entity, assigned).perform()
     else:
         raise Impossible(f"Nobody assigned to '{self.event.name.upper()}' key")
Exemple #12
0
 def perform(self) -> bool:
     components = ["fish"]  # bread, fish, fruit, meat
     if self.crewman.cooldown > 0:
         raise Impossible(f"{self.crewman.name} is still on cooldown")
     for item in components:
         if not (item in self.entity.cargo.manifest.keys()
                 and self.entity.cargo.manifest[item] > 0):
             raise Impossible(f"Cannot feed crew without {item}")
     self.crewman.cooldown = self.crewman.cooldown_max
     if len(components) > 1:
         used = f"each of {components[0]}"
         for item in components[1:]:
             used = used + f", {item}"
     else:
         used = components[0]
     for item in components:
         self.entity.cargo.manifest[item] -= 1
     self.entity.crew.tick_cooldowns()
     self.engine.message_log.add_message(
         f"{self.crewman.name} feeds the crew!")
     self.engine.message_log.add_message(f"Used 1 {used}")
     return True
    def perform(self) -> bool:
        # if self.event == PortVisit.SHIPYARD:  # Ship Upgrades
        #     raise Impossible(f"{self.event} action yet implemented")
        if self.event == PortVisit.MERCHANT:  # Buy / sell Cargo
            self.engine.game_state = GameStates.MERCHANT
            return False
        if self.event == PortVisit.TAVERN:  # Hire Crewmen
            self.engine.game_state = GameStates.TAVERN
            return False
        if self.event == PortVisit.SMITHY:  # Buy / Sell Weapons
            self.engine.game_state = GameStates.SMITHY
            return False

        raise Impossible(f"{self.event} action yet implemented")
 def perform(self) -> bool:
     components = ["meat"]
     if self.crewman.cooldown > 0:
         raise Impossible(f"{self.crewman.name} is still on cooldown")
     for item in components:
         if not (item in self.entity.cargo.manifest.keys() and self.entity.cargo.manifest[item] > 0):
             raise Impossible(f"Cannot fish without {item}")
     self.crewman.cooldown = self.crewman.cooldown_max
     if len(components) > 1:
         used = f"each of {components[0]}"
         for item in components[1:]:
             used = used + f", {item}"
     else:
         used = components[0]
     for item in components:
         self.entity.cargo.manifest[item] -= 1
     fish = randint(0, 3)
     if "fish" in self.entity.cargo.manifest.keys():
         self.entity.cargo.manifest['fish'] += fish
     else:
         self.entity.cargo.manifest['fish'] = fish
     self.engine.message_log.add_message(f"{self.crewman.name} catches {fish} fish")
     self.engine.message_log.add_message(f"Used 1 {used}")
     return True