coh-content-db 2.0.0-rc.1 → 2.0.0-rc.11

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 (100) hide show
  1. package/.editorconfig +10 -11
  2. package/.github/workflows/build.yml +4 -2
  3. package/.github/workflows/pull-request.yml +1 -1
  4. package/.github/workflows/release.yml +2 -2
  5. package/CHANGELOG.md +43 -0
  6. package/README.md +52 -24
  7. package/dist/coh-content-db.d.ts +678 -279
  8. package/dist/coh-content-db.js +828 -371
  9. package/dist/coh-content-db.js.map +1 -1
  10. package/dist/coh-content-db.mjs +803 -362
  11. package/dist/coh-content-db.mjs.map +1 -1
  12. package/eslint.config.mjs +1 -0
  13. package/package.json +1 -1
  14. package/src/main/api/alignment.ts +18 -2
  15. package/src/main/api/alternate-data.ts +2 -2
  16. package/src/main/api/badge-data.ts +20 -48
  17. package/src/main/api/badge-requirement-data.ts +64 -0
  18. package/src/main/api/badge-requirement-type.ts +32 -0
  19. package/src/main/api/badge-type.ts +15 -15
  20. package/src/main/api/bundle-data.ts +47 -0
  21. package/src/main/api/bundle-header-data.ts +37 -0
  22. package/src/main/api/contact-data.ts +48 -0
  23. package/src/main/api/enhancement-category.ts +26 -26
  24. package/src/main/api/location-data.ts +28 -0
  25. package/src/main/api/markdown-string.ts +4 -0
  26. package/src/main/api/mission-data.ts +83 -0
  27. package/src/main/api/mission-type.ts +2 -0
  28. package/src/main/api/morality.ts +31 -0
  29. package/src/main/api/sex.ts +8 -1
  30. package/src/main/api/zone-data.ts +20 -0
  31. package/src/main/db/abstract-index.ts +37 -0
  32. package/src/main/db/alignment-list.ts +54 -0
  33. package/src/main/db/alternates.ts +28 -42
  34. package/src/main/db/badge-index.ts +60 -0
  35. package/src/main/db/badge-requirement.ts +81 -0
  36. package/src/main/db/badge-search-options.ts +47 -0
  37. package/src/main/db/badge.ts +76 -71
  38. package/src/main/db/bundle-header.ts +44 -0
  39. package/src/main/db/coh-content-database.ts +123 -14
  40. package/src/main/db/contact.ts +62 -0
  41. package/src/main/db/location.ts +30 -0
  42. package/src/main/db/mission.ts +107 -0
  43. package/src/main/db/morality-list.ts +99 -0
  44. package/src/main/db/paged.ts +7 -0
  45. package/src/main/db/zone.ts +28 -0
  46. package/src/main/index.ts +23 -15
  47. package/src/main/util.ts +108 -7
  48. package/src/test/api/alignment.test.ts +38 -4
  49. package/src/test/api/badge-data.fixture.ts +1 -15
  50. package/src/test/api/badge-data.test.ts +4 -4
  51. package/src/test/api/badge-requirement-data.fixture.ts +7 -0
  52. package/src/test/api/badge-requirement-type.test.ts +31 -0
  53. package/src/test/api/badge-type.test.ts +5 -5
  54. package/src/test/api/bundle-data.fixture.ts +6 -0
  55. package/src/test/api/bundle-header-data.fixture.ts +6 -0
  56. package/src/test/api/contact-data.fixture.ts +7 -0
  57. package/src/test/api/enhancement-category.test.ts +5 -5
  58. package/src/test/api/mission-data.fixture.ts +12 -0
  59. package/src/test/api/sex.test.ts +33 -1
  60. package/src/test/api/zone-data.fixture.ts +8 -0
  61. package/src/test/db/abstract-index.test.ts +55 -0
  62. package/src/test/db/alignment-list.test.ts +200 -0
  63. package/src/test/db/alternates.test.ts +82 -117
  64. package/src/test/db/badge-index.test.ts +547 -0
  65. package/src/test/db/badge-requirement.test.ts +145 -0
  66. package/src/test/db/badge.test.ts +322 -14
  67. package/src/test/db/bundle-header.test.ts +76 -0
  68. package/src/test/db/coh-content-database.test.ts +264 -24
  69. package/src/test/db/contact.test.ts +97 -0
  70. package/src/test/db/location.test.ts +51 -0
  71. package/src/test/db/mission.test.ts +171 -0
  72. package/src/test/db/morality-list.test.ts +457 -0
  73. package/src/test/db/zone.test.ts +36 -0
  74. package/src/test/integration.test.ts +16 -0
  75. package/src/test/util.test.ts +144 -18
  76. package/src/main/api/badge-partial-data.ts +0 -65
  77. package/src/main/api/badge-partial-type.ts +0 -8
  78. package/src/main/api/change.ts +0 -14
  79. package/src/main/api/game-map-data.ts +0 -26
  80. package/src/main/api/plaque-type.ts +0 -6
  81. package/src/main/api/server-group-data.ts +0 -65
  82. package/src/main/api/vidiot-map-data.ts +0 -18
  83. package/src/main/api/vidiot-map-point-of-interest-data.ts +0 -30
  84. package/src/main/changelog.ts +0 -20
  85. package/src/main/db/badge-partial.ts +0 -35
  86. package/src/main/db/game-map.ts +0 -33
  87. package/src/main/db/server-group.ts +0 -112
  88. package/src/main/db/vidiot-map-point-of-interest.ts +0 -40
  89. package/src/main/db/vidiot-map.ts +0 -25
  90. package/src/test/api/badge-partial-data.fixture.ts +0 -17
  91. package/src/test/api/badge-partial-type.test.ts +0 -31
  92. package/src/test/api/game-map-data.fixture.ts +0 -10
  93. package/src/test/api/plaque-type.test.ts +0 -31
  94. package/src/test/api/server-group-data.fixture.ts +0 -23
  95. package/src/test/api/server-group-data.test.ts +0 -15
  96. package/src/test/api/vidiot-map-point-of-interest.fixture.ts +0 -10
  97. package/src/test/api/vidiot-map.fixture.ts +0 -9
  98. package/src/test/changelog.test.ts +0 -36
  99. package/src/test/db/server-group.test.ts +0 -124
  100. package/src/test/index.test.ts +0 -10
