chess4js 1.0.0-beta.5 → 1.0.0-beta.6

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.
package/README.md CHANGED
@@ -240,27 +240,29 @@ For the `Node` class:
240
240
 
241
241
  For the `Game` class
242
242
 
243
- | Method | Arguments | Return type | Description |
244
- |---------------------|------------------------------------|------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
245
- | setTag | name: String, value: String | undefined | Sets a tag pair (name and value). |
246
- | getTag | name: String | Nullable<String> | Retrieves the tag's value. |
247
- | toString | None | String | Returns the game in pgn format. |
248
- | toAnalysis | idSupplier?: () => Nullable\<any\> | Game | Creates a deep copy of this game, converting its mode to ANALYSIS and setting both repetition rules to AWARE. This makes the new instance fully mutable for analysis. |
249
- | deleteFromExclusive | node: Node | Node | Deletes all moves (the main line continuation and any variations) that follow the provided node. The node provided remains in the game. |
250
- | deleteFromInclusive | node: Node | Node | Deletes all moves (the main line continuation and any variations) that follow the provided node. The move represented by the node is effectively removed from the game. |
251
- | deleteBefore | node: Node | Node | Deletes all moves that preceded the provided node in the main line. The node (and its position) becomes the new effective start of the game, creating a new root Node. |
252
-
243
+ | Method | Arguments | Return type | Description |
244
+ |---------------------|------------------------------------|------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
245
+ | setTag | name: String, value: String | undefined | Sets a tag pair (name and value). |
246
+ | getTag | name: String | Nullable<String> | Retrieves the tag's value. |
247
+ | toString | None | String | Returns the game in pgn format. |
248
+ | toAnalysis | idSupplier?: () => Nullable\<any\> | Game | Creates a deep copy of this game, converting its mode to ANALYSIS and setting both repetition rules to AWARE. This makes the new instance fully mutable for analysis. |
249
+ | deleteFromExclusive | node: Node | Node | Deletes all moves (the main line continuation and any variations) that follow the provided node. The node provided remains in the game. |
250
+ | deleteFromInclusive | node: Node | Node | Deletes all moves (the main line continuation and any variations) that follow the provided node. The move represented by the node is effectively removed from the game. |
251
+ | deleteBefore | node: Node | Node | Deletes all moves that preceded the provided node in the main line. The node (and its position) becomes the new effective start of the game, creating a new root Node. |
252
+ | updateEco | None | undefined | Updates the instance's ECO ranking based on the last move of the main line. In match mode this is automatic, but in analysis this function must be called, otherwise the game will not be ranked. |
253
+
253
254
  For the `Node` class
254
255
 
255
- | Method | Arguments | Return type | Description |
256
- |-------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
257
- | appendMove | move: string, initialComment?: Nullable\<string\>, comment?: Nullable\<string\>, endLineComment?: Nullable\<string\>, suffixAnnotations?: Nullable\<ReadonlyArray\<number\>\>, notation?: Notation | Node | Appends a move and returns the added node. If the node already has a child, the added move will be a variation (RAV). Returns the new node if the move is legal, or the current node if the move is illegal. |
258
- | promoteChild | index: number | boolean | Promotes the child at the given index to the primary variation (children[0]). |
259
- | promoteNode | None | boolean | Promotes this node to the main line. |
260
- | removeChild | node: Node | boolean | Removes the specified child node (variation) from the current node's list of children. |
261
- | hasChildren | None | boolean | Checks if the node has children. |
262
- | belongsToMainLine | None | boolean | Indicates whether this node belongs to the main line (i.e., it is the first child of all its ancestors). |
263
- | copy | parent: Nullable\<Node\> | Node | Creates a deep copy of this node and its entire subtree, assigning the specified parent to the new copy. This process is recursive; copying the root node copies the entire game tree. |
256
+ | Method | Arguments | Return type | Description |
257
+ |-------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
258
+ | appendMove | move: string, initialComment?: Nullable\<string\>, comment?: Nullable\<string\>, endLineComment?: Nullable\<string\>, suffixAnnotations?: Nullable\<ReadonlyArray\<number\>\>, notation?: Notation | Node | Appends a move and returns the added node. If the node already has a child, the added move will be a variation (RAV). Returns the new node if the move is legal, or the current node if the move is illegal. |
259
+ | promoteChild | index: number | boolean | Promotes the child at the given index to the primary variation (children[0]). |
260
+ | promoteNode | None | boolean | Promotes this node to the main line. |
261
+ | removeChild | node: Node | boolean | Removes the specified child node (variation) from the current node's list of children. |
262
+ | hasChildren | None | boolean | Checks if the node has children. |
263
+ | belongsToMainLine | None | boolean | Indicates whether this node belongs to the main line (i.e., it is the first child of all its ancestors). |
264
+ | copy | parent: Nullable\<Node\> | Node | Creates a deep copy of this node and its entire subtree, assigning the specified parent to the new copy. This process is recursive; copying the root node copies the entire game tree. |
265
+ | toSan | language: string (deafult "english"), pieces: Nullable\<Array\<String\>\> (default null) | string | Converts a move to Standard Algebraic Notation (SAN). This function acts as a convenience wrapper to generate notation adapted to different languages. If the move is null, it returns an empty string. If the specified language is not predefined, a custom array of piece initials must be provided. Supported internal languages: "english", "spanish", "dutch", "french", "german", and "italian". |
264
266
 
265
267
  ### Factories and PGN parsing
266
268
 
package/chess4js.d.mts CHANGED
@@ -71,6 +71,7 @@ export declare class Game {
71
71
  deleteFromExclusive(node: Node): Node;
72
72
  deleteFromInclusive(node: Node): Node;
73
73
  deleteBefore(_this_: Game, node: Node): Node;
74
+ updateEco(): void;
74
75
  }
75
76
  /** @deprecated $metadata$ is used for internal purposes, please don't use it in your code, because it can be removed at any moment */
76
77
  export declare namespace Game.$metadata$ {
@@ -110,6 +111,7 @@ export declare class Node {
110
111
  hashCode(): number;
111
112
  equals(other: Nullable<any>): boolean;
112
113
  toString(): string;
114
+ toSan(language?: string, pieces?: Nullable<Array<string>>): string;
113
115
  }
114
116
  /** @deprecated $metadata$ is used for internal purposes, please don't use it in your code, because it can be removed at any moment */
115
117
  export declare namespace Node.$metadata$ {