promotionCheck method
Returns true if player chose a piece (isPromoted)
Implementation
Future<bool> promotionCheck(
ChessBoardInterface game,
Position position,
) async {
if (game.isEligibleForPromotion(position)) {
bool isPromoted =
await (onReachingPromotionRank == null && showDialogs
? _defaultPromotionDialog(game, position)
: onReachingPromotionRank != null
? onReachingPromotionRank!(position)
: Future.value(false));
if (!isPromoted) {
game.promotePawn(position, PieceType.queen);
isPromoted = true;
}
if (onPromoted != null) {
onPromoted!(position, game.getPiece(position));
}
return isPromoted;
}
return false;
}