God what's wrong with replays?
This commit is contained in:
parent
3807c7321e
commit
e524952970
|
@ -68,6 +68,7 @@ class ReplayStats{
|
||||||
late int topBtB;
|
late int topBtB;
|
||||||
late int topSpike;
|
late int topSpike;
|
||||||
late int tspins;
|
late int tspins;
|
||||||
|
late double roundLength; // in seconds
|
||||||
late Clears clears;
|
late Clears clears;
|
||||||
late Garbage garbage;
|
late Garbage garbage;
|
||||||
late Finesse finesse;
|
late Finesse finesse;
|
||||||
|
@ -85,12 +86,13 @@ class ReplayStats{
|
||||||
required this.topBtB,
|
required this.topBtB,
|
||||||
required this.topSpike,
|
required this.topSpike,
|
||||||
required this.tspins,
|
required this.tspins,
|
||||||
|
required this.roundLength,
|
||||||
required this.clears,
|
required this.clears,
|
||||||
required this.garbage,
|
required this.garbage,
|
||||||
required this.finesse,
|
required this.finesse,
|
||||||
});
|
});
|
||||||
|
|
||||||
ReplayStats.fromJson(Map<String, dynamic> json, int inputTopSpike){
|
ReplayStats.fromJson(Map<String, dynamic> json, int inputTopSpike, int framesLength){
|
||||||
seed = json['seed'];
|
seed = json['seed'];
|
||||||
linesCleared = json['lines'];
|
linesCleared = json['lines'];
|
||||||
piecesPlaced = json['piecesplaced'];
|
piecesPlaced = json['piecesplaced'];
|
||||||
|
@ -101,11 +103,16 @@ class ReplayStats{
|
||||||
topBtB = json['topbtb'];
|
topBtB = json['topbtb'];
|
||||||
topSpike = inputTopSpike;
|
topSpike = inputTopSpike;
|
||||||
tspins = json['tspins'];
|
tspins = json['tspins'];
|
||||||
|
roundLength = framesLength / 60;
|
||||||
clears = Clears.fromJson(json['clears']);
|
clears = Clears.fromJson(json['clears']);
|
||||||
garbage = Garbage.fromJson(json['garbage']);
|
garbage = Garbage.fromJson(json['garbage']);
|
||||||
finesse = Finesse.fromJson(json['finesse']);
|
finesse = Finesse.fromJson(json['finesse']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double get kpp => inputs / piecesPlaced;
|
||||||
|
double get kps => inputs / roundLength;
|
||||||
|
double get spp => score / piecesPlaced;
|
||||||
|
|
||||||
ReplayStats.createEmpty(){
|
ReplayStats.createEmpty(){
|
||||||
seed = -1;
|
seed = -1;
|
||||||
linesCleared = 0;
|
linesCleared = 0;
|
||||||
|
@ -117,6 +124,7 @@ class ReplayStats{
|
||||||
topBtB = 0;
|
topBtB = 0;
|
||||||
topSpike = 0;
|
topSpike = 0;
|
||||||
tspins = 0;
|
tspins = 0;
|
||||||
|
roundLength = 0.0;
|
||||||
clears = Clears(singles: 0, doubles: 0, triples: 0, quads: 0, pentas: 0, allClears: 0, tSpinZeros: 0, tSpinSingles: 0, tSpinDoubles: 0, tSpinTriples: 0, tSpinPentas: 0, tSpinQuads: 0, tSpinMiniZeros: 0, tSpinMiniSingles: 0, tSpinMiniDoubles: 0);
|
clears = Clears(singles: 0, doubles: 0, triples: 0, quads: 0, pentas: 0, allClears: 0, tSpinZeros: 0, tSpinSingles: 0, tSpinDoubles: 0, tSpinTriples: 0, tSpinPentas: 0, tSpinQuads: 0, tSpinMiniZeros: 0, tSpinMiniSingles: 0, tSpinMiniDoubles: 0);
|
||||||
garbage = Garbage(sent: 0, recived: 0, attack: 0, cleared: 0);
|
garbage = Garbage(sent: 0, recived: 0, attack: 0, cleared: 0);
|
||||||
finesse = Finesse(combo: 0, faults: 0, perfectPieces: 0);
|
finesse = Finesse(combo: 0, faults: 0, perfectPieces: 0);
|
||||||
|
@ -133,6 +141,7 @@ class ReplayStats{
|
||||||
topBtB: max(topBtB, other.topBtB),
|
topBtB: max(topBtB, other.topBtB),
|
||||||
topSpike: max(topSpike, other.topSpike),
|
topSpike: max(topSpike, other.topSpike),
|
||||||
tspins: tspins + other.tspins,
|
tspins: tspins + other.tspins,
|
||||||
|
roundLength: roundLength + other.roundLength,
|
||||||
clears: clears + other.clears,
|
clears: clears + other.clears,
|
||||||
garbage: garbage + other.garbage,
|
garbage: garbage + other.garbage,
|
||||||
finesse: finesse + other.finesse
|
finesse: finesse + other.finesse
|
||||||
|
@ -171,15 +180,15 @@ class ReplayData{
|
||||||
stats = [];
|
stats = [];
|
||||||
roundWinners = [];
|
roundWinners = [];
|
||||||
totalStats = [ReplayStats.createEmpty(), ReplayStats.createEmpty()];
|
totalStats = [ReplayStats.createEmpty(), ReplayStats.createEmpty()];
|
||||||
int firstInEndContext = json['data'][0]['board'].indexWhere((element) => element['id'] == endcontext[0].userId);
|
|
||||||
int secondInEndContext = json['data'][0]['board'].indexWhere((element) => element['id'] == endcontext[1].userId);
|
|
||||||
for(var round in json['data']) {
|
for(var round in json['data']) {
|
||||||
|
int firstInEndContext = round['replays'][0]["events"].last['data']['export']['options']['gameid'].startsWith(endcontext[0].userId) ? 0 : 1;
|
||||||
|
int secondInEndContext = round['replays'][1]["events"].last['data']['export']['options']['gameid'].startsWith(endcontext[1].userId) ? 1 : 0;
|
||||||
roundLengths.add(max(round['replays'][0]['frames'], round['replays'][1]['frames']));
|
roundLengths.add(max(round['replays'][0]['frames'], round['replays'][1]['frames']));
|
||||||
totalLength = totalLength + max(round['replays'][0]['frames'], round['replays'][1]['frames']);
|
totalLength = totalLength + max(round['replays'][0]['frames'], round['replays'][1]['frames']);
|
||||||
int winner = round['board'].indexWhere((element) => element['success'] == true);
|
int winner = round['board'].indexWhere((element) => element['success'] == true);
|
||||||
roundWinners.add([round['board'][winner]['id'], round['board'][winner]['username']]);
|
roundWinners.add([round['board'][winner]['id'], round['board'][winner]['username']]);
|
||||||
ReplayStats playerOne = ReplayStats.fromJson(round['replays'][firstInEndContext]['events'].last['data']['export']['stats'], biggestSpikeFromReplay(round['replays'][secondInEndContext]['events'])); // (events contain recived attacks)
|
ReplayStats playerOne = ReplayStats.fromJson(round['replays'][firstInEndContext]['events'].last['data']['export']['stats'], biggestSpikeFromReplay(round['replays'][secondInEndContext]['events']), round['replays'][firstInEndContext]['frames']); // (events contain recived attacks)
|
||||||
ReplayStats playerTwo = ReplayStats.fromJson(round['replays'][secondInEndContext]['events'].last['data']['export']['stats'], biggestSpikeFromReplay(round['replays'][firstInEndContext]['events']));
|
ReplayStats playerTwo = ReplayStats.fromJson(round['replays'][secondInEndContext]['events'].last['data']['export']['stats'], biggestSpikeFromReplay(round['replays'][firstInEndContext]['events']), round['replays'][secondInEndContext]['frames']);
|
||||||
stats.add([playerOne, playerTwo]);
|
stats.add([playerOne, playerTwo]);
|
||||||
totalStats[0] = totalStats[0] + playerOne;
|
totalStats[0] = totalStats[0] + playerOne;
|
||||||
totalStats[1] = totalStats[1] + playerTwo;
|
totalStats[1] = totalStats[1] + playerTwo;
|
||||||
|
|
|
@ -258,15 +258,27 @@ class TlMatchResultState extends State<TlMatchResultView> {
|
||||||
var greenSidePlayer = snapshot.data!.endcontext.indexWhere((element) => element.userId == widget.initPlayerId);
|
var greenSidePlayer = snapshot.data!.endcontext.indexWhere((element) => element.userId == widget.initPlayerId);
|
||||||
var redSidePlayer = snapshot.data!.endcontext.indexWhere((element) => element.userId != widget.initPlayerId);
|
var redSidePlayer = snapshot.data!.endcontext.indexWhere((element) => element.userId != widget.initPlayerId);
|
||||||
return Column(children: [
|
return Column(children: [
|
||||||
|
CompareThingy(greenSide: roundSelector.isNegative ? snapshot.data!.totalStats[greenSidePlayer].inputs : snapshot.data!.stats[roundSelector][greenSidePlayer].inputs,
|
||||||
|
redSide: roundSelector.isNegative ? snapshot.data!.totalStats[redSidePlayer].inputs : snapshot.data!.stats[roundSelector][redSidePlayer].inputs,
|
||||||
|
label: "Inputs", higherIsBetter: true),
|
||||||
CompareThingy(greenSide: roundSelector.isNegative ? snapshot.data!.totalStats[greenSidePlayer].piecesPlaced : snapshot.data!.stats[roundSelector][greenSidePlayer].piecesPlaced,
|
CompareThingy(greenSide: roundSelector.isNegative ? snapshot.data!.totalStats[greenSidePlayer].piecesPlaced : snapshot.data!.stats[roundSelector][greenSidePlayer].piecesPlaced,
|
||||||
redSide: roundSelector.isNegative ? snapshot.data!.totalStats[redSidePlayer].piecesPlaced : snapshot.data!.stats[roundSelector][redSidePlayer].piecesPlaced,
|
redSide: roundSelector.isNegative ? snapshot.data!.totalStats[redSidePlayer].piecesPlaced : snapshot.data!.stats[roundSelector][redSidePlayer].piecesPlaced,
|
||||||
label: "Pieces Placed", higherIsBetter: true),
|
label: "Pieces Placed", higherIsBetter: true),
|
||||||
|
CompareThingy(greenSide: roundSelector.isNegative ? snapshot.data!.totalStats[greenSidePlayer].kpp : snapshot.data!.stats[roundSelector][greenSidePlayer].kpp,
|
||||||
|
redSide: roundSelector.isNegative ? snapshot.data!.totalStats[redSidePlayer].kpp : snapshot.data!.stats[roundSelector][redSidePlayer].kpp,
|
||||||
|
label: "KpP", higherIsBetter: false, fractionDigits: 2,),
|
||||||
|
CompareThingy(greenSide: roundSelector.isNegative ? snapshot.data!.totalStats[greenSidePlayer].kps : snapshot.data!.stats[roundSelector][greenSidePlayer].kps,
|
||||||
|
redSide: roundSelector.isNegative ? snapshot.data!.totalStats[redSidePlayer].kps : snapshot.data!.stats[roundSelector][redSidePlayer].kps,
|
||||||
|
label: "KpS", higherIsBetter: true, fractionDigits: 2,),
|
||||||
CompareThingy(greenSide: roundSelector.isNegative ? snapshot.data!.totalStats[greenSidePlayer].linesCleared : snapshot.data!.stats[roundSelector][greenSidePlayer].linesCleared,
|
CompareThingy(greenSide: roundSelector.isNegative ? snapshot.data!.totalStats[greenSidePlayer].linesCleared : snapshot.data!.stats[roundSelector][greenSidePlayer].linesCleared,
|
||||||
redSide: roundSelector.isNegative ? snapshot.data!.totalStats[redSidePlayer].linesCleared : snapshot.data!.stats[roundSelector][redSidePlayer].linesCleared,
|
redSide: roundSelector.isNegative ? snapshot.data!.totalStats[redSidePlayer].linesCleared : snapshot.data!.stats[roundSelector][redSidePlayer].linesCleared,
|
||||||
label: "Lines Cleared", higherIsBetter: true),
|
label: "Lines Cleared", higherIsBetter: true),
|
||||||
CompareThingy(greenSide: roundSelector.isNegative ? snapshot.data!.totalStats[greenSidePlayer].score : snapshot.data!.stats[roundSelector][greenSidePlayer].score,
|
CompareThingy(greenSide: roundSelector.isNegative ? snapshot.data!.totalStats[greenSidePlayer].score : snapshot.data!.stats[roundSelector][greenSidePlayer].score,
|
||||||
redSide: roundSelector.isNegative ? snapshot.data!.totalStats[redSidePlayer].score : snapshot.data!.stats[roundSelector][redSidePlayer].score,
|
redSide: roundSelector.isNegative ? snapshot.data!.totalStats[redSidePlayer].score : snapshot.data!.stats[roundSelector][redSidePlayer].score,
|
||||||
label: "Score", higherIsBetter: true),
|
label: "Score", higherIsBetter: true),
|
||||||
|
CompareThingy(greenSide: roundSelector.isNegative ? snapshot.data!.totalStats[greenSidePlayer].spp : snapshot.data!.stats[roundSelector][greenSidePlayer].spp,
|
||||||
|
redSide: roundSelector.isNegative ? snapshot.data!.totalStats[redSidePlayer].spp : snapshot.data!.stats[roundSelector][redSidePlayer].spp,
|
||||||
|
label: "SpP", higherIsBetter: true, fractionDigits: 2,),
|
||||||
CompareThingy(greenSide: roundSelector.isNegative ? snapshot.data!.totalStats[greenSidePlayer].finessePercentage * 100 : snapshot.data!.stats[roundSelector][greenSidePlayer].finessePercentage * 100,
|
CompareThingy(greenSide: roundSelector.isNegative ? snapshot.data!.totalStats[greenSidePlayer].finessePercentage * 100 : snapshot.data!.stats[roundSelector][greenSidePlayer].finessePercentage * 100,
|
||||||
redSide: roundSelector.isNegative ? snapshot.data!.totalStats[redSidePlayer].finessePercentage * 100 : snapshot.data!.stats[roundSelector][redSidePlayer].finessePercentage * 100,
|
redSide: roundSelector.isNegative ? snapshot.data!.totalStats[redSidePlayer].finessePercentage * 100 : snapshot.data!.stats[roundSelector][redSidePlayer].finessePercentage * 100,
|
||||||
label: "Finnese", postfix: "%", fractionDigits: 2, higherIsBetter: true),
|
label: "Finnese", postfix: "%", fractionDigits: 2, higherIsBetter: true),
|
||||||
|
|
Loading…
Reference in New Issue