This commit is contained in:
Maciej Caderek
2022-02-14 17:46:14 +01:00
parent e0b79a7071
commit 3e20babe24
8 changed files with 90 additions and 17 deletions

View File

@@ -17,6 +17,7 @@ import readFile from "./utils/readFile";
import download from "./utils/download";
import { compressPGN } from "./game/PGNHelpers";
import extractUrlData from "./persistance/extractUrlData";
import importFromLink from "./imports/importFromLink";
const main = async () => {
const board = new Board(state.boardConfig);
@@ -101,12 +102,22 @@ const main = async () => {
window.location.hash = `v1/pgn/${compressPGN(game.pgn)}`;
await player.load(game);
setState("activeTab", "game");
},
async loadFEN(fen: string) {
const game = new Game().loadFEN(fen);
setState({ pgn: "", fen, moves: game.getMoves(), ply: 0, game });
await player.load(game);
},
async importPGN(link: string) {
const result = await importFromLink(link);
if (result.error) {
return;
}
await this.loadPGN(result.pgn);
},
async downloadImage() {
const data = await createImage(
state.fen,