Skip to content

Commit 3bc632b

Browse files
committed
Update dartchess version to get better move parsing
1 parent f894540 commit 3bc632b

File tree

8 files changed

+11
-13
lines changed

8 files changed

+11
-13
lines changed

lib/src/features/game/model/game_state.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class GameState with _$GameState {
3434
final List<Position<Chess>> positions = [Chess.initial];
3535
final List<String> sanMoves = [];
3636
for (final m in uciMoves) {
37-
final move = Move.fromUci(m);
37+
final move = Move.fromUci(m)!;
3838
final newPos = positions.last.playToSan(move);
3939
positions.add(newPos.item1);
4040
sanMoves.add(newPos.item2);

lib/src/features/game/ui/board/playable_game_screen.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ class _BoardBody extends ConsumerWidget {
227227
sideToMove: gameState?.position.turn.cg ?? game.orientation.cg,
228228
onMove: (cg.Move move, {bool? isPremove}) => ref
229229
.read(gameStateProvider.notifier)
230-
.onUserMove(game.id, Move.fromUci(move.uci)),
230+
.onUserMove(game.id, Move.fromUci(move.uci)!),
231231
),
232232
topPlayer: topPlayer,
233233
bottomPlayer: bottomPlayer,

lib/src/features/tv/data/tv_event.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class TvEvent with _$TvEvent {
5252
return pick('d').letOrThrow((dataPick) => TvEvent.fen(
5353
fen: dataPick('fen').asStringOrThrow(),
5454
lastMove: dataPick('lm')
55-
.letOrThrow((it) => Move.fromUci(it.asStringOrThrow())),
55+
.letOrThrow((it) => Move.fromUci(it.asStringOrThrow())!),
5656
whiteSeconds: dataPick('wc').asIntOrThrow(),
5757
blackSeconds: dataPick('bc').asIntOrThrow(),
5858
));

lib/src/utils/json.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ extension Dartchess on Pick {
1717
}
1818
if (value is String) {
1919
try {
20-
return Move.fromUci(value);
20+
return Move.fromUci(value)!;
2121
} catch (_) {
2222
throw PickException(
2323
"value $value at $debugParsingExit can't be casted to Move: invalid UCI string.");

lib/src/widgets/non_visual_game_board.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@ class NonVisualGameBoard extends StatelessWidget {
4848
if (scanResult != null) {
4949
return scanResult;
5050
}
51-
// TODO: uncomment when parseSan is available
52-
final move =
53-
Move.fromUci(command) /*?? gameState.position.parseSan(command)*/;
51+
final move = Move.fromUci(command) ?? position.parseSan(command);
5452
if (move != null) {
5553
onMove(move);
5654
return null;

pubspec.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,8 @@ packages:
196196
dependency: "direct main"
197197
description:
198198
path: "."
199-
ref: "68c756354b53c9f210f78b49ee1caa03ab5003bd"
200-
resolved-ref: "68c756354b53c9f210f78b49ee1caa03ab5003bd"
199+
ref: "90ed79af3db095fb40e1a14c7ee85aaccf83b1f3"
200+
resolved-ref: "90ed79af3db095fb40e1a14c7ee85aaccf83b1f3"
201201
url: "https://github.com/lichess-org/dartchess.git"
202202
source: git
203203
version: "0.1.0"

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ dependencies:
3535
dartchess:
3636
git:
3737
url: https://github.com/lichess-org/dartchess.git
38-
ref: 68c756354b53c9f210f78b49ee1caa03ab5003bd
38+
ref: 90ed79af3db095fb40e1a14c7ee85aaccf83b1f3
3939
chessground:
4040
git:
4141
url: https://github.com/lichess-org/flutter-chessground.git

test/features/game/ui/board/playable_game_screen_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ class FakeGameClient extends Fake implements http.Client {
352352
final move = request.url.path.substring(request.url.path.length - 4);
353353
moves.add(move);
354354
whiteTime -= 5000;
355-
position = position.play(Move.fromUci(move));
355+
position = position.play(Move.fromUci(move)!);
356356
_sendGameEvent(
357357
'{ "type": "gameState", "moves": "${moves.join(' ')}", "wtime": $whiteTime, "btime": $blackTime, "status": "started" }');
358358

@@ -362,14 +362,14 @@ class FakeGameClient extends Fake implements http.Client {
362362
case 1:
363363
moves.add('e7e5');
364364
blackTime -= 3000;
365-
position = position.play(Move.fromUci('e7e5'));
365+
position = position.play(Move.fromUci('e7e5')!);
366366
_sendGameEvent(
367367
'{ "type": "gameState", "moves": "${moves.join(' ')}", "wtime": $whiteTime, "btime": $blackTime, "status": "started" }');
368368
break;
369369
case 3:
370370
moves.add('b8c6');
371371
blackTime -= 6000;
372-
position = position.play(Move.fromUci('b8c6'));
372+
position = position.play(Move.fromUci('b8c6')!);
373373
_sendGameEvent(
374374
'{ "type": "gameState", "moves": "${moves.join(' ')}", "wtime": $whiteTime, "btime": $blackTime, "status": "started" }');
375375
break;

0 commit comments

Comments
 (0)