diff --git a/lib/data/dao/player_match_dao.dart b/lib/data/dao/player_match_dao.dart index f42b8bb..47c7b2d 100644 --- a/lib/data/dao/player_match_dao.dart +++ b/lib/data/dao/player_match_dao.dart @@ -66,7 +66,7 @@ class PlayerMatchDao extends DatabaseAccessor return (count ?? 0) > 0; } - /// Removes the association of a player with a game by deleting the record + /// Removes the association of a player with a match by deleting the record /// from the [PlayerMatchTable]. /// Returns `true` if more than 0 rows were affected, otherwise `false`. Future removePlayerFromMatch({ diff --git a/lib/presentation/views/main_menu/home_view.dart b/lib/presentation/views/main_menu/home_view.dart index c6322d8..d312516 100644 --- a/lib/presentation/views/main_menu/home_view.dart +++ b/lib/presentation/views/main_menu/home_view.dart @@ -82,7 +82,7 @@ class _HomeViewState extends State { return QuickInfoTile( width: constraints.maxWidth * 0.45, height: constraints.maxHeight * 0.15, - title: 'Games', + title: 'Matches', icon: Icons.groups_rounded, value: count, ); @@ -112,7 +112,7 @@ class _HomeViewState extends State { padding: const EdgeInsets.symmetric(vertical: 16.0), child: InfoTile( width: constraints.maxWidth * 0.95, - title: 'Recent Games', + title: 'Recent Matches', icon: Icons.timer, content: Padding( padding: const EdgeInsets.symmetric(horizontal: 40.0), @@ -127,7 +127,7 @@ class _HomeViewState extends State { return const Center( heightFactor: 4, child: Text( - 'Error while loading recent games.', + 'Error while loading recent matches.', ), ); } diff --git a/lib/presentation/views/main_menu/statistics_view.dart b/lib/presentation/views/main_menu/statistics_view.dart index 17376b2..6104e39 100644 --- a/lib/presentation/views/main_menu/statistics_view.dart +++ b/lib/presentation/views/main_menu/statistics_view.dart @@ -33,7 +33,7 @@ class _StatisticsViewState extends State { final matches = results[0] as List; final players = results[1] as List; winCounts = _calculateWinsForAllPlayers(matches, players); - matchCounts = _calculateGameAmountsForAllPlayers(matches, players); + matchCounts = _calculateMatchAmountsForAllPlayers(matches, players); winRates = computeWinRatePercent(wins: winCounts, matches: matchCounts); if (mounted) { setState(() { @@ -97,14 +97,14 @@ class _StatisticsViewState extends State { /// Calculates the number of wins for each player /// and returns a sorted list of tuples (playerName, winCount) List<(String, int)> _calculateWinsForAllPlayers( - List games, + List matches, List players, ) { List<(String, int)> winCounts = []; // Getting the winners - for (var game in games) { - final winner = game.winner; + for (var match in matches) { + final winner = match.winner; if (winner != null) { final index = winCounts.indexWhere((entry) => entry.$1 == winner.id); // -1 means winner not found in winCounts @@ -143,7 +143,7 @@ class _StatisticsViewState extends State { /// Calculates the number of matches played for each player /// and returns a sorted list of tuples (playerName, matchCount) - List<(String, int)> _calculateGameAmountsForAllPlayers( + List<(String, int)> _calculateMatchAmountsForAllPlayers( List matches, List players, ) { @@ -155,7 +155,7 @@ class _StatisticsViewState extends State { final members = match.group!.members.map((p) => p.id).toList(); for (var playerId in members) { final index = matchCounts.indexWhere((entry) => entry.$1 == playerId); - // -1 means player not found in gameCounts + // -1 means player not found in matchCounts if (index != -1) { final current = matchCounts[index].$2; matchCounts[index] = (playerId, current + 1); @@ -168,7 +168,7 @@ class _StatisticsViewState extends State { final members = match.players!.map((p) => p.id).toList(); for (var playerId in members) { final index = matchCounts.indexWhere((entry) => entry.$1 == playerId); - // -1 means player not found in gameCounts + // -1 means player not found in matchCounts if (index != -1) { final current = matchCounts[index].$2; matchCounts[index] = (playerId, current + 1); @@ -179,10 +179,10 @@ class _StatisticsViewState extends State { } } - // Adding all players with zero games + // Adding all players with zero matches for (var player in players) { final index = matchCounts.indexWhere((entry) => entry.$1 == player.id); - // -1 means player not found in gameCounts + // -1 means player not found in matchCounts if (index == -1) { matchCounts.add((player.id, 0)); } @@ -209,15 +209,15 @@ class _StatisticsViewState extends State { required List<(String, int)> matches, }) { final Map winsMap = {for (var e in wins) e.$1: e.$2}; - final Map gamesMap = {for (var e in matches) e.$1: e.$2}; + final Map matchesMap = {for (var e in matches) e.$1: e.$2}; // Get all unique player names - final names = {...winsMap.keys, ...gamesMap.keys}; + final names = {...winsMap.keys, ...matchesMap.keys}; // Calculate win rates final result = names.map((name) { final int w = winsMap[name] ?? 0; - final int g = gamesMap[name] ?? 0; + final int g = matchesMap[name] ?? 0; // Calculate percentage and round to 2 decimal places // Avoid division by zero final double percent = (g > 0)