fix: dont check if first move of variant exists

This commit is contained in:
chrislicodes 2023-05-25 16:30:19 +02:00
parent 599c4cf645
commit 8d60425798
5 changed files with 18 additions and 26 deletions

View file

@ -10,17 +10,19 @@ With this plugin, you can either import PGNs or simply start a fresh new game. I
## Table of contents
- [Motivation](#motivation)
- [Installation](#installation)
- [Usage](#usage)
- [Features](#features)
- [1.0.0](#100)
- [1.0.1](#101)
- [Settings](#settings)
- [Roadmap](#roadmap)
- [Tools Used](#tools-used)
- [Alternatives](#alternatives)
- [License](#license)
- [Obsidian Chess Study](#obsidian-chess-study)
- [Table of contents](#table-of-contents)
- [Motivation](#motivation)
- [Installation](#installation)
- [Usage](#usage)
- [Features](#features)
- [1.0.0](#100)
- [1.0.1](#101)
- [Settings](#settings)
- [Roadmap](#roadmap)
- [Tools Used](#tools-used)
- [Alternatives](#alternatives)
- [License](#license)
## Motivation
@ -42,9 +44,9 @@ Once you click `Submit`, Obsidian Chess Study will parse the PGN, generate a new
![chess-study-codeblock](imgs/chess-study-codeblock.png)
After that the PGN viewer/editor will render and you are good to go:
After that the PGN viewer/editor will render and you are good to go (styles are aligned with your theme and accent color):
![cchess-study-codeblock](imgs/chess-study-demo.gif)
![chess-study-codeblock](imgs/chess-study-demo.gif)
## Features
@ -62,6 +64,8 @@ After that the PGN viewer/editor will render and you are good to go:
- [x] Add support for variants (depth 1)
![chess-study-variants](imgs/chess-study-variants.png)
## Settings
Here are the available settings for a `chessStudy` code block:

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

View file

@ -187,7 +187,7 @@ export const ChessStudy = ({
} else {
const currentMove = moves[moveIndex];
//check if the next move is the same move
// check if the next move is the same move
const nextMove = moves[moveIndex + 1];
if (nextMove.san === newMove.san) {
@ -195,16 +195,6 @@ export const ChessStudy = ({
return draft;
}
//check if a variant with this first move already exists
const sameVariant = currentMove.variants.findIndex(
(variant) => variant.moves[0]?.san === newMove.san
);
if (sameVariant >= 0) {
draft.currentMove = currentMove.variants[sameVariant].moves[0];
return draft;
}
const move = {
...newMove,
moveId: moveId,

View file

@ -75,7 +75,6 @@ export const displayMoveInHistory = (
const chess = new Chess(moveToDisplay.after);
//TODO: Handle is view only if not the last move in variant - put this into a function also for inital setuo
chessView.set({
fen: moveToDisplay.after,
check: chess.isCheck(),

File diff suppressed because one or more lines are too long