@fboes/aerofly-custom-missions 1.2.2 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/.editorconfig +1 -5
  2. package/.eslintrc.json +24 -0
  3. package/CHANGELOG.md +59 -21
  4. package/dist/dto/AeroflyLocalizedText.js +44 -0
  5. package/dist/dto/AeroflyMission.js +173 -0
  6. package/dist/dto/AeroflyMissionCheckpoint.js +127 -0
  7. package/dist/dto/AeroflyMissionConditions.js +124 -0
  8. package/dist/dto/AeroflyMissionConditionsCloud.js +90 -0
  9. package/dist/dto/AeroflyMissionTargetPlane.js +35 -0
  10. package/dist/dto/AeroflyMissionsList.js +36 -0
  11. package/dist/index.js +7 -634
  12. package/dist/index.test.js +17 -11
  13. package/dist/node/AeroflyConfigurationNode.js +82 -0
  14. package/docs/custom_missions_user.tmc +3 -6
  15. package/docs/custom_missions_user.xml +100 -0
  16. package/package.json +9 -10
  17. package/src/dto/AeroflyLocalizedText.ts +74 -0
  18. package/src/dto/AeroflyMission.ts +372 -0
  19. package/src/dto/AeroflyMissionCheckpoint.ts +234 -0
  20. package/src/dto/AeroflyMissionConditions.ts +189 -0
  21. package/src/dto/AeroflyMissionConditionsCloud.ts +111 -0
  22. package/src/dto/AeroflyMissionTargetPlane.ts +62 -0
  23. package/src/dto/AeroflyMissionsList.ts +52 -0
  24. package/src/index.test.ts +22 -25
  25. package/src/index.ts +7 -1099
  26. package/src/node/AeroflyConfigurationNode.ts +89 -0
  27. package/types/AeroflyMissionCheckpoint.d.ts +140 -0
  28. package/types/AeroflyMissionTargetPlane.d.ts +40 -0
  29. package/types/dto/AeroflyConfigFileSet.d.ts +10 -0
  30. package/types/dto/AeroflyConfigFileSet.d.ts.map +1 -0
  31. package/types/dto/AeroflyConfiguration.interface.d.ts +4 -0
  32. package/types/dto/AeroflyConfiguration.interface.d.ts.map +1 -0
  33. package/types/dto/AeroflyLocalizedText.d.ts +58 -0
  34. package/types/dto/AeroflyLocalizedText.d.ts.map +1 -0
  35. package/types/dto/AeroflyMission.d.ts +163 -0
  36. package/types/dto/AeroflyMission.d.ts.map +1 -0
  37. package/types/dto/AeroflyMissionCheckpoint.d.ts +126 -0
  38. package/types/dto/AeroflyMissionCheckpoint.d.ts.map +1 -0
  39. package/types/dto/AeroflyMissionConditions.d.ts +102 -0
  40. package/types/dto/AeroflyMissionConditions.d.ts.map +1 -0
  41. package/types/dto/AeroflyMissionConditionsCloud.d.ts +57 -0
  42. package/types/dto/AeroflyMissionConditionsCloud.d.ts.map +1 -0
  43. package/types/dto/AeroflyMissionTargetPlane.d.ts +45 -0
  44. package/types/dto/AeroflyMissionTargetPlane.d.ts.map +1 -0
  45. package/types/dto/AeroflyMissionsList.d.ts +30 -0
  46. package/types/dto/AeroflyMissionsList.d.ts.map +1 -0
  47. package/types/dto/basicTypes.d.ts +1 -0
  48. package/types/index.d.ts +7 -585
  49. package/types/index.d.ts.map +1 -1
  50. package/types/node/AeroflyConfigurationNode.d.ts +14 -0
  51. package/types/node/AeroflyConfigurationNode.d.ts.map +1 -0
  52. package/eslint.config.js +0 -29
