For testing purposes send move to server.
This commit is contained in:
parent
76e141619b
commit
aa3e3187c4
@ -1,7 +1,9 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'chess_events.dart';
|
||||
import 'package:mchess/chess_bloc/chess_events.dart';
|
||||
import 'package:mchess/chessapp/chess_utils.dart';
|
||||
import 'package:mchess/connection/ws_connection.dart';
|
||||
|
||||
class ChessBloc extends Bloc<ChessEvent, ChessBoardState> {
|
||||
static final ChessBloc _instance = ChessBloc._internal();
|
||||
@ -18,12 +20,12 @@ class ChessBloc extends Bloc<ChessEvent, ChessBoardState> {
|
||||
return _instance;
|
||||
}
|
||||
|
||||
FutureOr<void> moveHandler(
|
||||
PieceMoved event,
|
||||
Emitter<ChessBoardState> emit,
|
||||
) {
|
||||
FutureOr<void> moveHandler(PieceMoved event, Emitter<ChessBoardState> emit) {
|
||||
Map<ChessCoordinate, ChessPiece> newPosition = {};
|
||||
|
||||
ServerConnection.getInstance().send(
|
||||
"from: ${event.startSquare.toString()} to: ${event.endSquare.toString()}");
|
||||
|
||||
newPosition[event.endSquare] = state.position[event.startSquare]!;
|
||||
newPosition[event.startSquare] = const ChessPiece.none();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user