def _doBlockedImpulseMove(self, quadrant: Quadrant, enterpriseCoordinates: Coordinates, results: LineOfSightResponse): """ Handle an impulse move where the Enterprise was blocked by an obstacle Args: quadrant: The current quadrant enterpriseCoordinates: Then enterprise sector coordinates results: The results from the line of sight query """ self._messageConsole.displayMessage(f'Destination is blocked by: {results.obstacle.id}') self._soundMachine.playSound(SoundType.PleaseRepeatRequest) baseGamePiece: BaseGamePiece = cast(BaseGamePiece, results.obstacle) blockerCoordinates: Coordinates = baseGamePiece.gameCoordinates stopEnergy: float = self._gameEngine.computeEnergyWhenBlocked(startSector=enterpriseCoordinates, endSector=blockerCoordinates) self._gameState.energy -= stopEnergy directionData: DirectionData = self._determineCloseCoordinatesToBlockedObject(quadrant=quadrant, targetCoordinates=blockerCoordinates) self.logger.info(f'Move Enterprise to: {directionData.coordinates}') self.__updateQuadrant(quadrant=quadrant, currentCoordinates=enterpriseCoordinates, targetCoordinates=directionData.coordinates) quadrant.enterprise.inMotion = True quadrant.enterpriseCoordinates = directionData.coordinates self._gameEngine.impulse(newCoordinates=directionData.coordinates, quadrant=quadrant, enterprise=quadrant.enterprise) self._soundMachine.playSound(SoundType.EnterpriseBlocked)
def _doImpulseMove(self, quadrant: Quadrant, enterpriseCoordinates: Coordinates, targetCoordinates: Coordinates): """ Handle impulse move if we are not blocked by any obstacles. Args: quadrant: The current quadrant enterpriseCoordinates: Then enterprise sector coordinates targetCoordinates: Where the player indicated we were moving """ self.__updateQuadrant(quadrant=quadrant, currentCoordinates=enterpriseCoordinates, targetCoordinates=targetCoordinates) quadrant.enterprise.destinationPoint = GamePiece.gamePositionToScreenPosition(gameCoordinates=targetCoordinates) quadrant.enterpriseCoordinates = targetCoordinates quadrant.enterprise.inMotion = True self._gameEngine.impulse(newCoordinates=targetCoordinates, quadrant=quadrant, enterprise=quadrant.enterprise) self._soundMachine.playSound(SoundType.Impulse) if quadrant.klingonCount > 0 or quadrant.commanderCount > 0 or quadrant.superCommanderCount > 0: self._gameState.shipCondition = ShipCondition.Red else: self._gameState.shipCondition = ShipCondition.Green