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/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.inCheck === true) {
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.inCheck === true) {
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.opponentColor(side)
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.scoreBoard(this.utils.opponentColor(this.options.orientation))
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) {
package/ui/Fen.js ADDED
@@ -0,0 +1,5 @@
1
+ export default {
2
+ currentPosition: null,
3
+ startPos: 'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1',
4
+ moves: []
5
+ }