Constructor
new SemanticChess(options:)
- Source:
Parameters:
Name | Type | Description |
---|---|---|
options: |
Object
|
options to initialize the chess game |
options.chess: |
null
|
string
|
Chess game from chess.js |
options.startPosition: |
null
|
string
|
start position of the game, using FEN |
options.url: |
string
|
url that represents the game |
options.userWebId: |
string
|
WebId of the user |
options.opponentWebId: |
string
|
WebId of the opponent |
options.moveBaseUrl: |
string
|
function
|
base url used to create urls for new moves |
options.name: |
null
|
string
|
name of the game |
options.lastMove: |
null
|
Object
|
latest move made in the game |
options.lastUserMove: |
null
|
Object
|
last move made by the use in the game |
options.colorOfUser: |
null
|
string
|
color of the user ('w' or 'b', default is 'w') |
options.uniqid: |
null
|
function
|
function that will return a unique id for the moves |
options.givenUpBy: |
null
|
string
|
WebId of the player that gave up |
Methods
doMove(move:, options:) → {null|Object}
This method does the next move, which specified via the san and the options.
It returns the corresponding SPARQL update and inbox notification if the move is valid.
It returns null if the move was invalid. For example, when the san is invalid or
when it's the opponents turn.
Note that opponents turns can only be added via the method loadMove.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
move: |
string
|
Object
|
new move either via SAN (string) or object (inherited from chess.js) |
options: |
Object
|
the options of the move, inherited from Chess from chess.js |
Returns:
- Type:
-
null
|Object
: corresponding SPARQL update and inbox notification
that is generated by doing the move
geMoveBaseUrl() → {function}
This method returns the function that generates the base url for a new move.
- Source:
Returns:
- Type:
-
function
: function that generates the base url for a new move
getChess() → {Chess}
This method returns chess.js game that is used.
- Source:
Returns:
- Type:
-
Chess
: Chess from chess.js
getLastMove() → {null|Object}
This method returns {san, url} of the last move made, where `san` is the SAN of the move and
`url` is the url of the move.
- Source:
Returns:
- Type:
-
null
|Object
: url that represents the move and SAN that describes the move
getLastUserMove() → {null|Object}
This method returns {san, url} of the last move made by the user, where `san` is the SAN of the move and
`url` is the url of the move.
- Source:
Returns:
- Type:
-
null
|Object
: url that represents the move and SAN that describes the move
getMinimumRDF() → {string}
This method returns the RDF (Turtle) representation of the game, without any moves.
- Source:
Returns:
- Type:
-
string
: RDF representation of the game
getName() → {string|null}
This method returns the name of the game.
- Source:
Returns:
- Type:
-
string
|null
: name of the game
getOpponentColor() → {string}
This method returns the color of the opponent, where 'w' is white and 'b' is black.
- Source:
Returns:
- Type:
-
string
: 'w' (white) or 'b' (black)
getOpponentWebId() → {string}
This method return the WebId of the opponent.
- Source:
Returns:
- Type:
-
string
: WebId of the opponent
getStartPosition() → {string|null}
This method returns the start position (using FEN) of the game.
- Source:
Returns:
- Type:
-
string
|null
: starting position of the game
getUrl() → {string}
This method returns the URL of the game.
- Source:
Returns:
- Type:
-
string
: URL of the game
getUserColor() → {string}
This method returns the color of the user, where 'w' is white and 'b' is black.
- Source:
Returns:
- Type:
-
string
: 'w' (white) or 'b' (black)
givenUpBy() → {string|null}
This method returns the WebId of the player that gave up.
- Source:
Returns:
- Type:
-
string
|null
: WebId of the player that gave up or null if nobody gave up
giveUpBy(webId:) → {Object}
This method is called to give up to game by a player.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
webId: |
the WebId of the player that gives up on the game |
Returns:
- Type:
-
Object
: corresponding SPARQL update and (inbox) notification
that is generated by giving up
isGivenUp() → {boolean}
This method returns true if the game is over because someone gave up.
- Source:
Returns:
- Type:
-
boolean
: true if someone give up on the game
isOpponentsTurn() → {boolean}
The method returns true if the next half move has to be made by the opponent.
- Source:
Returns:
- Type:
-
boolean
: true if the next half move has to be made by the opponent
isRealTime() → {boolean}
This method returns true if the game is played real time.
- Source:
Returns:
- Type:
-
boolean
: true if the game is played real time, else false
loadGiveUpBy(webId:)
This methods loads the giving up of a player.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
webId: |
the WebId of the player that gives up on the game |
loadMove(san:, options:) → {null|Object}
This method load a user's or opponent's move.
This method returns {url, san}, where `url` is the url of the newly loaded move and
`san` is the SAN of the newly loaded move.
This method returns null if the SAN of the move is invalid.
When multiple moves need to be loaded, they have to be loaded in the order that they are played.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
san: |
string
|
SAN of the new move |
options: |
Object
|
is inherited from Chess.move() from chess.js extended with the key url that represents the move |
Returns:
- Type:
-
null
|Object
: null if the move is invalid or the url and san of the move if valid