Moved Object.assign() to inside Body constructor.
This commit is contained in:
parent
8b190c8054
commit
ab1fede12a
3 changed files with 28 additions and 9 deletions
|
@ -98,14 +98,14 @@ export class JournalInterface extends EventEmitter {
|
|||
if (line.event === 'SAAScanComplete') {
|
||||
// This was a DSS, so set the DSS flag to true and add to list.
|
||||
detailedScanLine.DSSDone = true
|
||||
this.location.bodies.push(Object.assign(new Body, detailedScanLine))
|
||||
this.location.bodies.push(new Body(detailedScanLine))
|
||||
} else {
|
||||
// Else, check that the body hasn't already been added (by a DSS scan line).
|
||||
let r = find(this.location.bodies, {'BodyName': detailedScanLine.BodyName, 'BodyID': detailedScanLine.BodyID})
|
||||
|
||||
if (r === undefined) {
|
||||
// Body was not already logged, so add to list.
|
||||
this.location.bodies.push(Object.assign(new Body, detailedScanLine))
|
||||
this.location.bodies.push(new Body(detailedScanLine))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -122,7 +122,7 @@ export class JournalInterface extends EventEmitter {
|
|||
detailedScanLine = line
|
||||
|
||||
} else if (line.StarType !== undefined) { // Save stars to bodies list.
|
||||
this.location.bodies.push(Object.assign(new Body, line))
|
||||
this.location.bodies.push(new Body(line))
|
||||
|
||||
} else if (line.ScanType === 'AutoScan') { // Save auto/discovery scan bodies.
|
||||
// Check if planet, and then do the duplicate check (otherwise it's an
|
||||
|
@ -131,11 +131,11 @@ export class JournalInterface extends EventEmitter {
|
|||
let r = find(this.location.bodies, ['BodyID', line.BodyID])
|
||||
|
||||
if (r === undefined) {
|
||||
this.location.bodies.push(Object.assign(new Body, line))
|
||||
this.location.bodies.push(new Body(line))
|
||||
}
|
||||
|
||||
} else { // Asteroids.
|
||||
this.location.bodies.push(Object.assign(new Body, line))
|
||||
this.location.bodies.push(new Body(line))
|
||||
}
|
||||
}
|
||||
} else if (line.event === 'FSDJump') {
|
||||
|
@ -180,7 +180,7 @@ export class JournalInterface extends EventEmitter {
|
|||
body.DSSDone = true
|
||||
} else { // Body was missed on initial journal scan, so add it to the list.
|
||||
line.DSSDone = true
|
||||
body = Object.assign(new Body, line)
|
||||
body = new Body(line)
|
||||
this.location.bodies.push(body)
|
||||
}
|
||||
|
||||
|
@ -189,7 +189,7 @@ export class JournalInterface extends EventEmitter {
|
|||
let r = find(this.location.bodies, dupChecker)
|
||||
|
||||
if (r === undefined) {
|
||||
body = Object.assign(new Body, line)
|
||||
body = new Body(line)
|
||||
this.location.bodies.push(body)
|
||||
}
|
||||
}
|
||||
|
@ -198,6 +198,12 @@ export class JournalInterface extends EventEmitter {
|
|||
this.emit('BODY_SCANNED', body, DSS)
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- getNavRoute ---- */
|
||||
|
||||
getNavRoute() {
|
||||
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------- parseLine ---- */
|
||||
|
||||
// Parse and handle journal lines.
|
||||
|
@ -228,6 +234,11 @@ export class JournalInterface extends EventEmitter {
|
|||
DSSFlag = false
|
||||
break
|
||||
}
|
||||
|
||||
case 'NavRoute': {
|
||||
this.getNavRoute()
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
export class Body {
|
||||
constructor() {
|
||||
constructor(journalLine = null) {
|
||||
this.DSSDone = false
|
||||
|
||||
if (journalLine !== null) {
|
||||
Object.assign(this, journalLine)
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- isAsteroid ---- */
|
||||
|
|
|
@ -33,6 +33,7 @@ import './icons/flaticon.css'
|
|||
const { app } = require('electron')
|
||||
import { JournalInterface } from './interfaces/JournalInterface'
|
||||
import { createBodyRow } from './ui'
|
||||
import { Body } from './models/Body'
|
||||
|
||||
// Grab app.isPackaged from main process
|
||||
let isPackaged = false
|
||||
|
@ -53,6 +54,9 @@ if (journal.journalDir === null) {
|
|||
journal.watchDirectory()
|
||||
journal.watchJournal()
|
||||
|
||||
const test = {name: 'Test', ID: 'TestID'}
|
||||
console.log(new Body(test))
|
||||
|
||||
/* --------------------------------------------------------------------------- init complete ---- */
|
||||
|
||||
journal.once('INIT_COMPLETE', () => {
|
||||
|
@ -66,7 +70,7 @@ journal.once('INIT_COMPLETE', () => {
|
|||
$('#currentSystemIcon').removeClass('hidden')
|
||||
}
|
||||
|
||||
if (journal.location.bodies.length > 0) {
|
||||
if (journal.location?.bodies?.length > 0) {
|
||||
journal.location.bodies.forEach((body) => {
|
||||
const row = createBodyRow(body)
|
||||
// TODO APPRAISAL DATA
|
||||
|
|
Loading…
Reference in a new issue