diff --git a/lib/game/controller.dart b/lib/game/controller.dart index c93c7cd..b6b2315 100644 --- a/lib/game/controller.dart +++ b/lib/game/controller.dart @@ -164,9 +164,8 @@ class Game { hasHalfTime: _hasHalfTime(next), ); case GameStateSpeaking(accusations: final accusations, currentPlayerNumber: final pn): - final alreadySpoke = _log - .whereType() - .getAlreadySpokePlayers(currentDay: state.day); + final alreadySpoke = + _log.whereType().getAlreadySpokePlayers(currentDay: state.day); final shouldSpeakCount = players.aliveCount + _log .whereType() @@ -395,9 +394,8 @@ class Game { activePlayerNumber: players.sheriff.number, ); } - final killedPlayerNumber = _log - .whereType() - .getLastDayKilledPlayerNumber(); + final killedPlayerNumber = + _log.whereType().getLastDayKilledPlayerNumber(); if (killedPlayerNumber != null) { if (state.day == 2 && players.aliveCount >= players.count - 1) { return GameStateBestTurn( @@ -490,9 +488,7 @@ class Game { /// Gets previous game state according to game internal state, and returns it. /// Doesn't change internal state. May throw exceptions if game internal state is inconsistent. /// Returns `null` if there is no previous state. - BaseGameState? get previousState => _log - .whereType() - .getPreviousState(); + BaseGameState? get previousState => _log.whereType().getPreviousState(); void setPreviousState() { final prevState = previousState; @@ -768,9 +764,7 @@ class Game { } int get _consequentDaysWithoutDeaths { - final lastDeathDay = _log - .whereType() - .getLastDayPlayerLeft(); + final lastDeathDay = _log.whereType().getLastDayPlayerLeft(); return state.day - (lastDeathDay ?? 1); } diff --git a/lib/utils/state_change_utils.dart b/lib/utils/state_change_utils.dart index 66537f6..93cfe7f 100644 --- a/lib/utils/state_change_utils.dart +++ b/lib/utils/state_change_utils.dart @@ -39,7 +39,9 @@ extension StateChangeUtils on Iterable { Set getAlreadySpokePlayers({required int currentDay}) { final result = {}; for (final (previous, item) in _iterWithPrevious()) { - if (previous != null && item.hasStateChanged(previous) && item is GameStateSpeaking && + if (previous != null && + item.hasStateChanged(previous) && + item is GameStateSpeaking && item.day == currentDay) { result.add(item.currentPlayerNumber); } diff --git a/lib/widgets/bottom_controls.dart b/lib/widgets/bottom_controls.dart index ca8a541..2e9c6ad 100644 --- a/lib/widgets/bottom_controls.dart +++ b/lib/widgets/bottom_controls.dart @@ -21,9 +21,7 @@ class GameBottomControlBar extends StatelessWidget { PlayerList playersContainer, GameStateFinish nextState, ) async { - final bestTurn = controller.gameLog - .whereType() - .getBestTurn(); + final bestTurn = controller.gameLog.whereType().getBestTurn(); final guessedMafiaCount = bestTurn?.playerNumbers .where((e) => nextState.players[e - 1].role.team == RoleTeam.mafia) .length;