1
0
Fork 0
spacetac/src/core/missions/ActiveMissions.ts

45 lines
1.1 KiB
TypeScript
Raw Normal View History

module TS.SpaceTac {
/**
* A list of active missions
*/
export class ActiveMissions {
main: Mission | null = null
secondary: Mission[] = []
constructor() {
}
/**
* Start the main story arc
*/
startMainStory(universe: Universe, fleet: Fleet) {
this.main = new MainStory(universe, fleet);
}
/**
* Get the current list of active missions
*/
getCurrent(): Mission[] {
let result: Mission[] = [];
if (this.main) {
result.push(this.main);
}
return result.concat(this.secondary);
}
/**
* Check status for all active missions
*
* This will remove ended missions
*/
2017-06-29 17:25:38 +00:00
checkStatus(): void {
if (this.main) {
2017-06-29 17:25:38 +00:00
if (!this.main.checkStatus()) {
this.main = null;
}
}
2017-06-29 17:25:38 +00:00
this.secondary = this.secondary.filter(mission => mission.checkStatus());
}
}
}