diff --git a/lib/data_objects/tetrio.dart b/lib/data_objects/tetrio.dart index 79def98..ba79b51 100644 --- a/lib/data_objects/tetrio.dart +++ b/lib/data_objects/tetrio.dart @@ -340,10 +340,6 @@ class TetrioPlayer { return tlSeason1!.lessStrictCheck(other.tlSeason1!); } - TetrioPlayerFromLeaderboard convertToPlayerFromLeaderboard() => TetrioPlayerFromLeaderboard( - userId, username, role, xp, country, state, gamesPlayed, gamesWon, - tlSeason1!.tr, tlSeason1!.glicko??0, tlSeason1!.rd??noTrRd, tlSeason1!.rank, tlSeason1!.bestRank, tlSeason1!.apm??0, tlSeason1!.pps??0, tlSeason1!.vs??0, tlSeason1!.decaying); - @override String toString() { return "$username ($state)"; @@ -1453,6 +1449,10 @@ class TetraLeague { double? get esttracc => (estTr != null) ? estTr!.esttr - tr : null; + TetrioPlayerFromLeaderboard convertToPlayerFromLeaderboard(String id) => TetrioPlayerFromLeaderboard( + id, "", "user", -1, null, timestamp, gamesPlayed, gamesWon, + tr, glicko??0, rd??noTrRd, rank, bestRank, apm??0, pps??0, vs??0, decaying); + Map toJson() { final Map data = {}; if (gamesPlayed > 0) data['gamesplayed'] = gamesPlayed; @@ -2337,21 +2337,21 @@ class TetrioPlayersLeaderboard { } } - PlayerLeaderboardPosition? getLeaderboardPosition(TetrioPlayer user) { - if (user.tlSeason1?.gamesPlayed == 0) return null; + PlayerLeaderboardPosition? getLeaderboardPosition(Mapleague) { + if (league.values.first.gamesPlayed == 0) return null; bool fakePositions = false; late List copyOfLeaderboard; - if (leaderboard.indexWhere((element) => element.userId == user.userId) == -1){ + if (leaderboard.indexWhere((element) => element.userId == league.keys.first) == -1){ fakePositions =true; copyOfLeaderboard = List.of(leaderboard); - copyOfLeaderboard.add(user.convertToPlayerFromLeaderboard()); + copyOfLeaderboard.add(league.values.first.convertToPlayerFromLeaderboard(league.keys.first)); } List stats = [Stats.apm, Stats.pps, Stats.vs, Stats.gp, Stats.gw, Stats.wr, Stats.app, Stats.vsapm, Stats.dss, Stats.dsp, Stats.appdsp, Stats.cheese, Stats.gbe, Stats.nyaapp, Stats.area, Stats.eTR, Stats.acceTR]; List results = []; for (Stats stat in stats) { List sortedLeaderboard = getStatRanking(fakePositions ? copyOfLeaderboard : leaderboard, stat, reversed: stat == Stats.cheese ? true : false); - int position = sortedLeaderboard.indexWhere((element) => element.userId == user.userId) + 1; + int position = sortedLeaderboard.indexWhere((element) => element.userId == league.keys.first) + 1; if (position == 0) { results.add(null); } else { diff --git a/lib/services/custom_http_client.dart b/lib/services/custom_http_client.dart index e19b56e..c244a4f 100644 --- a/lib/services/custom_http_client.dart +++ b/lib/services/custom_http_client.dart @@ -1,5 +1,6 @@ import 'dart:math'; +import 'package:flutter/foundation.dart'; import 'package:http/http.dart' as http; class UserAgentClient extends http.BaseClient { @@ -11,7 +12,7 @@ class UserAgentClient extends http.BaseClient { @override Future send(http.BaseRequest request) { request.headers['user-agent'] = userAgent; - request.headers['X-Session-ID'] = "${Random().nextInt(1<<32)}"; + if (!kIsWeb) request.headers['X-Session-ID'] = "${Random().nextInt(1<<32)}"; return _inner.send(request); } } \ No newline at end of file diff --git a/lib/services/tetrio_crud.dart b/lib/services/tetrio_crud.dart index 05352ae..d27a2e6 100644 --- a/lib/services/tetrio_crud.dart +++ b/lib/services/tetrio_crud.dart @@ -411,7 +411,7 @@ class TetrioService extends DB { Cutoffs? cached = _cache.get("", Cutoffs); if (cached != null) return cached; - Uri url = Uri.https('ts.dan63.by', 'beanserver_blaster/cutoffs.json', {"users": null}); + Uri url = Uri.https('ts.dan63.by', 'beanserver_blaster/cutoffs.json'); try{ final response = await client.get(url); diff --git a/lib/views/main_view.dart b/lib/views/main_view.dart index 1fbdc79..b160e99 100644 --- a/lib/views/main_view.dart +++ b/lib/views/main_view.dart @@ -199,7 +199,7 @@ class _MainState extends State with TickerProviderStateMixin { everyone = teto.getCachedLeaderboard(); everyone ??= await teto.fetchTLLeaderboard(); if (meAmongEveryone == null && everyone!.leaderboard.isNotEmpty){ - meAmongEveryone = await compute(everyone!.getLeaderboardPosition, me); + meAmongEveryone = await compute(everyone!.getLeaderboardPosition, {me.userId: summaries.league}); if (meAmongEveryone != null) teto.cacheLeaderboardPositions(me.userId, meAmongEveryone!); } } @@ -216,7 +216,7 @@ class _MainState extends State with TickerProviderStateMixin { // if (everyone != null && summaries.league.gamesPlayed > 9) rankAverages = everyone?.averages[summaries.league.percentileRank]?[0]; // Making list of Tetra League matches - bool isTracking = await teto.isPlayerTracking(me.userId); + //bool isTracking = await teto.isPlayerTracking(me.userId); List states = []; TetraLeague? compareWith; Set uniqueTL = {}; @@ -274,7 +274,7 @@ class _MainState extends State with TickerProviderStateMixin { states.addAll(await teto.getPlayer(me.userId)); for (var element in states) { // For graphs I need only unique entries if (element.tlSeason1 != null && uniqueTL.isNotEmpty && uniqueTL.last != element.tlSeason1) uniqueTL.add(element.tlSeason1!); - if (uniqueTL.isEmpty) uniqueTL.add(element.tlSeason1!); + if (uniqueTL.isEmpty) uniqueTL.add(summaries.league); } // Also i need previous Tetra League State for comparison if avaliable if (uniqueTL.length >= 2){ diff --git a/lib/views/ranks_averages_view.dart b/lib/views/ranks_averages_view.dart index 78c5bbd..1749c6a 100644 --- a/lib/views/ranks_averages_view.dart +++ b/lib/views/ranks_averages_view.dart @@ -108,7 +108,7 @@ class RanksAverages extends State { ), Padding( padding: const EdgeInsets.only(right: 8.0), - child: Text(f2.format(snapshot.data!.gxe[rank]), textAlign: TextAlign.right, style: TextStyle(fontFamily: bigScreen ? "Eurostile Round" : "Eurostile Round Condensed", fontSize: 28, fontWeight: FontWeight.w500, color: Colors.white, shadows: textShadow)), + child: Text(f3.format(snapshot.data!.gxe[rank]), textAlign: TextAlign.right, style: TextStyle(fontFamily: bigScreen ? "Eurostile Round" : "Eurostile Round Condensed", fontSize: 28, fontWeight: FontWeight.w500, color: Colors.white, shadows: textShadow)), ), Padding( padding: const EdgeInsets.only(right: 8.0), diff --git a/pubspec.yaml b/pubspec.yaml index bf95d9e..ea53554 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,7 @@ name: tetra_stats description: Track your and other player stats in TETR.IO publish_to: 'none' -version: 1.6.4+30 +version: 1.6.5+31 environment: sdk: '>=3.0.0'