Change the point in time when the board gets cleared.

This commit is contained in:
Marco 2023-06-09 13:19:03 +02:00
parent d55c7bbe1a
commit e27f1c7c22
3 changed files with 4 additions and 3 deletions

View File

@ -6,9 +6,8 @@ typedef ChessMoveHistory = List<ChessMove>;
class ChessPosition {
static ChessPosition _instance = ChessPosition._internal();
final ChessPositionType position;
static ChessMoveHistory history = ChessMoveHistory.empty(growable: true);
final ChessPositionType position;
static ChessPosition getInstance() {
return _instance;

View File

@ -73,7 +73,6 @@ class ServerConnection {
}
void handleIncomingColorDeterminedMessage(ApiWebsocketMessage apiMessage) {
ChessBloc.getInstance().add(InitBoard());
ChessBloc.getInstance().add(
ColorDetermined(myColor: ChessColor.fromApiColor(apiMessage.color!)));
}

View File

@ -5,6 +5,8 @@ import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:http/http.dart';
import 'package:mchess/api/register.dart';
import 'package:mchess/chess_bloc/chess_bloc.dart';
import 'package:mchess/chess_bloc/chess_events.dart';
import 'package:mchess/pages/chess_game.dart';
import 'package:http/http.dart' as http;
import 'dart:convert';
@ -21,6 +23,7 @@ class _PrepareChessGameWidgetState extends State<PrepareChessGameWidget> {
@override
void initState() {
ChessBloc.getInstance().add(InitBoard());
randomGameResponse = registerForRandomGame();
super.initState();
}