Skip to content

Commit

Permalink
add push feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
radulle committed Jun 8, 2021
1 parent 5325e42 commit 043ab2a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Chess clock engine",
"author": "Nikola Radulaški",
"license": "MIT",
"version": "0.4.1",
"version": "0.5.0",
"keywords": [
"chess",
"chessclock",
Expand Down
9 changes: 5 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,17 @@ export class Clock {
}

/** Ends player's turn (push button). */
push(player: 0 | 1) {
if (this._status === 'done' || this._status === 'paused') return
if (this._lastPlayer === player) return
push(player: 0 | 1): boolean {
if (this._status === 'done' || this._status === 'paused') return false
if (this._lastPlayer === player) return false
if (this._status === 'ready') this._status = 'live'
if (this._interval !== undefined) clearInterval(this._interval)
if (this._timestamp === undefined) this._white = this._other(player)

this._lastPlayer = player

const done = this._record(player)
if (done) return
if (done) return false

this._logMove(player)

Expand All @@ -114,6 +114,7 @@ export class Clock {
}, this._updateInterval)

this._invokeCallback()
return true
}

/** Returns clock's state. */
Expand Down

0 comments on commit 043ab2a

Please sign in to comment.