2017-06-27 15:42:28 +00:00
|
|
|
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 {
|
2017-06-27 15:42:28 +00:00
|
|
|
if (this.main) {
|
2017-06-29 17:25:38 +00:00
|
|
|
if (!this.main.checkStatus()) {
|
2017-06-27 15:42:28 +00:00
|
|
|
this.main = null;
|
|
|
|
}
|
|
|
|
}
|
2017-06-29 17:25:38 +00:00
|
|
|
this.secondary = this.secondary.filter(mission => mission.checkStatus());
|
2017-06-27 15:42:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|