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
|
||||
# VS Code which you may wish to be included in version control, so this line
|
||||
# is commented out by default.
|
||||
#.vscode/
|
||||
.vscode/
|
||||
|
||||
# Flutter/Dart/Pub related
|
||||
**/doc/api/
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import 'dart:math';
|
||||
|
||||
class TetrioPlayer{
|
||||
class TetrioPlayer {
|
||||
String? userId;
|
||||
String? username;
|
||||
String? role;
|
||||
|
@ -45,15 +45,19 @@ class TetrioPlayer{
|
|||
this.zen,
|
||||
});
|
||||
|
||||
double getLevel(){
|
||||
return pow((xp!/500), 0.6)+(xp!/(5000+(max(0, xp!-4*pow(10, 6))/5000)))+1;
|
||||
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']);
|
||||
registrationTime = json['data']['user']['ts'] != null
|
||||
? DateTime.parse(json['data']['user']['ts'])
|
||||
: null;
|
||||
if (json['data']['user']['badges'] != null) {
|
||||
badges = <Badge>[];
|
||||
json['data']['user']['badges'].forEach((v) {
|
||||
|
@ -67,8 +71,9 @@ class TetrioPlayer{
|
|||
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;
|
||||
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'];
|
||||
|
@ -106,24 +111,19 @@ class TetrioPlayer{
|
|||
data['friend_count'] = friendCount;
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Badge{
|
||||
class Badge {
|
||||
String? badgeId;
|
||||
String? label;
|
||||
DateTime? ts;
|
||||
|
||||
Badge({
|
||||
required this.badgeId,
|
||||
required this.label,
|
||||
required this.ts
|
||||
});
|
||||
Badge({required this.badgeId, required this.label, required this.ts});
|
||||
|
||||
Badge.fromJson(Map<String, dynamic> json) {
|
||||
badgeId = json['id'];
|
||||
label = json['label'];
|
||||
ts = DateTime.parse(json['ts']);
|
||||
ts = json['ts'] != null ? DateTime.parse(json['ts']) : null;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
|
@ -154,7 +154,7 @@ class Connections {
|
|||
}
|
||||
}
|
||||
|
||||
class Clears{
|
||||
class Clears {
|
||||
int? singles;
|
||||
int? doubles;
|
||||
int? triples;
|
||||
|
@ -169,8 +169,8 @@ class Clears{
|
|||
int? tSpinMiniSingles;
|
||||
int? tSpinMiniDoubles;
|
||||
|
||||
Clears({
|
||||
this.singles,
|
||||
Clears(
|
||||
{this.singles,
|
||||
this.doubles,
|
||||
this.triples,
|
||||
this.quads,
|
||||
|
@ -182,8 +182,7 @@ class Clears{
|
|||
this.tSpinQuads,
|
||||
this.tSpinMiniZeros,
|
||||
this.tSpinMiniSingles,
|
||||
this.tSpinMiniDoubles
|
||||
});
|
||||
this.tSpinMiniDoubles});
|
||||
|
||||
Clears.fromJson(Map<String, dynamic> json) {
|
||||
singles = json['singles'];
|
||||
|
@ -239,16 +238,12 @@ class Discord {
|
|||
}
|
||||
}
|
||||
|
||||
class Finesse{
|
||||
class Finesse {
|
||||
int? combo;
|
||||
int? faults;
|
||||
int? perfectPieces;
|
||||
|
||||
Finesse({
|
||||
this.combo,
|
||||
this.faults,
|
||||
this.perfectPieces
|
||||
});
|
||||
Finesse({this.combo, this.faults, this.perfectPieces});
|
||||
|
||||
Finesse.fromJson(Map<String, dynamic> json) {
|
||||
combo = json['combo'];
|
||||
|
@ -265,7 +260,7 @@ class Finesse{
|
|||
}
|
||||
}
|
||||
|
||||
class EndContextSingle{
|
||||
class EndContextSingle {
|
||||
String? gameType;
|
||||
int? topBtB;
|
||||
int? topCombo;
|
||||
|
@ -281,8 +276,8 @@ class EndContextSingle{
|
|||
Clears? clears;
|
||||
Finesse? finesse;
|
||||
|
||||
EndContextSingle({
|
||||
this.gameType,
|
||||
EndContextSingle(
|
||||
{this.gameType,
|
||||
this.topBtB,
|
||||
this.topCombo,
|
||||
this.holds,
|
||||
|
@ -295,8 +290,7 @@ class EndContextSingle{
|
|||
this.finalTime,
|
||||
this.tSpins,
|
||||
this.clears,
|
||||
this.finesse
|
||||
});
|
||||
this.finesse});
|
||||
|
||||
EndContextSingle.fromJson(Map<String, dynamic> json) {
|
||||
seed = json['seed'];
|
||||
|
@ -311,7 +305,8 @@ class EndContextSingle{
|
|||
tSpins = json['tspins'];
|
||||
piecesPlaced = json['piecesplaced'];
|
||||
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'];
|
||||
}
|
||||
|
||||
|
@ -339,7 +334,7 @@ class EndContextSingle{
|
|||
}
|
||||
}
|
||||
|
||||
class Handling{
|
||||
class Handling {
|
||||
double? arr;
|
||||
double? das;
|
||||
int? sdf;
|
||||
|
@ -347,14 +342,8 @@ class Handling{
|
|||
bool? cancel;
|
||||
bool? safeLock;
|
||||
|
||||
Handling({
|
||||
this.arr,
|
||||
this.das,
|
||||
this.sdf,
|
||||
this.dcd,
|
||||
this.cancel,
|
||||
this.safeLock
|
||||
});
|
||||
Handling(
|
||||
{this.arr, this.das, this.sdf, this.dcd, this.cancel, this.safeLock});
|
||||
|
||||
Handling.fromJson(Map<String, dynamic> json) {
|
||||
arr = json['arr'];
|
||||
|
@ -377,7 +366,7 @@ class Handling{
|
|||
}
|
||||
}
|
||||
|
||||
class EndContextMulti{
|
||||
class EndContextMulti {
|
||||
String? userId;
|
||||
int? naturalOrder;
|
||||
int? inputs;
|
||||
|
@ -393,8 +382,8 @@ class EndContextMulti{
|
|||
List<double>? extraTracking;
|
||||
bool? success;
|
||||
|
||||
EndContextMulti({
|
||||
this.userId,
|
||||
EndContextMulti(
|
||||
{this.userId,
|
||||
this.naturalOrder,
|
||||
this.inputs,
|
||||
this.piecesPlaced,
|
||||
|
@ -407,14 +396,12 @@ class EndContextMulti{
|
|||
this.tertiaryTracking,
|
||||
this.extra,
|
||||
this.extraTracking,
|
||||
this.success
|
||||
});
|
||||
this.success});
|
||||
|
||||
EndContextMulti.fromJson(Map<String, dynamic> json) {
|
||||
userId = json['user']['_id'];
|
||||
handling = json['handling'] != null
|
||||
? Handling.fromJson(json['handling'])
|
||||
: null;
|
||||
handling =
|
||||
json['handling'] != null ? Handling.fromJson(json['handling']) : null;
|
||||
success = json['success'];
|
||||
inputs = json['inputs'];
|
||||
piecesPlaced = json['piecesplaced'];
|
||||
|
@ -426,7 +413,9 @@ class EndContextMulti{
|
|||
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>();
|
||||
extraTracking = json['points']['extraAvgTracking']
|
||||
['aggregatestats___vsscore']
|
||||
.cast<double>();
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
|
@ -444,12 +433,13 @@ class EndContextMulti{
|
|||
data['points']['secondary'] = secondary;
|
||||
data['points']['tertiary'] = tertiary;
|
||||
data['points']['extra']['vs'] = extra;
|
||||
data['points']['extraAvgTracking']['aggregatestats___vsscore'] = extraTracking;
|
||||
data['points']['extraAvgTracking']['aggregatestats___vsscore'] =
|
||||
extraTracking;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class TetraLeagueAlpha{
|
||||
class TetraLeagueAlpha {
|
||||
String? userId;
|
||||
int? gamesPlayed;
|
||||
int? gamesWon;
|
||||
|
@ -472,8 +462,8 @@ class TetraLeagueAlpha{
|
|||
double? vs;
|
||||
List? records;
|
||||
|
||||
TetraLeagueAlpha({
|
||||
this.userId,
|
||||
TetraLeagueAlpha(
|
||||
{this.userId,
|
||||
this.gamesPlayed,
|
||||
this.gamesWon,
|
||||
this.bestRank,
|
||||
|
@ -493,20 +483,19 @@ class TetraLeagueAlpha{
|
|||
this.apm,
|
||||
this.pps,
|
||||
this.vs,
|
||||
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();
|
||||
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();
|
||||
apm = json['apm']?.toDouble();
|
||||
pps = json['pps']?.toDouble();
|
||||
vs = json['vs']?.toDouble();
|
||||
decaying = json['decaying'];
|
||||
standing = json['standing'];
|
||||
percentile = json['percentile'].toDouble();
|
||||
|
@ -543,7 +532,7 @@ class TetraLeagueAlpha{
|
|||
}
|
||||
}
|
||||
|
||||
class RecordSingle{
|
||||
class RecordSingle {
|
||||
String? userId;
|
||||
String? replayId;
|
||||
String? ownId;
|
||||
|
@ -551,18 +540,19 @@ class RecordSingle{
|
|||
EndContextSingle? endContext;
|
||||
int? rank;
|
||||
|
||||
RecordSingle({
|
||||
this.userId,
|
||||
RecordSingle(
|
||||
{this.userId,
|
||||
this.replayId,
|
||||
this.ownId,
|
||||
this.timestamp,
|
||||
this.endContext,
|
||||
this.rank
|
||||
});
|
||||
this.rank});
|
||||
|
||||
RecordSingle.fromJson(Map<String, dynamic> json) {
|
||||
ownId = json['_id'];
|
||||
endContext = json['endcontext'] != null ? EndContextSingle.fromJson(json['endcontext']) : null;
|
||||
endContext = json['endcontext'] != null
|
||||
? EndContextSingle.fromJson(json['endcontext'])
|
||||
: null;
|
||||
replayId = json['replayid'];
|
||||
timestamp = json['ts'];
|
||||
userId = json['user']['_id'];
|
||||
|
@ -582,16 +572,12 @@ class RecordSingle{
|
|||
}
|
||||
}
|
||||
|
||||
class TetrioZen{
|
||||
class TetrioZen {
|
||||
String? userId;
|
||||
int? level;
|
||||
int? score;
|
||||
|
||||
TetrioZen({
|
||||
this.userId,
|
||||
this.level,
|
||||
this.score
|
||||
});
|
||||
TetrioZen({this.userId, this.level, this.score});
|
||||
|
||||
TetrioZen.fromJson(Map<String, dynamic> json) {
|
||||
level = json['level'];
|
||||
|
|
|
@ -3,6 +3,9 @@ import 'package:http/http.dart' as http;
|
|||
import 'dart:convert';
|
||||
import 'package:tetra_stats/data_objects/tetrio.dart';
|
||||
|
||||
String _searchFor = "";
|
||||
TetrioPlayer me = TetrioPlayer();
|
||||
|
||||
class MainView extends StatefulWidget {
|
||||
const MainView({Key? key}) : super(key: key);
|
||||
|
||||
|
@ -11,8 +14,10 @@ class MainView extends StatefulWidget {
|
|||
}
|
||||
|
||||
class _MainViewState extends State<MainView> {
|
||||
Future<TetrioPlayer> fetchTetrioPlayer() async {
|
||||
final response = await http.get(Uri.parse('https://ch.tetr.io/api/users/dan63047'));
|
||||
Future<TetrioPlayer> fetchTetrioPlayer(String user) async {
|
||||
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 the server did return a 200 OK response,
|
||||
|
@ -24,12 +29,13 @@ class _MainViewState extends State<MainView> {
|
|||
throw Exception('Failed to fetch player');
|
||||
}
|
||||
}
|
||||
|
||||
late Future<TetrioPlayer> me;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
me = fetchTetrioPlayer();
|
||||
me = fetchTetrioPlayer("blaarg");
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -40,21 +46,34 @@ class _MainViewState extends State<MainView> {
|
|||
),
|
||||
body: Row(
|
||||
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>(
|
||||
future: me,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
return Column(
|
||||
children: [
|
||||
return Column(children: [
|
||||
Text(snapshot.data!.username.toString()),
|
||||
Text("Level ${snapshot.data!.getLevel()}"),
|
||||
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")),
|
||||
]
|
||||
);
|
||||
Text(
|
||||
"${snapshot.data!.tlSeason1!.glicko}±${snapshot.data!.tlSeason1!.rd} GLICKO"),
|
||||
Text("${snapshot.data!.zen}")
|
||||
]);
|
||||
} else if (snapshot.hasError) {
|
||||
return Text('${snapshot.error}');
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue