Skip to content

Commit

Permalink
fix(Utils): Fix ts errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyasmirnov03 committed Dec 11, 2023
1 parent 171c3a9 commit 0a23471
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/utils/ship/getArrivalTime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ const multiplier: {[key in FlightMode]: number} = {
'STEALTH': 30
}

export function getArrivalTime(ship: ShipModel | undefined, waypoint: Waypoint): string {
export function getArrivalTime(ship: ShipModel | undefined, waypoint: Waypoint): string | undefined {
if (!ship) {
return;
}
const secondsToArrival = Math.round(
Math.round(
Math.max(1, Math.round(getDistanceToWaypoint(ship, waypoint)))
Expand Down
2 changes: 1 addition & 1 deletion src/utils/ship/getDistanceToWaypoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {ShipModel} from '../../models/ship.model.ts';
import {Waypoint} from '../../models/waypoint.model.ts';

export function getDistanceToWaypoint(ship: ShipModel | undefined, waypoint: Waypoint): number {
const point1 = {x: ship?.nav.route.destination.x, y: ship?.nav.route.destination.y};
const point1 = {x: ship?.nav.route.destination.x ?? 0, y: ship?.nav.route.destination.y ?? 0};
const point2 = {x: waypoint.x, y: waypoint.y};
const dx = point2.x - point1.x;
const dy = point2.y - point1.y;
Expand Down

0 comments on commit 0a23471

Please sign in to comment.