Skip to content

Commit

Permalink
hmm...
Browse files Browse the repository at this point in the history
  • Loading branch information
dan63047 committed Nov 2, 2024
1 parent 14494db commit e3d7e94
Show file tree
Hide file tree
Showing 13 changed files with 768 additions and 469 deletions.
6 changes: 6 additions & 0 deletions lib/data_objects/beta_record.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// ignore_for_file: hash_and_equals

import 'package:tetra_stats/data_objects/beta_league_results.dart';
import 'package:tetra_stats/data_objects/record_extras.dart';
import 'package:tetra_stats/data_objects/tetrio_prisecter.dart';

class BetaRecord{
late String id;
Expand All @@ -10,6 +12,8 @@ class BetaRecord{
late String enemyUsername;
late String enemyID;
late BetaLeagueResults results;
late LeagueExtras extras;
late Prisecter prisecter;

BetaRecord({required this.id, required this.replayID, required this.gamemode, required this.ts, required this.enemyUsername, required this.enemyID, required this.results});

Expand All @@ -21,5 +25,7 @@ class BetaRecord{
enemyUsername = json['otherusers'][0]['username'];
enemyID = json['otherusers'][0]['id'];
results = BetaLeagueResults.fromJson(json['results']);
prisecter = Prisecter.fromJson(json['p']);
extras = LeagueExtras.fromJson(json['extras']);
}
}
30 changes: 30 additions & 0 deletions lib/data_objects/record_extras.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,33 @@ class ZenithExtras extends RecordExtras{
}
}
}

class SmallLeague{
late double glicko;
late double rd;
late double tr;
late String rank;
late int placement;

SmallLeague(this.glicko, this.rd, this.tr, this.rank, this.placement);

SmallLeague.fromJson(Map<String, dynamic> json){
glicko = json['glicko'];
rd = json['rd'];
tr = json['tr'];
rank = json['rank'];
placement = json['placement'];
}
}

class LeagueExtras extends RecordExtras{
late String result;
Map<String, List<SmallLeague?>> league = {};

LeagueExtras.fromJson(Map<String, dynamic> json){
result = json['result'];
for (String userID in json['league'].keys){
league[userID] = [json['league'][userID][0] != null ? SmallLeague.fromJson(json['league'][userID][0]) : null, json['league'][userID][1] != null ? SmallLeague.fromJson(json['league'][userID][1]) : null];
}
}
}
3 changes: 3 additions & 0 deletions lib/data_objects/results_stats.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import 'package:tetra_stats/data_objects/clears.dart';
import 'package:tetra_stats/data_objects/finesse.dart';
import 'package:tetra_stats/data_objects/tetrio_multiplayer_replay.dart';
import 'package:tetra_stats/data_objects/zenith_results.dart';

class ResultsStats {
Expand All @@ -17,6 +18,7 @@ class ResultsStats {
late Duration finalTime;
late int tSpins;
late Clears clears;
late Garbage garbage;
late int kills;
Finesse? finesse;
ZenithResults? zenith;
Expand Down Expand Up @@ -57,6 +59,7 @@ class ResultsStats {
tSpins = json['tspins'];
piecesPlaced = json['piecesplaced'];
clears = Clears.fromJson(json['clears']);
garbage = Garbage.fromJson(json['garbage']);
kills = json['kills'];
if (json.containsKey("finesse")) finesse = Finesse.fromJson(json['finesse']);
if (json.containsKey("zenith")) zenith = ZenithResults.fromJson(json['zenith']);
Expand Down
10 changes: 8 additions & 2 deletions lib/data_objects/tetrio_multiplayer_replay.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ int biggestSpikeFromReplay(events){
class Garbage{ // charsys where???
late int sent;
late int recived;
late int attack;
int? attack;
late int cleared;
int? sent_normal;
int? maxspike;
int? maxspike_nomult;

Garbage({
required this.sent,
Expand All @@ -52,14 +55,17 @@ class Garbage{ // charsys where???
recived = json['received'];
attack = json['attack'];
cleared = json['cleared'];
sent_normal = json['sent_normal'];
maxspike = json['maxspike'];
maxspike_nomult = json['maxspike_nomult'];
}

Garbage.toJson(){
// наху надо
}

Garbage operator + (Garbage other){
return Garbage(sent: sent + other.sent, recived: recived + other.recived, attack: attack + other.attack, cleared: cleared + other.cleared);
return Garbage(sent: sent + other.sent, recived: recived + other.recived, attack: attack??0 + (other.attack??0), cleared: cleared + other.cleared);
}
}

Expand Down
81 changes: 75 additions & 6 deletions lib/data_objects/tetrio_players_leaderboard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,28 @@ class TetrioPlayersLeaderboard {
}
if (filtredLeaderboard.isNotEmpty){
double
avgAPM = 0,
avgPPS = 0,
avgVS = 0,
avgTR = 0,
avgGlixare = 0,
avgGlicko = 0,
avgRD = 0,
avgAPP = 0,
avgVSAPM = 0,
avgDSS = 0,
avgDSP = 0,
avgAPPDSP = 0,
avgCheese = 0,
avgGBE = 0,
avgNyaAPP = 0,
avgArea = 0,
avgEstTR = 0,
avgEstAcc = 0,
avgOpener = 0,
avgPlonk = 0,
avgStride = 0,
avgInfDS = 0,
lowestTR = 25000,
lowestGlixare = double.infinity,
lowestGlicko = double.infinity,
Expand Down Expand Up @@ -110,11 +132,7 @@ class TetrioPlayersLeaderboard {
highestOpener = double.negativeInfinity,
highestPlonk = double.negativeInfinity,
highestStride = double.negativeInfinity,
highestInfDS = double.negativeInfinity,
avgTR = 0,
avgGlixare = 0,
avgGlicko = 0,
avgRD = 0;
highestInfDS = double.negativeInfinity;
int avgGamesPlayed = 0,
avgGamesWon = 0,
totalGamesPlayed = 0,
Expand Down Expand Up @@ -174,10 +192,28 @@ class TetrioPlayersLeaderboard {
highestStrideID = "", highestStrideNick = "",
highestInfDSid = "", highestInfDSnick = "";
for (var entry in filtredLeaderboard){
avgAPM += entry.apm;
avgPPS += entry.pps;
avgVS += entry.vs;
avgTR += entry.tr;
avgGlixare += entry.gxe;
if (entry.glicko != null) avgGlicko += entry.glicko!;
if (entry.rd != null) avgRD += entry.rd!;
avgAPP += entry.nerdStats.app;
avgVSAPM += entry.nerdStats.vsapm;
avgDSS += entry.nerdStats.dss;
avgDSP += entry.nerdStats.dsp;
avgAPPDSP += entry.nerdStats.appdsp;
avgCheese += entry.nerdStats.cheese;
avgGBE += entry.nerdStats.gbe;
avgNyaAPP += entry.nerdStats.nyaapp;
avgArea += entry.nerdStats.area;
avgEstTR += entry.estTr.esttr;
avgEstAcc += entry.esttracc;
avgOpener += entry.playstyle.opener;
avgPlonk += entry.playstyle.plonk;
avgStride += entry.playstyle.stride;
avgInfDS += entry.playstyle.infds;
totalGamesPlayed += entry.gamesPlayed;
totalGamesWon += entry.gamesWon;
if (entry.tr < lowestTR){
Expand Down Expand Up @@ -431,13 +467,31 @@ class TetrioPlayersLeaderboard {
highestInfDSnick = entry.username;
}
}
avgAPM /= filtredLeaderboard.length;
avgPPS /= filtredLeaderboard.length;
avgVS /= filtredLeaderboard.length;
avgTR /= filtredLeaderboard.length;
avgGlixare /= filtredLeaderboard.length;
avgGlicko /= filtredLeaderboard.length;
avgRD /= filtredLeaderboard.length;
avgGamesPlayed = (totalGamesPlayed / filtredLeaderboard.length).floor();
avgGamesWon = (totalGamesWon / filtredLeaderboard.length).floor();
return [TetraLeague(id: "", timestamp: DateTime.now(), apm: null, pps: null, vs: null, gxe: avgGlixare, glicko: avgGlicko, rd: avgRD, gamesPlayed: avgGamesPlayed, gamesWon: avgGamesWon, bestRank: rank, decaying: false, tr: avgTR, rank: rank == "" ? "z" : rank, percentileRank: rank, percentile: rankCutoffs[rank]!, standing: -1, standingLocal: -1, nextAt: -1, prevAt: -1, season: currentSeason),
avgAPP /= filtredLeaderboard.length;
avgVSAPM /= filtredLeaderboard.length;
avgDSS /= filtredLeaderboard.length;
avgDSP /= filtredLeaderboard.length;
avgAPPDSP /= leaderboard.length;
avgCheese /= filtredLeaderboard.length;
avgGBE /= filtredLeaderboard.length;
avgNyaAPP /= filtredLeaderboard.length;
avgArea /= filtredLeaderboard.length;
avgEstTR /= filtredLeaderboard.length;
avgEstAcc /= filtredLeaderboard.length;
avgOpener /= filtredLeaderboard.length;
avgPlonk /= filtredLeaderboard.length;
avgStride /= filtredLeaderboard.length;
avgInfDS /= filtredLeaderboard.length;
return [TetraLeague(id: "", timestamp: DateTime.now(), apm: avgAPM, pps: avgPPS, vs: avgVS, gxe: avgGlixare, glicko: avgGlicko, rd: avgRD, gamesPlayed: avgGamesPlayed, gamesWon: avgGamesWon, bestRank: rank, decaying: false, tr: avgTR, rank: rank == "" ? "z" : rank, percentileRank: rank, percentile: rankCutoffs[rank]!, standing: -1, standingLocal: -1, nextAt: -1, prevAt: -1, season: currentSeason),
{
"totalGamesPlayed": totalGamesPlayed,
"totalGamesWon": totalGamesWon,
Expand Down Expand Up @@ -598,6 +652,21 @@ class TetrioPlayersLeaderboard {
"highestInfDS": highestInfDS,
"highestInfDSid": highestInfDSid,
"highestInfDSnick": highestInfDSnick,
"avgAPP": avgAPP,
"avgVSAPM": avgVSAPM,
"avgDSS": avgDSS,
"avgDSP": avgDSP,
"avgAPPDSP": avgAPPDSP,
"avgCheese": avgCheese,
"avgGBE": avgGBE,
"avgNyaAPP": avgNyaAPP,
"avgArea": avgArea,
"avgEstTR": avgEstTR,
"avgEstAcc": avgEstAcc,
"avgOpener": avgOpener,
"avgPlonk": avgPlonk,
"avgStride": avgStride,
"avgInfDS": avgInfDS,
"toEnterGlicko": rank.toLowerCase() != "z" ? leaderboard[(leaderboard.length * rankCutoffs[rank]!).floor()-1].glicko : 0,
}];
}else{
Expand Down
Loading

0 comments on commit e3d7e94

Please sign in to comment.