chess4js 1.0.0-beta.9 → 1.0.0-beta.9c

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
@@ -424,6 +424,7 @@ factory.
424
424
  | `white` | `Nullable<Player>` | The white player. |
425
425
  | `black` | `Nullable<Player>` | The black player. |
426
426
  | `outcome` | `string` | The outcome of the match, can be "1-0", "0-1", "1/2-1/2", "in game" or "suspended" |
427
+ | `id` | `Nullable<string>` | An id for the match |
427
428
 
428
429
  #### Factories
429
430
 
@@ -450,30 +451,36 @@ are two types: arena and swiss instances. Both are further detailed in the examp
450
451
 
451
452
  #### Properties
452
453
 
453
- | Property | Type | Description |
454
- |-------------------|-------------------------|------------------------------------------------------------------------------------------------------------------------------------------|
455
- | `impactFactor` | `number` | The K-factor that determines how much a single match affects the rating. A higher value leads to faster rating changes. Default is 32.0. |
456
- | `rangeFactor` | `number` | The scale factor used to determine win probability. Default is 400.0. |
457
- | `logisticBase` | `number` | The base of the exponent in the logistic function. Default is 10. |
458
- | `tiebreakers` | `Array<string>` | The strategy for breaking ties in the leaderboard. |
459
- | `leaderboard` | `ReadonlyArray<Player>` | Current player standings, ordered by score and tie-breakers. |
460
- | `completed` | `boolean` | Whether the tournament has reached its conclusion. |
461
- | `activeMatches` | `ReadonlyArray<Match>` | Current matches being played. |
462
- | `finishedMatches` | `ReadonlyArray<Match>` | All concluded matches in the tournament history. |
454
+ | Property | Type | Description |
455
+ |-------------------|--------------------------|------------------------------------------------------------------------------------------------------------------------------------------|
456
+ | `impactFactor` | `number` | The K-factor that determines how much a single match affects the rating. A higher value leads to faster rating changes. Default is 32.0. |
457
+ | `rangeFactor` | `number` | The scale factor used to determine win probability. Default is 400.0. |
458
+ | `logisticBase` | `number` | The base of the exponent in the logistic function. Default is 10. |
459
+ | `tiebreakers` | `Array<string>` | The strategy for breaking ties in the leaderboard. |
460
+ | `leaderboard` | `ReadonlyArray<Player>` | Current player standings, ordered by score and tie-breakers. |
461
+ | `completed` | `boolean` | Whether the tournament has reached its conclusion. |
462
+ | `activeMatches` | `ReadonlyArray<Match>` | Current matches being played. |
463
+ | `finishedMatches` | `ReadonlyArray<Match>` | All concluded matches in the tournament history. |
464
+ | `idGenerator` | `Nullable<() => string>` | Unique ID generator for assigning identifiers to match objects. |
465
+ | `id` | `Nullable<Any>` | The unique identifier for this tournament. |
466
+ | `name` | `Nullable<string>` | The display name of the tournament. |
467
+ | `timeControl` | `Nullable<string>` | The specific time settings for the matches (e.g., "3+2", "10 + 0"). |
468
+ | `type` | `Nullable<string>` | The category of the tournament based on the time control (e.g., "blitz", "bullet", "rapid"). |
463
469
 
464
470
  #### Methods
465
471
 
466
- | Method | Arguments | Return Type | Description |
467
- |----------------|--------------------|------------------------|----------------------------------------------------------------|
468
- | `addPlayer` | `player`: `Player` | None | Adds a player to the tournament. Player's name most be unique. |
469
- | `removePlayer` | `player`: `Player` | None | Removes a player from the tournament |
470
- | `nextRound` | None | `ReadonlyArray<Match>` | Generates a list of new pairings. |
472
+ | Method | Arguments | Return Type | Description |
473
+ |----------------|------------------------------------------------------------------------------------------------------------------------|------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------|
474
+ | `addPlayer` | `player`: `Player` | None | Adds a player to the tournament. Player's name most be unique. |
475
+ | `removePlayer` | `player`: `Player` | None | Removes a player from the tournament |
476
+ | `nextRound` | None | `ReadonlyArray<Match>` | Generates a list of new pairings. |
477
+ | `addMatch` | `white`: string, `black`: `Nullable<string>`, `outcome`: string, `id`: `Nullable<string>`, `round`: `Nullable<number>` | `boolean` | Adds a match to the tournament for the specified round. This method is ideal for cases where external logic is being used or an instance is being reconstructed. |
471
478
 
472
479
  #### Factories
473
480
 
474
- | Function | Arguments | Return Type | Description |
475
- |--------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------|-------------------------------------------------------------------------------|
476
- | `tournament` | `type`: `string`, `tiebreakers`: `Array<String>` default `["fidePerformance", "buchholz", "progressive", "sonnebornBerger"]`, `impactFactor`: `number` default `32`, `rangeFactor`: `number` default `400`, `logisticBase`: `number` default `10` | `Tournament` | Factory function to create a Tournament instance based on the specified type. |
481
+ | Function | Arguments | Return Type | Description |
482
+ |--------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------|-------------------------------------------------------------------------------|
483
+ | `tournament` | `type`: `string`, `tiebreakers`: `Array<String>` default `["fidePerformance", "buchholz", "progressive", "sonnebornBerger"]`, `impactFactor`: `number` default `32`, `rangeFactor`: `number` default `400`, `logisticBase`: `number` default `10`, `idGenerator`: `Nullable<() => string>` default `null`, `id`: `Nullable<any>` default `null`, `name`: `Nullable<string>` default `null`, `timeControl`: `Nullable<string>` default `null`, `timeControlType`: `Nullable<string>` default `null` | `Tournament` | Factory function to create a Tournament instance based on the specified type. |
477
484
 
478
485
  #### Examples
479
486
 
package/chess4js.d.mts CHANGED
@@ -85,6 +85,7 @@ export declare class Match {
85
85
  get black(): Nullable<Player>;
86
86
  get outcome(): string;
87
87
  set outcome(value: string);
88
+ get id(): Nullable<string>;
88
89
  toString(): string;
89
90
  }
90
91
  /** @deprecated $metadata$ is used for internal purposes, please don't use it in your code, because it can be removed at any moment */
@@ -391,11 +392,17 @@ export declare class Tournament {
391
392
  get leaderboard(): ReadonlyArray<Player>;
392
393
  get completed(): boolean;
393
394
  set completed(value: boolean);
395
+ get id(): Nullable<any>;
396
+ get name(): Nullable<string>;
397
+ get timeControl(): Nullable<string>;
398
+ get type(): Nullable<string>;
394
399
  get activeMatches(): ReadonlyArray<Match>;
395
400
  get finishedMatches(): ReadonlyArray<Match>;
401
+ get idGenerator(): Nullable<() => string>;
396
402
  addPlayer(player: Player): void;
397
403
  removePlayer(player: Player): void;
398
404
  nextRound(): ReadonlyArray<Match>;
405
+ addMatch(white: string, black: Nullable<string>, outcome: string, id: Nullable<string>, round: Nullable<number>): boolean;
399
406
  }
400
407
  /** @deprecated $metadata$ is used for internal purposes, please don't use it in your code, because it can be removed at any moment */
401
408
  export declare namespace Tournament.$metadata$ {
@@ -435,6 +442,6 @@ export declare function customGame(gameMode: string, threeRepetitionsMode: strin
435
442
  export declare function parseGames(pgnInput: string, idSupplier?: () => Nullable<any>): ReadonlyArray<Game>;
436
443
  export declare function scoreOf(score: string): Score;
437
444
  export declare function playerOf(name: string, initialElo: number): Player;
438
- export declare function matchOf(white: Player, black: Player, impactFactor?: number, rangeFactor?: number, logisticBase?: number): Match;
439
- export declare function tournament(type: string, tiebreakers?: Array<string>, impactFactor?: number, rangeFactor?: number, logisticBase?: number): Tournament;
445
+ export declare function matchOf(white: Player, black: Player, impactFactor?: number, rangeFactor?: number, logisticBase?: number, id?: Nullable<string>): Match;
446
+ export declare function tournament(type: string, tiebreakers?: Array<string>, impactFactor?: number, rangeFactor?: number, logisticBase?: number, idGenerator?: Nullable<() => string>, id?: Nullable<string>, name?: Nullable<string>, timeControl?: Nullable<string>, timeControlType?: Nullable<string>): Tournament;
440
447
  export declare function visibleSquares(piece: string, square: string, position: Position): Bitboard;