parent
94d4e650d5
commit
9bf80f651e
|
@ -445,6 +445,26 @@ class Clears {
|
|||
allClears = json['allclear'];
|
||||
}
|
||||
|
||||
Clears operator + (Clears other){
|
||||
return Clears(
|
||||
singles: singles + other.singles,
|
||||
doubles: doubles + other.doubles,
|
||||
triples: triples + other.triples,
|
||||
quads: quads + other.quads,
|
||||
pentas: pentas + other.pentas,
|
||||
allClears: allClears + other.allClears,
|
||||
tSpinZeros: tSpinZeros + other.tSpinZeros,
|
||||
tSpinSingles: tSpinSingles + other.tSpinSingles,
|
||||
tSpinDoubles: tSpinDoubles + other.tSpinDoubles,
|
||||
tSpinTriples: tSpinTriples + other.tSpinTriples,
|
||||
tSpinPentas: tSpinPentas + other.tSpinPentas,
|
||||
tSpinQuads: tSpinQuads + other.tSpinQuads,
|
||||
tSpinMiniZeros: tSpinMiniZeros + other.tSpinMiniZeros,
|
||||
tSpinMiniSingles: tSpinMiniSingles + other.tSpinMiniSingles,
|
||||
tSpinMiniDoubles: tSpinMiniDoubles + other.tSpinMiniDoubles
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['singles'] = singles;
|
||||
|
@ -501,6 +521,10 @@ class Finesse {
|
|||
perfectPieces = json['perfectpieces'];
|
||||
}
|
||||
|
||||
Finesse operator + (Finesse other){
|
||||
return Finesse(combo: max(combo, other.combo), faults: faults + other.faults, perfectPieces: perfectPieces + other.perfectPieces);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['combo'] = combo;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import 'dart:io';
|
||||
import 'dart:math';
|
||||
import 'tetrio.dart';
|
||||
|
||||
|
@ -19,7 +20,7 @@ class Garbage{ // charsys where???
|
|||
|
||||
Garbage.fromJson(Map<String, dynamic> json){
|
||||
sent = json['sent'];
|
||||
recived = json['recived'];
|
||||
recived = json['received'];
|
||||
attack = json['attack'];
|
||||
cleared = json['cleared'];
|
||||
}
|
||||
|
@ -27,11 +28,16 @@ class Garbage{ // charsys where???
|
|||
Garbage.toJson(){
|
||||
// наху надо
|
||||
}
|
||||
|
||||
Garbage operator + (Garbage other){
|
||||
return Garbage(sent: sent + other.sent, recived: recived + other.recived, attack: attack + other.attack, cleared: cleared + other.cleared);
|
||||
}
|
||||
}
|
||||
|
||||
class ReplayStats{
|
||||
late int seed;
|
||||
late int linesCleared;
|
||||
late int piecesPlaced;
|
||||
late int inputs;
|
||||
late int holds;
|
||||
late int score;
|
||||
|
@ -46,6 +52,7 @@ class ReplayStats{
|
|||
ReplayStats({
|
||||
required this.seed,
|
||||
required this.linesCleared,
|
||||
required this.piecesPlaced,
|
||||
required this.inputs,
|
||||
required this.holds,
|
||||
required this.score,
|
||||
|
@ -61,6 +68,7 @@ class ReplayStats{
|
|||
ReplayStats.fromJson(Map<String, dynamic> json){
|
||||
seed = json['seed'];
|
||||
linesCleared = json['lines'];
|
||||
piecesPlaced = json['piecesplaced'];
|
||||
inputs = json['inputs'];
|
||||
holds = json['holds'];
|
||||
score = json['score'];
|
||||
|
@ -73,13 +81,46 @@ class ReplayStats{
|
|||
kills = json['kills'];
|
||||
}
|
||||
|
||||
ReplayStats.createEmpty(){
|
||||
seed = -1;
|
||||
linesCleared = 0;
|
||||
piecesPlaced = 0;
|
||||
inputs = 0;
|
||||
holds = 0;
|
||||
score = 0;
|
||||
topCombo = 0;
|
||||
topBtB = 0;
|
||||
tspins = 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);
|
||||
finesse = Finesse(combo: 0, faults: 0, perfectPieces: 0);
|
||||
kills = 0;
|
||||
}
|
||||
|
||||
ReplayStats operator + (ReplayStats other){
|
||||
return ReplayStats(seed: -1,
|
||||
linesCleared: linesCleared + other.linesCleared,
|
||||
piecesPlaced: piecesPlaced + other.piecesPlaced,
|
||||
inputs: inputs + other.inputs,
|
||||
holds: holds + other.holds,
|
||||
score: score + other.score,
|
||||
topCombo: max(topCombo, other.topCombo),
|
||||
topBtB: max(topBtB, other.topBtB),
|
||||
tspins: tspins + other.tspins,
|
||||
clears: clears + other.clears,
|
||||
garbage: garbage + other.garbage,
|
||||
finesse: finesse + other.finesse,
|
||||
kills: kills + other.kills);
|
||||
}
|
||||
}
|
||||
|
||||
class ReplayData{
|
||||
late String id;
|
||||
late List<EndContextMulti> endcontext;
|
||||
late List<List<ReplayStats>> stats;
|
||||
late List<ReplayStats> totalStats;
|
||||
late List<int> roundLengths; // in frames
|
||||
late int totalLength; // in frames
|
||||
|
||||
ReplayData({
|
||||
required this.id,
|
||||
|
@ -89,7 +130,29 @@ class ReplayData{
|
|||
});
|
||||
|
||||
ReplayData.fromJson(Map<String, dynamic> json){
|
||||
// завтра разберусь,
|
||||
// пока что знаю, что тут будет for loop, который чекает replay["data"]
|
||||
id = json["_id"];
|
||||
endcontext = [EndContextMulti.fromJson(json["endcontext"][0]), EndContextMulti.fromJson(json["endcontext"][1])];
|
||||
roundLengths = [];
|
||||
totalLength = 0;
|
||||
stats = [];
|
||||
totalStats = [ReplayStats.createEmpty(), ReplayStats.createEmpty()];
|
||||
|
||||
for(var round in json['data']) {
|
||||
roundLengths.add(max(round['replays'][0]['frames'], round['replays'][1]['frames']));
|
||||
totalLength = totalLength + max(round['replays'][0]['frames'], round['replays'][1]['frames']);
|
||||
ReplayStats playerOne = ReplayStats.fromJson(round['replays'][0]['events'].last['data']['export']['stats']);
|
||||
ReplayStats playerTwo = ReplayStats.fromJson(round['replays'][1]['events'].last['data']['export']['stats']);
|
||||
stats.add([playerOne, playerTwo]);
|
||||
totalStats[0] = totalStats[0] + playerOne;
|
||||
totalStats[1] = totalStats[1] + playerTwo;
|
||||
// print(round['replays'][0]['events'].last['data']['export']['stats']);
|
||||
// for (var event in round['replays'][0]['events']){
|
||||
// if (event["type"] == "ige" && event["data"]["data"]["type"] == "interaction_confirm"){
|
||||
// print(event['data']["data"]["data"]); // lol
|
||||
// }
|
||||
// }
|
||||
}
|
||||
// Сами по себе эти ивенты ничего не дают,
|
||||
// Хотя можно попробовать вычислить biggest spike
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
// ignore_for_file: type_literal_in_constant_pattern
|
||||
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
@ -11,6 +12,7 @@ import 'package:fl_chart/fl_chart.dart';
|
|||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:tetra_stats/data_objects/tetrio.dart';
|
||||
import 'package:tetra_stats/data_objects/tetrio_multiplayer_replay.dart';
|
||||
import 'package:tetra_stats/gen/strings.g.dart';
|
||||
import 'package:tetra_stats/services/tetrio_crud.dart';
|
||||
import 'package:tetra_stats/main.dart' show prefs;
|
||||
|
@ -267,6 +269,10 @@ class _MainState extends State<MainView> with SingleTickerProviderStateMixin {
|
|||
value: "history",
|
||||
child: Text(t.fetchAndsaveTLHistory),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: "test",
|
||||
child: Text("Test replay reading"),
|
||||
),
|
||||
PopupMenuItem(
|
||||
value: "/states",
|
||||
child: Text(t.showStoredData),
|
||||
|
@ -281,12 +287,21 @@ class _MainState extends State<MainView> with SingleTickerProviderStateMixin {
|
|||
),
|
||||
],
|
||||
onSelected: (value) {
|
||||
if (value == "refresh") {changePlayer(_searchFor);
|
||||
return;}
|
||||
if (value == "history"){changePlayer(_searchFor, fetchHistory: true);
|
||||
return;}
|
||||
//Navigator.pushNamed(context, value);
|
||||
context.go(value);
|
||||
switch (value){
|
||||
case "refresh":
|
||||
changePlayer(_searchFor);
|
||||
break;
|
||||
case "history":
|
||||
changePlayer(_searchFor, fetchHistory: true);
|
||||
break;
|
||||
case "test":
|
||||
var replayfile = File("/home/dan63047/Загрузки/659337dd1eef65e513c5dc8d.ttrm").readAsStringSync();
|
||||
var testObject = ReplayData.fromJson(jsonDecode(replayfile));
|
||||
print("lol");
|
||||
break;
|
||||
default:
|
||||
context.go(value);
|
||||
}
|
||||
},
|
||||
),
|
||||
] : null,
|
||||
|
|
Loading…
Reference in New Issue