@scm-js/plugin-api 1.71.0 → 1.73.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 (2) hide show
  1. package/index.d.ts +72 -3
  2. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -861,6 +861,11 @@ export interface TerrainType extends TerrainName {
861
861
  group: number;
862
862
  height: 0 | 1 | 2;
863
863
  buildable: boolean;
864
+ /**
865
+ * The name in the user's language, where `name` is not a string of the catalogue's: a pair
866
+ * terrain's name is put together ("Mud (mid ground)", "Group 3672"). Shown through `terrainLabel`.
867
+ */
868
+ label?: string;
864
869
  }
865
870
  export type GroupKind = "terrain" | "edge" | "doodad" | "other";
866
871
  export interface TileInfo {
@@ -895,7 +900,11 @@ export interface Rect {
895
900
  x1: number;
896
901
  y1: number;
897
902
  }
898
- /** What Replace Terrain matches or writes: a flat terrain type (by ISOM id) or one exact tile. */
903
+ /**
904
+ * What Replace Terrain matches or writes: a flat terrain type or one exact tile. A terrain's id
905
+ * is its ISOM id (the CV5 `index` of the flat pair), or a pair id (`palette.ts#PAIR_TERRAIN`)
906
+ * for flat ground the tileset does not type — a mod's added pairs.
907
+ */
899
908
  export type TerrainPick = {
900
909
  kind: "terrain";
901
910
  id: number;
@@ -4347,6 +4356,25 @@ export interface GameDataProfile {
4347
4356
  * editor never fetches it.
4348
4357
  */
4349
4358
  url?: string;
4359
+ /**
4360
+ * The races the data set adds to the game's own, when they are declared (no game file says
4361
+ * what a mod's races are called). Kept with the id: a profile handed to `attach` or
4362
+ * `install` with races keeps them, and one without gets those kept before for the same id —
4363
+ * after a new release of the mod (a new hash) as well. `setRaces` changes them. Absent in an
4364
+ * editor from before races a data set adds (`api.gameData.source()?.profile.races ?? []`).
4365
+ */
4366
+ races?: DataSetRace[];
4367
+ }
4368
+ /** A race a data set adds to the game's own. */
4369
+ export interface DataSetRace {
4370
+ /** The race byte: 8–255. (0–7 are the game's and cannot be declared.) */
4371
+ id: number;
4372
+ /** What it is called, 40 characters at most, trimmed, not empty. */
4373
+ name: string;
4374
+ /** The lower-case letter its per-race files go by (`game\<letter>console.pcx`, `rez\statbtn<letter>.bin`), when it has them. */
4375
+ letter?: string;
4376
+ /** The game's race it plays as, where only the game's three are known: 0, 1 or 2. Absent: not declared. */
4377
+ like?: 0 | 1 | 2;
4350
4378
  }
4351
4379
  /** Where the session's game data comes from. */
4352
4380
  export interface GameDataSource {
@@ -4541,6 +4569,41 @@ export interface GameDataApi {
4541
4569
  * api.gameData.rehash(await modHashOfTheFiles());
4542
4570
  */
4543
4571
  rehash(hash: string | null): GameDataSource | null;
4572
+ /**
4573
+ * The races the data set in use adds; empty for the game's own or when none is declared.
4574
+ * Absent in an editor from before races a data set adds: call it as
4575
+ * `api.gameData.races?.() ?? []`.
4576
+ */
4577
+ races(): DataSetRace[];
4578
+ /**
4579
+ * Declare the races a data set adds, replacing its table: the data set in use by default,
4580
+ * or the profile `id`. Kept with the profile's id (it survives a new release of the mod and
4581
+ * a re-attach). Rows are normalized: sorted by id, a row with an id outside 8–255, an id an
4582
+ * earlier row has, or no name (or one over 40 characters) dropped; an empty list forgets
4583
+ * them. The game's own data set (and a Remastered installation's) takes none: returns null.
4584
+ * For the set in use, returns its source with the races, and fires what a change of the
4585
+ * data set fires (the `"gameData"` event), so open panels repaint; for another set, keeps
4586
+ * them for when it is used and returns null.
4587
+ *
4588
+ * @example
4589
+ * api.gameData.setRaces?.([{ id: 9, name: "Hivemind Remnant", letter: "h", like: 0 }]);
4590
+ * api.names.race(9); // "Hivemind Remnant"
4591
+ */
4592
+ setRaces(races: readonly DataSetRace[], id?: string): GameDataSource | null;
4593
+ /**
4594
+ * What the data set in use suggests about races it adds, for a person naming them: `names`,
4595
+ * the strings its `rez\network.tbl` has past the game's own table, and `letters`, the
4596
+ * letters other than z, t, p and n with a `game\<letter>console.pcx` or
4597
+ * `rez\statbtn<letter>.bin` of its own. Names and letters already declared are left out;
4598
+ * empty for the game's own data set. These are hints a person confirms, never names to fill
4599
+ * in. A set in memory (`attach`) is asked through its function; a stored copy keeps none of
4600
+ * these files, so it gives none. Absent in an editor from before it
4601
+ * (`api.gameData.raceCandidates?.()`).
4602
+ */
4603
+ raceCandidates(): Promise<{
4604
+ names: string[];
4605
+ letters: string[];
4606
+ }>;
4544
4607
  }
4545
4608
  /**
4546
4609
  * The constants a plugin needs to *write* a record rather than read one: the bit masks in
@@ -5071,8 +5134,12 @@ export interface NamesApi {
5071
5134
  /** An OWNR / IOWN controller byte: `Human`, `Computer`, `Neutral`, … */
5072
5135
  playerType(value: number): string;
5073
5136
  playerTypes(): NamedValue[];
5074
- /** A SIDE race byte. */
5137
+ /**
5138
+ * A SIDE race byte: the game's eight by name, a race the data set in use declares
5139
+ * (`gameData.races()`) by its name, any other `Race {n}`.
5140
+ */
5075
5141
  race(value: number): string;
5142
+ /** The game's eight races in StarEdit's order, then the races the data set in use declares, by id. */
5076
5143
  races(): NamedValue[];
5077
5144
  /** One of the 27 trigger player groups (`Player 1` … `Non Allied Victory Players`). */
5078
5145
  playerGroup(value: number): string;
@@ -5721,12 +5788,14 @@ export interface TestMapFile {
5721
5788
  * The data set the map is being made with, when it is not the game's own: its id and
5722
5789
  * name as `gameData.profile()` gives them, and the digest of its files (empty when none
5723
5790
  * is known). A target that plays the map should play it with those files — the site's
5724
- * play page is handed it as `dataSet` in its `scmjs.play` message.
5791
+ * play page is handed it as `dataSet` in its `scmjs.play` message. `races` when the data
5792
+ * set declares the races it adds (`gameData.races()`), so the target can name them.
5725
5793
  */
5726
5794
  dataSet?: {
5727
5795
  id: string;
5728
5796
  name: string;
5729
5797
  hash: string;
5798
+ races?: DataSetRace[];
5730
5799
  };
5731
5800
  }
5732
5801
  /** What a preferences page's `mount` is handed. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scm-js/plugin-api",
3
- "version": "1.71.0",
3
+ "version": "1.73.0",
4
4
  "description": "Type declarations for the scmJS plugin API",
5
5
  "license": "MIT",
6
6
  "types": "index.d.ts",