chess-console
Version:
ES6 Module for playing chess
88 lines (86 loc) • 4.08 kB
HTML
<html lang="en">
<head>
<title>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://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
<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><a href="../">chess-console</a></h1>
<h2>Local vs Random in a different style</h2>
<div id="console-container"></div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>
<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://cdn.jsdelivr.net/npm/es-module-shims@1.7.2/dist/es-module-shims.min.js"></script>
<!-- @formatter:off -->
<script type="importmap">
{
"imports": {
"cm-chessboard/": "../node_modules/cm-chessboard/",
"cm-web-modules/": "../node_modules/cm-web-modules/",
"chess.mjs/": "../node_modules/chess.mjs/",
"cm-pgn/": "../node_modules/cm-pgn/",
"cm-chess/": "../node_modules/cm-chess/",
"bootstrap-show-modal/": "../node_modules/bootstrap-show-modal/"
}
}
</script>
<!-- @formatter:on -->
<script type="module">
import {BORDER_TYPE} from "cm-chessboard/src/Chessboard.js"
import {ChessConsole} from "../src/ChessConsole.js"
import {LocalPlayer} from "../src/players/LocalPlayer.js"
import {RandomPlayer} from "../src/players/RandomPlayer.js"
import {Board, CONSOLE_MARKER_TYPE} from "../src/components/Board.js"
import {GameStateOutput} from "../src/components/GameStateOutput.js"
import {History} from "../src/components/History.js"
import {CapturedPieces} from "../src/components/CapturedPieces.js"
import {HistoryControl} from "../src/components/HistoryControl.js"
import {GameControl} from "../src/components/GameControl/GameControl.js"
import {Persistence} from "../src/components/Persistence.js"
import {Sound} from "../src/components/Sound.js"
new ChessConsole(
document.getElementById("console-container"),
{name: "Local Player", type: LocalPlayer},
{name: "Random Player", type: RandomPlayer}
).initialized.then((chessConsole) => {
new Board(chessConsole, {
assetsUrl: "../node_modules/cm-chessboard/assets/",
markers: {
moveInput: {class: "marker-square", slice: "markerSquare"},
wrongMove: {class: "marker-square-danger", slice: "markerSquare"},
premove: {class: "marker-square-primary", slice: "markerSquare"},
legalMove: CONSOLE_MARKER_TYPE.legalMove,
legalMoveCapture: CONSOLE_MARKER_TYPE.legalMoveCapture
},
style: {
cssClass: "green",
borderType: BORDER_TYPE.frame,
showCoordinates: true,
pieces: {file: "pieces/staunty.svg"}
}
}).initialized.then(() => {
new Persistence(chessConsole, {
savePrefix: "Random"
}).load()
})
new GameStateOutput(chessConsole)
new History(chessConsole)
new HistoryControl(chessConsole)
new CapturedPieces(chessConsole)
new GameControl(chessConsole)
new Sound(chessConsole, {
soundSpriteFile: "../assets/sounds/chess_console_sounds.mp3"
})
})
</script>
</body>
</html>