cm-chess 2.1.7 → 2.3.0

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
@@ -1,7 +1,7 @@
1
1
  # cm-chess
2
2
 
3
3
  It is like [chess.js](https://github.com/jhlywa/chess.js),
4
- but is an ES6 module, can handle history variants (tree-structured move history),
4
+ but is an ES6 module, can handle history variations (tree-structured move history),
5
5
  PGN header values, Nags and Comments.
6
6
 
7
7
  ## Install
@@ -11,7 +11,7 @@ PGN header values, Nags and Comments.
11
11
  ## Features
12
12
 
13
13
  - It has a similar API to chess.js
14
- - It can handle history variants
14
+ - It can handle history variations
15
15
  - It can add Nags, Comments and Annotations
16
16
  - It is used by the 7,000 users of [chessmail](https://www.chessmail.de) (it works)
17
17
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cm-chess",
3
- "version": "2.1.7",
4
- "description": "Like chess.js, but in ES6 and can handle variants (tree-structured move history)",
3
+ "version": "2.3.0",
4
+ "description": "Like chess.js, but in ES6 and can handle variations (tree-structured move history)",
5
5
  "main": "./src/cm-chess/Chess.js",
6
6
  "scripts": {
7
7
  "test": "mocha --require babel-core/register ./test/*.js",
@@ -24,11 +24,11 @@
24
24
  },
25
25
  "homepage": "https://github.com/shaack/cm-chess#readme",
26
26
  "dependencies": {
27
- "chess.mjs": "^1.1.1",
28
- "cm-pgn": "^2.1.4",
29
- "modrator": "^1.1.6"
27
+ "chess.mjs": "^1.2.0",
28
+ "cm-pgn": "^2.1.9",
29
+ "modrator": "^1.2.1"
30
30
  },
31
31
  "devDependencies": {
32
- "teevi": "^2.1.4"
32
+ "teevi": "^2.1.11"
33
33
  }
34
34
  }
@@ -143,13 +143,13 @@ export class Chess {
143
143
  }
144
144
 
145
145
  /**
146
- * @returns {undefined|move} the last move of the main variant or `undefined`, if no move was made
146
+ * @returns {null|move} the last move of the main variation or `null`, if no move was made
147
147
  */
148
148
  lastMove() {
149
149
  if (this.pgn.history.moves.length > 0) {
150
150
  return this.pgn.history.moves[this.pgn.history.moves.length - 1]
151
151
  } else {
152
- return undefined
152
+ return null
153
153
  }
154
154
  }
155
155
 
@@ -172,7 +172,7 @@ export class Chess {
172
172
  }
173
173
 
174
174
  /**
175
- * Load a PGN with variants, NAGs, header and annotations. cm-chess uses cm-pgn
175
+ * Load a PGN with variations, NAGs, header and annotations. cm-chess uses cm-pgn
176
176
  * fot the header and history. See https://github.com/shaack/cm-pgn
177
177
  * @param pgn
178
178
  */
@@ -183,24 +183,35 @@ export class Chess {
183
183
  /**
184
184
  * Make a move in the game.
185
185
  * @param move
186
- * @param previousMove optional, the previous move (variants)
186
+ * @param previousMove optional, the previous move (for variations)
187
187
  * @param sloppy to allow sloppy SAN
188
- * @returns {{}|undefined}
188
+ * @returns {{}|null}
189
189
  */
190
190
  move(move, previousMove = undefined, sloppy = true) {
191
191
  try {
192
192
  return this.pgn.history.addMove(move, previousMove, sloppy)
193
193
  } catch (e) {
194
- return undefined
194
+ return null
195
195
  }
196
196
  }
197
197
 
198
+ /**
199
+ * Don't make a move, just validate, if it would be a correct move
200
+ * @param move
201
+ * @param previousMove optional, the previous move (for variations)
202
+ * @param sloppy to allow sloppy SAN
203
+ * @returns the move object or null if not valid
204
+ */
205
+ validateMove(move, previousMove = undefined, sloppy = true) {
206
+ return this.pgn.history.validateMove(move, previousMove, sloppy)
207
+ }
208
+
198
209
  /**
199
210
  * This one is not fully implemented in cm-pgn. For now, it just uses pgn() of chess.js.
200
211
  * @returns {string} the PGN of the game.
201
212
  */
202
213
  renderPgn() {
203
- // TODO create pgn with variants, annotations, nags (for now just render main variant)
214
+ // TODO create pgn with variations, annotations, nags (for now just render main variation)
204
215
  const chess = new ChessJs(this.setUpFen())
205
216
  const moves = this.pgn.history.moves
206
217
  for (const move of moves) {
@@ -239,7 +250,7 @@ export class Chess {
239
250
  }
240
251
 
241
252
  /**
242
- * @returns {string} "b" or "w" the color to move in the main variant
253
+ * @returns {string} "b" or "w" the color to move in the main variation
243
254
  */
244
255
  turn() {
245
256
  let factor = 0
@@ -281,4 +292,4 @@ export class Chess {
281
292
  }
282
293
 
283
294
 
284
- }
295
+ }
package/test/TestChess.js CHANGED
@@ -2,22 +2,22 @@ import {Chess, COLOR, FEN} from "../src/cm-chess/Chess.js"
2
2
  import {TAGS} from "../lib/cm-pgn/Header.js"
3
3
  import {describe, it, assert} from "../node_modules/teevi/src/teevi.js"
4
4
 
5
- // TODO create a test, which demonstrates all features, including variants
5
+ // TODO create a test, which demonstrates all features, including variations
6
6
 
7
7
  describe("Chess", function () {
8
8
 
9
9
  it("should create empty Chess", () => {
10
10
  const chess = new Chess()
11
- assert.equals(chess.history().length, 0)
12
- assert.equals(Object.keys(chess.header()).length, 0)
13
- assert.equals(chess.fen(), FEN.start)
11
+ assert.equal(chess.history().length, 0)
12
+ assert.equal(Object.keys(chess.header()).length, 0)
13
+ assert.equal(chess.fen(), FEN.start)
14
14
  })
15
15
 
16
16
  it("should load a game from FEN", function () {
17
17
  const fen = "4k3/pppppppp/8/8/8/8/PPPPPPPP/4K3 w - - 0 1"
18
18
  const chess = new Chess(fen)
19
- assert.equals(chess.pgn.header.tags[TAGS.FEN], fen)
20
- assert.equals(chess.fen(), fen)
19
+ assert.equal(chess.pgn.header.tags[TAGS.FEN], fen)
20
+ assert.equal(chess.fen(), fen)
21
21
  })
22
22
 
23
23
  it("should load a pgn with SetUp and FEN", function () {
@@ -26,9 +26,9 @@ describe("Chess", function () {
26
26
 
27
27
  1. e4 (1. d4 {Die Variante} d5) e5 {Ein Kommentar} 2. a3`
28
28
  const chess = new Chess({pgn: pgn})
29
- assert.equals(chess.move("Nc6"), undefined)
29
+ assert.equal(chess.move("Nc6"), null)
30
30
  const result = chess.move("h6")
31
- assert.equals(result.fen, "4k3/pppp1pp1/7p/4p3/4P3/P7/1PPP1PPP/4K3 w - - 0 3")
31
+ assert.equal(result.fen, "4k3/pppp1pp1/7p/4p3/4P3/P7/1PPP1PPP/4K3 w - - 0 3")
32
32
  })
33
33
 
34
34
  it("should load a pgn", function () {
@@ -48,13 +48,13 @@ describe("Chess", function () {
48
48
  11.Bf4 b5 12.a4 Bb7 13.Re1 Nd5 14.Bg3 Kc8 15.axb5 cxb5 16.Qd3 Bc6
49
49
  17.Bf5 exf5 18.Rxe7 Bxe7 19.c4 1-0`
50
50
  chess.loadPgn(pgn)
51
- assert.equals(chess.history().length, 37)
52
- assert.equals(chess.header()[TAGS.White], "Deep Blue")
51
+ assert.equal(chess.history().length, 37)
52
+ assert.equal(chess.header()[TAGS.White], "Deep Blue")
53
53
  const firstMove = chess.history()[0]
54
- assert.equals(firstMove.color, "w")
55
- assert.equals(firstMove.san, "e4")
56
- assert.equals(firstMove.fen, "rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1")
57
- assert.equals(chess.history()[19].commentAfter, "Kasparov schüttelt kurz den Kopf")
54
+ assert.equal(firstMove.color, "w")
55
+ assert.equal(firstMove.san, "e4")
56
+ assert.equal(firstMove.fen, "rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1")
57
+ assert.equal(chess.history()[19].commentAfter, "Kasparov schüttelt kurz den Kopf")
58
58
  })
59
59
 
60
60
  it("should load a pgn with SetUp", () => {
@@ -68,7 +68,7 @@ describe("Chess", function () {
68
68
  1. Qc1 Qe6 2. Qxc7
69
69
  0-1`
70
70
  const chess = new Chess({pgn: pgn})
71
- assert.equals(chess.history()[2].san, "Qxc7")
71
+ assert.equal(chess.history()[2].san, "Qxc7")
72
72
  })
73
73
 
74
74
  it('should parse stappenmethode weekly.pgn', () => {
@@ -88,9 +88,9 @@ describe("Chess", function () {
88
88
  1... Bf8 (1... Qf8? 2. Qxf8+ Bxf8 3. exd4) 2. exd4 Qxd4+ {%Q} 3. Kh1 Bh3
89
89
  0-1`
90
90
  chess.loadPgn(pgn)
91
- assert.equals(5, chess.pgn.history.moves.length)
92
- assert.equals("Schaak opheffen", chess.pgn.header.tags[TAGS.White])
93
- assert.equals("app 037-1", chess.pgn.header.tags[TAGS.Annotator])
91
+ assert.equal(5, chess.pgn.history.moves.length)
92
+ assert.equal("Schaak opheffen", chess.pgn.header.tags[TAGS.White])
93
+ assert.equal("app 037-1", chess.pgn.header.tags[TAGS.Annotator])
94
94
  })
95
95
 
96
96
  it('should allow traverse through moves', () => {
@@ -101,18 +101,18 @@ describe("Chess", function () {
101
101
  1. Qc5+ Kd3 2. Qc2+ Kd4 3. Qd2+ Bd3 4. Qe3+ Kxe3 (4... Kc3 5. Qc1+ Kb3 6. Qa3+ Kc4 7. Qb4+ Kd5 8. Qc5#) 5. Bc5#
102
102
  1-0`
103
103
  chess.loadPgn(pgn)
104
- assert.equals(chess.turn(), COLOR.black)
104
+ assert.equal(chess.turn(), COLOR.black)
105
105
  const firstMove = chess.history()[0]
106
- assert.equals(firstMove.san, "Qc5+")
106
+ assert.equal(firstMove.san, "Qc5+")
107
107
  const secondMove = firstMove.next
108
- assert.equals(secondMove.san, "Kd3")
109
- assert.equals(chess.lastMove().san, "Bc5#")
110
- assert.equals(chess.gameOver(), true)
111
- assert.equals(chess.lastMove().inCheckmate, true)
112
- assert.equals(chess.inCheckmate(), true)
113
- assert.equals(chess.inDraw(), false)
108
+ assert.equal(secondMove.san, "Kd3")
109
+ assert.equal(chess.lastMove().san, "Bc5#")
110
+ assert.equal(chess.gameOver(), true)
111
+ assert.equal(chess.lastMove().inCheckmate, true)
112
+ assert.equal(chess.inCheckmate(), true)
113
+ assert.equal(chess.inDraw(), false)
114
114
  // TODO result, 1-0 is missing
115
- assert.equals(chess.renderPgn(), `[SetUp "1"]
115
+ assert.equal(chess.renderPgn(), `[SetUp "1"]
116
116
  [FEN "8/8/b2Bq3/7Q/3kp3/5pP1/8/3K4 w - - 0 1"]
117
117
 
118
118
  1. Qc5+ Kd3 2. Qc2+ Kd4 3. Qd2+ Bd3 4. Qe3+ Kxe3 5. Bc5#`)
@@ -120,38 +120,39 @@ describe("Chess", function () {
120
120
 
121
121
  it('should add move at the end of the history', () => {
122
122
  const chess = new Chess()
123
- assert.equals(chess.turn(), COLOR.white)
123
+ assert.equal(chess.turn(), COLOR.white)
124
124
  chess.move("e4")
125
- assert.equals(chess.turn(), COLOR.black)
126
- assert.equals(chess.history()[0].san, "e4")
125
+ assert.equal(chess.turn(), COLOR.black)
126
+ assert.equal(chess.history()[0].san, "e4")
127
127
  chess.move("e5")
128
- assert.equals(chess.turn(), COLOR.white)
128
+ assert.equal(chess.turn(), COLOR.white)
129
129
  })
130
130
 
131
131
  it('should provide correct turn after loading a FEN', () => {
132
132
  const chess = new Chess()
133
133
  chess.load('rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1')
134
- assert.equals(chess.turn(), COLOR.black)
134
+ assert.equal(chess.turn(), COLOR.black)
135
135
  })
136
136
 
137
- it('invalid move should return `undefined`', () => {
137
+ it('invalid move should return `null`', () => {
138
138
  const chess = new Chess()
139
139
  chess.load('rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1')
140
- assert.equals(chess.turn(), COLOR.black)
140
+ assert.equal(chess.turn(), COLOR.black)
141
+ // assert.notEqual(chess.validateMove("a1"), null)
141
142
  const move = chess.move("a1")
142
- assert.equals(move, undefined)
143
+ assert.equal(move, null)
143
144
  })
144
145
 
145
146
  it('should return pieces', () => {
146
147
  const chess = new Chess()
147
- assert.equals(chess.pieces().length, 32)
148
+ assert.equal(chess.pieces().length, 32)
148
149
  const pgn = `[SetUp "1"]
149
150
  [FEN "8/8/b2Bq3/7Q/3kp3/5pP1/8/3K4 w - - 0 1"]
150
151
 
151
152
  1. Qc5+ Kd3 2. Qc2+ Kd4 3. Qd2+ Bd3 4. Qe3+ Kxe3 (4... Kc3 5. Qc1+ Kb3 6. Qa3+ Kc4 7. Qb4+ Kd5 8. Qc5#) 5. Bc5#
152
153
  1-0`
153
154
  chess.loadPgn(pgn)
154
- assert.equals(chess.pieces("k").length, 2)
155
+ assert.equal(chess.pieces("k").length, 2)
155
156
  })
156
157
 
157
158
  it('should undo lastMove', () => {
@@ -162,9 +163,9 @@ describe("Chess", function () {
162
163
  1. Qc5+ Kd3 2. Qc2+ Kd4 3. Qd2+ Bd3 4. Qe3+ Kxe3 (4... Kc3 5. Qc1+ Kb3 6. Qa3+ Kc4 7. Qb4+ Kd5 8. Qc5#) 5. Bc5#
163
164
  1-0`
164
165
  chess.loadPgn(pgn)
165
- assert.equals(chess.history().length, 9)
166
+ assert.equal(chess.history().length, 9)
166
167
  chess.undo()
167
- assert.equals(chess.history().length, 8)
168
+ assert.equal(chess.history().length, 8)
168
169
  })
169
170
 
170
171
  it('should undo more moves', () => {
@@ -177,10 +178,10 @@ describe("Chess", function () {
177
178
  chess.loadPgn(pgn)
178
179
  chess.undo(chess.history()[5])
179
180
  // console.log(chess.history());
180
- assert.equals(chess.history().length, 5)
181
- assert.equals(chess.plyCount(), 5)
182
- assert.equals(chess.fenOfPly(0), "8/8/b2Bq3/7Q/3kp3/5pP1/8/3K4 w - - 0 1")
183
- assert.equals(chess.fenOfPly(3), "8/8/b2Bq3/8/4p3/3k1pP1/2Q5/3K4 b - - 3 2")
181
+ assert.equal(chess.history().length, 5)
182
+ assert.equal(chess.plyCount(), 5)
183
+ assert.equal(chess.fenOfPly(0), "8/8/b2Bq3/7Q/3kp3/5pP1/8/3K4 w - - 0 1")
184
+ assert.equal(chess.fenOfPly(3), "8/8/b2Bq3/8/4p3/3k1pP1/2Q5/3K4 b - - 3 2")
184
185
  })
185
186
 
186
187
  it("should not load incorrect FEN", function () {
@@ -203,10 +204,20 @@ describe("Chess", function () {
203
204
  it("should load different PGNs and then work correctly", function () {
204
205
  const fen = "ppppkppp/pppppppp/pppppppp/pppppppp/8/8/8/RNBQKBNR w KQ - 0 1"
205
206
  const chess = new Chess({fen: fen})
206
- assert.true(chess.move("e4") === undefined)
207
- assert.true(chess.move("Ke2") !== undefined)
207
+ assert.true(chess.move("e4") === null)
208
+ assert.true(chess.move("Ke2") !== null)
208
209
  chess.load(FEN.start)
209
210
  assert.true(chess.move("e4"))
210
211
  })
211
212
 
212
- })
213
+ it("should validate Moves", function() {
214
+ const chess = new Chess()
215
+ assert.notEqual(chess.validateMove("e4"), null)
216
+ assert.notEqual(chess.validateMove("e3"), null)
217
+ assert.notEqual(chess.validateMove("Nf3"), null)
218
+ assert.equal(chess.validateMove("xyz"), null)
219
+ assert.equal(chess.validateMove("e6"), null)
220
+
221
+ })
222
+
223
+ })
package/test/TestFen.js CHANGED
@@ -5,11 +5,11 @@ describe("Fen", function () {
5
5
 
6
6
  it("should parse a fen", () => {
7
7
  const fen = new Fen("rnbqkbnr/pp1ppppp/8/2p5/4P3/5N2/PPPP1PPP/RNBQKB1R b KQkq - 1 2")
8
- assert.equals(fen.position, "rnbqkbnr/pp1ppppp/8/2p5/4P3/5N2/PPPP1PPP/RNBQKB1R")
9
- assert.equals(fen.colorToPlay, "b")
10
- assert.equals(fen.castlings.length, 4)
11
- assert.equals(fen.enPassantTargetSquare, undefined)
12
- assert.equals(fen.plyClock, 1)
13
- assert.equals(fen.moveNumber, 2)
8
+ assert.equal(fen.position, "rnbqkbnr/pp1ppppp/8/2p5/4P3/5N2/PPPP1PPP/RNBQKB1R")
9
+ assert.equal(fen.colorToPlay, "b")
10
+ assert.equal(fen.castlings.length, 4)
11
+ assert.equal(fen.enPassantTargetSquare, undefined)
12
+ assert.equal(fen.plyClock, 1)
13
+ assert.equal(fen.moveNumber, 2)
14
14
  })
15
- })
15
+ })
@@ -1,77 +0,0 @@
1
- /**
2
- * Author and copyright: Stefan Haack (https://shaack.com)
3
- * Repository: https://github.com/shaack/cm-chess
4
- * License: MIT, see file 'LICENSE'
5
- *
6
- * @deprecated
7
- */
8
-
9
- import {COLOR} from "../Chess.js"
10
-
11
- export const PIECES = {
12
- // https://en.wikipedia.org/wiki/Chess_piece_relative_value
13
- notation: {
14
- de: {
15
- R: "T", N: "S", B: "L", Q: "D", K: "K", P: ""
16
- }
17
- },
18
- figures: {
19
- utf8: {
20
- Rw: "♖", Nw: "♘", Bw: "♗", Qw: "♕", Kw: "♔", Pw: "♙",
21
- Rb: "♜", Nb: "♞", Bb: "♝", Qb: "♛", Kb: "♚", Pb: "♟"
22
- },
23
- fontAwesomePro: {
24
- Rw: '<i class="far fa-fw fa-chess-rook"></i>',
25
- Nw: '<i class="far fa-fw fa-chess-knight"></i>',
26
- Bw: '<i class="far fa-fw fa-chess-bishop"></i>',
27
- Qw: '<i class="far fa-fw fa-chess-queen"></i>',
28
- Kw: '<i class="far fa-fw fa-chess-king"></i>',
29
- Pw: '<i class="far fa-fw fa-chess-pawn"></i>',
30
- Rb: '<i class="fas fa-fw fa-chess-rook"></i>',
31
- Nb: '<i class="fas fa-fw fa-chess-knight"></i>',
32
- Bb: '<i class="fas fa-fw fa-chess-bishop"></i>',
33
- Qb: '<i class="fas fa-fw fa-chess-queen"></i>',
34
- Kb: '<i class="fas fa-fw fa-chess-king"></i>',
35
- Pb: '<i class="fas fa-fw fa-chess-pawn"></i>'
36
- }
37
- }
38
- }
39
-
40
- // noinspection JSUnusedGlobalSymbols
41
- export class ChessRender {
42
- static san(san, color = COLOR.white, lang = "en", mode = "text", pieces = PIECES.figures.utf8) {
43
- // console.warn("ChessRender is deprecated and will be removed in future")
44
- if(mode === "figures") {
45
- if (color === COLOR.white) {
46
- return this.replaceAll(san, {
47
- "R": pieces.Rw,
48
- "N": pieces.Nw,
49
- "B": pieces.Bw,
50
- "Q": pieces.Qw,
51
- "K": pieces.Kw
52
- })
53
- } else {
54
- return this.replaceAll(san, {
55
- "R": pieces.Rb,
56
- "N": pieces.Nb,
57
- "B": pieces.Bb,
58
- "Q": pieces.Qb,
59
- "K": pieces.Kb
60
- })
61
- }
62
- } else if(mode === "text") {
63
- return this.replaceAll(san, PIECES.notation[lang])
64
- } else {
65
- console.error("mode must be 'text' or 'figures'")
66
- }
67
- }
68
- static replaceAll(str, replacementsObj, ignoreCase = false) {
69
- let retStr = str
70
- const flags = ignoreCase ? "gi" : "g"
71
- for (let needle in replacementsObj) {
72
- // noinspection JSUnfilteredForInLoop
73
- retStr = retStr.replace(new RegExp(needle, flags), replacementsObj[needle])
74
- }
75
- return retStr
76
- }
77
- }
@@ -1,416 +0,0 @@
1
- /**
2
- * Author and copyright: Stefan Haack (https://shaack.com)
3
- * Repository: https://github.com/shaack/cm-chess
4
- * License: MIT, see file 'LICENSE'
5
- *
6
- * @deprecated
7
- */
8
-
9
- const openings = [
10
- {
11
- "moves": "d2d4d7d5e2e4d5e4b1c3g8f6f2f3e4f3",
12
- "name_de": "BDG",
13
- "name_en": "BDG",
14
- "descriptionLink_de": "Blackmar-Diemer-Gambit",
15
- "descriptionLink_en": "Blackmar–Diemer_Gambit"
16
- },
17
- {
18
- "moves": "d2d4g8f6c2c4e7e6g1f3c7c5d4d5b7b5",
19
- "name_de": "Blumfeld-Gambit",
20
- "name_en": "Blumenfeld Gambit",
21
- "descriptionLink_de": "Blumenfeld-Gambit",
22
- "descriptionLink_en": "Blumenfeld_Gambit"
23
- },
24
- {
25
- "moves": "c2c4g8f6d2d4e7e6g1f3c7c5d4d5b7b5",
26
- "name_de": "Blumfeld-Gambit",
27
- "name_en": "Blumenfeld Gambit",
28
- "descriptionLink_de": "Blumenfeld-Gambit",
29
- "descriptionLink_en": "Blumenfeld_Gambit"
30
- },
31
- {
32
- "moves": "d2d4g8f6c2c4g7g6b1c3f8g7e2e4d7d6",
33
- "name_de": "Königsindisch",
34
- "name_en": "King's Indian Def.",
35
- "descriptionLink_de": "Königsindische_Verteidigung",
36
- "descriptionLink_en": "King%27s_Indian_Defence"
37
- },
38
- {
39
- "moves": "c2c4g8f6d2d4g7g6b1c3f8g7e2e4d7d6",
40
- "name_de": "Königsindisch",
41
- "name_en": "King's Indian Def.",
42
- "descriptionLink_de": "Königsindische_Verteidigung",
43
- "descriptionLink_en": "King%27s_Indian_Defence"
44
- },
45
- {
46
- "moves": "e2e4e7e5d2d4e5d4c2c3d4c3f1c4",
47
- "name_de": "Nordisches Gambit",
48
- "name_en": "Danish Gambit",
49
- "descriptionLink_de": "Nordisches_Gambit",
50
- "descriptionLink_en": "Danish_Gambit"
51
- },
52
- {
53
- "moves": "d2d4g8f6c2c4e7e6g1f3f8b4",
54
- "name_de": "Bogoindisch",
55
- "name_en": "Bogo-Indian",
56
- "descriptionLink_de": "Bogoljubow-Indische_Verteidigung",
57
- "descriptionLink_en": "Bogo-Indian_Defence"
58
- },
59
- {
60
- "moves": "c2c4g8f6d2d4e7e6g1f3f8b4",
61
- "name_de": "Bogoindisch",
62
- "name_en": "Bogo-Indian",
63
- "descriptionLink_de": "Bogoljubow-Indische_Verteidigung",
64
- "descriptionLink_en": "Bogo-Indian_Defence"
65
- },
66
- {
67
- "moves": "d2d4g8f6c2c4e7e5d4e5f6g4",
68
- "name_de": "Budapester Gambit",
69
- "name_en": "Budapest Gambit",
70
- "descriptionLink_de": "Budapester_Gambit",
71
- "descriptionLink_en": "Budapest_Gambit"
72
- },
73
- {
74
- "moves": "c2c4g8f6d2d4e7e5d4e5f6g4",
75
- "name_de": "Budapester Gambit",
76
- "name_en": "Budapest Gambit",
77
- "descriptionLink_de": "Budapester_Gambit",
78
- "descriptionLink_en": "Budapest_Gambit"
79
- },
80
- {
81
- "moves": "d2d4g8f6c2c4e7e6g1f3b7b6",
82
- "name_de": "Damenindisch",
83
- "name_en": "Queen's Indian",
84
- "descriptionLink_de": "Damenindische_Verteidigung",
85
- "descriptionLink_en": "Queen%27s_Indian_Defense"
86
- },
87
- {
88
- "moves": "c2c4g8f6d2d4e7e6g1f3b7b6",
89
- "name_de": "Damenindisch",
90
- "name_en": "Queen's Indian",
91
- "descriptionLink_de": "Damenindische_Verteidigung",
92
- "descriptionLink_en": "Queen%27s_Indian_Defense"
93
- },
94
- {
95
- "moves": "d2d4g8f6c2c4g7g6b1c3d7d5",
96
- "name_de": "Grünfeld-Indisch",
97
- "name_en": "Grünfeld Defence",
98
- "descriptionLink_de": "Grünfeld-Indische_Verteidigung",
99
- "descriptionLink_en": "Grünfeld_Defence"
100
- },
101
- {
102
- "moves": "c2c4g8f6d2d4g7g6b1c3d7d5",
103
- "name_de": "Grünfeld-Indisch",
104
- "name_en": "Grünfeld Defence",
105
- "descriptionLink_de": "Grünfeld-Indische_Verteidigung",
106
- "descriptionLink_en": "Grünfeld_Defence"
107
- },
108
- {
109
- "moves": "e2e4e7e5g1f3b8c6f1c4f8c5",
110
- "name_de": "Italienisch",
111
- "name_en": "Giuoco Piano",
112
- "descriptionLink_de": "Italienische_Partie",
113
- "descriptionLink_en": "Giuoco_Piano"
114
- },
115
- {
116
- "moves": "d2d4g8f6c2c4e7e6b1c3f8b4",
117
- "name_de": "Nimzo-Indisch",
118
- "name_en": "Nimzo-Indian Def.",
119
- "descriptionLink_de": "Nimzowitsch-Indische_Verteidigung",
120
- "descriptionLink_en": "Nimzo-Indian_Defence"
121
- },
122
- {
123
- "moves": "d2d4e7e6c2c4g8f6b1c3f8b4",
124
- "name_de": "Nimzo-Indisch",
125
- "name_en": "Nimzo-Indian Def.",
126
- "descriptionLink_de": "Nimzowitsch-Indische_Verteidigung",
127
- "descriptionLink_en": "Nimzo-Indian_Defence"
128
- },
129
- {
130
- "moves": "c2c4g8f6d2d4e7e6b1c3f8b4",
131
- "name_de": "Nimzo-Indisch",
132
- "name_en": "Nimzo-Indian Def.",
133
- "descriptionLink_de": "Nimzowitsch-Indische_Verteidigung",
134
- "descriptionLink_en": "Nimzo-Indian_Defence"
135
- },
136
- {
137
- "moves": "e2e4e7e5g1f3b8c6d2d4e5d4",
138
- "name_de": "Schottisch",
139
- "name_en": "Scotch Game",
140
- "descriptionLink_de": "Schottische_Partie",
141
- "descriptionLink_en": "Scotch_Game"
142
- },
143
- {
144
- "moves": "e2e4e7e5g1f3b8c6f1c4f8e7",
145
- "name_de": "Ungarisch",
146
- "name_en": "Hungarian Defence",
147
- "descriptionLink_de": "Ungarische_Verteidigung",
148
- "descriptionLink_en": "Hungarian_Defense"
149
- },
150
- {
151
- "moves": "e2e4e7e5g1f3b8c6b1c3g8f6",
152
- "name_de": "Vierspringerspiel",
153
- "name_en": "Four Knights Game",
154
- "descriptionLink_de": "Vierspringerspiel",
155
- "descriptionLink_en": "Four_Knights_Game"
156
- },
157
- {
158
- "moves": "d2d4g8f6c2c4c7c5d4d5b7b5",
159
- "name_de": "Wolga-Gambit",
160
- "name_en": "Benko Gambit",
161
- "descriptionLink_de": "Wolga-Gambit",
162
- "descriptionLink_en": "Benko_Gambit"
163
- },
164
- {
165
- "moves": "c2c4g8f6d2d4c7c5d4d5b7b5",
166
- "name_de": "Wolga-Gambit",
167
- "name_en": "Benko Gambit",
168
- "descriptionLink_de": "Wolga-Gambit",
169
- "descriptionLink_en": "Benko_Gambit"
170
- },
171
- {
172
- "moves": "e2e4e7e5g1f3b8c6f1c4g8f6",
173
- "name_de": "Zweispringerspiel",
174
- "name_en": "Two Knights Def.",
175
- "descriptionLink_de": "Zweispringerspiel_im_Nachzuge",
176
- "descriptionLink_en": "Two_Knights_Defense"
177
- },
178
- {
179
- "moves": "d2d4g8f6c2c4e7e6g2g3",
180
- "name_de": "Katalanisch",
181
- "name_en": "Catalan Opening",
182
- "descriptionLink_de": "Katalanische_Eröffnung",
183
- "descriptionLink_en": "Catalan_Opening"
184
- },
185
- {
186
- "moves": "c2c4g8f6d2d4e7e6g2g3",
187
- "name_de": "Katalanisch",
188
- "name_en": "Catalan Opening",
189
- "descriptionLink_de": "Katalanische_Eröffnung",
190
- "descriptionLink_en": "Catalan_Opening"
191
- },
192
- {
193
- "moves": "e2e4e7e5g1f3b8c6c2c3",
194
- "name_de": "Ponziani",
195
- "name_en": "Ponziani Opening",
196
- "descriptionLink_de": "Ponziani-Eröffnung",
197
- "descriptionLink_en": "Ponziani_Opening"
198
- },
199
- {
200
- "moves": "e2e4e7e5g1f3b8c6f1b5",
201
- "name_de": "Spanisch",
202
- "name_en": "Ruy Lopez",
203
- "descriptionLink_de": "Spanische_Partie",
204
- "descriptionLink_en": "Ruy_Lopez"
205
- },
206
- {
207
- "moves": "d2d4g8f6c2c4d7d6",
208
- "name_de": "Altindisch",
209
- "name_en": "Old Indian Defence",
210
- "descriptionLink_de": "Altindische_Verteidigung",
211
- "descriptionLink_en": "Old_Indian_Defense"
212
- },
213
- {
214
- "moves": "c2c4g8f6d2d4d7d6",
215
- "name_de": "Altindisch",
216
- "name_en": "Old Indian Defence",
217
- "descriptionLink_de": "Altindische_Verteidigung",
218
- "descriptionLink_en": "Old_Indian_Defense"
219
- },
220
- {
221
- "moves": "d2d4g8f6c2c4c7c5",
222
- "name_de": "Benoni",
223
- "name_en": "Benoni Defence",
224
- "descriptionLink_de": "Benoni-Verteidigung",
225
- "descriptionLink_en": "Benoni_Defense"
226
- },
227
- {
228
- "moves": "c2c4g8f6d2d4c7c5",
229
- "name_de": "Benoni",
230
- "name_en": "Benoni Defence",
231
- "descriptionLink_de": "Benoni-Verteidigung",
232
- "descriptionLink_en": "Benoni_Defense"
233
- },
234
- {
235
- "moves": "d2d4g8f6c2c4b8c6",
236
- "name_de": "Mexikanisch",
237
- "name_en": "King's Indian Def.",
238
- "descriptionLink_de": "Mexikanische_Verteidigung",
239
- "descriptionLink_en": "Black_Knights%27_Tango"
240
- },
241
- {
242
- "moves": "c2c4g8f6d2d4b8c6",
243
- "name_de": "Mexikanisch",
244
- "name_en": "Black Knights' Tango",
245
- "descriptionLink_de": "Mexikanische_Verteidigung",
246
- "descriptionLink_en": "Black_Knights%27_Tango"
247
- },
248
- {
249
- "moves": "e2e4e7e5d2d4e5d4",
250
- "name_de": "Mittelgambit",
251
- "name_en": "Center Game",
252
- "descriptionLink_de": "Mittelgambit",
253
- "descriptionLink_en": "Center_Game"
254
- },
255
- {
256
- "moves": "e2e4e7e5g1f3d7d6",
257
- "name_de": "Philidor",
258
- "name_en": "Philidor Defence",
259
- "descriptionLink_de": "Philidor-Verteidigung",
260
- "descriptionLink_en": "Philidor_Defence"
261
- },
262
- {
263
- "moves": "e2e4e7e5g1f3g8f6",
264
- "name_de": "Russisch",
265
- "name_en": "Russian",
266
- "descriptionLink_de": "Russische_Verteidigung",
267
- "descriptionLink_en": "Petrov%27s_Defence"
268
- },
269
- {
270
- "moves": "e2e4e7e5g1e2",
271
- "name_de": "Alapin",
272
- "name_en": "Alapin's Opening",
273
- "descriptionLink_de": "Alapin-Eröffnung",
274
- "descriptionLink_en": "Alapin%27s_Opening"
275
- },
276
- {
277
- "moves": "d2d4d7d5c2c4",
278
- "name_de": "Damengambit",
279
- "name_en": "Queen's Gambit",
280
- "descriptionLink_de": "Damengambit",
281
- "descriptionLink_en": "Queen%27s_Gambit"
282
- },
283
- {
284
- "moves": "d2d4g8f6c2c4",
285
- "name_de": "Indisch",
286
- "name_en": "Indian Defence",
287
- "descriptionLink_de": "Indische_Verteidigung",
288
- "descriptionLink_en": "Indian_Defence"
289
- },
290
- {
291
- "moves": "c2c4g8f6d2d4",
292
- "name_de": "Indisch",
293
- "name_en": "Indian Defence",
294
- "descriptionLink_de": "Indische_Verteidigung",
295
- "descriptionLink_en": "Indian_Defence"
296
- },
297
- {
298
- "moves": "e2e4e7e5f2f4",
299
- "name_de": "Königsgambit",
300
- "name_en": "King's Gambit",
301
- "descriptionLink_de": "Königsgambit",
302
- "descriptionLink_en": "King%27s_Gambit"
303
- },
304
- {
305
- "moves": "e2e4e7e5f1c4",
306
- "name_de": "Läuferspiel",
307
- "name_en": "Bishop's Opening",
308
- "descriptionLink_de": "Läuferspiel",
309
- "descriptionLink_en": "Bishop%27s_Opening"
310
- },
311
- {
312
- "moves": "e2e4d7d5e4d5",
313
- "name_de": "Skandinavisch",
314
- "name_en": "Scandinavian Def.",
315
- "descriptionLink_de": "Skandinavische_Verteidigung",
316
- "descriptionLink_en": "Scandinavian_Defense"
317
- },
318
- {
319
- "moves": "e2e4g8f6",
320
- "name_de": "Aljechin",
321
- "name_en": "Alekhine's Defence",
322
- "descriptionLink_de": "Aljechin-Verteidigung",
323
- "descriptionLink_en": "Alekhine%27s_Defence"
324
- },
325
- {
326
- "moves": "e2e4c7c6",
327
- "name_de": "Caro-Kann",
328
- "name_en": "Caro–Kann Defence",
329
- "descriptionLink_de": "Caro-Kann",
330
- "descriptionLink_en": "Caro–Kann_Defence"
331
- },
332
- {
333
- "moves": "d2d4d7d5",
334
- "name_de": "Damenbauernspiel",
335
- "name_en": "Queen's Pawn Game",
336
- "descriptionLink_de": "Damenbauernspiel",
337
- "descriptionLink_en": "Queen%27s_Pawn_Game"
338
- },
339
- {
340
- "moves": "e2e4e7e6",
341
- "name_de": "Französisch",
342
- "name_en": "French Defence",
343
- "descriptionLink_de": "Französische_Verteidigung",
344
- "descriptionLink_en": "French_Defence"
345
- },
346
- {
347
- "moves": "d2d4f7f5",
348
- "name_de": "Holländisch",
349
- "name_en": "Dutch Defence",
350
- "descriptionLink_de": "Holländische_Verteidigung",
351
- "descriptionLink_en": "Dutch_Defence"
352
- },
353
- {
354
- "moves": "e2e4d7d6",
355
- "name_de": "Jugoslawisch",
356
- "name_en": "Pirc Defence",
357
- "descriptionLink_de": "Pirc-Ufimzew-Verteidigung",
358
- "descriptionLink_en": "Pirc_Defence"
359
- },
360
- {
361
- "moves": "e2e4b8c6",
362
- "name_de": "Nimzowitsch",
363
- "name_en": "Nimzowitsch Def.",
364
- "descriptionLink_de": "Nimzowitsch-Verteidigung",
365
- "descriptionLink_en": "Nimzowitsch_Defence"
366
- },
367
- {
368
- "moves": "e2e4b7b5",
369
- "name_de": "Owen",
370
- "name_en": "Owen's Defence",
371
- "descriptionLink_de": "Owen-Verteidigung",
372
- "descriptionLink_en": "Owen%27s_Defence"
373
- },
374
- {
375
- "moves": "e2e4g7g6",
376
- "name_de": "Robatsch",
377
- "name_en": "Robatsch Defence",
378
- "descriptionLink_de": "Moderne_Verteidigung",
379
- "descriptionLink_en": "Modern_Defense"
380
- },
381
- {
382
- "moves": "e2e4c7c5",
383
- "name_de": "Sizilianisch",
384
- "name_en": "Sicilian Defence",
385
- "descriptionLink_de": "Sizilianische_Verteidigung",
386
- "descriptionLink_en": "Sicilian_Defence"
387
- },
388
- {
389
- "moves": "c2c4",
390
- "name_de": "Englisch",
391
- "name_en": "English Opening",
392
- "descriptionLink_de": "Englische_Eröffnung",
393
- "descriptionLink_en": "English_Opening"
394
- },
395
- {
396
- "moves": "b2b4",
397
- "name_de": "Orang Utan",
398
- "name_en": "Orangutan",
399
- "descriptionLink_de": "Orang-Utan_(Schach)",
400
- "descriptionLink_en": "Sokolsky_Opening"
401
- }
402
- ];
403
-
404
- export function detect(moves) {
405
- console.warn("Openings is deprecated")
406
- let i;
407
- for (i in openings) {
408
- const opening = openings[i];
409
- if (opening.moves.length <= moves.length) {
410
- const movesTruncated = moves.substring(0, opening.moves.length);
411
- if (movesTruncated === opening.moves) {
412
- return opening;
413
- }
414
- }
415
- }
416
- }
@@ -1,3 +0,0 @@
1
- # Deprecated
2
-
3
- These tools will be moved somewhere else in future versions, don't use them.