Skip to content

Commit

Permalink
Releasing the CN locale + redesign graphs
Browse files Browse the repository at this point in the history
  • Loading branch information
dan63047 committed Sep 12, 2024
1 parent d0a6946 commit 28f0d0a
Show file tree
Hide file tree
Showing 7 changed files with 415 additions and 206 deletions.
63 changes: 63 additions & 0 deletions lib/data_objects/tetra_league.dart
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,69 @@ class TetraLeague {
pps ?? 0,
vs ?? 0,
decaying);

num? getStatByEnum(Stats stat){
switch (stat) {
case Stats.tr:
return tr;
case Stats.glicko:
return glicko;
case Stats.gxe:
return gxe;
case Stats.s1tr:
return s1tr;
case Stats.rd:
return rd;
case Stats.gp:
return gamesPlayed;
case Stats.gw:
return gamesWon;
case Stats.wr:
return winrate*100;
case Stats.apm:
return apm;
case Stats.pps:
return pps;
case Stats.vs:
return vs;
case Stats.app:
return nerdStats?.app;
case Stats.dss:
return nerdStats?.dss;
case Stats.dsp:
return nerdStats?.dsp;
case Stats.appdsp:
return nerdStats?.appdsp;
case Stats.vsapm:
return nerdStats?.vsapm;
case Stats.cheese:
return nerdStats?.cheese;
case Stats.gbe:
return nerdStats?.gbe;
case Stats.nyaapp:
return nerdStats?.nyaapp;
case Stats.area:
return nerdStats?.area;
case Stats.eTR:
return estTr?.esttr;
case Stats.acceTR:
return esttracc;
case Stats.acceTRabs:
return esttracc?.abs();
case Stats.opener:
return playstyle?.opener;
case Stats.plonk:
return playstyle?.plonk;
case Stats.infDS:
return playstyle?.infds;
case Stats.stride:
return playstyle?.stride;
case Stats.stridemMinusPlonk:
return (playstyle?.stride??0.00) - (playstyle?.plonk??0.00);
case Stats.openerMinusInfDS:
return (playstyle?.opener??0.00) - (playstyle?.infds??0.00);
}
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
Expand Down
6 changes: 3 additions & 3 deletions lib/gen/strings.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/// Locales: 3
/// Strings: 1818 (606 per locale)
///
/// Built on 2024-09-11 at 14:14 UTC
/// Built on 2024-09-12 at 20:23 UTC
// coverage:ignore-file
// ignore_for_file: type=lint
Expand Down Expand Up @@ -1620,7 +1620,7 @@ class _StringsZhCn implements Translations {
many: '只有 ${n} 个记录',
other: '只有 ${n} 个记录',
);
@override String get noRecord => '只有 个记录';
@override String get noRecord => '没有记录';
@override String get botRecord => '机器人不予参加排位赛';
@override String get anonRecord => '匿名用户不予参加排位赛';
@override String get notEnoughData => '没有足够的数据';
Expand Down Expand Up @@ -3580,7 +3580,7 @@ extension on _StringsZhCn {
many: '只有 ${n} 个记录',
other: '只有 ${n} 个记录',
);
case 'noRecord': return ({required Object n}) => '只有 ${n} 个记录';
case 'noRecord': return '没有记录';
case 'botRecord': return '机器人不予参加排位赛';
case 'anonRecord': return '匿名用户不予参加排位赛';
case 'notEnoughData': return '没有足够的数据';
Expand Down
2 changes: 1 addition & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import 'package:sqflite_common_ffi/sqflite_ffi.dart';
import 'package:sqflite_common_ffi_web/sqflite_ffi_web.dart';
import 'package:tetra_stats/gen/strings.g.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:tetra_stats/views/main_view_tiles.dart';
import 'package:tetra_stats/views/main_view.dart';
import 'package:tetra_stats/views/settings_view.dart';
import 'package:tetra_stats/views/tracked_players_view.dart';
import 'package:tetra_stats/views/calc_view.dart';
Expand Down
55 changes: 55 additions & 0 deletions lib/services/tetrio_crud.dart
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,61 @@ class TetrioService extends DB {
}
}

Future<List<Cutoffs>> fetchCutoffsHistory() async {
Uri url = Uri.https('ts.dan63.by', 'beanserver_blaster/history.csv');

try{
final response = await client.get(url);

switch (response.statusCode) {
case 200:
List<List<dynamic>> csv = const CsvToListConverter().convert(response.body)..removeAt(0);
List<Cutoffs> history = [];
for (List<dynamic> entry in csv){
Map<String, double> tr = {};
Map<String, double> glicko = {};
Map<String, double> gxe = {};
for(int i = 0; i < ranks.length; i++){
tr[ranks[ranks.length + i - ranks.length]] = entry[1 + i*3];
glicko[ranks[ranks.length + i - ranks.length]] = entry[2 + i*3];
glicko[ranks[ranks.length + i - ranks.length]] = entry[3 + i*3];
}
history.add(
Cutoffs(
DateTime.fromMillisecondsSinceEpoch(entry[0]),
tr,
glicko,
gxe
)
);
}
return history;
case 404:
developer.log("fetchCutoffsHistory: Cutoffs are gone", name: "services/tetrio_crud", error: response.statusCode);
return [];
// if not 200 or 404 - throw a unique for each code exception
case 403:
throw P1nkl0bst3rForbidden();
case 429:
throw P1nkl0bst3rTooManyRequests();
case 418:
throw TetrioOskwareBridgeProblem();
case 500:
case 502:
case 503:
case 504:
developer.log("fetchCutoffsHistory: Cutoffs are unavalable (${response.statusCode})", name: "services/tetrio_crud", error: response.statusCode);
return [];
default:
developer.log("fetchCutoffsHistory: Failed to fetch top Cutoffs", name: "services/tetrio_crud", error: response.statusCode);
throw ConnectionIssue(response.statusCode, response.reasonPhrase??"No reason");
}
} on http.ClientException catch (e, s) { // If local http client fails
developer.log("$e, $s");
throw http.ClientException(e.message, e.uri); // just assuming, that our end user don't have acess to the internet
}
}

Future<TetrioPlayerFromLeaderboard> fetchTopOneFromTheLeaderboard() async {
TetrioPlayerFromLeaderboard? cached = _cache.get("topone", TetrioPlayerFromLeaderboard);
if (cached != null) return cached;
Expand Down
Loading

0 comments on commit 28f0d0a

Please sign in to comment.