Ability to compare player with himself in past

i spend all day on because of DropdownMenu
So i used DropdownButton
This commit is contained in:
dan63047 2023-06-19 23:42:37 +03:00
parent d193c62d51
commit 22de2a4ccb
5 changed files with 374 additions and 111 deletions

View File

@ -10,8 +10,8 @@
- ~~Sqlite Database and service, that can work with it~~ *v0.0.2* - ~~Sqlite Database and service, that can work with it~~ *v0.0.2*
- ~~Ability to track player~~ - ~~Ability to track player~~
- ~~Ability to compare 2 players~~ *v0.1.0, we are here* - ~~Ability to compare 2 players~~ *v0.1.0, we are here*
- ~~Stats Calculator~~ *dev build are here* - ~~Stats Calculator~~
- Ability to compare player with himself in past - ~~Ability to compare player with himself in past~~ *dev build are here*
- Tetra League matches history - Tetra League matches history
- Tetra League historic charts for tracked players (maybe even same sh*t for 40l and blitz well see) - Tetra League historic charts for tracked players (maybe even same sh*t for 40l and blitz well see)
- Better UI with delta and hints for stats *that will be v0.2.0* - Better UI with delta and hints for stats *that will be v0.2.0*

View File

@ -179,7 +179,7 @@ class TetrioPlayer {
int get hashCode => state.hashCode; int get hashCode => state.hashCode;
@override @override
bool operator ==(covariant TetrioPlayer other) => (userId == other.userId); bool operator ==(covariant TetrioPlayer other) => isSameState(other) && state.isAtSameMomentAs(other.state);
} }
class Badge { class Badge {

View File

@ -6,16 +6,17 @@ import 'package:tetra_stats/data_objects/tetrio.dart';
import 'package:tetra_stats/services/tetrio_crud.dart'; import 'package:tetra_stats/services/tetrio_crud.dart';
TetrioPlayer? theGreenSide; TetrioPlayer? theGreenSide;
List<DropdownMenuItem<TetrioPlayer>>? greenSideStates;
TetrioPlayer? theRedSide; TetrioPlayer? theRedSide;
List<DropdownMenuItem<TetrioPlayer>>? redSideStates;
final TetrioService teto = TetrioService(); final TetrioService teto = TetrioService();
final DateFormat dateFormat = DateFormat.yMMMd().add_Hms();
FocusNode greenFocusNode = FocusNode();
FocusNode redFocusNode = FocusNode();
class CompareView extends StatefulWidget { class CompareView extends StatefulWidget {
final TetrioPlayer greenSide; final TetrioPlayer greenSide;
final TetrioPlayer? redSide; final TetrioPlayer? redSide;
const CompareView({Key? key, required this.greenSide, required this.redSide}) : super(key: key); const CompareView({Key? key, required this.greenSide, required this.redSide})
: super(key: key);
@override @override
State<StatefulWidget> createState() => CompareState(); State<StatefulWidget> createState() => CompareState();
@ -27,32 +28,91 @@ class CompareState extends State<CompareView> {
@override @override
void initState() { void initState() {
theGreenSide = widget.greenSide; theGreenSide = widget.greenSide;
theRedSide = widget.redSide; fetchGreenSide(widget.greenSide.userId);
if (widget.redSide != null) fetchRedSide(widget.redSide!.userId);
_scrollController = ScrollController(); _scrollController = ScrollController();
super.initState(); super.initState();
} }
@override
void dispose(){
greenSideStates = null;
theGreenSide = null;
redSideStates = null;
theRedSide = null;
super.dispose();
}
void fetchRedSide(String user) async { void fetchRedSide(String user) async {
try { try {
theRedSide = await teto.fetchPlayer(user, false); theRedSide = await teto.fetchPlayer(user, false);
late List<TetrioPlayer> states;
try{
states = await teto.getPlayer(theRedSide!.userId);
redSideStates = <DropdownMenuItem<TetrioPlayer>>[];
for (final TetrioPlayer state in states) {
redSideStates!.add(DropdownMenuItem<TetrioPlayer>(
value: state, child: Text(dateFormat.format(state.state))));
}
redSideStates!.add(DropdownMenuItem<TetrioPlayer>(
value: theRedSide!, child: const Text("Most recent one")));
}on Exception {
states = [];
redSideStates = null;
}
} on Exception { } on Exception {
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text("Falied to assign $user"))); ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(content: Text("Falied to assign $user")));
} }
setState(() {}); setState(() {});
} }
void changeRedSide(TetrioPlayer user) {
setState(() {theRedSide = user;});
}
void fetchGreenSide(String user) async { void fetchGreenSide(String user) async {
try { try {
theGreenSide = await teto.fetchPlayer(user, false); theGreenSide = await teto.fetchPlayer(user, false);
late List<TetrioPlayer> states;
greenSideStates = null;
try{
states = await teto.getPlayer(theGreenSide!.userId);
greenSideStates = <DropdownMenuItem<TetrioPlayer>>[];
for (final TetrioPlayer state in states) {
greenSideStates!.add(DropdownMenuItem<TetrioPlayer>(
value: state, child: Text(dateFormat.format(state.state))));
}
greenSideStates!.add(DropdownMenuItem<TetrioPlayer>(
value: theGreenSide!, child: const Text("Most recent one")));
}on Exception {
states = [];
greenSideStates = null;
}
} on Exception { } on Exception {
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text("Falied to assign $user"))); ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(content: Text("Falied to assign $user")));
} }
setState(() {}); setState(() {});
} }
double getWinrateByTR(double yourGlicko, double yourRD, double notyourGlicko, double notyourRD) { void changeGreenSide(TetrioPlayer user) {
setState(() {theGreenSide = user;});
}
double getWinrateByTR(double yourGlicko, double yourRD, double notyourGlicko,
double notyourRD) {
return ((1 / return ((1 /
(1 + pow(10, (notyourGlicko - yourGlicko) / (400 * sqrt(1 + (3 * pow(0.0057564273, 2) * (pow(yourRD, 2) + pow(notyourRD, 2)) / pow(pi, 2)))))))); (1 +
pow(
10,
(notyourGlicko - yourGlicko) /
(400 *
sqrt(1 +
(3 *
pow(0.0057564273, 2) *
(pow(yourRD, 2) + pow(notyourRD, 2)) /
pow(pi, 2))))))));
} }
void _justUpdate() { void _justUpdate() {
@ -93,7 +153,9 @@ class CompareState extends State<CompareView> {
padding: const EdgeInsets.fromLTRB(8, 0, 8, 0), padding: const EdgeInsets.fromLTRB(8, 0, 8, 0),
child: PlayerSelector( child: PlayerSelector(
player: theGreenSide, player: theGreenSide,
change: fetchGreenSide, states: greenSideStates,
fetch: fetchGreenSide,
change: changeGreenSide,
updateState: _justUpdate, updateState: _justUpdate,
), ),
), ),
@ -116,7 +178,9 @@ class CompareState extends State<CompareView> {
padding: const EdgeInsets.fromLTRB(8, 0, 8, 0), padding: const EdgeInsets.fromLTRB(8, 0, 8, 0),
child: PlayerSelector( child: PlayerSelector(
player: theRedSide, player: theRedSide,
change: fetchRedSide, states: redSideStates,
fetch: fetchRedSide,
change: changeRedSide,
updateState: _justUpdate, updateState: _justUpdate,
), ),
), ),
@ -134,10 +198,14 @@ class CompareState extends State<CompareView> {
body: theGreenSide != null && theRedSide != null body: theGreenSide != null && theRedSide != null
? ListView( ? ListView(
children: [ children: [
if (theGreenSide!.role != "banned" && theRedSide!.role != "banned") if (theGreenSide!.role != "banned" &&
theRedSide!.role != "banned")
Column( Column(
children: [ children: [
CompareRegTimeThingy(greenSide: theGreenSide!.registrationTime, redSide: theRedSide!.registrationTime, label: "Registred"), CompareRegTimeThingy(
greenSide: theGreenSide!.registrationTime,
redSide: theRedSide!.registrationTime,
label: "Registred"),
CompareThingy( CompareThingy(
label: "Level", label: "Level",
greenSide: theGreenSide!.level, greenSide: theGreenSide!.level,
@ -145,22 +213,31 @@ class CompareState extends State<CompareView> {
higherIsBetter: true, higherIsBetter: true,
fractionDigits: 2, fractionDigits: 2,
), ),
if (!theGreenSide!.gameTime.isNegative && !theRedSide!.gameTime.isNegative) if (!theGreenSide!.gameTime.isNegative &&
!theRedSide!.gameTime.isNegative)
CompareThingy( CompareThingy(
greenSide: theGreenSide!.gameTime.inMicroseconds / 1000000 / 60 / 60, greenSide: theGreenSide!.gameTime.inMicroseconds /
redSide: theRedSide!.gameTime.inMicroseconds / 1000000 / 60 / 60, 1000000 /
60 /
60,
redSide: theRedSide!.gameTime.inMicroseconds /
1000000 /
60 /
60,
label: "Hours Played", label: "Hours Played",
higherIsBetter: true, higherIsBetter: true,
fractionDigits: 2, fractionDigits: 2,
), ),
if (theGreenSide!.gamesPlayed >= 0 && theRedSide!.gamesPlayed >= 0) if (theGreenSide!.gamesPlayed >= 0 &&
theRedSide!.gamesPlayed >= 0)
CompareThingy( CompareThingy(
label: "Online Games", label: "Online Games",
greenSide: theGreenSide!.gamesPlayed, greenSide: theGreenSide!.gamesPlayed,
redSide: theRedSide!.gamesPlayed, redSide: theRedSide!.gamesPlayed,
higherIsBetter: true, higherIsBetter: true,
), ),
if (theGreenSide!.gamesWon >= 0 && theRedSide!.gamesWon >= 0) if (theGreenSide!.gamesWon >= 0 &&
theRedSide!.gamesWon >= 0)
CompareThingy( CompareThingy(
label: "Games Won", label: "Games Won",
greenSide: theGreenSide!.gamesWon, greenSide: theGreenSide!.gamesWon,
@ -176,16 +253,25 @@ class CompareState extends State<CompareView> {
], ],
) )
else else
CompareBoolThingy(greenSide: theGreenSide!.role == "banned", redSide: theRedSide!.role == "banned", label: "Banned", trueIsBetter: false), CompareBoolThingy(
greenSide: theGreenSide!.role == "banned",
redSide: theRedSide!.role == "banned",
label: "Banned",
trueIsBetter: false),
const Divider(), const Divider(),
theGreenSide!.tlSeason1.gamesPlayed > 0 && theRedSide!.tlSeason1.gamesPlayed > 0 theGreenSide!.tlSeason1.gamesPlayed > 0 &&
theRedSide!.tlSeason1.gamesPlayed > 0
? Column( ? Column(
children: [ children: [
Padding( Padding(
padding: const EdgeInsets.only(bottom: 16), padding: const EdgeInsets.only(bottom: 16),
child: Text("Tetra League", style: TextStyle(fontFamily: "Eurostile Round Extended", fontSize: bigScreen ? 42 : 28)), child: Text("Tetra League",
style: TextStyle(
fontFamily: "Eurostile Round Extended",
fontSize: bigScreen ? 42 : 28)),
), ),
if (theGreenSide!.tlSeason1.gamesPlayed > 9 && theRedSide!.tlSeason1.gamesPlayed > 9) if (theGreenSide!.tlSeason1.gamesPlayed > 9 &&
theRedSide!.tlSeason1.gamesPlayed > 9)
CompareThingy( CompareThingy(
label: "TR", label: "TR",
greenSide: theGreenSide!.tlSeason1.rating, greenSide: theGreenSide!.tlSeason1.rating,
@ -207,12 +293,14 @@ class CompareState extends State<CompareView> {
), ),
CompareThingy( CompareThingy(
label: "WR %", label: "WR %",
greenSide: theGreenSide!.tlSeason1.winrate * 100, greenSide:
theGreenSide!.tlSeason1.winrate * 100,
redSide: theRedSide!.tlSeason1.winrate * 100, redSide: theRedSide!.tlSeason1.winrate * 100,
fractionDigits: 2, fractionDigits: 2,
higherIsBetter: true, higherIsBetter: true,
), ),
if (theGreenSide!.tlSeason1.gamesPlayed > 9 && theRedSide!.tlSeason1.gamesPlayed > 9) if (theGreenSide!.tlSeason1.gamesPlayed > 9 &&
theRedSide!.tlSeason1.gamesPlayed > 9)
CompareThingy( CompareThingy(
label: "Glicko", label: "Glicko",
greenSide: theGreenSide!.tlSeason1.glicko!, greenSide: theGreenSide!.tlSeason1.glicko!,
@ -220,7 +308,8 @@ class CompareState extends State<CompareView> {
fractionDigits: 2, fractionDigits: 2,
higherIsBetter: true, higherIsBetter: true,
), ),
if (theGreenSide!.tlSeason1.gamesPlayed > 9 && theRedSide!.tlSeason1.gamesPlayed > 9) if (theGreenSide!.tlSeason1.gamesPlayed > 9 &&
theRedSide!.tlSeason1.gamesPlayed > 9)
CompareThingy( CompareThingy(
label: "RD", label: "RD",
greenSide: theGreenSide!.tlSeason1.rd!, greenSide: theGreenSide!.tlSeason1.rd!,
@ -228,21 +317,25 @@ class CompareState extends State<CompareView> {
fractionDigits: 3, fractionDigits: 3,
higherIsBetter: false, higherIsBetter: false,
), ),
if (theGreenSide!.tlSeason1.standing > 0 && theRedSide!.tlSeason1.standing > 0) if (theGreenSide!.tlSeason1.standing > 0 &&
theRedSide!.tlSeason1.standing > 0)
CompareThingy( CompareThingy(
label: "№ in LB", label: "№ in LB",
greenSide: theGreenSide!.tlSeason1.standing, greenSide: theGreenSide!.tlSeason1.standing,
redSide: theRedSide!.tlSeason1.standing, redSide: theRedSide!.tlSeason1.standing,
higherIsBetter: false, higherIsBetter: false,
), ),
if (theGreenSide!.tlSeason1.standingLocal > 0 && theRedSide!.tlSeason1.standingLocal > 0) if (theGreenSide!.tlSeason1.standingLocal > 0 &&
theRedSide!.tlSeason1.standingLocal > 0)
CompareThingy( CompareThingy(
label: "№ in local LB", label: "№ in local LB",
greenSide: theGreenSide!.tlSeason1.standingLocal, greenSide:
theGreenSide!.tlSeason1.standingLocal,
redSide: theRedSide!.tlSeason1.standingLocal, redSide: theRedSide!.tlSeason1.standingLocal,
higherIsBetter: false, higherIsBetter: false,
), ),
if (theGreenSide!.tlSeason1.apm != null && theRedSide!.tlSeason1.apm != null) if (theGreenSide!.tlSeason1.apm != null &&
theRedSide!.tlSeason1.apm != null)
CompareThingy( CompareThingy(
label: "APM", label: "APM",
greenSide: theGreenSide!.tlSeason1.apm!, greenSide: theGreenSide!.tlSeason1.apm!,
@ -250,7 +343,8 @@ class CompareState extends State<CompareView> {
fractionDigits: 2, fractionDigits: 2,
higherIsBetter: true, higherIsBetter: true,
), ),
if (theGreenSide!.tlSeason1.pps != null && theRedSide!.tlSeason1.pps != null) if (theGreenSide!.tlSeason1.pps != null &&
theRedSide!.tlSeason1.pps != null)
CompareThingy( CompareThingy(
label: "PPS", label: "PPS",
greenSide: theGreenSide!.tlSeason1.pps!, greenSide: theGreenSide!.tlSeason1.pps!,
@ -258,7 +352,8 @@ class CompareState extends State<CompareView> {
fractionDigits: 2, fractionDigits: 2,
higherIsBetter: true, higherIsBetter: true,
), ),
if (theGreenSide!.tlSeason1.vs != null && theRedSide!.tlSeason1.vs != null) if (theGreenSide!.tlSeason1.vs != null &&
theRedSide!.tlSeason1.vs != null)
CompareThingy( CompareThingy(
label: "VS", label: "VS",
greenSide: theGreenSide!.tlSeason1.vs!, greenSide: theGreenSide!.tlSeason1.vs!,
@ -284,7 +379,10 @@ class CompareState extends State<CompareView> {
children: [ children: [
Padding( Padding(
padding: const EdgeInsets.only(bottom: 16), padding: const EdgeInsets.only(bottom: 16),
child: Text("Nerd Stats", style: TextStyle(fontFamily: "Eurostile Round Extended", fontSize: bigScreen ? 42 : 28)), child: Text("Nerd Stats",
style: TextStyle(
fontFamily: "Eurostile Round Extended",
fontSize: bigScreen ? 42 : 28)),
), ),
CompareThingy( CompareThingy(
label: "APP", label: "APP",
@ -316,14 +414,16 @@ class CompareState extends State<CompareView> {
), ),
CompareThingy( CompareThingy(
label: "APP + DS/P", label: "APP + DS/P",
greenSide: theGreenSide!.tlSeason1.nerdStats!.appdsp, greenSide:
theGreenSide!.tlSeason1.nerdStats!.appdsp,
redSide: theRedSide!.tlSeason1.nerdStats!.appdsp, redSide: theRedSide!.tlSeason1.nerdStats!.appdsp,
fractionDigits: 3, fractionDigits: 3,
higherIsBetter: true, higherIsBetter: true,
), ),
CompareThingy( CompareThingy(
label: "Cheese", label: "Cheese",
greenSide: theGreenSide!.tlSeason1.nerdStats!.cheese, greenSide:
theGreenSide!.tlSeason1.nerdStats!.cheese,
redSide: theRedSide!.tlSeason1.nerdStats!.cheese, redSide: theRedSide!.tlSeason1.nerdStats!.cheese,
fractionDigits: 2, fractionDigits: 2,
higherIsBetter: true, higherIsBetter: true,
@ -337,7 +437,8 @@ class CompareState extends State<CompareView> {
), ),
CompareThingy( CompareThingy(
label: "Weighted APP", label: "Weighted APP",
greenSide: theGreenSide!.tlSeason1.nerdStats!.nyaapp, greenSide:
theGreenSide!.tlSeason1.nerdStats!.nyaapp,
redSide: theRedSide!.tlSeason1.nerdStats!.nyaapp, redSide: theRedSide!.tlSeason1.nerdStats!.nyaapp,
fractionDigits: 3, fractionDigits: 3,
higherIsBetter: true, higherIsBetter: true,
@ -356,7 +457,8 @@ class CompareState extends State<CompareView> {
fractionDigits: 2, fractionDigits: 2,
higherIsBetter: true, higherIsBetter: true,
), ),
if (theGreenSide!.tlSeason1.gamesPlayed > 9 && theGreenSide!.tlSeason1.gamesPlayed > 9) if (theGreenSide!.tlSeason1.gamesPlayed > 9 &&
theGreenSide!.tlSeason1.gamesPlayed > 9)
CompareThingy( CompareThingy(
label: "Acc. of Est.", label: "Acc. of Est.",
greenSide: theGreenSide!.tlSeason1.esttracc!, greenSide: theGreenSide!.tlSeason1.esttracc!,
@ -372,7 +474,8 @@ class CompareState extends State<CompareView> {
clipBehavior: Clip.hardEdge, clipBehavior: Clip.hardEdge,
children: [ children: [
Padding( Padding(
padding: const EdgeInsets.fromLTRB(20, 20, 20, 20), padding:
const EdgeInsets.fromLTRB(20, 20, 20, 20),
child: SizedBox( child: SizedBox(
height: 300, height: 300,
width: 300, width: 300,
@ -380,10 +483,15 @@ class CompareState extends State<CompareView> {
RadarChartData( RadarChartData(
radarShape: RadarShape.polygon, radarShape: RadarShape.polygon,
tickCount: 4, tickCount: 4,
ticksTextStyle: const TextStyle(color: Colors.transparent, fontSize: 10), ticksTextStyle: const TextStyle(
radarBorderData: const BorderSide(color: Colors.transparent, width: 1), color: Colors.transparent,
gridBorderData: const BorderSide(color: Colors.white24, width: 1), fontSize: 10),
tickBorderData: const BorderSide(color: Colors.transparent, width: 1), radarBorderData: const BorderSide(
color: Colors.transparent, width: 1),
gridBorderData: const BorderSide(
color: Colors.white24, width: 1),
tickBorderData: const BorderSide(
color: Colors.transparent, width: 1),
getTitle: (index, angle) { getTitle: (index, angle) {
switch (index) { switch (index) {
case 0: case 0:
@ -397,56 +505,132 @@ class CompareState extends State<CompareView> {
angle: angle, angle: angle,
); );
case 2: case 2:
return RadarChartTitle(text: 'VS', angle: angle); return RadarChartTitle(
text: 'VS', angle: angle);
case 3: case 3:
return RadarChartTitle(text: 'APP', angle: angle + 180); return RadarChartTitle(
text: 'APP',
angle: angle + 180);
case 4: case 4:
return RadarChartTitle(text: 'DS/S', angle: angle + 180); return RadarChartTitle(
text: 'DS/S',
angle: angle + 180);
case 5: case 5:
return RadarChartTitle(text: 'DS/P', angle: angle + 180); return RadarChartTitle(
text: 'DS/P',
angle: angle + 180);
case 6: case 6:
return RadarChartTitle(text: 'APP+DS/P', angle: angle + 180); return RadarChartTitle(
text: 'APP+DS/P',
angle: angle + 180);
case 7: case 7:
return RadarChartTitle(text: 'VS/APM', angle: angle + 180); return RadarChartTitle(
text: 'VS/APM',
angle: angle + 180);
case 8: case 8:
return RadarChartTitle(text: 'Cheese', angle: angle); return RadarChartTitle(
text: 'Cheese', angle: angle);
case 9: case 9:
return RadarChartTitle(text: 'Gb Eff.', angle: angle); return RadarChartTitle(
text: 'Gb Eff.', angle: angle);
default: default:
return const RadarChartTitle(text: ''); return const RadarChartTitle(
text: '');
} }
}, },
dataSets: [ dataSets: [
RadarDataSet( RadarDataSet(
fillColor: const Color.fromARGB(115, 76, 175, 79), fillColor: const Color.fromARGB(
115, 76, 175, 79),
borderColor: Colors.green, borderColor: Colors.green,
dataEntries: [ dataEntries: [
RadarEntry(value: theGreenSide!.tlSeason1.apm! * 1), RadarEntry(
RadarEntry(value: theGreenSide!.tlSeason1.pps! * 45), value: theGreenSide!
RadarEntry(value: theGreenSide!.tlSeason1.vs! * 0.444), .tlSeason1.apm! *
RadarEntry(value: theGreenSide!.tlSeason1.nerdStats!.app * 185), 1),
RadarEntry(value: theGreenSide!.tlSeason1.nerdStats!.dss * 175), RadarEntry(
RadarEntry(value: theGreenSide!.tlSeason1.nerdStats!.dsp * 450), value: theGreenSide!
RadarEntry(value: theGreenSide!.tlSeason1.nerdStats!.appdsp * 140), .tlSeason1.pps! *
RadarEntry(value: theGreenSide!.tlSeason1.nerdStats!.vsapm * 60), 45),
RadarEntry(value: theGreenSide!.tlSeason1.nerdStats!.cheese * 1.25), RadarEntry(
RadarEntry(value: theGreenSide!.tlSeason1.nerdStats!.gbe * 315), value: theGreenSide!
.tlSeason1.vs! *
0.444),
RadarEntry(
value: theGreenSide!.tlSeason1
.nerdStats!.app *
185),
RadarEntry(
value: theGreenSide!.tlSeason1
.nerdStats!.dss *
175),
RadarEntry(
value: theGreenSide!.tlSeason1
.nerdStats!.dsp *
450),
RadarEntry(
value: theGreenSide!.tlSeason1
.nerdStats!.appdsp *
140),
RadarEntry(
value: theGreenSide!.tlSeason1
.nerdStats!.vsapm *
60),
RadarEntry(
value: theGreenSide!.tlSeason1
.nerdStats!.cheese *
1.25),
RadarEntry(
value: theGreenSide!.tlSeason1
.nerdStats!.gbe *
315),
], ],
), ),
RadarDataSet( RadarDataSet(
fillColor: const Color.fromARGB(115, 244, 67, 54), fillColor: const Color.fromARGB(
115, 244, 67, 54),
borderColor: Colors.red, borderColor: Colors.red,
dataEntries: [ dataEntries: [
RadarEntry(value: theRedSide!.tlSeason1.apm! * 1), RadarEntry(
RadarEntry(value: theRedSide!.tlSeason1.pps! * 45), value:
RadarEntry(value: theRedSide!.tlSeason1.vs! * 0.444), theRedSide!.tlSeason1.apm! *
RadarEntry(value: theRedSide!.tlSeason1.nerdStats!.app * 185), 1),
RadarEntry(value: theRedSide!.tlSeason1.nerdStats!.dss * 175), RadarEntry(
RadarEntry(value: theRedSide!.tlSeason1.nerdStats!.dsp * 450), value:
RadarEntry(value: theRedSide!.tlSeason1.nerdStats!.appdsp * 140), theRedSide!.tlSeason1.pps! *
RadarEntry(value: theRedSide!.tlSeason1.nerdStats!.vsapm * 60), 45),
RadarEntry(value: theRedSide!.tlSeason1.nerdStats!.cheese * 1.25), RadarEntry(
RadarEntry(value: theRedSide!.tlSeason1.nerdStats!.gbe * 315), value:
theRedSide!.tlSeason1.vs! *
0.444),
RadarEntry(
value: theRedSide!.tlSeason1
.nerdStats!.app *
185),
RadarEntry(
value: theRedSide!.tlSeason1
.nerdStats!.dss *
175),
RadarEntry(
value: theRedSide!.tlSeason1
.nerdStats!.dsp *
450),
RadarEntry(
value: theRedSide!.tlSeason1
.nerdStats!.appdsp *
140),
RadarEntry(
value: theRedSide!.tlSeason1
.nerdStats!.vsapm *
60),
RadarEntry(
value: theRedSide!.tlSeason1
.nerdStats!.cheese *
1.25),
RadarEntry(
value: theRedSide!.tlSeason1
.nerdStats!.gbe *
315),
], ],
), ),
RadarDataSet( RadarDataSet(
@ -467,13 +651,16 @@ class CompareState extends State<CompareView> {
) )
], ],
), ),
swapAnimationDuration: const Duration(milliseconds: 150), // Optional swapAnimationDuration: const Duration(
swapAnimationCurve: Curves.linear, // Optional milliseconds: 150), // Optional
swapAnimationCurve:
Curves.linear, // Optional
), ),
), ),
), ),
Padding( Padding(
padding: const EdgeInsets.fromLTRB(20, 20, 20, 20), padding:
const EdgeInsets.fromLTRB(20, 20, 20, 20),
child: SizedBox( child: SizedBox(
height: 300, height: 300,
width: 300, width: 300,
@ -481,10 +668,15 @@ class CompareState extends State<CompareView> {
RadarChartData( RadarChartData(
radarShape: RadarShape.polygon, radarShape: RadarShape.polygon,
tickCount: 4, tickCount: 4,
ticksTextStyle: const TextStyle(color: Colors.transparent, fontSize: 10), ticksTextStyle: const TextStyle(
radarBorderData: const BorderSide(color: Colors.transparent, width: 1), color: Colors.transparent,
gridBorderData: const BorderSide(color: Colors.white24, width: 1), fontSize: 10),
tickBorderData: const BorderSide(color: Colors.transparent, width: 1), radarBorderData: const BorderSide(
color: Colors.transparent, width: 1),
gridBorderData: const BorderSide(
color: Colors.white24, width: 1),
tickBorderData: const BorderSide(
color: Colors.transparent, width: 1),
getTitle: (index, angle) { getTitle: (index, angle) {
switch (index) { switch (index) {
case 0: case 0:
@ -498,32 +690,54 @@ class CompareState extends State<CompareView> {
angle: angle, angle: angle,
); );
case 2: case 2:
return RadarChartTitle(text: 'Inf Ds', angle: angle + 180); return RadarChartTitle(
text: 'Inf Ds',
angle: angle + 180);
case 3: case 3:
return RadarChartTitle(text: 'Plonk', angle: angle); return RadarChartTitle(
text: 'Plonk', angle: angle);
default: default:
return const RadarChartTitle(text: ''); return const RadarChartTitle(
text: '');
} }
}, },
dataSets: [ dataSets: [
RadarDataSet( RadarDataSet(
fillColor: const Color.fromARGB(115, 76, 175, 79), fillColor: const Color.fromARGB(
115, 76, 175, 79),
borderColor: Colors.green, borderColor: Colors.green,
dataEntries: [ dataEntries: [
RadarEntry(value: theGreenSide!.tlSeason1.playstyle!.opener), RadarEntry(
RadarEntry(value: theGreenSide!.tlSeason1.playstyle!.stride), value: theGreenSide!.tlSeason1
RadarEntry(value: theGreenSide!.tlSeason1.playstyle!.infds), .playstyle!.opener),
RadarEntry(value: theGreenSide!.tlSeason1.playstyle!.plonk), RadarEntry(
value: theGreenSide!.tlSeason1
.playstyle!.stride),
RadarEntry(
value: theGreenSide!.tlSeason1
.playstyle!.infds),
RadarEntry(
value: theGreenSide!.tlSeason1
.playstyle!.plonk),
], ],
), ),
RadarDataSet( RadarDataSet(
fillColor: const Color.fromARGB(115, 244, 67, 54), fillColor: const Color.fromARGB(
115, 244, 67, 54),
borderColor: Colors.red, borderColor: Colors.red,
dataEntries: [ dataEntries: [
RadarEntry(value: theRedSide!.tlSeason1.playstyle!.opener), RadarEntry(
RadarEntry(value: theRedSide!.tlSeason1.playstyle!.stride), value: theRedSide!.tlSeason1
RadarEntry(value: theRedSide!.tlSeason1.playstyle!.infds), .playstyle!.opener),
RadarEntry(value: theRedSide!.tlSeason1.playstyle!.plonk), RadarEntry(
value: theRedSide!.tlSeason1
.playstyle!.stride),
RadarEntry(
value: theRedSide!.tlSeason1
.playstyle!.infds),
RadarEntry(
value: theRedSide!.tlSeason1
.playstyle!.plonk),
], ],
), ),
RadarDataSet( RadarDataSet(
@ -548,22 +762,33 @@ class CompareState extends State<CompareView> {
) )
], ],
), ),
swapAnimationDuration: const Duration(milliseconds: 150), // Optional swapAnimationDuration: const Duration(
swapAnimationCurve: Curves.linear, // Optional milliseconds: 150), // Optional
swapAnimationCurve:
Curves.linear, // Optional
), ),
), ),
), ),
const Divider(), const Divider(),
Padding( Padding(
padding: const EdgeInsets.only(bottom: 16), padding: const EdgeInsets.only(bottom: 16),
child: Text("Win Chance", style: TextStyle(fontFamily: "Eurostile Round Extended", fontSize: bigScreen ? 42 : 28)), child: Text("Win Chance",
style: TextStyle(
fontFamily: "Eurostile Round Extended",
fontSize: bigScreen ? 42 : 28)),
), ),
CompareThingy( CompareThingy(
label: "By Glicko", label: "By Glicko",
greenSide: getWinrateByTR(theGreenSide!.tlSeason1.glicko!, theGreenSide!.tlSeason1.rd!, theRedSide!.tlSeason1.glicko!, greenSide: getWinrateByTR(
theGreenSide!.tlSeason1.glicko!,
theGreenSide!.tlSeason1.rd!,
theRedSide!.tlSeason1.glicko!,
theRedSide!.tlSeason1.rd!) * theRedSide!.tlSeason1.rd!) *
100, 100,
redSide: getWinrateByTR(theRedSide!.tlSeason1.glicko!, theRedSide!.tlSeason1.rd!, theGreenSide!.tlSeason1.glicko!, redSide: getWinrateByTR(
theRedSide!.tlSeason1.glicko!,
theRedSide!.tlSeason1.rd!,
theGreenSide!.tlSeason1.glicko!,
theGreenSide!.tlSeason1.rd!) * theGreenSide!.tlSeason1.rd!) *
100, 100,
fractionDigits: 2, fractionDigits: 2,
@ -584,9 +809,15 @@ class CompareState extends State<CompareView> {
class PlayerSelector extends StatelessWidget { class PlayerSelector extends StatelessWidget {
final TetrioPlayer? player; final TetrioPlayer? player;
final List<DropdownMenuItem<TetrioPlayer>>? states;
final Function fetch;
final Function change; final Function change;
final Function updateState; final Function updateState;
const PlayerSelector({super.key, required this.player, required this.change, required this.updateState}); const PlayerSelector(
{super.key,
required this.player,
required this.updateState,
required this.fetch, this.states, required this.change, });
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -601,9 +832,9 @@ class PlayerSelector extends StatelessWidget {
controller: playerController, controller: playerController,
decoration: const InputDecoration(counter: Offstage()), decoration: const InputDecoration(counter: Offstage()),
onSubmitted: (String value) { onSubmitted: (String value) {
change(value); fetch(value);
}), }),
if (player != null) if (player != null && states == null)
Text( Text(
player!.toString(), player!.toString(),
style: const TextStyle( style: const TextStyle(
@ -620,7 +851,16 @@ class PlayerSelector extends StatelessWidget {
), ),
], ],
), ),
) ),
if (player != null && states != null)
Padding(
padding: const EdgeInsets.only(bottom: 8.0),
child: DropdownButton(
items: states,
value: player,
onChanged: (value) => change(value!),
),
)
], ],
); );
} }
@ -632,7 +872,13 @@ class CompareThingy extends StatelessWidget {
final String label; final String label;
final bool higherIsBetter; final bool higherIsBetter;
final int? fractionDigits; final int? fractionDigits;
const CompareThingy({super.key, required this.greenSide, required this.redSide, required this.label, required this.higherIsBetter, this.fractionDigits}); const CompareThingy(
{super.key,
required this.greenSide,
required this.redSide,
required this.label,
required this.higherIsBetter,
this.fractionDigits});
String verdict(num greenSide, num redSide, int fraction) { String verdict(num greenSide, num redSide, int fraction) {
var f = NumberFormat("+#,###.##;-#,###.##"); var f = NumberFormat("+#,###.##;-#,###.##");
@ -696,7 +942,8 @@ class CompareThingy extends StatelessWidget {
textAlign: TextAlign.center, textAlign: TextAlign.center,
), ),
Text( Text(
verdict(greenSide, redSide, fractionDigits != null ? fractionDigits! + 2 : 0), verdict(greenSide, redSide,
fractionDigits != null ? fractionDigits! + 2 : 0),
style: const TextStyle(fontSize: 16), style: const TextStyle(fontSize: 16),
textAlign: TextAlign.center, textAlign: TextAlign.center,
) )
@ -752,7 +999,12 @@ class CompareBoolThingy extends StatelessWidget {
final bool redSide; final bool redSide;
final String label; final String label;
final bool trueIsBetter; final bool trueIsBetter;
const CompareBoolThingy({super.key, required this.greenSide, required this.redSide, required this.label, required this.trueIsBetter}); const CompareBoolThingy(
{super.key,
required this.greenSide,
required this.redSide,
required this.label,
required this.trueIsBetter});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -861,7 +1113,12 @@ class CompareDurationThingy extends StatelessWidget {
final Duration redSide; final Duration redSide;
final String label; final String label;
final bool higherIsBetter; final bool higherIsBetter;
const CompareDurationThingy({super.key, required this.greenSide, required this.redSide, required this.label, required this.higherIsBetter}); const CompareDurationThingy(
{super.key,
required this.greenSide,
required this.redSide,
required this.label,
required this.higherIsBetter});
Duration verdict(Duration greenSide, Duration redSide) { Duration verdict(Duration greenSide, Duration redSide) {
return greenSide - redSide; return greenSide - redSide;
@ -927,12 +1184,18 @@ class CompareRegTimeThingy extends StatelessWidget {
final DateTime? redSide; final DateTime? redSide;
final String label; final String label;
final int? fractionDigits; final int? fractionDigits;
const CompareRegTimeThingy({super.key, required this.greenSide, required this.redSide, required this.label, this.fractionDigits}); const CompareRegTimeThingy(
{super.key,
required this.greenSide,
required this.redSide,
required this.label,
this.fractionDigits});
String verdict(DateTime? greenSide, DateTime? redSide) { String verdict(DateTime? greenSide, DateTime? redSide) {
var f = NumberFormat("#,### days later;#,### days before"); var f = NumberFormat("#,### days later;#,### days before");
String result = "---"; String result = "---";
if (greenSide != null && redSide != null) result = f.format(greenSide.difference(redSide).inDays); if (greenSide != null && redSide != null)
result = f.format(greenSide.difference(redSide).inDays);
return result; return result;
} }

View File

@ -18,7 +18,6 @@ const allowedHeightForPlayerIdInPixels = 40.0;
const allowedHeightForPlayerBioInPixels = 30.0; const allowedHeightForPlayerBioInPixels = 30.0;
const givenTextHeightByScreenPercentage = 0.3; const givenTextHeightByScreenPercentage = 0.3;
final NumberFormat timeInSec = NumberFormat("#,###.###s."); final NumberFormat timeInSec = NumberFormat("#,###.###s.");
final DateFormat dateFormat = DateFormat.yMMMd().add_Hms();
class MainView extends StatefulWidget { class MainView extends StatefulWidget {
const MainView({Key? key}) : super(key: key); const MainView({Key? key}) : super(key: key);

View File

@ -30,6 +30,7 @@ class UserThingy extends StatelessWidget {
bool bigScreen = constraints.maxWidth > 768; bool bigScreen = constraints.maxWidth > 768;
double bannerHeight = bigScreen ? 240 : 120; double bannerHeight = bigScreen ? 240 : 120;
double pfpHeight = 128; double pfpHeight = 128;
return Column( return Column(
children: [ children: [
Flex( Flex(