@@ -0,0 +1,90 @@
1
+ import { AeroflyConfigurationNode } from "../node/AeroflyConfigurationNode.js";
2
+ import { feetPerMeter } from "./AeroflyMission.js";
3
+ /**
4
+ * @class
5
+ * A cloud layer for the current flight plan's weather data
6
+ *
7
+ * The purpose of this class is to collect data needed for Aerofly FS4's
8
+ * `custom_missions_user.tmc` flight plan file format, and export the structure
9
+ * for this file via the `toString()` method.
10
+ */
11
+ export class AeroflyMissionConditionsCloud {
12
+ /**
13
+ * @param {number} cover 0..1, percentage
14
+ * @param {number} base altitude in meters AGL
15
+ */
16
+ constructor(cover, base) {
17
+ this.cover = cover;
18
+ this.base = base;
19
+ }
20
+ /**
21
+ * @param {number} cover 0..1, percentage
22
+ * @param {number} base_feet altitude, but in feet AGL instead of meters AGL
23
+ * @returns {AeroflyMissionConditionsCloud} self
24
+ */
25
+ static createInFeet(cover, base_feet) {
26
+ return new AeroflyMissionConditionsCloud(cover, base_feet / feetPerMeter);
27
+ }
28
+ /**
29
+ * @param {number} base_feet `this.base` in feet instead of meters
30
+ */
31
+ set base_feet(base_feet) {
32
+ this.base = base_feet / feetPerMeter;
33
+ }
34
+ /**
35
+ * @returns {number} `this.base` in feet instead of meters
36
+ */
37
+ get base_feet() {
38
+ return this.base * feetPerMeter;
39
+ }
40
+ /**
41
+ * @returns {string} Cloud coverage as text representation like "OVC" for `this.cover`
42
+ */
43
+ get cover_code() {
44
+ if (this.cover < 1 / 8) {
45
+ return "CLR";
46
+ }
47
+ else if (this.cover <= 2 / 8) {
48
+ return "FEW";
49
+ }
50
+ else if (this.cover <= 4 / 8) {
51
+ return "SCT";
52
+ }
53
+ else if (this.cover <= 7 / 8) {
54
+ return "BKN";
55
+ }
56
+ return "OVC";
57
+ }
58
+ /**
59
+ * @param {number} index if used in an array will set the array index
60
+ * @returns {AeroflyConfigurationNode[]} to use in Aerofly FS4's `custom_missions_user.tmc`
61
+ */
62
+ getElements(index = 0) {
63
+ const getIndexString = (index) => {
64
+ switch (index) {
65
+ case 0:
66
+ return "cloud";
67
+ case 1:
68
+ return "cirrus";
69
+ case 2:
70
+ return "cumulus_mediocris";
71
+ default:
72
+ return "more_clouds";
73
+ }
74
+ };
75
+ const indexString = getIndexString(index);
76
+ return [
77
+ new AeroflyConfigurationNode("float64", `${indexString}_cover`, this.cover ?? 0, this.cover_code),
78
+ new AeroflyConfigurationNode("float64", `${indexString}_base`, this.base, `${this.base_feet} ft AGL`),
79
+ ];
80
+ }
81
+ /**
82
+ * @param {number} index if used in an array will set the array index
83
+ * @returns {string} to use in Aerofly FS4's `custom_missions_user.tmc`
84
+ */
85
+ toString(index = 0) {
86
+ return this.getElements()
87
+ .map((element) => element.toString(index))
88
+ .join("\n");
89
+ }
90
+ }
@@ -0,0 +1,35 @@
1
+ import { AeroflyConfigurationNode } from "../node/AeroflyConfigurationNode.js";
2
+ /**
3
+ * @class
4
+ * A target plane which the aircraft needs to cross.
5
+ */
6
+ export class AeroflyMissionTargetPlane {
7
+ /**
8
+ *
9
+ * @param {number} longitude easting, using the World Geodetic
10
+ * System 1984 (WGS 84) [WGS84] datum, with longitude and latitude units
11
+ * of decimal degrees; -180..180
12
+ * @param {number}latitude northing, using the World Geodetic
13
+ * System 1984 (WGS 84) [WGS84] datum, with longitude and latitude units
14
+ * of decimal degrees; -90..90
15
+ * @param {number} dir in degree
16
+ * @param {string} name of property
17
+ */
18
+ constructor(longitude, latitude, dir, name = "finish") {
19
+ this.longitude = longitude;
20
+ this.latitude = latitude;
21
+ this.dir = dir;
22
+ this.name = name;
23
+ }
24
+ getElement() {
25
+ return new AeroflyConfigurationNode("tmmission_target_plane", this.name)
26
+ .appendChild("vector2_float64", "lon_lat", [this.longitude, this.latitude])
27
+ .appendChild("float64", "direction", this.dir);
28
+ }
29
+ /**
30
+ * @returns {string} to use in Aerofly FS4's `custom_missions_user.tmc`
31
+ */
32
+ toString() {
33
+ return this.getElement().toString();
34
+ }
35
+ }
@@ -0,0 +1,36 @@
1
+ import { AeroflyConfigurationNode } from "../node/AeroflyConfigurationNode.js";
2
+ /**
3
+ * @class
4
+ * A list of flight plans.
5
+ *
6
+ * The purpose of this class is to collect data needed for Aerofly FS4's
7
+ * `custom_missions_user.tmc` flight plan file format, and export the structure
8
+ * for this file via the `toString()` method.
9
+ */
10
+ export class AeroflyMissionsList {
11
+ /**
12
+ * @param {AeroflyMission[]} missions in this mission list
13
+ */
14
+ constructor(missions = []) {
15
+ this.missions = missions;
16
+ }
17
+ getElement() {
18
+ return new AeroflyConfigurationNode("file", "").append(new AeroflyConfigurationNode("tmmissions_list", "").append(new AeroflyConfigurationNode("list_tmmission_definition", "missions").append(...this.missions.map((m) => {
19
+ const mission = m.getElement();
20
+ mission._comment = `End of ${mission.name}`;
21
+ return mission;
22
+ }))));
23
+ }
24
+ /**
25
+ * @returns {string} to use in Aerofly FS4's `custom_missions_user.tmc`
26
+ */
27
+ toString() {
28
+ return this.getElement().toString();
29
+ }
30
+ /**
31
+ * @returns {string} XML represenation of this mission list
32
+ */
33
+ toXmlString() {
34
+ return this.getElement().toXmlString();
35
+ }
36
+ }