-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ply limit alert and prevent premoves in stalemates / insufficient material positions #16679
Closed
Closed
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
7165c3a
Alert the user when no more moves allowed in a chapter.
johndoknjas c823d9d
Merge branch 'master' into ply-alert
johndoknjas 985511a
Have different alerts depending on the reason for no more moves.
johndoknjas ee36932
Merge branch 'master' into no-more-moves-alert
johndoknjas 463a850
Do not allow the user to make premoves when the game is over.
johndoknjas c85f71e
Merge branch 'master' into no-more-moves-alert
johndoknjas bed3e80
Merge branch 'prevent-premoves-drawn-pos' into no-more-moves-alert
johndoknjas ce815f8
Update code to no longer handle stalemate and insufficient material c…
johndoknjas 86fe0a6
Give the ply limit alert on all types of analysis boards, not just st…
johndoknjas 4877896
Use the lichess custom alert.
johndoknjas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,7 @@ import ForecastCtrl from './forecast/forecastCtrl'; | |
import { type ArrowKey, type KeyboardMove, ctrl as makeKeyboardMove } from 'keyboardMove'; | ||
import * as control from './control'; | ||
import type { PgnError } from 'chessops/pgn'; | ||
import { confirm } from 'common/dialog'; | ||
import { confirm, alert } from 'common/dialog'; | ||
import api from './api'; | ||
|
||
export default class AnalyseCtrl { | ||
|
@@ -353,7 +353,8 @@ export default class AnalyseCtrl { | |
config.movable!.color = color; | ||
} | ||
config.premovable = { | ||
enabled: config.movable!.color && config.turnColor !== config.movable!.color, | ||
enabled: | ||
config.movable!.color && config.turnColor !== config.movable!.color && !this.currPosition().isEnd(), | ||
}; | ||
this.cgConfig = config; | ||
return config; | ||
|
@@ -574,7 +575,8 @@ export default class AnalyseCtrl { | |
} | ||
|
||
onPremoveSet = () => { | ||
if (this.study) this.study.onPremoveSet(); | ||
if (this.node.dests === '') alert('Too many moves for a lichess board.'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a weird assumption to make and one that would probably backfire. Can we use the ply number instead? |
||
else if (this.study) this.study.onPremoveSet(); | ||
}; | ||
|
||
addNode(node: Tree.Node, path: Tree.Path) { | ||
|
@@ -740,6 +742,8 @@ export default class AnalyseCtrl { | |
return setupPosition(lichessRules(this.data.game.variant.key), setup); | ||
} | ||
|
||
currPosition = () => this.position(this.node).unwrap(); | ||
|
||
canUseCeval(): boolean { | ||
return !this.node.threefold && !this.outcome(); | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the point of analysis premoves again? Since we can move all pieces.
I suppose it's only useful in specific applications like "learn from your mistakes" where only one side is playable. That would be a better thing to check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ornicar I think the main point is when the connection to the server is poor. E.g., if you open a study board and turn off wifi, the next move should be a premove.