2.0.3 • Published 9 months ago

@typinghare/board-game-clock-core v2.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
9 months ago

Board Game Clock Core

Get Started

Create a game

import { Game, Player, TimeControl } from '@typinghare/board-game-clock-core'

const ROLE_A = 'A'
const ROLE_B = 'B'

// Create a game with two players (A & B), applying default time control and default player
const game = new Game([ROLE_A, ROLE_B], new TimeControl(), Player)

// Start the game
game.start()

// Get players
const playerA = game.getPlayer(ROLE_A)
const playerB = game.getPlayer(ROLE_B)

// Player A presses, player B's timer runs
playerA.press()

// Set onStop callback function
game.onStop = function(stopper, timeUpRole) {
    console.log(`Game stops. Player ${stopper} stops the game.`)
    if (timeUpRole) {
        console.log(`Player ${timeUpRole} has run out of time.`)
    }
}

// Stop the game
game.stop()

Two-Player Game

import { Player, TimeControl, TwoPlayerGame } from '@typinghare/board-game-clock-core'

// Create a two-player game
const game = new TwoPlayerGame(new TimeControl(), Player)

Use General Two-player Game

Use Simulator

Customize a New Game

1.1.2

10 months ago

2.0.3

9 months ago

2.0.2

9 months ago

2.0.1

10 months ago

2.0.0

10 months ago

1.1.1

11 months ago

1.1.0

11 months ago

1.0.5

11 months ago

1.0.4

11 months ago

1.0.3

11 months ago

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago

0.2.0

11 months ago

0.1.7

11 months ago

0.1.6

11 months ago

0.1.5

11 months ago

0.1.4

11 months ago

0.1.3

11 months ago

0.1.2

11 months ago

0.1.1

11 months ago

0.1.0

11 months ago

0.0.8

11 months ago

0.0.7

11 months ago

0.0.6

11 months ago

0.0.5

11 months ago

0.0.4

11 months ago

0.0.3

11 months ago

0.0.2

12 months ago

0.0.1

12 months ago