StatisticsView erstellen #30

Merged
sneeex merged 6 commits from feature/6-statisticsview-erstellen into development 2025-11-23 12:59:40 +00: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),
StatisticsTile(
icon: Icons.casino,
icon: Icons.percent,
sneeex marked this conversation as resolved Outdated

hier vielleicht besser irgendein Pokal icon oder so? Weil so ist das doppelt, das blöd

hier vielleicht besser irgendein Pokal icon oder so? Weil so ist das doppelt, das blöd

fixed

fixed
title: 'Winrate per Player',
width: constraints.maxWidth * 0.95,
values: winRates,
@@ -105,7 +105,6 @@ class _StatisticsViewState extends State<StatisticsView> {
itemCount: 10,
barColor: Colors.green,
),
SizedBox(height: MediaQuery.paddingOf(context).bottom),
],
),
@@ -129,6 +128,7 @@ class _StatisticsViewState extends State<StatisticsView> {
final winner = game.winner;
if (winner != null) {
final index = winCounts.indexWhere((entry) => entry.$1 == winner.id);
// -1 means winner not found in winCounts
if (index != -1) {
sneeex marked this conversation as resolved Outdated

maybe comment, dass -1 heißt nicht gefunden, war mir jetzt nicht klar.
Falls du's machst, natürlich bei allen

maybe comment, dass -1 heißt nicht gefunden, war mir jetzt nicht klar. Falls du's machst, natürlich bei allen

Habs jetzt mal für euch hinzugefügt, weil ihr ja beide relativ neu seid, ist halt aber einfach der return Wert dieser Funktion. Können es dann bei Zeiten wieder entfernen

Habs jetzt mal für euch hinzugefügt, weil ihr ja beide relativ neu seid, ist halt aber einfach der return Wert dieser Funktion. Können es dann bei Zeiten wieder entfernen
final current = winCounts[index].$2;
winCounts[index] = (winner.id, current + 1);
@@ -141,6 +141,7 @@ class _StatisticsViewState extends State<StatisticsView> {
// Adding all players with zero wins
for (var player in players) {
final index = winCounts.indexWhere((entry) => entry.$1 == player.id);
// -1 means player not found in winCounts
if (index == -1) {
winCounts.add((player.id, 0));
}
@@ -175,6 +176,7 @@ class _StatisticsViewState extends State<StatisticsView> {
final members = game.group!.members.map((p) => p.id).toList();
for (var playerId in members) {
final index = gameCounts.indexWhere((entry) => entry.$1 == playerId);
// -1 means player not found in gameCounts
if (index != -1) {
final current = gameCounts[index].$2;
gameCounts[index] = (playerId, current + 1);
@@ -187,6 +189,7 @@ class _StatisticsViewState extends State<StatisticsView> {
final members = game.players!.map((p) => p.id).toList();
for (var playerId in members) {
final index = gameCounts.indexWhere((entry) => entry.$1 == playerId);
// -1 means player not found in gameCounts
if (index != -1) {
final current = gameCounts[index].$2;
gameCounts[index] = (playerId, current + 1);
@@ -200,6 +203,7 @@ class _StatisticsViewState extends State<StatisticsView> {
// Adding all players with zero games
for (var player in players) {
final index = gameCounts.indexWhere((entry) => entry.$1 == player.id);
// -1 means player not found in gameCounts
if (index == -1) {
gameCounts.add((player.id, 0));
}

View File

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