Skip to content
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

1043 add castling method option v2 #1347

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

Jimima
Copy link
Contributor

@Jimima Jimima commented Jan 8, 2025

Adds an option to change castling method. Still needs some work to tidy up but the approach is implemented. Note that it only really works for Standard variants as chess960 always uses king over rook. I think this is okay but maybe the UI could make this clearer.

@veloce
Copy link
Contributor

veloce commented Jan 9, 2025

Just for my understanding, why the v1 was closed? thanks :)

@Jimima
Copy link
Contributor Author

Jimima commented Jan 9, 2025

Sure, I had attempted an implementation that modified dartchess and chessground which maybe was not the correct approach. I didn't have a great deal of time to look at it at that point so I just closed the PRs for hygeine. See here for reference lichess-org/dartchess#44

This change is limited to only the mobile app with no changes elsewhere. Not sure if this is the right approach still, happy to be told if you think there is an alternative way to come at it

@Jimima Jimima force-pushed the 1043-add-castling-method-option-v2 branch from c97a375 to b2a2c28 Compare January 17, 2025 10:52
@Jimima Jimima force-pushed the 1043-add-castling-method-option-v2 branch from b2a2c28 to c8348c0 Compare January 17, 2025 10:54
@Jimima Jimima marked this pull request as ready for review January 17, 2025 11:12
@Jimima
Copy link
Contributor Author

Jimima commented Jan 17, 2025

I think this is ready to be looked at @veloce. Not sure what's going on with the tests but maybe an issue unrelated to this PR?

@julien4215
Copy link
Contributor

A fix was pushed on the main branch. The tests need to be rerun manually.

@veloce
Copy link
Contributor

veloce commented Jan 20, 2025

@Jimima can you rebase your branch on top of main so the tests pass? thank.

@Jimima
Copy link
Contributor Author

Jimima commented Jan 20, 2025

@veloce done!

Copy link
Contributor

@veloce veloce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this. This is looking good but there are a couple of issues to address on top of the comments I've made:

  • for now this settings applies only to online games, but it should also apply to puzzles, analysis, study, etc.
  • the logic you added to game_controller.dart must be refactored so it can work everywhere.
  • this is the time for a refactoring: we need a global board wrapper so we can apply settings to the whole app
  • a good starting point for this refactoring imo, is the private _BoardWidget which should be extracted to a public widget in another file. It should be modified to take only BoardPrefs and BoardSettingsOverride (and not directly the ChessboardSettings from chessground which should be constructed inside the widget from the prefs and the optional override).
  • the new castling logic should be tested


// TODO: l10n
String get label => switch (this) {
CastlingMethod.kingOverRook => 'Move king over rook',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

translation keys already exist: look at app_en.arb: preferencesCastleByMovingOntoTheRook.

enum CastlingMethod {
kingOverRook,
kingTwoSquares,
either;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not support either because it is not supported on website.

The default is kingOverRook

@@ -369,3 +429,11 @@ String pieceShiftMethodl10n(BuildContext context, PieceShiftMethod pieceShiftMet
PieceShiftMethod.drag => context.l10n.preferencesDragPiece,
PieceShiftMethod.tapTwoSquares => 'Tap two squares',
};

String castlingMethodl10n(BuildContext context, CastlingMethod castlingMethod) =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicated l10n logic; must be defined directly in the enum to be consistent with rest of code.

@Jimima
Copy link
Contributor Author

Jimima commented Jan 21, 2025

Thanks for the feedback, that all makes sense. I also wonder if we are worried about premoves respecting the preference as right now they do not. I think the main site does not either but I would need to check this.

@Jimima Jimima marked this pull request as draft January 21, 2025 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants