Trying to do cutoffs

This commit is contained in:
dan63047 2024-09-17 01:37:25 +03:00
parent dbdfe29dc0
commit 8d7bccfac0
3 changed files with 115 additions and 14 deletions

View File

@ -5,20 +5,32 @@ class CutoffTetrio {
late double percentile;
late double tr;
late double targetTr;
late double apm;
late double pps;
late double vs;
late double? apm;
late double? pps;
late double? vs;
late int count;
late double countPercentile;
CutoffTetrio({
required this.pos,
required this.percentile,
required this.tr,
required this.targetTr,
required this.apm,
required this.pps,
required this.vs,
required this.count,
required this.countPercentile
});
CutoffTetrio.fromJson(Map<String, dynamic> json, int total){
pos = json['pos'];
percentile = json['percentile'].toDouble();
tr = json['tr'].toDouble();
targetTr = json['targettr'].toDouble();
apm = json['apm'].toDouble();
pps = json['pps'].toDouble();
vs = json['vs'].toDouble();
apm = json['apm']?.toDouble();
pps = json['pps']?.toDouble();
vs = json['vs']?.toDouble();
count = json['count'];
countPercentile = count / total;
}

View File

@ -10,6 +10,7 @@ import 'package:syncfusion_flutter_charts/charts.dart';
import 'package:syncfusion_flutter_gauges/gauges.dart';
import 'package:tetra_stats/data_objects/badge.dart';
import 'package:tetra_stats/data_objects/beta_record.dart';
import 'package:tetra_stats/data_objects/cutoff_tetrio.dart';
import 'package:tetra_stats/data_objects/distinguishment.dart';
import 'package:tetra_stats/data_objects/est_tr.dart';
import 'package:tetra_stats/data_objects/nerd_stats.dart';
@ -210,6 +211,14 @@ class _MainState extends State<MainView> with TickerProviderStateMixin {
}
}
class FetchCutoffsResults{
late bool success;
CutoffsTetrio? cutoffs;
Exception? exception;
FetchCutoffsResults(this.success, this.cutoffs, this.exception);
}
class DestinationCutoffs extends StatefulWidget{
final BoxConstraints constraints;
@ -220,12 +229,92 @@ class DestinationCutoffs extends StatefulWidget{
}
class _DestinationCutoffsState extends State<DestinationCutoffs> {
Future<CutoffsTetrio> fetch() async {
TetrioPlayerFromLeaderboard top1;
CutoffsTetrio cutoffs;
List<dynamic> requests = await Future.wait([
teto.fetchCutoffsTetrio(),
teto.fetchTopOneFromTheLeaderboard(),
]);
cutoffs = requests[0];
top1 = requests[1];
cutoffs.data["top1"] = CutoffTetrio(
pos: 1,
percentile: 0.00,
tr: top1.tr,
targetTr: 25000,
apm: top1.apm,
pps: top1.pps,
vs: top1.vs,
count: 1,
countPercentile: 0.0
);
return cutoffs;
}
@override
Widget build(BuildContext context) {
return Column(
children: [
Card(),
]
return FutureBuilder<CutoffsTetrio>(
future: fetch(),
builder: (context, snapshot) {
switch (snapshot.connectionState){
case ConnectionState.none:
case ConnectionState.waiting:
return const Center(child: CircularProgressIndicator());
case ConnectionState.active:
case ConnectionState.done:
if (snapshot.hasData){
return Column(
children: [
Card(
child: Center(child: Text("Tetra League State")),
),
Card(
child: Padding(
padding: const EdgeInsets.fromLTRB(20.0, 8.0, 20.0, 8.0),
child: SfLinearGauge(
minimum: 0.00000000,
maximum: 25000.0000,
showTicks: false,
showLabels: false,
ranges: [
for (var cutoff in snapshot.data!.data.keys) LinearGaugeRange(
position: LinearElementPosition.outside,
startValue: snapshot.data!.data[cutoff]!.tr,
startWidth: 20.0,
endWidth: 20.0,
endValue: switch (cutoff){
"top1" => 25000.00,
"x+" => snapshot.data!.data["top1"]!.tr,
_ => snapshot.data!.data[ranks[ranks.indexOf(cutoff)+1]]!.tr
},
color: cutoff != "top1" ? rankColors[cutoff] : null,
//shaderCallback: (bounds) {
// make shader blyat
// },
),
for (var cutoff in snapshot.data!.data.keys) LinearGaugeRange(
position: LinearElementPosition.inside,
startValue: snapshot.data!.data[cutoff]!.targetTr,
endValue: switch (cutoff){
"top1" => 25000.00,
"x+" => snapshot.data!.data["top1"]!.targetTr,
_ => snapshot.data!.data[ranks[ranks.indexOf(cutoff)+1]]!.targetTr
},
color: cutoff != "top1" ? rankColors[cutoff] : null,
)
],
),
),
),
]
);
}
if (snapshot.hasError){ return FutureError(snapshot); }
}
return Text("huh?");
}
);
}
}

View File

@ -114,19 +114,19 @@ class RanksAverages extends State<RankAveragesView> {
),
Padding(
padding: const EdgeInsets.only(right: 8.0),
child: Text(f2.format(snapshot.data!.data[rank]!.apm), textAlign: TextAlign.right, style: const TextStyle(fontFamily: "Eurostile Round", fontSize: 28, fontWeight: FontWeight.w100, color: Colors.white, shadows: textShadow)),
child: Text(snapshot.data?.data[rank]?.apm != null ? f2.format(snapshot.data!.data[rank]!.apm) : "-.--", textAlign: TextAlign.right, style: TextStyle(fontFamily: "Eurostile Round", fontSize: 28, fontWeight: FontWeight.w100, color: snapshot.data?.data[rank]?.apm != null ? Colors.white : Colors.grey, shadows: textShadow)),
),
Padding(
padding: const EdgeInsets.only(right: 8.0),
child: Text(f2.format(snapshot.data!.data[rank]!.pps), textAlign: TextAlign.right, style: const TextStyle(fontFamily: "Eurostile Round", fontSize: 28, fontWeight: FontWeight.w100, color: Colors.white, shadows: textShadow)),
child: Text(snapshot.data?.data[rank]?.pps != null ? f2.format(snapshot.data!.data[rank]!.pps) : "-.--", textAlign: TextAlign.right, style: TextStyle(fontFamily: "Eurostile Round", fontSize: 28, fontWeight: FontWeight.w100, color: snapshot.data?.data[rank]?.pps != null ? Colors.white : Colors.grey, shadows: textShadow)),
),
Padding(
padding: const EdgeInsets.only(right: 8.0),
child: Text(f2.format(snapshot.data!.data[rank]!.vs), textAlign: TextAlign.right, style: const TextStyle(fontFamily: "Eurostile Round", fontSize: 28, fontWeight: FontWeight.w100, color: Colors.white, shadows: textShadow)),
child: Text(snapshot.data?.data[rank]?.vs != null ? f2.format(snapshot.data!.data[rank]!.vs) : "-.--", textAlign: TextAlign.right, style: TextStyle(fontFamily: "Eurostile Round", fontSize: 28, fontWeight: FontWeight.w100, color: snapshot.data?.data[rank]?.vs != null ? Colors.white : Colors.grey, shadows: textShadow)),
),
Padding(
padding: const EdgeInsets.only(right: 8.0),
child: Text("${f3.format(snapshot.data!.data[rank]!.apm / (snapshot.data!.data[rank]!.pps * 60))} APP\n${f3.format(snapshot.data!.data[rank]!.vs / snapshot.data!.data[rank]!.apm)} VS/APM", textAlign: TextAlign.right, style: const TextStyle(fontFamily: "Eurostile Round", fontSize: 14, fontWeight: FontWeight.w100, color: Colors.white, shadows: textShadow)),
child: Text("${snapshot.data?.data[rank]?.apm != null && snapshot.data?.data[rank]?.pps != null ? f3.format(snapshot.data!.data[rank]!.apm! / (snapshot.data!.data[rank]!.pps! * 60)) : "-.---"} APP\n${snapshot.data?.data[rank]?.apm != null && snapshot.data?.data[rank]?.vs != null ? f3.format(snapshot.data!.data[rank]!.vs! / snapshot.data!.data[rank]!.apm!) : "-.---"} VS/APM", textAlign: TextAlign.right, style: TextStyle(fontFamily: "Eurostile Round", fontSize: 14, fontWeight: FontWeight.w100, color: snapshot.data?.data[rank]?.apm != null && snapshot.data?.data[rank]?.pps != null && snapshot.data?.data[rank]?.vs != null ? Colors.white : Colors.grey, shadows: textShadow)),
),
Padding(
padding: const EdgeInsets.only(right: 8.0),