7 Commits

Author SHA1 Message Date
17e882986d Merge pull request 'StatisticsView erstellen' (#30) from feature/6-statisticsview-erstellen into development
Reviewed-on: #30
Reviewed-by: mathiskir <mathis.kirchner.mk@gmail.com>
2025-11-23 12:59:40 +00:00
7cda25a380 Changed item count back to normal
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m19s
Pull Request Pipeline / lint (pull_request) Successful in 2m23s
2025-11-23 12:34:42 +01:00
e9b041e43a Changed double depiction
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m20s
Pull Request Pipeline / lint (pull_request) Successful in 2m23s
2025-11-23 12:33:13 +01:00
c38c731b41 Merge branch 'development' into feature/6-statisticsview-erstellen
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m25s
Pull Request Pipeline / lint (pull_request) Successful in 2m25s
# Conflicts:
#	lib/presentation/views/main_menu/statistics_view.dart
2025-11-23 12:19:03 +01:00
d411f58134 Changed icon for second statistics tile
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m21s
Pull Request Pipeline / lint (pull_request) Successful in 2m22s
2025-11-23 12:18:05 +01:00
fee5c57207 Added comments for return value -1 2025-11-23 12:13:30 +01:00
acc5b0a3e9 Merge branch 'development' into feature/6-statisticsview-erstellen
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m33s
Pull Request Pipeline / lint (pull_request) Successful in 2m33s
2025-11-23 00:36:33 +01:00
2 changed files with 9 additions and 3 deletions

View File

@@ -89,7 +89,7 @@ class _StatisticsViewState extends State<StatisticsView> {
), ),
SizedBox(height: constraints.maxHeight * 0.02), SizedBox(height: constraints.maxHeight * 0.02),
StatisticsTile( StatisticsTile(
icon: Icons.casino, icon: Icons.percent,
title: 'Winrate per Player', title: 'Winrate per Player',
width: constraints.maxWidth * 0.95, width: constraints.maxWidth * 0.95,
values: winRates, values: winRates,
@@ -105,7 +105,6 @@ class _StatisticsViewState extends State<StatisticsView> {
itemCount: 10, itemCount: 10,
barColor: Colors.green, barColor: Colors.green,
), ),
SizedBox(height: MediaQuery.paddingOf(context).bottom), SizedBox(height: MediaQuery.paddingOf(context).bottom),
], ],
), ),
@@ -129,6 +128,7 @@ class _StatisticsViewState extends State<StatisticsView> {
final winner = game.winner; final winner = game.winner;
if (winner != null) { if (winner != null) {
final index = winCounts.indexWhere((entry) => entry.$1 == winner.id); final index = winCounts.indexWhere((entry) => entry.$1 == winner.id);
// -1 means winner not found in winCounts
if (index != -1) { if (index != -1) {
final current = winCounts[index].$2; final current = winCounts[index].$2;
winCounts[index] = (winner.id, current + 1); winCounts[index] = (winner.id, current + 1);
@@ -141,6 +141,7 @@ class _StatisticsViewState extends State<StatisticsView> {
// Adding all players with zero wins // Adding all players with zero wins
for (var player in players) { for (var player in players) {
final index = winCounts.indexWhere((entry) => entry.$1 == player.id); final index = winCounts.indexWhere((entry) => entry.$1 == player.id);
// -1 means player not found in winCounts
if (index == -1) { if (index == -1) {
winCounts.add((player.id, 0)); winCounts.add((player.id, 0));
} }
@@ -175,6 +176,7 @@ class _StatisticsViewState extends State<StatisticsView> {
final members = game.group!.members.map((p) => p.id).toList(); final members = game.group!.members.map((p) => p.id).toList();
for (var playerId in members) { for (var playerId in members) {
final index = gameCounts.indexWhere((entry) => entry.$1 == playerId); final index = gameCounts.indexWhere((entry) => entry.$1 == playerId);
// -1 means player not found in gameCounts
if (index != -1) { if (index != -1) {
final current = gameCounts[index].$2; final current = gameCounts[index].$2;
gameCounts[index] = (playerId, current + 1); gameCounts[index] = (playerId, current + 1);
@@ -187,6 +189,7 @@ class _StatisticsViewState extends State<StatisticsView> {
final members = game.players!.map((p) => p.id).toList(); final members = game.players!.map((p) => p.id).toList();
for (var playerId in members) { for (var playerId in members) {
final index = gameCounts.indexWhere((entry) => entry.$1 == playerId); final index = gameCounts.indexWhere((entry) => entry.$1 == playerId);
// -1 means player not found in gameCounts
if (index != -1) { if (index != -1) {
final current = gameCounts[index].$2; final current = gameCounts[index].$2;
gameCounts[index] = (playerId, current + 1); gameCounts[index] = (playerId, current + 1);
@@ -200,6 +203,7 @@ class _StatisticsViewState extends State<StatisticsView> {
// Adding all players with zero games // Adding all players with zero games
for (var player in players) { for (var player in players) {
final index = gameCounts.indexWhere((entry) => entry.$1 == player.id); final index = gameCounts.indexWhere((entry) => entry.$1 == player.id);
// -1 means player not found in gameCounts
if (index == -1) { if (index == -1) {
gameCounts.add((player.id, 0)); gameCounts.add((player.id, 0));
} }

View File

@@ -80,7 +80,9 @@ class StatisticsTile extends StatelessWidget {
const Spacer(), const Spacer(),
Center( Center(
child: Text( child: Text(
values[index].$2.toString(), values[index].$2 <= 1
? values[index].$2.toStringAsFixed(2)
: values[index].$2.toString(),
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: const TextStyle( style: const TextStyle(
fontSize: 16, fontSize: 16,