forked from shaack/chess-console-stockfish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
123 lines (118 loc) · 5.5 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<!DOCTYPE html>
<html lang="en">
<head>
<title>Stockfish for chess-console</title>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, user-scalable=yes, initial-scale=1.0"/>
<meta http-equiv="X-UA-Compatible" content="ie=edge"/>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"/>
<link rel="stylesheet" href="./assets/styles/screen.css"/>
</head>
<body>
<div class="container-fluid">
<h1>Stockfish for <a href="https://github.com/shaack/chess-console">chess-console</a></h1>
<div id="console-container" class="mb-3"></div>
<form>
<div class="input-group mb-4">
<label for="fenInput" class="sr-only">FEN</label>
<div class="input-group-prepend">
<button id="fenButton" class="btn btn-outline-primary" type="button">Init with FEN</button>
</div>
<input id="fenInput" class="form-control" placeholder="FEN"
value="ppppkppp/pppppppp/pppppppp/pppppppp/8/8/8/RNBQKBNR w KQ - 0 1"/>
</div>
</form>
<h3>Repositories and further information on GitHub</h3>
<dl>
<dt>the Stockfish player for chess-console</dt>
<dd><a href="https://github.com/shaack/chess-console-stockfish">chess-console-stockfish</a></dd>
<dt>The framework for playing chess in a website</dt>
<dd><a href="https://github.com/shaack/chess-console">chess-console</a></dd>
<dt>the SVG rendered board used in chess-console</dt>
<dd><a href="https://github.com/shaack/cm-chessboard">cm-chessboard</a></dd>
<dt>The Stockfish player used online at chessmail</dt>
<dd><a href="https://www.chessmail.eu/pages/chess-computer.html">chessmail.eu</a>
<dt>The chess computer engine in JavaScript (External)</dt>
<dd><a href="https://github.com/nmrugg/stockfish.js">stockfish-niklasf-v10.js</a>
</dd>
</dl>
<p>
copyright © <a href="https://shaack.com">shaack.com</a> engineering.<br/>
Source code license: <a href="https://github.com/shaack/chess-console/blob/master/LICENSE">MIT</a>.
License for the Sounds: <a href="https://creativecommons.org/licenses/by/4.0/">CC BY 4.0</a>. License of the SVG
pieces <a href="https://creativecommons.org/licenses/by-sa/3.0/">CC BY-SA 3.0</a>.
</p>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"
integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49"
crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"
integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy"
crossorigin="anonymous"></script>
<script type="module">
import {ChessConsole} from "./lib/chess-console/ChessConsole.js"
import {LocalPlayer} from "./lib/chess-console/players/LocalPlayer.js"
import {Board} from "./lib/chess-console/components/Board/Board.js"
import {GameStateOutput} from "./lib/chess-console/components/GameStateOutput.js"
import {History} from "./lib/chess-console/components/History.js"
import {CapturedPieces} from "./lib/chess-console/components/CapturedPieces.js"
import {HistoryControl} from "./lib/chess-console/components/HistoryControl.js"
import {Persistence} from "./lib/chess-console/components/Persistence.js"
import {Sound} from "./lib/chess-console/components/Sound.js"
import {StockfishGameControl} from "./src/chess-console-stockfish/StockfishGameControl.js"
import {StockfishPlayer} from "./src/chess-console-stockfish/StockfishPlayer.js"
import {StockfishStateView} from "./src/chess-console-stockfish/StockfishStateView.js"
import {I18n} from "./lib/cm-web-modules/i18n/I18n.js"
const i18n = new I18n()
i18n.load({
de: {
playerName: "Spieler"
},
en: {
playerName: "Player"
}
})
const chessConsole = new ChessConsole(
document.getElementById("console-container"),
{name: i18n.t("playerName"), type: LocalPlayer},
{
name: "Stockfish", type: StockfishPlayer, props: {
worker: "./lib/stockfish-v10-niklasf.js",
book: "./assets/books/openings.bin",
level: 1,
debug: true
}
},
{
figuresSpriteFile: "../node_modules/cm-chessboard/assets/images/chessboard-sprite-staunty.svg"
})
new Board(chessConsole).initialization.then(() => {
new Persistence(chessConsole, {
savePrefix: "Stockfish"
}).load()
})
new History(chessConsole)
new HistoryControl(chessConsole)
new CapturedPieces(chessConsole)
new StockfishGameControl(chessConsole, {
player: chessConsole.opponent
})
new StockfishStateView(chessConsole, chessConsole.opponent )
new GameStateOutput(chessConsole)
new Sound(chessConsole, {
soundSpriteFile: "../assets/sounds/chess_console_sounds.mp3"
})
document.getElementById("fenButton").addEventListener("click", () => {
const fen = document.getElementById("fenInput").value
const pgn = `[SetUp "1"]
[FEN "${fen}"]`
chessConsole.initGame({
pgn: pgn
})
})
</script>
</body>
</html>