@@ -1,39 +1,165 @@
1
- import { Badge, createBadgeReference, createMapReference, GameMap } from '../main'
1
+ import { Badge, badgeLink, badgeUri, coalesceToArray, Contact, contactLink, contactUri, Mission, missionLink, missionUri, Zone, zoneLink, zoneUri } from '../main'
2
2
  import { badgeDataFixture } from './api/badge-data.fixture'
3
- import { gameMapDataFixture } from './api/game-map-data.fixture'
3
+ import { zoneDataFixture } from './api/zone-data.fixture'
4
+ import { contactDataFixture } from './api/contact-data.fixture'
5
+ import { missionDataFixture } from './api/mission-data.fixture'
4
6
 
5
- describe(createBadgeReference.name, () => {
7
+ describe(badgeUri.name, () => {
6
8
  test('should return the expected pattern', () => {
7
- expect(createBadgeReference('foo')).toBe('[badge:foo]')
8
- expect(createBadgeReference('bar')).toBe('[badge:bar]')
9
- expect(createBadgeReference('foo-bar')).toBe('[badge:foo-bar]')
9
+ expect(badgeUri('foo')).toBe('badge://foo')
10
+ expect(badgeUri('bar')).toBe('badge://bar')
11
+ expect(badgeUri('foo-bar')).toBe('badge://foo-bar')
10
12
  })
11
13
 
12
14
  test('should accept a Badge object', () => {
13
15
  const badge = new Badge(badgeDataFixture.create({ key: 'foo' }))
14
- expect(createBadgeReference(badge)).toBe('[badge:foo]')
16
+ expect(badgeUri(badge)).toBe('badge://foo')
15
17
  })
16
18
 
17
19
  test('should accept a BadgeData object', () => {
18
20
  const badge = badgeDataFixture.create({ key: 'foo' })
19
- expect(createBadgeReference(badge)).toBe('[badge:foo]')
21
+ expect(badgeUri(badge)).toBe('badge://foo')
20
22
  })
21
23
  })
22
24
 
23
- describe(createMapReference.name, () => {
25
+ describe(badgeLink.name, () => {
24
26
  test('should return the expected pattern', () => {
25
- expect(createMapReference('foo')).toBe('[map:foo]')
26
- expect(createMapReference('bar')).toBe('[map:bar]')
27
- expect(createMapReference('foo-bar')).toBe('[map:foo-bar]')
27
+ expect(badgeLink('foo')).toBe('[foo](badge://foo)')
28
+ expect(badgeLink('bar')).toBe('[bar](badge://bar)')
29
+ expect(badgeLink('foo-bar')).toBe('[foo-bar](badge://foo-bar)')
28
30
  })
29
31
 
30
- test('should accept a GameMap object', () => {
31
- const map = new GameMap(gameMapDataFixture.create({ key: 'foo' }))
32
- expect(createMapReference(map)).toBe('[map:foo]')
32
+ test('should accept a Badge object', () => {
33
+ const badge = new Badge(badgeDataFixture.create({ key: 'foo' }))
34
+ expect(badgeLink(badge)).toBe('[foo](badge://foo)')
35
+ })
36
+
37
+ test('should accept a BadgeData object', () => {
38
+ const badge = badgeDataFixture.create({ key: 'foo' })
39
+ expect(badgeLink(badge)).toBe('[foo](badge://foo)')
40
+ })
41
+ })
42
+
43
+ describe(contactUri.name, () => {
44
+ test('should return the expected pattern', () => {
45
+ expect(contactUri('foo')).toBe('contact://foo')
46
+ expect(contactUri('bar')).toBe('contact://bar')
47
+ expect(contactUri('foo-bar')).toBe('contact://foo-bar')
48
+ })
49
+
50
+ test('should accept a Contact object', () => {
51
+ const contact = new Contact(contactDataFixture.create({ key: 'foo' }))
52
+ expect(contactUri(contact)).toBe('contact://foo')
53
+ })
54
+
55
+ test('should accept a ContactData object', () => {
56
+ const contact = contactDataFixture.create({ key: 'foo' })
57
+ expect(contactUri(contact)).toBe('contact://foo')
58
+ })
59
+ })
60
+
61
+ describe(contactLink.name, () => {
62
+ test('should return the expected pattern', () => {
63
+ expect(contactLink('foo')).toBe('[foo](contact://foo)')
64
+ expect(contactLink('bar')).toBe('[bar](contact://bar)')
65
+ expect(contactLink('foo-bar')).toBe('[foo-bar](contact://foo-bar)')
66
+ })
67
+
68
+ test('should accept a Contact object', () => {
69
+ const contact = new Contact(contactDataFixture.create({ key: 'foo' }))
70
+ expect(contactLink(contact)).toBe('[foo](contact://foo)')
71
+ })
72
+
73
+ test('should accept a ContactData object', () => {
74
+ const contact = contactDataFixture.create({ key: 'foo' })
75
+ expect(contactLink(contact)).toBe('[foo](contact://foo)')
76
+ })
77
+ })
78
+
79
+ describe(missionUri.name, () => {
80
+ test('should return the expected pattern', () => {
81
+ expect(missionUri('foo')).toBe('mission://foo')
82
+ expect(missionUri('bar')).toBe('mission://bar')
83
+ expect(missionUri('foo-bar')).toBe('mission://foo-bar')
84
+ })
85
+
86
+ test('should accept a Mission object', () => {
87
+ const mission = new Mission(missionDataFixture.create({ key: 'foo' }))
88
+ expect(missionUri(mission)).toBe('mission://foo')
89
+ })
90
+
91
+ test('should accept a MissionData object', () => {
92
+ const mission = missionDataFixture.create({ key: 'foo' })
93
+ expect(missionUri(mission)).toBe('mission://foo')
94
+ })
95
+ })
96
+
97
+ describe(missionLink.name, () => {
98
+ test('should return the expected pattern', () => {
99
+ expect(missionLink('foo')).toBe('[foo](mission://foo)')
100
+ expect(missionLink('bar')).toBe('[bar](mission://bar)')
101
+ expect(missionLink('foo-bar')).toBe('[foo-bar](mission://foo-bar)')
102
+ })
103
+
104
+ test('should accept a Mission object', () => {
105
+ const mission = new Mission(missionDataFixture.create({ key: 'foo' }))
106
+ expect(missionLink(mission)).toBe('[foo](mission://foo)')
107
+ })
108
+
109
+ test('should accept a MissionData object', () => {
110
+ const mission = missionDataFixture.create({ key: 'foo' })
111
+ expect(missionLink(mission)).toBe('[foo](mission://foo)')
112
+ })
113
+ })
114
+
115
+ describe(zoneUri.name, () => {
116
+ test('should return the expected pattern', () => {
117
+ expect(zoneUri('foo')).toBe('zone://foo')
118
+ expect(zoneUri('bar')).toBe('zone://bar')
119
+ expect(zoneUri('foo-bar')).toBe('zone://foo-bar')
120
+ })
121
+
122
+ test('should accept a Zone object', () => {
123
+ const zone = new Zone(zoneDataFixture.create({ key: 'foo' }))
124
+ expect(zoneUri(zone)).toBe('zone://foo')
125
+ })
126
+
127
+ test('should accept a ZoneData object', () => {
128
+ const zone = zoneDataFixture.create({ key: 'foo' })
129
+ expect(zoneUri(zone)).toBe('zone://foo')
130
+ })
131
+ })
132
+
133
+ describe(zoneLink.name, () => {
134
+ test('should return the expected pattern', () => {
135
+ expect(zoneLink('foo')).toBe('[foo](zone://foo)')
136
+ expect(zoneLink('bar')).toBe('[bar](zone://bar)')
137
+ expect(zoneLink('foo-bar')).toBe('[foo-bar](zone://foo-bar)')
138
+ })
139
+
140
+ test('should accept a Zone object', () => {
141
+ const zone = new Zone(zoneDataFixture.create({ key: 'foo' }))
142
+ expect(zoneLink(zone)).toBe('[foo](zone://foo)')
143
+ })
144
+
145
+ test('should accept a ZoneData object', () => {
146
+ const zone = zoneDataFixture.create({ key: 'foo' })
147
+ expect(zoneLink(zone)).toBe('[foo](zone://foo)')
148
+ })
149
+ })
150
+
151
+ describe(coalesceToArray.name, () => {
152
+ test('should return an array unmodified', () => {
153
+ expect(coalesceToArray(['a', 'b'])).toStrictEqual(['a', 'b'])
154
+ expect(coalesceToArray([1, 2])).toStrictEqual([1, 2])
155
+ })
156
+
157
+ test('should return a single value as a single-value array', () => {
158
+ expect(coalesceToArray('a')).toStrictEqual(['a'])
159
+ expect(coalesceToArray(1)).toStrictEqual([1])
33
160
  })
34
161
 
35
- test('should accept a GameMapData object', () => {
36
- const map = gameMapDataFixture.create({ key: 'foo' })
37
- expect(createMapReference(map)).toBe('[map:foo]')
162
+ test('should return undefined value as undefined', () => {
163
+ expect(coalesceToArray()).toBeUndefined()
38
164
  })
39
165
  })
@@ -1,65 +0,0 @@
1
- import { EnhancementCategory } from './enhancement-category'
2
- import { BadgePartialType } from './badge-partial-type'
3
- import { PlaqueType } from './plaque-type'
4
-
5
- export interface BadgePartialData {
6
- /**
7
- * Key.
8
- */
9
- readonly key: string
10
-
11
- /**
12
- * Type of partial.
13
- */
14
- readonly type: BadgePartialType | string
15
-
16
- /**
17
- * Map the partial is located on.
18
- */
19
- readonly mapKey?: string
20
-
21
- /**
22
- * /loc coordinates.
23
- */
24
- readonly loc?: number[]
25
-
26
- /**
27
- * Is it a wall plaque or a physical monument?
28
- */
29
- readonly plaqueType?: PlaqueType | string
30
-
31
- /**
32
- * Plaque inscription.
33
- */
34
- readonly inscription?: string
35
-
36
- /**
37
- * The number or letter the partial appears as on Vidiot Maps.
38
- */
39
- readonly vidiotMapKey?: string
40
-
41
- /**
42
- * The badge required for this partial.
43
- */
44
- readonly badgeKey?: string
45
-
46
- /**
47
- * Level of the invention required.
48
- */
49
- readonly inventionLevel?: number
50
-
51
- /**
52
- * The types of enhancements required to be crafted.
53
- */
54
- readonly inventionTypes?: (EnhancementCategory | string)[]
55
-
56
- /**
57
- * Number of invention crafts required.
58
- */
59
- readonly inventionCount?: number
60
-
61
- /**
62
- * Any additional notes.
63
- */
64
- readonly notes?: string
65
- }
@@ -1,8 +0,0 @@
1
- export const BADGE_PARTIAL_TYPE = [
2
- 'PLAQUE',
3
- 'BADGE',
4
- 'INVENTION',
5
- 'INVENTION_PLUS_ONE', // Some invention badges require you to build x of two different invention levels, 'plus one of either level'.
6
- ] as const
7
-
8
- export type BadgePartialType = typeof BADGE_PARTIAL_TYPE[number]
@@ -1,14 +0,0 @@
1
- export interface Change {
2
- /**
3
- * The version number in {@link http://semver.org|semver} format.
4
- */
5
- version: string
6
- /**
7
- * Date of the change.
8
- */
9
- date: Date
10
- /**
11
- * Description of the change in {@link https://www.markdownguide.org/|Markdown} format.
12
- */
13
- description: string
14
- }
@@ -1,26 +0,0 @@
1
- import { Link } from './link'
2
- import { VidiotMapData } from './vidiot-map-data'
3
-
4
- export interface GameMapData {
5
- /**
6
- * Unique key used to reference this badge.
7
- *
8
- * Keys can only contain lowercase letters, numbers and hyphens (`-`).
9
- */
10
- readonly key: string
11
-
12
- /**
13
- * The name of the map as it appears in-game.
14
- */
15
- readonly name: string
16
-
17
- /**
18
- * List of external links for this Map. Wiki, forums, etc.
19
- */
20
- readonly links?: Link[]
21
-
22
- /**
23
- * List of Vidiot Map assets for this map.
24
- */
25
- readonly vidiotMaps?: VidiotMapData[]
26
- }
@@ -1,6 +0,0 @@
1
- export const PLAQUE_TYPE = [
2
- 'WALL_PLAQUE',
3
- 'MONUMENT',
4
- ]
5
-
6
- export type PlaqueType = typeof PLAQUE_TYPE[number]
@@ -1,65 +0,0 @@
1
- import { ArchetypeData } from './archetype-data'
2
- import { GameMapData } from './game-map-data'
3
- import { BadgeData } from './badge-data'
4
- import { Change } from './change'
5
- import { Link } from './link'
6
-
7
- /**
8
- * A server group is a group or company that hosts a set of game servers, such as Homecoming (https://forums.homecomingservers.com/).
9
- */
10
- export interface ServerGroupData {
11
- /**
12
- * Unique key used to reference this server group.
13
- *
14
- * Keys can only contain lowercase letters, numbers and hyphens (`-`).
15
- */
16
- readonly key: string
17
-
18
- /**
19
- * Name of the server group.
20
- */
21
- readonly name: string
22
-
23
- /**
24
- * Description of the server group.
25
- *
26
- * Supports {@link https://www.markdownguide.org/|Markdown} format.
27
- */
28
- readonly description?: string
29
-
30
- /**
31
- * Repository where the db content package is maintained.
32
- */
33
- readonly repository?: string
34
-
35
- /**
36
- * List of external links for this Badge. Wiki, forums, etc.
37
- */
38
- readonly links?: Link[]
39
-
40
- /**
41
- * List of the game server names in this server group.
42
- * Torchbearer, Excelsior, etc.
43
- */
44
- readonly servers?: string[]
45
-
46
- /**
47
- * List of archetypes available in this server group.
48
- */
49
- readonly archetypes?: ArchetypeData[]
50
-
51
- /**
52
- * List of game maps supported by this server group.
53
- */
54
- readonly maps?: GameMapData[]
55
-
56
- /**
57
- * List of badges available on this server group.
58
- */
59
- readonly badges?: BadgeData[]
60
-
61
- /**
62
- * Change log for this data package.
63
- */
64
- readonly changelog?: Change[]
65
- }
@@ -1,18 +0,0 @@
1
- import { VidiotMapPointOfInterestData } from './vidiot-map-point-of-interest-data'
2
-
3
- export interface VidiotMapData {
4
- /**
5
- * URL of the map image.
6
- */
7
- readonly imageUrl: string
8
-
9
- /**
10
- * Name to display for the Vidiot map.
11
- */
12
- readonly name?: string
13
-
14
- /**
15
- * List of Points of Interest labelled on the image.
16
- */
17
- readonly pointsOfInterest?: VidiotMapPointOfInterestData[]
18
- }
@@ -1,30 +0,0 @@
1
- export interface VidiotMapPointOfInterestData {
2
- /**
3
- * The pixel-space position of the PoI on the map graphic.
4
- *
5
- * Screen-space, pixels from top-left `[0, 0]`.
6
- */
7
- readonly pos?: [number, number]
8
-
9
- /**
10
- * Freeform notes about the PoI.
11
- *
12
- * Supports {@link https://www.markdownguide.org/|Markdown} format.
13
- */
14
- readonly notes?: string
15
-
16
- /**
17
- * If the POI is a zone transfer, the map it transfers to.
18
- */
19
- readonly mapKey?: string
20
-
21
- /**
22
- * If the POI is a badge, the badge.
23
- */
24
- readonly badgeKey?: string
25
-
26
- /**
27
- * If the POI is a partial for a badge, the partial key.
28
- */
29
- readonly badgePartialKey?: string
30
- }
@@ -1,20 +0,0 @@
1
- import { Change } from './api/change'
2
-
3
- export const CHANGELOG: Change[] = [
4
- {
5
- version: '2.0.0',
6
- date: new Date('2025-03-12'),
7
- description: ''
8
- + '* Replaced redundant interfaces with their concrete equivalents.\n'
9
- + '* Replaced enums with extensible union types; Server groups with new badge types, enhancement types, etc. can now extend them locally.\n'
10
- + '* Removed the `serverGroup` property from entities to simplify the object tree; Server group context will need to be managed separately.\n'
11
- + '* Standardized pluralization of some field names (name, icon).\n'
12
- + '* Combined `settitle` ids into a single tuple field.\n'
13
- + '* Change from GNU to The Unlicense.\n'
14
- + '* Removed dependency on lodash. There are now no third-party runtime dependencies.\n'
15
- + '* Moved from webpack to rollup for packaging.\n'
16
- + '* Add eslint for linting.\n'
17
- + '* Add jest for unit tests.\n'
18
- + '* Added GitHub Actions for CI.\n',
19
- },
20
- ]
@@ -1,35 +0,0 @@
1
- import { BadgePartialData } from '../api/badge-partial-data'
2
- import { PlaqueType } from '../api/plaque-type'
3
- import { BadgePartialType } from '../api/badge-partial-type'
4
- import { EnhancementCategory } from '../api/enhancement-category'
5
- import { Key } from './key'
6
-
7
- export class BadgePartial {
8
- readonly key: string
9
- readonly type: BadgePartialType | string
10
- readonly mapKey?: string
11
- readonly loc?: number[]
12
- readonly plaqueType?: PlaqueType | string
13
- readonly inscription?: string
14
- readonly vidiotMapKey?: string
15
- readonly badgeKey?: string
16
- readonly inventionLevel?: number
17
- readonly inventionTypes?: (EnhancementCategory | string)[]
18
- readonly inventionCount?: number
19
- readonly notes?: string
20
-
21
- constructor(data: BadgePartialData) {
22
- this.key = new Key(data.key).value
23
- this.type = data.type
24
- this.mapKey = data.mapKey
25
- this.loc = data.loc
26
- this.plaqueType = data.plaqueType
27
- this.inscription = data.inscription
28
- this.vidiotMapKey = data.vidiotMapKey
29
- this.badgeKey = data.badgeKey
30
- this.inventionLevel = data.inventionLevel
31
- this.inventionTypes = data.inventionTypes
32
- this.inventionCount = data.inventionCount
33
- this.notes = data.notes
34
- }
35
- }
@@ -1,33 +0,0 @@
1
- import { VidiotMap } from './vidiot-map'
2
- import { Link } from '../api/link'
3
- import { GameMapData } from '../api/game-map-data'
4
- import { Key } from './key'
5
-
6
- export class GameMap {
7
- /**
8
- * The database key for this map.
9
- */
10
- readonly key: string
11
-
12
- /**
13
- * The name of the map as it appears in-game.
14
- */
15
- readonly name: string
16
-
17
- /**
18
- * List of external links for this Map. Wiki, forums, etc.
19
- */
20
- readonly links?: Link[]
21
-
22
- /**
23
- * List of Vidiot Map assets for this map.
24
- */
25
- readonly vidiotMaps?: VidiotMap[]
26
-
27
- constructor(data: GameMapData) {
28
- this.key = new Key(data.key).value
29
- this.name = data.name
30
- this.links = data.links
31
- this.vidiotMaps = data.vidiotMaps?.map(data => new VidiotMap(data))
32
- }
33
- }
@@ -1,112 +0,0 @@
1
- import { Archetype } from './archetype'
2
- import { Badge } from './badge'
3
- import { ServerGroupData } from '../api/server-group-data'
4
- import { Key } from './key'
5
- import { Change } from '../api/change'
6
- import { GameMap } from './game-map'
7
- import { Link } from '../api/link'
8
-
9
- export class ServerGroup {
10
- readonly #archetypeIndex: Record<string, Archetype> = {}
11
- readonly #mapIndex: Record<string, GameMap> = {}
12
- readonly #badgeIndex: Record<string, Badge> = {}
13
-
14
- /**
15
- * The database key for this server group.
16
- */
17
- readonly key: string
18
-
19
- /**
20
- * Name of the server group.
21
- */
22
- readonly name: string
23
-
24
- /**
25
- * Description of the server group.
26
- *
27
- * Supports {@link https://www.markdownguide.org/|Markdown} format.
28
- */
29
- readonly description?: string
30
-
31
- /**
32
- * Repository where the db content package is maintained.
33
- */
34
- readonly repository?: string
35
-
36
- /**
37
- * List of external links for this Server Group. Wiki, forums, etc.
38
- */
39
- readonly links?: Link[]
40
-
41
- /**
42
- * List of the game server names in this server group.
43
- * Torchbearer, Excelsior, etc.
44
- */
45
- readonly servers: string[]
46
-
47
- /**
48
- * List of archetypes available in this server group.
49
- */
50
- readonly archetypes: Archetype[]
51
-
52
- /**
53
- * List of game maps supported by this server group.
54
- */
55
- readonly maps: GameMap[]
56
-
57
- /**
58
- * List of badges available on this server group.
59
- */
60
- readonly badges: Badge[]
61
-
62
- /**
63
- * Change log for this data package.
64
- */
65
- readonly changelog?: Change[]
66
-
67
- constructor(data: ServerGroupData) {
68
- this.key = new Key(data.key).value
69
- this.name = data.name
70
- this.description = data.description
71
- this.repository = data.repository
72
- this.links = data.links
73
- this.servers = data.servers ?? []
74
- this.archetypes = data.archetypes?.map((data) => {
75
- if (this.#archetypeIndex[data.key] !== undefined) throw new Error(`Duplicate archetype key [${data.key}]`)
76
- const archetype = new Archetype(data)
77
- this.#archetypeIndex[archetype.key] = archetype
78
- return archetype
79
- }) ?? []
80
- this.maps = data.maps?.map((data) => {
81
- if (this.#mapIndex[data.key] !== undefined) throw new Error(`Duplicate map key [${data.key}]`)
82
- const map = new GameMap(data)
83
- this.#mapIndex[map.key] = map
84
- return map
85
- }) ?? []
86
- this.badges = data.badges?.map((data) => {
87
- if (this.#badgeIndex[data.key] !== undefined) throw new Error(`Duplicate badge key [${data.key}]`)
88
- const badge = new Badge(data)
89
- this.#badgeIndex[badge.key] = badge
90
- return badge
91
- }) ?? []
92
- this.changelog = data.changelog
93
- }
94
-
95
- getArchetype(key: string): Archetype {
96
- const result = this.#archetypeIndex[key]
97
- if (result === undefined) throw new Error(`Unknown archetype key [${key}]`)
98
- return result
99
- }
100
-
101
- getMap(key: string): GameMap {
102
- const result = this.#mapIndex[key]
103
- if (result === undefined) throw new Error(`Unknown map key [${key}]`)
104
- return result
105
- }
106
-
107
- getBadge(key: string): Badge {
108
- const result = this.#badgeIndex[key]
109
- if (result === undefined) throw new Error(`Unknown badge key [${key}]`)
110
- return result
111
- }
112
- }
@@ -1,40 +0,0 @@
1
- import { VidiotMapPointOfInterestData } from '../api/vidiot-map-point-of-interest-data'
2
-
3
- export class VidiotMapPointOfInterest {
4
- /**
5
- * The pixel-space position of the PoI on the map graphic.
6
- *
7
- * Screen-space, pixels from top-left `[0, 0]`.
8
- */
9
- readonly pos?: [number, number]
10
-
11
- /**
12
- * Freeform notes about the PoI.
13
- *
14
- * Supports {@link https://www.markdownguide.org/|Markdown} format.
15
- */
16
- readonly notes?: string
17
-
18
- /**
19
- * If the POI is a zone transfer, the map it transfers to.
20
- */
21
- readonly mapKey?: string
22
-
23
- /**
24
- * If the POI is a badge, the badge.
25
- */
26
- readonly badgeKey?: string
27
-
28
- /**
29
- * If the POI is a partial for a badge, the partial key.
30
- */
31
- readonly badgePartialKey?: string
32
-
33
- constructor(data: VidiotMapPointOfInterestData) {
34
- this.pos = data.pos
35
- this.notes = data.notes
36
- this.mapKey = data.mapKey
37
- this.badgeKey = data.badgeKey
38
- this.badgePartialKey = data.badgePartialKey
39
- }
40
- }