ok i can check now evrevone i want
This commit is contained in:
parent
d65b43db5c
commit
6625c5efbc
|
@ -19,7 +19,7 @@ migrate_working_dir/
|
||||||
# The .vscode folder contains launch configuration and tasks you configure in
|
# The .vscode folder contains launch configuration and tasks you configure in
|
||||||
# VS Code which you may wish to be included in version control, so this line
|
# VS Code which you may wish to be included in version control, so this line
|
||||||
# is commented out by default.
|
# is commented out by default.
|
||||||
#.vscode/
|
.vscode/
|
||||||
|
|
||||||
# Flutter/Dart/Pub related
|
# Flutter/Dart/Pub related
|
||||||
**/doc/api/
|
**/doc/api/
|
||||||
|
|
|
@ -46,14 +46,18 @@ class TetrioPlayer{
|
||||||
});
|
});
|
||||||
|
|
||||||
double getLevel() {
|
double getLevel() {
|
||||||
return pow((xp!/500), 0.6)+(xp!/(5000+(max(0, xp!-4*pow(10, 6))/5000)))+1;
|
return pow((xp! / 500), 0.6) +
|
||||||
|
(xp! / (5000 + (max(0, xp! - 4 * pow(10, 6)) / 5000))) +
|
||||||
|
1;
|
||||||
}
|
}
|
||||||
|
|
||||||
TetrioPlayer.fromJson(Map<String, dynamic> json) {
|
TetrioPlayer.fromJson(Map<String, dynamic> json) {
|
||||||
userId = json['data']['user']['_id'];
|
userId = json['data']['user']['_id'];
|
||||||
username = json['data']['user']['username'];
|
username = json['data']['user']['username'];
|
||||||
role = json['data']['user']['role'];
|
role = json['data']['user']['role'];
|
||||||
registrationTime = DateTime.parse(json['data']['user']['ts']);
|
registrationTime = json['data']['user']['ts'] != null
|
||||||
|
? DateTime.parse(json['data']['user']['ts'])
|
||||||
|
: null;
|
||||||
if (json['data']['user']['badges'] != null) {
|
if (json['data']['user']['badges'] != null) {
|
||||||
badges = <Badge>[];
|
badges = <Badge>[];
|
||||||
json['data']['user']['badges'].forEach((v) {
|
json['data']['user']['badges'].forEach((v) {
|
||||||
|
@ -67,8 +71,9 @@ class TetrioPlayer{
|
||||||
country = json['data']['user']['country'];
|
country = json['data']['user']['country'];
|
||||||
supporterTier = json['data']['user']['supporter_tier'];
|
supporterTier = json['data']['user']['supporter_tier'];
|
||||||
verified = json['data']['user']['verified'];
|
verified = json['data']['user']['verified'];
|
||||||
tlSeason1 =
|
tlSeason1 = json['data']['user']['league'] != null
|
||||||
json['data']['user']['league'] != null ? TetraLeagueAlpha.fromJson(json['data']['user']['league']) : null;
|
? TetraLeagueAlpha.fromJson(json['data']['user']['league'])
|
||||||
|
: null;
|
||||||
avatarRevision = json['data']['user']['avatar_revision'];
|
avatarRevision = json['data']['user']['avatar_revision'];
|
||||||
bannerRevision = json['data']['user']['banner_revision'];
|
bannerRevision = json['data']['user']['banner_revision'];
|
||||||
bio = json['data']['user']['bio'];
|
bio = json['data']['user']['bio'];
|
||||||
|
@ -106,7 +111,6 @@ class TetrioPlayer{
|
||||||
data['friend_count'] = friendCount;
|
data['friend_count'] = friendCount;
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class Badge {
|
class Badge {
|
||||||
|
@ -114,16 +118,12 @@ class Badge{
|
||||||
String? label;
|
String? label;
|
||||||
DateTime? ts;
|
DateTime? ts;
|
||||||
|
|
||||||
Badge({
|
Badge({required this.badgeId, required this.label, required this.ts});
|
||||||
required this.badgeId,
|
|
||||||
required this.label,
|
|
||||||
required this.ts
|
|
||||||
});
|
|
||||||
|
|
||||||
Badge.fromJson(Map<String, dynamic> json) {
|
Badge.fromJson(Map<String, dynamic> json) {
|
||||||
badgeId = json['id'];
|
badgeId = json['id'];
|
||||||
label = json['label'];
|
label = json['label'];
|
||||||
ts = DateTime.parse(json['ts']);
|
ts = json['ts'] != null ? DateTime.parse(json['ts']) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
Map<String, dynamic> toJson() {
|
||||||
|
@ -169,8 +169,8 @@ class Clears{
|
||||||
int? tSpinMiniSingles;
|
int? tSpinMiniSingles;
|
||||||
int? tSpinMiniDoubles;
|
int? tSpinMiniDoubles;
|
||||||
|
|
||||||
Clears({
|
Clears(
|
||||||
this.singles,
|
{this.singles,
|
||||||
this.doubles,
|
this.doubles,
|
||||||
this.triples,
|
this.triples,
|
||||||
this.quads,
|
this.quads,
|
||||||
|
@ -182,8 +182,7 @@ class Clears{
|
||||||
this.tSpinQuads,
|
this.tSpinQuads,
|
||||||
this.tSpinMiniZeros,
|
this.tSpinMiniZeros,
|
||||||
this.tSpinMiniSingles,
|
this.tSpinMiniSingles,
|
||||||
this.tSpinMiniDoubles
|
this.tSpinMiniDoubles});
|
||||||
});
|
|
||||||
|
|
||||||
Clears.fromJson(Map<String, dynamic> json) {
|
Clears.fromJson(Map<String, dynamic> json) {
|
||||||
singles = json['singles'];
|
singles = json['singles'];
|
||||||
|
@ -244,11 +243,7 @@ class Finesse{
|
||||||
int? faults;
|
int? faults;
|
||||||
int? perfectPieces;
|
int? perfectPieces;
|
||||||
|
|
||||||
Finesse({
|
Finesse({this.combo, this.faults, this.perfectPieces});
|
||||||
this.combo,
|
|
||||||
this.faults,
|
|
||||||
this.perfectPieces
|
|
||||||
});
|
|
||||||
|
|
||||||
Finesse.fromJson(Map<String, dynamic> json) {
|
Finesse.fromJson(Map<String, dynamic> json) {
|
||||||
combo = json['combo'];
|
combo = json['combo'];
|
||||||
|
@ -281,8 +276,8 @@ class EndContextSingle{
|
||||||
Clears? clears;
|
Clears? clears;
|
||||||
Finesse? finesse;
|
Finesse? finesse;
|
||||||
|
|
||||||
EndContextSingle({
|
EndContextSingle(
|
||||||
this.gameType,
|
{this.gameType,
|
||||||
this.topBtB,
|
this.topBtB,
|
||||||
this.topCombo,
|
this.topCombo,
|
||||||
this.holds,
|
this.holds,
|
||||||
|
@ -295,8 +290,7 @@ class EndContextSingle{
|
||||||
this.finalTime,
|
this.finalTime,
|
||||||
this.tSpins,
|
this.tSpins,
|
||||||
this.clears,
|
this.clears,
|
||||||
this.finesse
|
this.finesse});
|
||||||
});
|
|
||||||
|
|
||||||
EndContextSingle.fromJson(Map<String, dynamic> json) {
|
EndContextSingle.fromJson(Map<String, dynamic> json) {
|
||||||
seed = json['seed'];
|
seed = json['seed'];
|
||||||
|
@ -311,7 +305,8 @@ class EndContextSingle{
|
||||||
tSpins = json['tspins'];
|
tSpins = json['tspins'];
|
||||||
piecesPlaced = json['piecesplaced'];
|
piecesPlaced = json['piecesplaced'];
|
||||||
clears = json['clears'] != null ? Clears.fromJson(json['clears']) : null;
|
clears = json['clears'] != null ? Clears.fromJson(json['clears']) : null;
|
||||||
finesse = json['finesse'] != null ? Finesse.fromJson(json['finesse']) : null;
|
finesse =
|
||||||
|
json['finesse'] != null ? Finesse.fromJson(json['finesse']) : null;
|
||||||
gameType = json['gametype'];
|
gameType = json['gametype'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -347,14 +342,8 @@ class Handling{
|
||||||
bool? cancel;
|
bool? cancel;
|
||||||
bool? safeLock;
|
bool? safeLock;
|
||||||
|
|
||||||
Handling({
|
Handling(
|
||||||
this.arr,
|
{this.arr, this.das, this.sdf, this.dcd, this.cancel, this.safeLock});
|
||||||
this.das,
|
|
||||||
this.sdf,
|
|
||||||
this.dcd,
|
|
||||||
this.cancel,
|
|
||||||
this.safeLock
|
|
||||||
});
|
|
||||||
|
|
||||||
Handling.fromJson(Map<String, dynamic> json) {
|
Handling.fromJson(Map<String, dynamic> json) {
|
||||||
arr = json['arr'];
|
arr = json['arr'];
|
||||||
|
@ -393,8 +382,8 @@ class EndContextMulti{
|
||||||
List<double>? extraTracking;
|
List<double>? extraTracking;
|
||||||
bool? success;
|
bool? success;
|
||||||
|
|
||||||
EndContextMulti({
|
EndContextMulti(
|
||||||
this.userId,
|
{this.userId,
|
||||||
this.naturalOrder,
|
this.naturalOrder,
|
||||||
this.inputs,
|
this.inputs,
|
||||||
this.piecesPlaced,
|
this.piecesPlaced,
|
||||||
|
@ -407,14 +396,12 @@ class EndContextMulti{
|
||||||
this.tertiaryTracking,
|
this.tertiaryTracking,
|
||||||
this.extra,
|
this.extra,
|
||||||
this.extraTracking,
|
this.extraTracking,
|
||||||
this.success
|
this.success});
|
||||||
});
|
|
||||||
|
|
||||||
EndContextMulti.fromJson(Map<String, dynamic> json) {
|
EndContextMulti.fromJson(Map<String, dynamic> json) {
|
||||||
userId = json['user']['_id'];
|
userId = json['user']['_id'];
|
||||||
handling = json['handling'] != null
|
handling =
|
||||||
? Handling.fromJson(json['handling'])
|
json['handling'] != null ? Handling.fromJson(json['handling']) : null;
|
||||||
: null;
|
|
||||||
success = json['success'];
|
success = json['success'];
|
||||||
inputs = json['inputs'];
|
inputs = json['inputs'];
|
||||||
piecesPlaced = json['piecesplaced'];
|
piecesPlaced = json['piecesplaced'];
|
||||||
|
@ -426,7 +413,9 @@ class EndContextMulti{
|
||||||
secondaryTracking = json['points']['secondaryAvgTracking'].cast<double>();
|
secondaryTracking = json['points']['secondaryAvgTracking'].cast<double>();
|
||||||
tertiaryTracking = json['points']['tertiaryAvgTracking'].cast<double>();
|
tertiaryTracking = json['points']['tertiaryAvgTracking'].cast<double>();
|
||||||
extra = json['points']['extra']['vs'];
|
extra = json['points']['extra']['vs'];
|
||||||
extraTracking = json['points']['extraAvgTracking']['aggregatestats___vsscore'].cast<double>();
|
extraTracking = json['points']['extraAvgTracking']
|
||||||
|
['aggregatestats___vsscore']
|
||||||
|
.cast<double>();
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, dynamic> toJson() {
|
Map<String, dynamic> toJson() {
|
||||||
|
@ -444,7 +433,8 @@ class EndContextMulti{
|
||||||
data['points']['secondary'] = secondary;
|
data['points']['secondary'] = secondary;
|
||||||
data['points']['tertiary'] = tertiary;
|
data['points']['tertiary'] = tertiary;
|
||||||
data['points']['extra']['vs'] = extra;
|
data['points']['extra']['vs'] = extra;
|
||||||
data['points']['extraAvgTracking']['aggregatestats___vsscore'] = extraTracking;
|
data['points']['extraAvgTracking']['aggregatestats___vsscore'] =
|
||||||
|
extraTracking;
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -472,8 +462,8 @@ class TetraLeagueAlpha{
|
||||||
double? vs;
|
double? vs;
|
||||||
List? records;
|
List? records;
|
||||||
|
|
||||||
TetraLeagueAlpha({
|
TetraLeagueAlpha(
|
||||||
this.userId,
|
{this.userId,
|
||||||
this.gamesPlayed,
|
this.gamesPlayed,
|
||||||
this.gamesWon,
|
this.gamesWon,
|
||||||
this.bestRank,
|
this.bestRank,
|
||||||
|
@ -493,20 +483,19 @@ class TetraLeagueAlpha{
|
||||||
this.apm,
|
this.apm,
|
||||||
this.pps,
|
this.pps,
|
||||||
this.vs,
|
this.vs,
|
||||||
this.records
|
this.records});
|
||||||
});
|
|
||||||
|
|
||||||
TetraLeagueAlpha.fromJson(Map<String, dynamic> json) {
|
TetraLeagueAlpha.fromJson(Map<String, dynamic> json) {
|
||||||
gamesPlayed = json['gamesplayed'];
|
gamesPlayed = json['gamesplayed'];
|
||||||
gamesWon = json['gameswon'];
|
gamesWon = json['gameswon'];
|
||||||
rating = json['rating'].toDouble();
|
rating = json['rating'].toDouble();
|
||||||
glicko = json['glicko'].toDouble();
|
glicko = json['glicko']?.toDouble();
|
||||||
rd = json['rd'].toDouble();
|
rd = json['rd']?.toDouble();
|
||||||
rank = json['rank'];
|
rank = json['rank'];
|
||||||
bestRank = json['bestrank'];
|
bestRank = json['bestrank'];
|
||||||
apm = json['apm'].toDouble();
|
apm = json['apm']?.toDouble();
|
||||||
pps = json['pps'].toDouble();
|
pps = json['pps']?.toDouble();
|
||||||
vs = json['vs'].toDouble();
|
vs = json['vs']?.toDouble();
|
||||||
decaying = json['decaying'];
|
decaying = json['decaying'];
|
||||||
standing = json['standing'];
|
standing = json['standing'];
|
||||||
percentile = json['percentile'].toDouble();
|
percentile = json['percentile'].toDouble();
|
||||||
|
@ -551,18 +540,19 @@ class RecordSingle{
|
||||||
EndContextSingle? endContext;
|
EndContextSingle? endContext;
|
||||||
int? rank;
|
int? rank;
|
||||||
|
|
||||||
RecordSingle({
|
RecordSingle(
|
||||||
this.userId,
|
{this.userId,
|
||||||
this.replayId,
|
this.replayId,
|
||||||
this.ownId,
|
this.ownId,
|
||||||
this.timestamp,
|
this.timestamp,
|
||||||
this.endContext,
|
this.endContext,
|
||||||
this.rank
|
this.rank});
|
||||||
});
|
|
||||||
|
|
||||||
RecordSingle.fromJson(Map<String, dynamic> json) {
|
RecordSingle.fromJson(Map<String, dynamic> json) {
|
||||||
ownId = json['_id'];
|
ownId = json['_id'];
|
||||||
endContext = json['endcontext'] != null ? EndContextSingle.fromJson(json['endcontext']) : null;
|
endContext = json['endcontext'] != null
|
||||||
|
? EndContextSingle.fromJson(json['endcontext'])
|
||||||
|
: null;
|
||||||
replayId = json['replayid'];
|
replayId = json['replayid'];
|
||||||
timestamp = json['ts'];
|
timestamp = json['ts'];
|
||||||
userId = json['user']['_id'];
|
userId = json['user']['_id'];
|
||||||
|
@ -587,11 +577,7 @@ class TetrioZen{
|
||||||
int? level;
|
int? level;
|
||||||
int? score;
|
int? score;
|
||||||
|
|
||||||
TetrioZen({
|
TetrioZen({this.userId, this.level, this.score});
|
||||||
this.userId,
|
|
||||||
this.level,
|
|
||||||
this.score
|
|
||||||
});
|
|
||||||
|
|
||||||
TetrioZen.fromJson(Map<String, dynamic> json) {
|
TetrioZen.fromJson(Map<String, dynamic> json) {
|
||||||
level = json['level'];
|
level = json['level'];
|
||||||
|
|
|
@ -3,6 +3,9 @@ import 'package:http/http.dart' as http;
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'package:tetra_stats/data_objects/tetrio.dart';
|
import 'package:tetra_stats/data_objects/tetrio.dart';
|
||||||
|
|
||||||
|
String _searchFor = "";
|
||||||
|
TetrioPlayer me = TetrioPlayer();
|
||||||
|
|
||||||
class MainView extends StatefulWidget {
|
class MainView extends StatefulWidget {
|
||||||
const MainView({Key? key}) : super(key: key);
|
const MainView({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@ -11,8 +14,10 @@ class MainView extends StatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class _MainViewState extends State<MainView> {
|
class _MainViewState extends State<MainView> {
|
||||||
Future<TetrioPlayer> fetchTetrioPlayer() async {
|
Future<TetrioPlayer> fetchTetrioPlayer(String user) async {
|
||||||
final response = await http.get(Uri.parse('https://ch.tetr.io/api/users/dan63047'));
|
var url = Uri.https('ch.tetr.io', 'api/users/$user');
|
||||||
|
final response = await http.get(url);
|
||||||
|
// final response = await http.get(Uri.parse('https://ch.tetr.io/'));
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
// If the server did return a 200 OK response,
|
// If the server did return a 200 OK response,
|
||||||
|
@ -24,12 +29,13 @@ class _MainViewState extends State<MainView> {
|
||||||
throw Exception('Failed to fetch player');
|
throw Exception('Failed to fetch player');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
late Future<TetrioPlayer> me;
|
late Future<TetrioPlayer> me;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
me = fetchTetrioPlayer();
|
me = fetchTetrioPlayer("blaarg");
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -41,20 +47,33 @@ class _MainViewState extends State<MainView> {
|
||||||
body: Row(
|
body: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: TextField(
|
||||||
|
onChanged: (String value) {
|
||||||
|
_searchFor = value;
|
||||||
|
},
|
||||||
|
maxLength: 25,
|
||||||
|
)),
|
||||||
|
TextButton(
|
||||||
|
child: const Text("Search"),
|
||||||
|
onPressed: () {
|
||||||
|
setState(() {
|
||||||
|
me = fetchTetrioPlayer(_searchFor);
|
||||||
|
});
|
||||||
|
}),
|
||||||
FutureBuilder<TetrioPlayer>(
|
FutureBuilder<TetrioPlayer>(
|
||||||
future: me,
|
future: me,
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
if (snapshot.hasData) {
|
if (snapshot.hasData) {
|
||||||
return Column(
|
return Column(children: [
|
||||||
children: [
|
|
||||||
Text(snapshot.data!.username.toString()),
|
Text(snapshot.data!.username.toString()),
|
||||||
Text("Level ${snapshot.data!.getLevel()}"),
|
Text("Level ${snapshot.data!.getLevel()}"),
|
||||||
Text("Registered ${snapshot.data!.registrationTime}"),
|
Text("Registered ${snapshot.data!.registrationTime}"),
|
||||||
Text("${snapshot.data!.tlSeason1!.rating} TR"),
|
Text("${snapshot.data!.tlSeason1!.rating} TR"),
|
||||||
Text("${snapshot.data!.tlSeason1!.glicko}±${snapshot.data!.tlSeason1!.rd} GLICKO"),
|
Text(
|
||||||
TextButton(onPressed: (){print("killed");}, child: const Text("kill")),
|
"${snapshot.data!.tlSeason1!.glicko}±${snapshot.data!.tlSeason1!.rd} GLICKO"),
|
||||||
]
|
Text("${snapshot.data!.zen}")
|
||||||
);
|
]);
|
||||||
} else if (snapshot.hasError) {
|
} else if (snapshot.hasError) {
|
||||||
return Text('${snapshot.error}');
|
return Text('${snapshot.error}');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue