OMG I CAN FETCH MYSELF!!! UNBELIEVABLE!!!
This commit is contained in:
parent
a059b942f3
commit
d65b43db5c
|
@ -1,217 +1,607 @@
|
||||||
|
import 'dart:math';
|
||||||
|
|
||||||
class TetrioPlayer{
|
class TetrioPlayer{
|
||||||
final String userId;
|
String? userId;
|
||||||
final String username;
|
String? username;
|
||||||
final String role;
|
String? role;
|
||||||
final DateTime registrationTime;
|
int? avatarRevision;
|
||||||
final List badges;
|
int? bannerRevision;
|
||||||
final String bio;
|
DateTime? registrationTime;
|
||||||
final String country;
|
List<Badge>? badges;
|
||||||
final int friendCount;
|
String? bio;
|
||||||
final int gamesPlayed;
|
String? country;
|
||||||
final int gamesWon;
|
int? friendCount;
|
||||||
final double gameTime;
|
int? gamesPlayed;
|
||||||
final double xp;
|
int? gamesWon;
|
||||||
final int supporterTier;
|
double? gameTime;
|
||||||
final bool verified;
|
double? xp;
|
||||||
final List<String> connection;
|
int? supporterTier;
|
||||||
final TetraLeagueAlpha tlSeason1;
|
bool? verified;
|
||||||
final List<TetrioSprint> sprint;
|
Connections? connections;
|
||||||
final List<TetrioBlitz> blitz;
|
TetraLeagueAlpha? tlSeason1;
|
||||||
final TetrioZen zen;
|
List<RecordSingle>? sprint;
|
||||||
|
List<RecordSingle>? blitz;
|
||||||
|
TetrioZen? zen;
|
||||||
|
|
||||||
const TetrioPlayer({
|
TetrioPlayer({
|
||||||
required this.userId,
|
this.userId,
|
||||||
required this.username,
|
this.username,
|
||||||
required this.role,
|
this.role,
|
||||||
required this.registrationTime,
|
this.registrationTime,
|
||||||
required this.badges,
|
this.badges,
|
||||||
required this.bio,
|
this.bio,
|
||||||
required this.country,
|
this.country,
|
||||||
required this.friendCount,
|
this.friendCount,
|
||||||
required this.gamesPlayed,
|
this.gamesPlayed,
|
||||||
required this.gamesWon,
|
this.gamesWon,
|
||||||
required this.gameTime,
|
this.gameTime,
|
||||||
required this.xp,
|
this.xp,
|
||||||
required this.supporterTier,
|
this.supporterTier,
|
||||||
required this.verified,
|
this.verified,
|
||||||
required this.connection,
|
this.connections,
|
||||||
required this.tlSeason1,
|
this.tlSeason1,
|
||||||
required this.sprint,
|
this.sprint,
|
||||||
required this.blitz,
|
this.blitz,
|
||||||
required this.zen,
|
this.zen,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
double getLevel(){
|
||||||
|
return pow((xp!/500), 0.6)+(xp!/(5000+(max(0, xp!-4*pow(10, 6))/5000)))+1;
|
||||||
|
}
|
||||||
|
|
||||||
|
TetrioPlayer.fromJson(Map<String, dynamic> json) {
|
||||||
|
userId = json['data']['user']['_id'];
|
||||||
|
username = json['data']['user']['username'];
|
||||||
|
role = json['data']['user']['role'];
|
||||||
|
registrationTime = DateTime.parse(json['data']['user']['ts']);
|
||||||
|
if (json['data']['user']['badges'] != null) {
|
||||||
|
badges = <Badge>[];
|
||||||
|
json['data']['user']['badges'].forEach((v) {
|
||||||
|
badges!.add(Badge.fromJson(v));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
xp = json['data']['user']['xp'].toDouble();
|
||||||
|
gamesPlayed = json['data']['user']['gamesplayed'];
|
||||||
|
gamesWon = json['data']['user']['gameswon'];
|
||||||
|
gameTime = json['data']['user']['gametime'].toDouble();
|
||||||
|
country = json['data']['user']['country'];
|
||||||
|
supporterTier = json['data']['user']['supporter_tier'];
|
||||||
|
verified = json['data']['user']['verified'];
|
||||||
|
tlSeason1 =
|
||||||
|
json['data']['user']['league'] != null ? TetraLeagueAlpha.fromJson(json['data']['user']['league']) : null;
|
||||||
|
avatarRevision = json['data']['user']['avatar_revision'];
|
||||||
|
bannerRevision = json['data']['user']['banner_revision'];
|
||||||
|
bio = json['data']['user']['bio'];
|
||||||
|
connections = json['data']['user']['connections'] != null
|
||||||
|
? Connections.fromJson(json['data']['user']['connections'])
|
||||||
|
: null;
|
||||||
|
friendCount = json['data']['user']['friend_count'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = <String, dynamic>{};
|
||||||
|
data['_id'] = userId;
|
||||||
|
data['username'] = username;
|
||||||
|
data['role'] = role;
|
||||||
|
data['ts'] = registrationTime;
|
||||||
|
if (badges != null) {
|
||||||
|
data['badges'] = badges!.map((v) => v.toJson()).toList();
|
||||||
|
}
|
||||||
|
data['xp'] = xp;
|
||||||
|
data['gamesplayed'] = gamesPlayed;
|
||||||
|
data['gameswon'] = gamesWon;
|
||||||
|
data['gametime'] = gameTime;
|
||||||
|
data['country'] = country;
|
||||||
|
data['supporter_tier'] = supporterTier;
|
||||||
|
data['verified'] = verified;
|
||||||
|
if (tlSeason1 != null) {
|
||||||
|
data['league'] = tlSeason1!.toJson();
|
||||||
|
}
|
||||||
|
data['avatar_revision'] = avatarRevision;
|
||||||
|
data['banner_revision'] = bannerRevision;
|
||||||
|
data['bio'] = bio;
|
||||||
|
if (connections != null) {
|
||||||
|
data['connections'] = connections!.toJson();
|
||||||
|
}
|
||||||
|
data['friend_count'] = friendCount;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class EndContextClears{
|
class Badge{
|
||||||
final int singles;
|
String? badgeId;
|
||||||
final int doubles;
|
String? label;
|
||||||
final int triples;
|
DateTime? ts;
|
||||||
final int quads;
|
|
||||||
final int allClears;
|
|
||||||
final int tSpinZeros;
|
|
||||||
final int tSpinSingles;
|
|
||||||
final int tSpinDoubles;
|
|
||||||
final int tSpinTriples;
|
|
||||||
final int tSpinQuads;
|
|
||||||
final int tSpinMiniZeros;
|
|
||||||
final int tSpinMiniSingles;
|
|
||||||
final int tSpinMiniDoubles;
|
|
||||||
|
|
||||||
const EndContextClears({
|
Badge({
|
||||||
required this.singles,
|
required this.badgeId,
|
||||||
required this.doubles,
|
required this.label,
|
||||||
required this.triples,
|
required this.ts
|
||||||
required this.quads,
|
});
|
||||||
required this.allClears,
|
|
||||||
required this.tSpinZeros,
|
Badge.fromJson(Map<String, dynamic> json) {
|
||||||
required this.tSpinSingles,
|
badgeId = json['id'];
|
||||||
required this.tSpinDoubles,
|
label = json['label'];
|
||||||
required this.tSpinTriples,
|
ts = DateTime.parse(json['ts']);
|
||||||
required this.tSpinQuads,
|
}
|
||||||
required this.tSpinMiniZeros,
|
|
||||||
required this.tSpinMiniSingles,
|
Map<String, dynamic> toJson() {
|
||||||
required this.tSpinMiniDoubles
|
final Map<String, dynamic> data = <String, dynamic>{};
|
||||||
});
|
data['id'] = badgeId;
|
||||||
|
data['label'] = label;
|
||||||
|
data['ts'] = ts;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class EndContextFinesse{
|
class Connections {
|
||||||
final int combo;
|
Discord? discord;
|
||||||
final int faults;
|
|
||||||
final int perfectPieces;
|
|
||||||
|
|
||||||
const EndContextFinesse({
|
Connections({this.discord});
|
||||||
required this.combo,
|
|
||||||
required this.faults,
|
Connections.fromJson(Map<String, dynamic> json) {
|
||||||
required this.perfectPieces
|
discord =
|
||||||
});
|
json['discord'] != null ? Discord.fromJson(json['discord']) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = <String, dynamic>{};
|
||||||
|
if (discord != null) {
|
||||||
|
data['discord'] = discord!.toJson();
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ReplayEndContextSingle{
|
class Clears{
|
||||||
final String gameType;
|
int? singles;
|
||||||
final int topBtB;
|
int? doubles;
|
||||||
final int topCombo;
|
int? triples;
|
||||||
final int holds;
|
int? quads;
|
||||||
final int inputs;
|
int? allClears;
|
||||||
final int level;
|
int? tSpinZeros;
|
||||||
final int piecesPlaced;
|
int? tSpinSingles;
|
||||||
final int lines;
|
int? tSpinDoubles;
|
||||||
final int score;
|
int? tSpinTriples;
|
||||||
final int seed;
|
int? tSpinQuads;
|
||||||
final double finalTime;
|
int? tSpinMiniZeros;
|
||||||
final int tSpins;
|
int? tSpinMiniSingles;
|
||||||
final EndContextClears clears;
|
int? tSpinMiniDoubles;
|
||||||
final EndContextFinesse finesse;
|
|
||||||
|
|
||||||
const ReplayEndContextSingle({
|
Clears({
|
||||||
required this.gameType,
|
this.singles,
|
||||||
required this.topBtB,
|
this.doubles,
|
||||||
required this.topCombo,
|
this.triples,
|
||||||
required this.holds,
|
this.quads,
|
||||||
required this.inputs,
|
this.allClears,
|
||||||
required this.level,
|
this.tSpinZeros,
|
||||||
required this.piecesPlaced,
|
this.tSpinSingles,
|
||||||
required this.lines,
|
this.tSpinDoubles,
|
||||||
required this.score,
|
this.tSpinTriples,
|
||||||
required this.seed,
|
this.tSpinQuads,
|
||||||
required this.finalTime,
|
this.tSpinMiniZeros,
|
||||||
required this.tSpins,
|
this.tSpinMiniSingles,
|
||||||
required this.clears,
|
this.tSpinMiniDoubles
|
||||||
required this.finesse
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Clears.fromJson(Map<String, dynamic> json) {
|
||||||
|
singles = json['singles'];
|
||||||
|
doubles = json['doubles'];
|
||||||
|
triples = json['triples'];
|
||||||
|
quads = json['quads'];
|
||||||
|
tSpinZeros = json['realtspins'];
|
||||||
|
tSpinMiniZeros = json['minitspins'];
|
||||||
|
tSpinMiniSingles = json['minitspinsingles'];
|
||||||
|
tSpinSingles = json['tspinsingles'];
|
||||||
|
tSpinMiniDoubles = json['minitspindoubles'];
|
||||||
|
tSpinDoubles = json['tspindoubles'];
|
||||||
|
tSpinTriples = json['tspintriples'];
|
||||||
|
tSpinQuads = json['tspinquads'];
|
||||||
|
allClears = json['allclear'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = <String, dynamic>{};
|
||||||
|
data['singles'] = singles;
|
||||||
|
data['doubles'] = doubles;
|
||||||
|
data['triples'] = triples;
|
||||||
|
data['quads'] = quads;
|
||||||
|
data['realtspins'] = tSpinZeros;
|
||||||
|
data['minitspins'] = tSpinMiniZeros;
|
||||||
|
data['minitspinsingles'] = tSpinMiniSingles;
|
||||||
|
data['tspinsingles'] = tSpinSingles;
|
||||||
|
data['minitspindoubles'] = tSpinMiniDoubles;
|
||||||
|
data['tspindoubles'] = tSpinDoubles;
|
||||||
|
data['tspintriples'] = tSpinTriples;
|
||||||
|
data['tspinquads'] = tSpinQuads;
|
||||||
|
data['allclear'] = allClears;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Discord {
|
||||||
|
String? id;
|
||||||
|
String? username;
|
||||||
|
|
||||||
|
Discord({this.id, this.username});
|
||||||
|
|
||||||
|
Discord.fromJson(Map<String, dynamic> json) {
|
||||||
|
id = json['id'];
|
||||||
|
username = json['username'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = <String, dynamic>{};
|
||||||
|
data['id'] = id;
|
||||||
|
data['username'] = username;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Finesse{
|
||||||
|
int? combo;
|
||||||
|
int? faults;
|
||||||
|
int? perfectPieces;
|
||||||
|
|
||||||
|
Finesse({
|
||||||
|
this.combo,
|
||||||
|
this.faults,
|
||||||
|
this.perfectPieces
|
||||||
|
});
|
||||||
|
|
||||||
|
Finesse.fromJson(Map<String, dynamic> json) {
|
||||||
|
combo = json['combo'];
|
||||||
|
faults = json['faults'];
|
||||||
|
perfectPieces = json['perfectpieces'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = <String, dynamic>{};
|
||||||
|
data['combo'] = combo;
|
||||||
|
data['faults'] = faults;
|
||||||
|
data['perfectpieces'] = perfectPieces;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class EndContextSingle{
|
||||||
|
String? gameType;
|
||||||
|
int? topBtB;
|
||||||
|
int? topCombo;
|
||||||
|
int? holds;
|
||||||
|
int? inputs;
|
||||||
|
int? level;
|
||||||
|
int? piecesPlaced;
|
||||||
|
int? lines;
|
||||||
|
int? score;
|
||||||
|
int? seed;
|
||||||
|
double? finalTime;
|
||||||
|
int? tSpins;
|
||||||
|
Clears? clears;
|
||||||
|
Finesse? finesse;
|
||||||
|
|
||||||
|
EndContextSingle({
|
||||||
|
this.gameType,
|
||||||
|
this.topBtB,
|
||||||
|
this.topCombo,
|
||||||
|
this.holds,
|
||||||
|
this.inputs,
|
||||||
|
this.level,
|
||||||
|
this.piecesPlaced,
|
||||||
|
this.lines,
|
||||||
|
this.score,
|
||||||
|
this.seed,
|
||||||
|
this.finalTime,
|
||||||
|
this.tSpins,
|
||||||
|
this.clears,
|
||||||
|
this.finesse
|
||||||
|
});
|
||||||
|
|
||||||
|
EndContextSingle.fromJson(Map<String, dynamic> json) {
|
||||||
|
seed = json['seed'];
|
||||||
|
lines = json['lines'];
|
||||||
|
inputs = json['inputs'];
|
||||||
|
holds = json['holds'];
|
||||||
|
finalTime = json['finalTime'];
|
||||||
|
score = json['score'];
|
||||||
|
level = json['level'];
|
||||||
|
topCombo = json['topcombo'];
|
||||||
|
topBtB = json['topbtb'];
|
||||||
|
tSpins = json['tspins'];
|
||||||
|
piecesPlaced = json['piecesplaced'];
|
||||||
|
clears = json['clears'] != null ? Clears.fromJson(json['clears']) : null;
|
||||||
|
finesse = json['finesse'] != null ? Finesse.fromJson(json['finesse']) : null;
|
||||||
|
gameType = json['gametype'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = <String, dynamic>{};
|
||||||
|
data['seed'] = seed;
|
||||||
|
data['lines'] = lines;
|
||||||
|
data['inputs'] = inputs;
|
||||||
|
data['holds'] = holds;
|
||||||
|
data['score'] = score;
|
||||||
|
data['level'] = level;
|
||||||
|
data['topcombo'] = topCombo;
|
||||||
|
data['topbtb'] = topBtB;
|
||||||
|
data['tspins'] = tSpins;
|
||||||
|
data['piecesplaced'] = piecesPlaced;
|
||||||
|
if (clears != null) {
|
||||||
|
data['clears'] = clears!.toJson();
|
||||||
|
}
|
||||||
|
if (finesse != null) {
|
||||||
|
data['finesse'] = finesse!.toJson();
|
||||||
|
}
|
||||||
|
data['finalTime'] = finalTime;
|
||||||
|
data['gametype'] = gameType;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Handling{
|
||||||
|
double? arr;
|
||||||
|
double? das;
|
||||||
|
int? sdf;
|
||||||
|
int? dcd;
|
||||||
|
bool? cancel;
|
||||||
|
bool? safeLock;
|
||||||
|
|
||||||
|
Handling({
|
||||||
|
this.arr,
|
||||||
|
this.das,
|
||||||
|
this.sdf,
|
||||||
|
this.dcd,
|
||||||
|
this.cancel,
|
||||||
|
this.safeLock
|
||||||
|
});
|
||||||
|
|
||||||
|
Handling.fromJson(Map<String, dynamic> json) {
|
||||||
|
arr = json['arr'];
|
||||||
|
das = json['das'];
|
||||||
|
dcd = json['dcd'];
|
||||||
|
sdf = json['sdf'];
|
||||||
|
safeLock = json['safelock'];
|
||||||
|
cancel = json['cancel'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = <String, dynamic>{};
|
||||||
|
data['arr'] = arr;
|
||||||
|
data['das'] = das;
|
||||||
|
data['dcd'] = dcd;
|
||||||
|
data['sdf'] = sdf;
|
||||||
|
data['safelock'] = safeLock;
|
||||||
|
data['cancel'] = cancel;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class EndContextMulti{
|
||||||
|
String? userId;
|
||||||
|
int? naturalOrder;
|
||||||
|
int? inputs;
|
||||||
|
int? piecesPlaced;
|
||||||
|
Handling? handling;
|
||||||
|
int? points;
|
||||||
|
int? wins;
|
||||||
|
double? secondary;
|
||||||
|
List<double>? secondaryTracking;
|
||||||
|
double? tertiary;
|
||||||
|
List<double>? tertiaryTracking;
|
||||||
|
double? extra;
|
||||||
|
List<double>? extraTracking;
|
||||||
|
bool? success;
|
||||||
|
|
||||||
|
EndContextMulti({
|
||||||
|
this.userId,
|
||||||
|
this.naturalOrder,
|
||||||
|
this.inputs,
|
||||||
|
this.piecesPlaced,
|
||||||
|
this.handling,
|
||||||
|
this.points,
|
||||||
|
this.wins,
|
||||||
|
this.secondary,
|
||||||
|
this.secondaryTracking,
|
||||||
|
this.tertiary,
|
||||||
|
this.tertiaryTracking,
|
||||||
|
this.extra,
|
||||||
|
this.extraTracking,
|
||||||
|
this.success
|
||||||
|
});
|
||||||
|
|
||||||
|
EndContextMulti.fromJson(Map<String, dynamic> json) {
|
||||||
|
userId = json['user']['_id'];
|
||||||
|
handling = json['handling'] != null
|
||||||
|
? Handling.fromJson(json['handling'])
|
||||||
|
: null;
|
||||||
|
success = json['success'];
|
||||||
|
inputs = json['inputs'];
|
||||||
|
piecesPlaced = json['piecesplaced'];
|
||||||
|
naturalOrder = json['naturalorder'];
|
||||||
|
wins = json['wins'];
|
||||||
|
points = json['points']['primary'];
|
||||||
|
secondary = json['points']['secondary'];
|
||||||
|
tertiary = json['points']['tertiary'];
|
||||||
|
secondaryTracking = json['points']['secondaryAvgTracking'].cast<double>();
|
||||||
|
tertiaryTracking = json['points']['tertiaryAvgTracking'].cast<double>();
|
||||||
|
extra = json['points']['extra']['vs'];
|
||||||
|
extraTracking = json['points']['extraAvgTracking']['aggregatestats___vsscore'].cast<double>();
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = <String, dynamic>{};
|
||||||
|
data['user'] = userId;
|
||||||
|
if (handling != null) {
|
||||||
|
data['handling'] = handling!.toJson();
|
||||||
|
}
|
||||||
|
data['success'] = success;
|
||||||
|
data['inputs'] = inputs;
|
||||||
|
data['piecesplaced'] = piecesPlaced;
|
||||||
|
data['naturalorder'] = naturalOrder;
|
||||||
|
data['wins'] = wins;
|
||||||
|
data['points']['primary'] = points;
|
||||||
|
data['points']['secondary'] = secondary;
|
||||||
|
data['points']['tertiary'] = tertiary;
|
||||||
|
data['points']['extra']['vs'] = extra;
|
||||||
|
data['points']['extraAvgTracking']['aggregatestats___vsscore'] = extraTracking;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class TetraLeagueAlpha{
|
class TetraLeagueAlpha{
|
||||||
final String userId;
|
String? userId;
|
||||||
final int gamesPlayed;
|
int? gamesPlayed;
|
||||||
final int gamesWon;
|
int? gamesWon;
|
||||||
final String bestRank;
|
String? bestRank;
|
||||||
final bool decaying;
|
bool? decaying;
|
||||||
final double rating;
|
double? rating;
|
||||||
final String rank;
|
String? rank;
|
||||||
final double gliko;
|
double? glicko;
|
||||||
final double rd;
|
double? rd;
|
||||||
final String percentileRank;
|
String? percentileRank;
|
||||||
final String percentile;
|
double? percentile;
|
||||||
final int standing;
|
int? standing;
|
||||||
final int standingLocal;
|
int? standingLocal;
|
||||||
final String nextRank;
|
String? nextRank;
|
||||||
final int nextAt;
|
int? nextAt;
|
||||||
final String prevRank;
|
String? prevRank;
|
||||||
final int prevAt;
|
int? prevAt;
|
||||||
final double apm;
|
double? apm;
|
||||||
final double pps;
|
double? pps;
|
||||||
final double vs;
|
double? vs;
|
||||||
final List records;
|
List? records;
|
||||||
|
|
||||||
const TetraLeagueAlpha({
|
TetraLeagueAlpha({
|
||||||
required this.userId,
|
this.userId,
|
||||||
required this.gamesPlayed,
|
this.gamesPlayed,
|
||||||
required this.gamesWon,
|
this.gamesWon,
|
||||||
required this.bestRank,
|
this.bestRank,
|
||||||
required this.decaying,
|
this.decaying,
|
||||||
required this.rating,
|
this.rating,
|
||||||
required this.rank,
|
this.rank,
|
||||||
required this.gliko,
|
this.glicko,
|
||||||
required this.rd,
|
this.rd,
|
||||||
required this.percentileRank,
|
this.percentileRank,
|
||||||
required this.percentile,
|
this.percentile,
|
||||||
required this.standing,
|
this.standing,
|
||||||
required this.standingLocal,
|
this.standingLocal,
|
||||||
required this.nextRank,
|
this.nextRank,
|
||||||
required this.nextAt,
|
this.nextAt,
|
||||||
required this.prevRank,
|
this.prevRank,
|
||||||
required this.prevAt,
|
this.prevAt,
|
||||||
required this.apm,
|
this.apm,
|
||||||
required this.pps,
|
this.pps,
|
||||||
required this.vs,
|
this.vs,
|
||||||
required this.records
|
this.records
|
||||||
});
|
});
|
||||||
|
|
||||||
|
TetraLeagueAlpha.fromJson(Map<String, dynamic> json) {
|
||||||
|
gamesPlayed = json['gamesplayed'];
|
||||||
|
gamesWon = json['gameswon'];
|
||||||
|
rating = json['rating'].toDouble();
|
||||||
|
glicko = json['glicko'].toDouble();
|
||||||
|
rd = json['rd'].toDouble();
|
||||||
|
rank = json['rank'];
|
||||||
|
bestRank = json['bestrank'];
|
||||||
|
apm = json['apm'].toDouble();
|
||||||
|
pps = json['pps'].toDouble();
|
||||||
|
vs = json['vs'].toDouble();
|
||||||
|
decaying = json['decaying'];
|
||||||
|
standing = json['standing'];
|
||||||
|
percentile = json['percentile'].toDouble();
|
||||||
|
standingLocal = json['standing_local'];
|
||||||
|
prevRank = json['prev_rank'];
|
||||||
|
prevAt = json['prev_at'];
|
||||||
|
nextRank = json['next_rank'];
|
||||||
|
nextAt = json['next_at'];
|
||||||
|
percentileRank = json['percentile_rank'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = <String, dynamic>{};
|
||||||
|
data['gamesplayed'] = gamesPlayed;
|
||||||
|
data['gameswon'] = gamesWon;
|
||||||
|
data['rating'] = rating;
|
||||||
|
data['glicko'] = glicko;
|
||||||
|
data['rd'] = rd;
|
||||||
|
data['rank'] = rank;
|
||||||
|
data['bestrank'] = bestRank;
|
||||||
|
data['apm'] = apm;
|
||||||
|
data['pps'] = pps;
|
||||||
|
data['vs'] = vs;
|
||||||
|
data['decaying'] = decaying;
|
||||||
|
data['standing'] = standing;
|
||||||
|
data['percentile'] = percentile;
|
||||||
|
data['standing_local'] = standingLocal;
|
||||||
|
data['prev_rank'] = prevRank;
|
||||||
|
data['prev_at'] = prevAt;
|
||||||
|
data['next_rank'] = nextRank;
|
||||||
|
data['next_at'] = nextAt;
|
||||||
|
data['percentile_rank'] = percentileRank;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class TetrioSprint{
|
class RecordSingle{
|
||||||
final String userId;
|
String? userId;
|
||||||
final String replayId;
|
String? replayId;
|
||||||
final String ownId;
|
String? ownId;
|
||||||
final DateTime timestamp;
|
DateTime? timestamp;
|
||||||
final ReplayEndContextSingle endContext;
|
EndContextSingle? endContext;
|
||||||
final int rank;
|
int? rank;
|
||||||
|
|
||||||
const TetrioSprint({
|
RecordSingle({
|
||||||
required this.userId,
|
this.userId,
|
||||||
required this.replayId,
|
this.replayId,
|
||||||
required this.ownId,
|
this.ownId,
|
||||||
required this.timestamp,
|
this.timestamp,
|
||||||
required this.endContext,
|
this.endContext,
|
||||||
required this.rank
|
this.rank
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
class TetrioBlitz{
|
|
||||||
final String userId;
|
|
||||||
final String replayId;
|
|
||||||
final String ownId;
|
|
||||||
final DateTime timestamp;
|
|
||||||
final ReplayEndContextSingle endContext;
|
|
||||||
final int rank;
|
|
||||||
|
|
||||||
const TetrioBlitz({
|
|
||||||
required this.userId,
|
|
||||||
required this.replayId,
|
|
||||||
required this.ownId,
|
|
||||||
required this.timestamp,
|
|
||||||
required this.endContext,
|
|
||||||
required this.rank
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
RecordSingle.fromJson(Map<String, dynamic> json) {
|
||||||
|
ownId = json['_id'];
|
||||||
|
endContext = json['endcontext'] != null ? EndContextSingle.fromJson(json['endcontext']) : null;
|
||||||
|
replayId = json['replayid'];
|
||||||
|
timestamp = json['ts'];
|
||||||
|
userId = json['user']['_id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = <String, dynamic>{};
|
||||||
|
data['_id'] = ownId;
|
||||||
|
if (endContext != null) {
|
||||||
|
data['endcontext'] = endContext!.toJson();
|
||||||
|
}
|
||||||
|
data['ismulti'] = false;
|
||||||
|
data['replayid'] = replayId;
|
||||||
|
data['ts'] = timestamp;
|
||||||
|
data['user_id'] = userId;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class TetrioZen{
|
class TetrioZen{
|
||||||
final String userId;
|
String? userId;
|
||||||
final int level;
|
int? level;
|
||||||
final int score;
|
int? score;
|
||||||
|
|
||||||
const TetrioZen({
|
TetrioZen({
|
||||||
required this.userId,
|
this.userId,
|
||||||
required this.level,
|
this.level,
|
||||||
required this.score
|
this.score
|
||||||
});
|
});
|
||||||
|
|
||||||
|
TetrioZen.fromJson(Map<String, dynamic> json) {
|
||||||
|
level = json['level'];
|
||||||
|
score = json['score'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
final Map<String, dynamic> data = <String, dynamic>{};
|
||||||
|
data['level'] = level;
|
||||||
|
data['score'] = score;
|
||||||
|
return data;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:tetra_stats/views/main_view.dart';
|
import 'package:tetra_stats/views/main_view.dart';
|
||||||
|
|
||||||
void main() {
|
void main() => runApp(MaterialApp(
|
||||||
runApp(const MyApp());
|
home: MainView(),
|
||||||
}
|
));
|
||||||
|
|
|
@ -1,36 +1,69 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
|
import 'dart:convert';
|
||||||
|
import 'package:tetra_stats/data_objects/tetrio.dart';
|
||||||
|
|
||||||
class MyApp extends StatelessWidget {
|
class MainView extends StatefulWidget {
|
||||||
const MyApp({super.key});
|
const MainView({Key? key}) : super(key: key);
|
||||||
|
|
||||||
Future<http.Response> fetchPlayer() {
|
@override
|
||||||
return http.get(Uri.parse('https://ch.tetr.io/api/users/6098518e3d5155e6ec429cdc'));
|
State<MainView> createState() => _MainViewState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MainViewState extends State<MainView> {
|
||||||
|
Future<TetrioPlayer> fetchTetrioPlayer() async {
|
||||||
|
final response = await http.get(Uri.parse('https://ch.tetr.io/api/users/dan63047'));
|
||||||
|
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
// If the server did return a 200 OK response,
|
||||||
|
// then parse the JSON.
|
||||||
|
return TetrioPlayer.fromJson(jsonDecode(response.body));
|
||||||
|
} else {
|
||||||
|
// If the server did not return a 200 OK response,
|
||||||
|
// then throw an exception.
|
||||||
|
throw Exception('Failed to fetch player');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
late Future<TetrioPlayer> me;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
me = fetchTetrioPlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return MaterialApp(
|
return Scaffold(
|
||||||
title: 'Flutter Demo',
|
appBar: AppBar(
|
||||||
theme: ThemeData(
|
title: const Text("Tetra Stats"),
|
||||||
primarySwatch: Colors.blue,
|
|
||||||
),
|
),
|
||||||
home: Scaffold(
|
body: Row(
|
||||||
appBar: AppBar(
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
title: const Text("Tetra Stats"),
|
children:[
|
||||||
),
|
FutureBuilder<TetrioPlayer>(
|
||||||
body: Row(
|
future: me,
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
builder: (context, snapshot) {
|
||||||
children:[
|
if (snapshot.hasData) {
|
||||||
Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
const Text("dan63047"),
|
Text(snapshot.data!.username.toString()),
|
||||||
const Text("18601 TR"),
|
Text("Level ${snapshot.data!.getLevel()}"),
|
||||||
TextButton(onPressed: (){print("killed");}, child: const Text(".don die"))
|
Text("Registered ${snapshot.data!.registrationTime}"),
|
||||||
]
|
Text("${snapshot.data!.tlSeason1!.rating} TR"),
|
||||||
)
|
Text("${snapshot.data!.tlSeason1!.glicko}±${snapshot.data!.tlSeason1!.rd} GLICKO"),
|
||||||
],
|
TextButton(onPressed: (){print("killed");}, child: const Text("kill")),
|
||||||
),
|
]
|
||||||
|
);
|
||||||
|
} else if (snapshot.hasError) {
|
||||||
|
return Text('${snapshot.error}');
|
||||||
|
}
|
||||||
|
|
||||||
|
// By default, show a loading spinner.
|
||||||
|
return const CircularProgressIndicator();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue