2023-05-10 21:44:54 -07:00
|
|
|
import type { asteroidScan, autoScan, detailedScan, planetScan, starScan } from "../@types/journalLines"
|
2023-05-10 21:30:06 -07:00
|
|
|
|
2023-05-10 21:44:54 -07:00
|
|
|
export interface Body extends starScan<'AutoScan'|'DetailedScan'>, asteroidScan<'AutoScan'|'DetailedScan'>, planetScan<'AutoScan'|'DetailedScan'> {}
|
2023-05-09 12:55:15 -07:00
|
|
|
export class Body {
|
2023-05-10 21:30:06 -07:00
|
|
|
DSSDone: boolean
|
2023-05-10 21:44:54 -07:00
|
|
|
|
2023-05-10 21:30:06 -07:00
|
|
|
constructor(journalLine: autoScan|detailedScan|null = null, DSS: boolean = false) {
|
|
|
|
this.DSSDone = DSS
|
2023-05-09 20:13:25 -07:00
|
|
|
|
|
|
|
if (journalLine !== null) {
|
|
|
|
Object.assign(this, journalLine)
|
|
|
|
}
|
2023-05-09 12:55:15 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------------- isAsteroid ---- */
|
|
|
|
|
2023-05-10 21:44:54 -07:00
|
|
|
isAsteroid(): boolean {
|
2023-05-09 12:55:15 -07:00
|
|
|
return this.BodyName.includes('Belt')
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------------- isPlanet ---- */
|
|
|
|
|
2023-05-10 21:44:54 -07:00
|
|
|
isPlanet(): boolean {
|
2023-05-09 12:55:15 -07:00
|
|
|
return !!this.PlanetClass
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------ isStar ---- */
|
|
|
|
|
2023-05-10 21:44:54 -07:00
|
|
|
isStar(): boolean {
|
2023-05-09 12:55:15 -07:00
|
|
|
return !!this.StarType
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------------- nameIcon ---- */
|
|
|
|
|
2023-05-10 21:44:54 -07:00
|
|
|
nameIcon(): string|null {
|
|
|
|
let nameIcon: string|null = null
|
2023-05-09 12:55:15 -07:00
|
|
|
|
|
|
|
if (this.isAsteroid()) {
|
|
|
|
nameIcon = 'asteroid-4'
|
|
|
|
} else if (this.isStar()) {
|
|
|
|
nameIcon = 'star'
|
|
|
|
} else if (this.isPlanet()) {
|
|
|
|
nameIcon = 'jupiter-3'
|
|
|
|
}
|
|
|
|
|
|
|
|
return nameIcon
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------------- simpleName ---- */
|
|
|
|
|
2023-05-10 21:44:54 -07:00
|
|
|
simpleName(): string {
|
2023-05-09 12:55:15 -07:00
|
|
|
return this.BodyName.replace(this.StarSystem, '')
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------------- typeIcon ---- */
|
|
|
|
|
2023-05-10 21:44:54 -07:00
|
|
|
typeIcon(): string|null {
|
|
|
|
let typeIcon: string|null = null
|
2023-05-09 12:55:15 -07:00
|
|
|
|
|
|
|
if (this.isStar() || this.isAsteroid()) {
|
|
|
|
typeIcon = this.nameIcon()
|
|
|
|
} else {
|
2023-05-10 21:44:54 -07:00
|
|
|
const planetClass: string = this.PlanetClass.toLowerCase()
|
2023-05-09 12:55:15 -07:00
|
|
|
|
|
|
|
if (planetClass.includes('metal')) {
|
|
|
|
typeIcon = 'ingot'
|
|
|
|
} else if (planetClass.includes('icy')) {
|
|
|
|
typeIcon = 'snowflake'
|
|
|
|
} else if (planetClass.includes('earth')) {
|
|
|
|
typeIcon = 'earth'
|
|
|
|
} else if (planetClass.includes('gas giant')) {
|
|
|
|
typeIcon = 'jupiter-1'
|
|
|
|
} else if (planetClass.includes('rock')) {
|
|
|
|
typeIcon = 'asteroid-3'
|
|
|
|
} else if (planetClass.includes('water') || planetClass.includes('ammonia')) {
|
|
|
|
typeIcon = 'water-drops'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return typeIcon
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------------- distance ---- */
|
|
|
|
|
2023-05-10 21:44:54 -07:00
|
|
|
distance(): string {
|
2023-05-09 12:55:15 -07:00
|
|
|
return Intl.NumberFormat().format(Math.round(this.DistanceFromArrivalLS))
|
|
|
|
}
|
|
|
|
}
|