schachnovelle 1.1.1 → 1.1.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/package.json +1 -1
- package/ui/Board.js +6 -4
- package/ui/Game.js +6 -6
- package/ui/index.js +7 -1
package/package.json
CHANGED
package/ui/Board.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
const
|
|
2
|
-
const Printer = require('./Printer')
|
|
1
|
+
const plainChalk = require('./plainChalk')
|
|
3
2
|
const Utils = require('./Utils')
|
|
4
3
|
|
|
5
4
|
const files = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']
|
|
@@ -19,8 +18,11 @@ class Board {
|
|
|
19
18
|
this.ranks = ranks
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
this.chalk = options.chalk ||
|
|
23
|
-
|
|
21
|
+
this.chalk = options.chalk || plainChalk
|
|
22
|
+
if (!options.printer) {
|
|
23
|
+
throw new Error('Board requires a printer instance via options.printer')
|
|
24
|
+
}
|
|
25
|
+
this.printer = options.printer
|
|
24
26
|
this.utils = new Utils()
|
|
25
27
|
}
|
|
26
28
|
|
package/ui/Game.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
2
|
const Side = require("./Side")
|
|
3
3
|
const Board = require("./Board")
|
|
4
|
-
const Printer = require("./Printer")
|
|
5
4
|
const Utils = require("./Utils")
|
|
6
5
|
|
|
7
|
-
const Enquirer = require("enquirer")
|
|
8
|
-
|
|
9
6
|
class Game {
|
|
10
7
|
constructor(options) {
|
|
8
|
+
if (!options || !options.enquirer || typeof options.enquirer.prompt !== 'function') {
|
|
9
|
+
throw new Error('Game requires an enquirer-like instance via options.enquirer')
|
|
10
|
+
}
|
|
11
|
+
|
|
11
12
|
this.white = new Side("white")
|
|
12
13
|
this.black = new Side("black")
|
|
13
14
|
this.playingAs = options.playingAs
|
|
@@ -27,8 +28,7 @@ class Game {
|
|
|
27
28
|
chalk: options.chalk
|
|
28
29
|
})
|
|
29
30
|
|
|
30
|
-
this.enquirer = options.enquirer
|
|
31
|
-
this.printer = new Printer(options.spacing)
|
|
31
|
+
this.enquirer = options.enquirer
|
|
32
32
|
this.utils = new Utils()
|
|
33
33
|
}
|
|
34
34
|
|
package/ui/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
const spacing = 1
|
|
2
|
+
const Enquirer = require('enquirer')
|
|
2
3
|
const { Select } = require('enquirer')
|
|
4
|
+
const chalk = require('chalk')
|
|
3
5
|
|
|
4
6
|
const { spawn } = require('child_process')
|
|
5
7
|
|
|
@@ -7,6 +9,7 @@ const Game = require('./Game')
|
|
|
7
9
|
const Printer = require('./Printer')
|
|
8
10
|
|
|
9
11
|
const printer = new Printer(spacing)
|
|
12
|
+
const enquirer = new Enquirer()
|
|
10
13
|
|
|
11
14
|
/**
|
|
12
15
|
* Welcome to Schachnovelle
|
|
@@ -75,7 +78,10 @@ exports.localGame = () => {
|
|
|
75
78
|
const game = new Game({
|
|
76
79
|
playingAs: choices.color,
|
|
77
80
|
spacing,
|
|
78
|
-
mode: 'bare'
|
|
81
|
+
mode: 'bare',
|
|
82
|
+
enquirer,
|
|
83
|
+
printer,
|
|
84
|
+
chalk
|
|
79
85
|
})
|
|
80
86
|
|
|
81
87
|
printer.clearView()
|