From c5c5fab8ac385ccb64a911f3e5274ff331310197 Mon Sep 17 00:00:00 2001 From: dan63047 Date: Sun, 13 Oct 2024 14:13:42 +0300 Subject: [PATCH] New 40 lines and Blitz averages --- lib/data_objects/tetrio_constants.dart | 74 ++++++++++++------------ lib/main.dart | 2 +- lib/utils/relative_timestamps.dart | 4 ++ lib/views/main_view.dart | 8 +-- lib/views/main_view_tiles.dart | 4 +- lib/views/sprint_and_blitz_averages.dart | 4 +- lib/widgets/singleplayer_record.dart | 8 +-- 7 files changed, 54 insertions(+), 50 deletions(-) diff --git a/lib/data_objects/tetrio_constants.dart b/lib/data_objects/tetrio_constants.dart index 934463d..2c3b217 100644 --- a/lib/data_objects/tetrio_constants.dart +++ b/lib/data_objects/tetrio_constants.dart @@ -166,46 +166,46 @@ const Map rankColors = { }; const Map sprintAverages = { - // based on https://discord.com/channels/673303546107658242/674421736162197515/1244287342965952562 - 'x': Duration(seconds: 25, milliseconds: 144), - 'u': Duration(seconds: 36, milliseconds: 115), - 'ss': Duration(seconds: 46, milliseconds: 396), - 's+': Duration(seconds: 55, milliseconds: 056), - 's': Duration(seconds: 61, milliseconds: 892), - 's-': Duration(seconds: 68, milliseconds: 918), - 'a+': Duration(seconds: 76, milliseconds: 187), - 'a': Duration(seconds: 83, milliseconds: 529), - 'a-': Duration(seconds: 88, milliseconds: 608), - 'b+': Duration(seconds: 97, milliseconds: 626), - 'b': Duration(seconds: 104, milliseconds: 687), - 'b-': Duration(seconds: 113, milliseconds: 372), - 'c+': Duration(seconds: 123, milliseconds: 461), - 'c': Duration(seconds: 135, milliseconds: 326), - 'c-': Duration(seconds: 147, milliseconds: 056), - 'd+': Duration(seconds: 156, milliseconds: 757), - 'd': Duration(seconds: 167, milliseconds: 393), - //'z': Duration(seconds: 66, milliseconds: 802) + // based on https://discord.com/channels/673303546107658242/674421736162197515/1277367281264889908 + 'x+': Duration(seconds: 18, milliseconds: 867), + 'x': Duration(seconds: 23, milliseconds: 277), + 'u': Duration(seconds: 28, milliseconds: 853), + 'ss': Duration(seconds: 35, milliseconds: 173), + 's+': Duration(seconds: 39, milliseconds: 028), + 's': Duration(seconds: 45, milliseconds: 807), + 's-': Duration(seconds: 48, milliseconds: 840), + 'a+': Duration(seconds: 54, milliseconds: 975), + 'a': Duration(seconds: 60, milliseconds: 287), + 'a-': Duration(seconds: 64, milliseconds: 019), + 'b+': Duration(seconds: 76, milliseconds: 531), + 'b': Duration(seconds: 77, milliseconds: 635), + 'b-': Duration(seconds: 92, milliseconds: 279), + 'c+': Duration(seconds: 97, milliseconds: 911), + 'c': Duration(seconds: 104, milliseconds: 700), + 'c-': Duration(seconds: 115, milliseconds: 173), + 'd+': Duration(seconds: 131, milliseconds: 486), + 'd': Duration(seconds: 158, milliseconds: 397), }; const Map blitzAverages = { - 'x': 600715, - 'u': 379418, - 'ss': 233740, - 's+': 158295, - 's': 125164, - 's-': 100933, - 'a+': 83593, - 'a': 68613, - 'a-': 60219, - 'b+': 51197, - 'b': 44171, - 'b-': 39045, - 'c+': 34130, - 'c': 28931, - 'c-': 25095, - 'd+': 22944, - 'd': 20728, - //'z': 72084 + 'x+': 879378, + 'x': 677479, + 'u': 485962, + 'ss': 369043, + 's+': 279242, + 's': 245619, + 's-': 199368, + 'a+': 162035, + 'a': 130949, + 'a-': 111505, + 'b+': 97251, + 'b': 83580, + 'b-': 70511, + 'c+': 56747, + 'c': 43002, + 'c-': 38925, + 'd+': 30483, + 'd': 22513, }; List seasonStarts = [ diff --git a/lib/main.dart b/lib/main.dart index c0b11f3..8e3a945 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -16,7 +16,7 @@ import 'package:sqflite_common_ffi/sqflite_ffi.dart'; import 'package:sqflite_common_ffi_web/sqflite_ffi_web.dart'; import 'package:tetra_stats/gen/strings.g.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; -import 'package:tetra_stats/views/main_view_tiles.dart'; +import 'package:tetra_stats/views/main_view.dart'; import 'package:tetra_stats/views/settings_view.dart'; import 'package:tetra_stats/views/tracked_players_view.dart'; import 'package:tetra_stats/views/calc_view.dart'; diff --git a/lib/utils/relative_timestamps.dart b/lib/utils/relative_timestamps.dart index 5176221..4096018 100644 --- a/lib/utils/relative_timestamps.dart +++ b/lib/utils/relative_timestamps.dart @@ -73,6 +73,10 @@ String get40lTime(int microseconds){ return microseconds > 60000000 ? "${(microseconds/1000000/60).floor()}:${(secs.format(microseconds /1000000 % 60))}" : _timeInSec.format(microseconds / 1000000); } +String getALittleBitMoreNormalTime(Duration time){ + return "${intf.format(time.inMinutes)}:${(fixedSecs.format(time.inMilliseconds/1000%60))}"; +} + String getMoreNormalTime(Duration time){ return "${nonsecs.format(time.inMinutes)}:${(fixedSecs.format(time.inMilliseconds/1000%60))}"; } diff --git a/lib/views/main_view.dart b/lib/views/main_view.dart index 9a593a6..c02d45f 100644 --- a/lib/views/main_view.dart +++ b/lib/views/main_view.dart @@ -1137,10 +1137,10 @@ class _TwoRecordsThingy extends StatelessWidget { Widget build(BuildContext context) { late MapEntry closestAverageBlitz; late bool blitzBetterThanClosestAverage; - bool? blitzBetterThanRankAverage = (rank != null && rank != "z" && rank != "x+" && blitz != null) ? blitz!.stats.score > blitzAverages[rank]! : null; + bool? blitzBetterThanRankAverage = (rank != null && rank != "z" && blitz != null) ? blitz!.stats.score > blitzAverages[rank]! : null; late MapEntry closestAverageSprint; late bool sprintBetterThanClosestAverage; - bool? sprintBetterThanRankAverage = (rank != null && rank != "z" && rank != "x+" && sprint != null) ? sprint!.stats.finalTime < sprintAverages[rank]! : null; + bool? sprintBetterThanRankAverage = (rank != null && rank != "z" && sprint != null) ? sprint!.stats.finalTime < sprintAverages[rank]! : null; if (sprint != null) { closestAverageSprint = sprintAverages.entries.singleWhere((element) => element.value == sprintAverages.values.reduce((a, b) => (a-sprint!.stats.finalTime).abs() < (b -sprint!.stats.finalTime).abs() ? a : b)); sprintBetterThanClosestAverage = sprint!.stats.finalTime < closestAverageSprint.value; @@ -1178,7 +1178,7 @@ class _TwoRecordsThingy extends StatelessWidget { text: "", style: const TextStyle(fontFamily: "Eurostile Round", fontSize: 14, color: Colors.grey), children: [ - if (rank != null && rank != "z" && rank != "x+") TextSpan(text: "${t.verdictGeneral(n: readableTimeDifference(sprint!.stats.finalTime, sprintAverages[rank]!), verdict: sprintBetterThanRankAverage??false ? t.verdictBetter : t.verdictWorse, rank: rank!.toUpperCase())}\n", style: TextStyle( + if (rank != null && rank != "z") TextSpan(text: "${t.verdictGeneral(n: readableTimeDifference(sprint!.stats.finalTime, sprintAverages[rank]!), verdict: sprintBetterThanRankAverage??false ? t.verdictBetter : t.verdictWorse, rank: rank!.toUpperCase())}\n", style: TextStyle( color: sprintBetterThanRankAverage??false ? Colors.greenAccent : Colors.redAccent )) else TextSpan(text: "${t.verdictGeneral(n: readableTimeDifference(sprint!.stats.finalTime, closestAverageSprint.value), verdict: sprintBetterThanClosestAverage ? t.verdictBetter : t.verdictWorse, rank: closestAverageSprint.key.toUpperCase())}\n", style: TextStyle( @@ -1261,7 +1261,7 @@ class _TwoRecordsThingy extends StatelessWidget { text: "", style: const TextStyle(fontFamily: "Eurostile Round", fontSize: 14, color: Colors.grey), children: [ - if (rank != null && rank != "z" && rank != "x+") TextSpan(text: "${t.verdictGeneral(n: readableIntDifference(blitz!.stats.score, blitzAverages[rank]!), verdict: blitzBetterThanRankAverage??false ? t.verdictBetter : t.verdictWorse, rank: rank!.toUpperCase())}\n", style: TextStyle( + if (rank != null && rank != "z") TextSpan(text: "${t.verdictGeneral(n: readableIntDifference(blitz!.stats.score, blitzAverages[rank]!), verdict: blitzBetterThanRankAverage??false ? t.verdictBetter : t.verdictWorse, rank: rank!.toUpperCase())}\n", style: TextStyle( color: blitzBetterThanRankAverage??false ? Colors.greenAccent : Colors.redAccent )) else TextSpan(text: "${t.verdictGeneral(n: readableIntDifference(blitz!.stats.score, closestAverageBlitz.value), verdict: blitzBetterThanClosestAverage ? t.verdictBetter : t.verdictWorse, rank: closestAverageBlitz.key.toUpperCase())}\n", style: TextStyle( diff --git a/lib/views/main_view_tiles.dart b/lib/views/main_view_tiles.dart index 5ea9cce..1cfd74e 100644 --- a/lib/views/main_view_tiles.dart +++ b/lib/views/main_view_tiles.dart @@ -1823,7 +1823,7 @@ class RecordSummary extends StatelessWidget{ text: "", style: const TextStyle(fontFamily: "Eurostile Round", fontSize: 14, color: Colors.grey), children: [ - if (rank != null && rank != "z" && rank != "x+") TextSpan(text: "${t.verdictGeneral(n: switch(record!.gamemode){ + if (rank != null && rank != "z") TextSpan(text: "${t.verdictGeneral(n: switch(record!.gamemode){ "40l" => readableTimeDifference(record!.stats.finalTime, sprintAverages[rank]!), "blitz" => readableIntDifference(record!.stats.score, blitzAverages[rank]!), _ => record!.stats.score.toString() @@ -2500,7 +2500,7 @@ class _DestinationHomeState extends State with SingleTickerProv text: "", style: const TextStyle(fontFamily: "Eurostile Round", fontSize: 14, color: Colors.grey), children: [ - if (rank != null && rank != "z" && rank != "x+") TextSpan(text: "${t.verdictGeneral(n: switch(record.gamemode){ + if (rank != null && rank != "z") TextSpan(text: "${t.verdictGeneral(n: switch(record.gamemode){ "40l" => readableTimeDifference(record.stats.finalTime, sprintAverages[rank]!), "blitz" => readableIntDifference(record.stats.score, blitzAverages[rank]!), _ => record.stats.score.toString() diff --git a/lib/views/sprint_and_blitz_averages.dart b/lib/views/sprint_and_blitz_averages.dart index 9ac06ed..0fd8630 100644 --- a/lib/views/sprint_and_blitz_averages.dart +++ b/lib/views/sprint_and_blitz_averages.dart @@ -81,7 +81,7 @@ class SprintAndBlitzState extends State { Container(decoration: BoxDecoration(boxShadow: [BoxShadow(color: Colors.black.withAlpha(132), blurRadius: 32.0, blurStyle: BlurStyle.inner)]), child: Image.asset("res/tetrio_tl_alpha_ranks/${sprintEntry.key}.png", height: 48)), Padding( padding: const EdgeInsets.only(right: 8.0), - child: Text(get40lTime(sprintEntry.value.inMicroseconds), textAlign: TextAlign.right, style: TextStyle(fontFamily: bigScreen ? "Eurostile Round" : "Eurostile Round Condensed", fontSize: 28, fontWeight: FontWeight.w500, color: Colors.white, shadows: textShadow)), + child: Text(getALittleBitMoreNormalTime(sprintEntry.value), textAlign: TextAlign.right, style: TextStyle(fontFamily: bigScreen ? "Eurostile Round" : "Eurostile Round Condensed", fontSize: 28, fontWeight: FontWeight.w500, color: Colors.white, shadows: textShadow)), ), Padding( padding: const EdgeInsets.only(right: 8.0), @@ -91,7 +91,7 @@ class SprintAndBlitzState extends State { ) ], ), - Text(t.sprintAndBlitsRelevance(date: dateFormat.format(DateTime(2024, 5, 26)))) + Text(t.sprintAndBlitsRelevance(date: dateFormat.format(DateTime(2024, 8, 25)))) ], ), ), diff --git a/lib/widgets/singleplayer_record.dart b/lib/widgets/singleplayer_record.dart index 62bec0d..d2086b9 100644 --- a/lib/widgets/singleplayer_record.dart +++ b/lib/widgets/singleplayer_record.dart @@ -30,10 +30,10 @@ class SingleplayerRecord extends StatelessWidget { if (record == null) return Center(child: Text(t.noRecord, textAlign: TextAlign.center, style: const TextStyle(fontFamily: "Eurostile Round", fontSize: 28))); late MapEntry closestAverageBlitz; late bool blitzBetterThanClosestAverage; - bool? blitzBetterThanRankAverage = (rank != null && rank != "z" && rank != "x+") ? record!.stats.score > blitzAverages[rank]! : null; + bool? blitzBetterThanRankAverage = (rank != null && rank != "z") ? record!.stats.score > blitzAverages[rank]! : null; late MapEntry closestAverageSprint; late bool sprintBetterThanClosestAverage; - bool? sprintBetterThanRankAverage = (rank != null && rank != "z" && rank != "x+") ? record!.stats.finalTime < sprintAverages[rank]! : null; + bool? sprintBetterThanRankAverage = (rank != null && rank != "z") ? record!.stats.finalTime < sprintAverages[rank]! : null; if (record!.gamemode == "40l") { closestAverageSprint = sprintAverages.entries.singleWhere((element) => element.value == sprintAverages.values.reduce((a, b) => (a-record!.stats.finalTime).abs() < (b -record!.stats.finalTime).abs() ? a : b)); sprintBetterThanClosestAverage = record!.stats.finalTime < closestAverageSprint.value; @@ -76,13 +76,13 @@ class SingleplayerRecord extends StatelessWidget { text: "", style: const TextStyle(fontFamily: "Eurostile Round", fontSize: 14, color: Colors.grey), children: [ - if (record!.gamemode == "40l" && (rank != null && rank != "z" && rank != "x+")) TextSpan(text: "${t.verdictGeneral(n: readableTimeDifference(record!.stats.finalTime, sprintAverages[rank]!), verdict: sprintBetterThanRankAverage??false ? t.verdictBetter : t.verdictWorse, rank: rank!.toUpperCase())}\n", style: TextStyle( + if (record!.gamemode == "40l" && (rank != null && rank != "z")) TextSpan(text: "${t.verdictGeneral(n: readableTimeDifference(record!.stats.finalTime, sprintAverages[rank]!), verdict: sprintBetterThanRankAverage??false ? t.verdictBetter : t.verdictWorse, rank: rank!.toUpperCase())}\n", style: TextStyle( color: sprintBetterThanRankAverage??false ? Colors.greenAccent : Colors.redAccent )) else if (record!.gamemode == "40l" && (rank == null || rank == "z" || rank != "x+")) TextSpan(text: "${t.verdictGeneral(n: readableTimeDifference(record!.stats.finalTime, closestAverageSprint.value), verdict: sprintBetterThanClosestAverage ? t.verdictBetter : t.verdictWorse, rank: closestAverageSprint.key.toUpperCase())}\n", style: TextStyle( color: sprintBetterThanClosestAverage ? Colors.greenAccent : Colors.redAccent )) - else if (record!.gamemode == "blitz" && (rank != null && rank != "z" && rank != "x+")) TextSpan(text: "${t.verdictGeneral(n: readableIntDifference(record!.stats.score, blitzAverages[rank]!), verdict: blitzBetterThanRankAverage??false ? t.verdictBetter : t.verdictWorse, rank: rank!.toUpperCase())}\n", style: TextStyle( + else if (record!.gamemode == "blitz" && (rank != null && rank != "z")) TextSpan(text: "${t.verdictGeneral(n: readableIntDifference(record!.stats.score, blitzAverages[rank]!), verdict: blitzBetterThanRankAverage??false ? t.verdictBetter : t.verdictWorse, rank: rank!.toUpperCase())}\n", style: TextStyle( color: blitzBetterThanRankAverage??false ? Colors.greenAccent : Colors.redAccent )) else if (record!.gamemode == "blitz" && (rank == null || rank == "z" || rank != "x+")) TextSpan(text: "${t.verdictGeneral(n: readableIntDifference(record!.stats.score, closestAverageBlitz.value), verdict: blitzBetterThanClosestAverage ? t.verdictBetter : t.verdictWorse, rank: closestAverageBlitz.key.toUpperCase())}\n", style: TextStyle(