schachnovelle 1.0.0 → 1.0.2
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/CHANGELOG.md +23 -0
- package/README.md +6 -2
- package/package.json +7 -3
- package/server/api.js +119 -11
- package/server/index.js +331 -31
- package/ui/Board.js +25 -4
- package/ui/Fen.js +5 -0
- package/ui/Game.js +405 -332
- package/ui/LichessGame.js +11 -0
- package/ui/Side.js +10 -9
- package/ui/Utils.js +3 -2
- package/ui/index.js +72 -8
- package/ui/moves.js +0 -0
- package/views/error.pug +6 -0
- package/views/index.pug +6 -0
- package/views/layout.pug +6 -0
- package/views/welcome.pug +6 -0
- package/yarn-error.log +0 -367
package/ui/Board.js
CHANGED
|
@@ -29,9 +29,11 @@ class Board {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
render () {
|
|
32
|
+
// this.topCheck()
|
|
32
33
|
this.topRank()
|
|
33
34
|
this.board()
|
|
34
35
|
this.bottomRank()
|
|
36
|
+
// this.bottomCheck()
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
getPiece (file, rank) {
|
|
@@ -53,13 +55,13 @@ class Board {
|
|
|
53
55
|
* Pieces
|
|
54
56
|
*/
|
|
55
57
|
if (activeWhitePiece) {
|
|
56
|
-
if (activeWhitePiece.
|
|
58
|
+
if (activeWhitePiece.type === 'King' && this.white.inCheck) {
|
|
57
59
|
return chalk`{red ${activeWhitePiece.piece}} `
|
|
58
60
|
} else {
|
|
59
61
|
return chalk`{black ${activeWhitePiece.piece}} `
|
|
60
62
|
}
|
|
61
63
|
} else if (activeBlackPiece) {
|
|
62
|
-
if (activeBlackPiece.
|
|
64
|
+
if (activeBlackPiece.type === 'King' && this.black.inCheck) {
|
|
63
65
|
return chalk`{red ${activeBlackPiece.piece}} `
|
|
64
66
|
} else {
|
|
65
67
|
return chalk`{black ${activeBlackPiece.piece}} `
|
|
@@ -92,7 +94,7 @@ class Board {
|
|
|
92
94
|
scoreBoard (side) {
|
|
93
95
|
let scoreBoard = ''
|
|
94
96
|
let score = 0
|
|
95
|
-
const opponent = this.utils.
|
|
97
|
+
const opponent = this.utils.opposingColor(side)
|
|
96
98
|
const pieces = this.capturedPieces(opponent)
|
|
97
99
|
|
|
98
100
|
if (pieces.length > 0) {
|
|
@@ -110,11 +112,30 @@ class Board {
|
|
|
110
112
|
this.printer.addSpace('y')
|
|
111
113
|
}
|
|
112
114
|
|
|
115
|
+
/**
|
|
116
|
+
* For development only. Display if the king is in check
|
|
117
|
+
*/
|
|
118
|
+
topCheck () {
|
|
119
|
+
const side = this.utils.opposingColor(this.options.orientation)
|
|
120
|
+
this.printer.print(side + ' king in check: ' + this[side].inCheck)
|
|
121
|
+
this.printer.addSpace('y')
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* For development only. Display if the king is in check
|
|
126
|
+
*/
|
|
127
|
+
bottomCheck () {
|
|
128
|
+
const side = this.options.orientation
|
|
129
|
+
this.printer.print(side + ' king in check: ' + this[side].inCheck)
|
|
130
|
+
this.printer.addSpace('y')
|
|
131
|
+
}
|
|
132
|
+
|
|
113
133
|
/**
|
|
114
134
|
* Top signage
|
|
115
135
|
*/
|
|
116
136
|
topRank () {
|
|
117
|
-
this.
|
|
137
|
+
const side = this.utils.opposingColor(this.options.orientation)
|
|
138
|
+
this.scoreBoard(side)
|
|
118
139
|
let renderTopRank = this.printer.tab
|
|
119
140
|
renderTopRank = this.printer.addSpace('x', renderTopRank)
|
|
120
141
|
for (let file in this.files) {
|