1.0.4 • Published 6 months ago

@types/tictactoejs v1.0.4

Weekly downloads
2
License
MIT
Repository
github
Last release
6 months ago

Installation

npm install --save @types/tictactoejs

Summary

This package contains type definitions for tictactoejs (https://www.npmjs.com/package/tictactoejs).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/tictactoejs.

index.d.ts

// Type definitions for tictactoejs 1.0
// Project: https://www.npmjs.com/package/tictactoejs
// Definitions by: DefinitelyTyped <https://github.com/DefinitelyTyped>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

export class TicTacToe {
  /**
   * The game's constructor
   */
  constructor(requestSize?: number);
  /**
   * Restart the game
   */
  reset(requestSize?: number): void;
  /**
   * Get the current game's size
   * @returns the game size
   */
  getSize(): number;
  /**
   * Check, whether it's X' turn or O's
   * @returns whose turn it is
   */
  turn(): "X" | "O";
  /**
   * Get the current board
   * @returns the current board as ascii
   */
  ascii(): string;
  /**
   * Get the current board
   * @returns the current board as ascii (alternative style)
   */
  ascii2(): string;
  /**
   * Does a move (bottom left is 1|1, bottom right is 3|1)
   * @returns whether the move was successful
   */
  move(x: number, y: number): boolean;
  /**
   * Check whether the provided coordinates exist on the current board
   * @returns whether the current coordinates exist
   */
  exists(x: number, y: number): boolean;
  /**
   * Check which player occupies the provided coordinates
   * @returns the player occupying these coordinates
   */
  get(x: number, y: number): "X" | "O" | null;
  /**
   * Do a move with array style coordinates (top left is 0|0, top right is 0|2)
   * @returns whether the move was successful
   */
  moveArray(row: number, col: number): boolean;
  /**
   * Check the game's current state
   * @returns the game state
   */
  status(): "X" | "O" | "draw" | "in progress";
  /**
   * Check whether the game is over
   * @returns the game state
   */
  gameOver(): boolean;
  /**
   * Check whether the game ended in a draw
   * @returns the game state
   */
  isDraw(): boolean;
  /**
   * Check the valid moves (all unoccupied coordinates)
   * @returns an array of objects with the x and y values
   */
  legalMoves(): [{ x: number; y: number }];
  /**
   * Do a random move (no logic or AI involved, this is completely random)
   * @returns an object with the x and y value of the random move
   */
  randomMove(): { x: number; y: number };
}

Additional Details

  • Last updated: Thu, 23 Dec 2021 23:35:56 GMT
  • Dependencies: none
  • Global values: none

Credits

These definitions were written by DefinitelyTyped.

1.0.2

8 months ago

1.0.4

6 months ago

1.0.3

7 months ago

1.0.1

2 years ago

1.0.0

4 years ago