Skip to content

Commit

Permalink
Reformat code
Browse files Browse the repository at this point in the history
  • Loading branch information
evgfilim1 committed Apr 5, 2024
1 parent 8a5d8f4 commit 0abcad6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
18 changes: 6 additions & 12 deletions lib/game/controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,8 @@ class Game {
hasHalfTime: _hasHalfTime(next),
);
case GameStateSpeaking(accusations: final accusations, currentPlayerNumber: final pn):
final alreadySpoke = _log
.whereType<StateChangeGameLogItem>()
.getAlreadySpokePlayers(currentDay: state.day);
final alreadySpoke =
_log.whereType<StateChangeGameLogItem>().getAlreadySpokePlayers(currentDay: state.day);
final shouldSpeakCount = players.aliveCount +
_log
.whereType<PlayerKickedGameLogItem>()
Expand Down Expand Up @@ -395,9 +394,8 @@ class Game {
activePlayerNumber: players.sheriff.number,
);
}
final killedPlayerNumber = _log
.whereType<StateChangeGameLogItem>()
.getLastDayKilledPlayerNumber();
final killedPlayerNumber =
_log.whereType<StateChangeGameLogItem>().getLastDayKilledPlayerNumber();
if (killedPlayerNumber != null) {
if (state.day == 2 && players.aliveCount >= players.count - 1) {
return GameStateBestTurn(
Expand Down Expand Up @@ -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<StateChangeGameLogItem>()
.getPreviousState();
BaseGameState? get previousState => _log.whereType<StateChangeGameLogItem>().getPreviousState();

void setPreviousState() {
final prevState = previousState;
Expand Down Expand Up @@ -768,9 +764,7 @@ class Game {
}

int get _consequentDaysWithoutDeaths {
final lastDeathDay = _log
.whereType<StateChangeGameLogItem>()
.getLastDayPlayerLeft();
final lastDeathDay = _log.whereType<StateChangeGameLogItem>().getLastDayPlayerLeft();
return state.day - (lastDeathDay ?? 1);
}

Expand Down
4 changes: 3 additions & 1 deletion lib/utils/state_change_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ extension StateChangeUtils on Iterable<StateChangeGameLogItem> {
Set<int> getAlreadySpokePlayers({required int currentDay}) {
final result = <int>{};
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);
}
Expand Down
4 changes: 1 addition & 3 deletions lib/widgets/bottom_controls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ class GameBottomControlBar extends StatelessWidget {
PlayerList playersContainer,
GameStateFinish nextState,
) async {
final bestTurn = controller.gameLog
.whereType<StateChangeGameLogItem>()
.getBestTurn();
final bestTurn = controller.gameLog.whereType<StateChangeGameLogItem>().getBestTurn();
final guessedMafiaCount = bestTurn?.playerNumbers
.where((e) => nextState.players[e - 1].role.team == RoleTeam.mafia)
.length;
Expand Down

0 comments on commit 0abcad6

Please sign in to comment.