i have to quickly resolve the situation
This commit is contained in:
parent
1824e353c3
commit
9096c423ce
|
@ -1,26 +1,26 @@
|
||||||
import 'dart:convert';
|
// import 'dart:convert';
|
||||||
import 'dart:io';
|
// import 'dart:io';
|
||||||
|
|
||||||
import 'package:path_provider/path_provider.dart';
|
// import 'package:path_provider/path_provider.dart';
|
||||||
|
|
||||||
import 'tetrio_multiplayer_replay.dart';
|
// import 'tetrio_multiplayer_replay.dart';
|
||||||
|
|
||||||
// That thing allows me to test my new staff i'm trying to implement
|
// // That thing allows me to test my new staff i'm trying to implement
|
||||||
void main() async {
|
// void main() async {
|
||||||
// List<Tetromino> queue = List.from(tetrominoes);
|
// // List<Tetromino> queue = List.from(tetrominoes);
|
||||||
// TetrioRNG rng = TetrioRNG(0);
|
// // TetrioRNG rng = TetrioRNG(0);
|
||||||
// queue = rng.shuffleList(queue);
|
// // queue = rng.shuffleList(queue);
|
||||||
// print(queue);
|
// // print(queue);
|
||||||
// queue = List.from(tetrominoes);
|
// // queue = List.from(tetrominoes);
|
||||||
// queue = rng.shuffleList(queue);
|
// // queue = rng.shuffleList(queue);
|
||||||
// print(queue);
|
// // print(queue);
|
||||||
|
|
||||||
//var downloadPath = await getDownloadsDirectory();
|
// //var downloadPath = await getDownloadsDirectory();
|
||||||
var replayJson = jsonDecode(File("/home/dan63047/Документы/replays/6550eecf2ffc5604e6224fc5.ttrm").readAsStringSync());
|
// var replayJson = jsonDecode(File("/home/dan63047/Документы/replays/6550eecf2ffc5604e6224fc5.ttrm").readAsStringSync());
|
||||||
ReplayData replay = ReplayData.fromJson(replayJson);
|
// ReplayData replay = ReplayData.fromJson(replayJson);
|
||||||
//List<List<Tetromino>> board = [for (var i = 0 ; i < 40; i++) [for (var i = 0 ; i < 10; i++) Tetromino.empty]];
|
// //List<List<Tetromino>> board = [for (var i = 0 ; i < 40; i++) [for (var i = 0 ; i < 10; i++) Tetromino.empty]];
|
||||||
List<Event> events = readEventList(replay.rawJson);
|
// List<Event> events = readEventList(replay.rawJson);
|
||||||
events.retainWhere((element) => element.type == EventType.ige);
|
// events.retainWhere((element) => element.type == EventType.ige);
|
||||||
print((events[1] as EventIGE).data.data);
|
// print((events[1] as EventIGE).data.data);
|
||||||
exit(0);
|
// exit(0);
|
||||||
}
|
// }
|
|
@ -271,508 +271,516 @@ class ReplayData{
|
||||||
|
|
||||||
// can't belive i have to implement that difficult shit
|
// can't belive i have to implement that difficult shit
|
||||||
|
|
||||||
List<Event> readEventList(Map<dynamic, dynamic> json){
|
// List<Event> readEventList(Map<dynamic, dynamic> json){
|
||||||
List<Event> events = [];
|
// List<Event> events = [];
|
||||||
int id = 0;
|
// int id = 0;
|
||||||
for (var event in json['data'][0]['replays'][0]['events']){
|
// for (var event in json['data'][0]['replays'][0]['events']){
|
||||||
int frame = event["frame"];
|
// int frame = event["frame"];
|
||||||
EventType type = EventType.values.byName(event['type']);
|
// EventType type = EventType.values.byName(event['type']);
|
||||||
switch (type) {
|
// switch (type) {
|
||||||
case EventType.start:
|
// case EventType.start:
|
||||||
events.add(Event(id, frame, type));
|
// events.add(Event(id, frame, type));
|
||||||
break;
|
// break;
|
||||||
case EventType.full:
|
// case EventType.full:
|
||||||
events.add(EventFull(id, frame, type, DataFull.fromJson(event["data"])));
|
// events.add(EventFull(id, frame, type, DataFull.fromJson(event["data"])));
|
||||||
break;
|
// break;
|
||||||
case EventType.targets:
|
// case EventType.targets:
|
||||||
events.add(EventTargets(id, frame, type, Targets.fromJson(event["data"])));
|
// events.add(EventTargets(id, frame, type, Targets.fromJson(event["data"])));
|
||||||
break;
|
// break;
|
||||||
case EventType.keydown:
|
// case EventType.keydown:
|
||||||
events.add(EventKeyPress(id, frame, type,
|
// events.add(EventKeyPress(id, frame, type,
|
||||||
Keypress(
|
// Keypress(
|
||||||
KeyType.values.byName(event['data']['key']),
|
// KeyType.values.byName(event['data']['key']),
|
||||||
event['data']['subframe'],
|
// event['data']['subframe'],
|
||||||
false)
|
// false)
|
||||||
));
|
// ));
|
||||||
break;
|
// break;
|
||||||
case EventType.keyup:
|
// case EventType.keyup:
|
||||||
events.add(EventKeyPress(id, frame, type,
|
// events.add(EventKeyPress(id, frame, type,
|
||||||
Keypress(
|
// Keypress(
|
||||||
KeyType.values.byName(event['data']['key']),
|
// KeyType.values.byName(event['data']['key']),
|
||||||
event['data']['subframe'],
|
// event['data']['subframe'],
|
||||||
true)
|
// true)
|
||||||
));
|
// ));
|
||||||
break;
|
// break;
|
||||||
case EventType.end:
|
// case EventType.end:
|
||||||
events.add(EventEnd(id, frame, type, EndData(event['data']['reason'], DataFull.fromJson(event['data']['export']))));
|
// events.add(EventEnd(id, frame, type, EndData(event['data']['reason'], DataFull.fromJson(event['data']['export']))));
|
||||||
break;
|
// break;
|
||||||
case EventType.ige:
|
// case EventType.ige:
|
||||||
events.add(EventIGE(id, frame, type, IGE(
|
// events.add(EventIGE(id, frame, type, IGE(
|
||||||
event['data']['id'],
|
// event['data']['id'],
|
||||||
event['data']['frame'],
|
// event['data']['frame'],
|
||||||
event['data']['type'],
|
// event['data']['type'],
|
||||||
event['data']['data']
|
// event['data']['data']
|
||||||
))
|
// ))
|
||||||
);
|
// );
|
||||||
break;
|
// break;
|
||||||
case EventType.exit:
|
// case EventType.exit:
|
||||||
events.add(Event(id, frame, type));
|
// events.add(Event(id, frame, type));
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
id++;
|
// id++;
|
||||||
}
|
// }
|
||||||
return events;
|
// return events;
|
||||||
}
|
// }
|
||||||
|
|
||||||
enum EventType
|
// enum EventType
|
||||||
{
|
// {
|
||||||
start,
|
// start,
|
||||||
end,
|
// end,
|
||||||
full,
|
// full,
|
||||||
keydown,
|
// keydown,
|
||||||
keyup,
|
// keyup,
|
||||||
targets,
|
// targets,
|
||||||
ige,
|
// ige,
|
||||||
exit
|
// exit
|
||||||
}
|
// }
|
||||||
|
|
||||||
enum KeyType
|
// enum KeyType
|
||||||
{
|
// {
|
||||||
moveLeft,
|
// moveLeft,
|
||||||
moveRight,
|
// moveRight,
|
||||||
softDrop,
|
// softDrop,
|
||||||
rotateCCW,
|
// rotateCCW,
|
||||||
rotateCW,
|
// rotateCW,
|
||||||
rotate180,
|
// rotate180,
|
||||||
hardDrop,
|
// hardDrop,
|
||||||
hold,
|
// hold,
|
||||||
chat,
|
// chat,
|
||||||
exit,
|
// exit,
|
||||||
retry
|
// retry
|
||||||
}
|
// }
|
||||||
|
|
||||||
class Event{
|
// class Event{
|
||||||
int id;
|
|
||||||
int frame;
|
|
||||||
EventType type;
|
|
||||||
//dynamic data;
|
|
||||||
|
|
||||||
Event(this.id, this.frame, this.type);
|
|
||||||
|
|
||||||
@override
|
|
||||||
String toString(){
|
|
||||||
return "E#$id f#$frame: $type";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class Keypress{
|
|
||||||
KeyType key;
|
|
||||||
late double subframe;
|
|
||||||
bool released;
|
|
||||||
|
|
||||||
Keypress(this.key, num sframe, this.released){
|
|
||||||
subframe = sframe.toDouble();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class EventKeyPress extends Event{
|
|
||||||
Keypress data;
|
|
||||||
|
|
||||||
EventKeyPress(super.id, super.frame, super.type, this.data);
|
|
||||||
}
|
|
||||||
|
|
||||||
class Targets{
|
|
||||||
String? id;
|
|
||||||
int? frame;
|
|
||||||
String? type;
|
|
||||||
List<String>? data;
|
|
||||||
|
|
||||||
Targets(this.id, this.frame, this.type, this.data);
|
|
||||||
|
|
||||||
Targets.fromJson(Map<String, dynamic> json){
|
|
||||||
id = json["id"];
|
|
||||||
frame = json["frame"];
|
|
||||||
type = json["type"];
|
|
||||||
data = json["data"];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class EventTargets extends Event{
|
|
||||||
Targets data;
|
|
||||||
|
|
||||||
EventTargets(super.id, super.frame, super.type, this.data);
|
|
||||||
}
|
|
||||||
|
|
||||||
class IGEdata{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
enum GarbageStatus
|
|
||||||
{
|
|
||||||
sleeping,
|
|
||||||
caution,
|
|
||||||
spawn,
|
|
||||||
danger
|
|
||||||
}
|
|
||||||
|
|
||||||
// class GarbageData{
|
|
||||||
// int id;
|
// int id;
|
||||||
// int iid;
|
// int frame;
|
||||||
// int ackiid;
|
// EventType type;
|
||||||
// String username;
|
// //dynamic data;
|
||||||
// String type;
|
|
||||||
// bool active;
|
|
||||||
// GarbageStatus status;
|
|
||||||
// int delay;
|
|
||||||
// bool queued;
|
|
||||||
// int amt;
|
|
||||||
// int x;
|
|
||||||
// int y;
|
|
||||||
// int size;
|
|
||||||
// int column;
|
|
||||||
// int cid;
|
|
||||||
// bool firstcycle;
|
|
||||||
// int gid;
|
|
||||||
|
|
||||||
// GarbageData.fromJson(Map<String, dynamic> data){
|
// Event(this.id, this.frame, this.type);
|
||||||
// id;
|
|
||||||
// iid;
|
// @override
|
||||||
// ackiid;
|
// String toString(){
|
||||||
// username;
|
// return "E#$id f#$frame: $type";
|
||||||
// type;
|
|
||||||
// active;
|
|
||||||
// status;
|
|
||||||
// delay;
|
|
||||||
// queued;
|
|
||||||
// amt;
|
|
||||||
// x;
|
|
||||||
// y;
|
|
||||||
// size;
|
|
||||||
// column;
|
|
||||||
// cid;
|
|
||||||
// firstcycle;
|
|
||||||
// gid;
|
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// class IGEdataTarget extends {
|
// class Keypress{
|
||||||
// String type;
|
// KeyType key;
|
||||||
// List<String> targets;
|
// late double subframe;
|
||||||
// int frame;
|
// bool released;
|
||||||
|
|
||||||
|
// Keypress(this.key, num sframe, this.released){
|
||||||
|
// subframe = sframe.toDouble();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// class EventKeyPress extends Event{
|
||||||
|
// Keypress data;
|
||||||
|
|
||||||
|
// EventKeyPress(super.id, super.frame, super.type, this.data);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// class Targets{
|
||||||
|
// String? id;
|
||||||
|
// int? frame;
|
||||||
|
// String? type;
|
||||||
|
// List<String>? data;
|
||||||
|
|
||||||
|
// Targets(this.id, this.frame, this.type, this.data);
|
||||||
|
|
||||||
|
// Targets.fromJson(Map<String, dynamic> json){
|
||||||
|
// id = json["id"];
|
||||||
|
// frame = json["frame"];
|
||||||
|
// type = json["type"];
|
||||||
|
// data = json["data"];
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// class EventTargets extends Event{
|
||||||
|
// Targets data;
|
||||||
|
|
||||||
|
// EventTargets(super.id, super.frame, super.type, this.data);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// class IGEdata{
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
// enum GarbageStatus
|
||||||
|
// {
|
||||||
|
// sleeping,
|
||||||
|
// caution,
|
||||||
|
// spawn,
|
||||||
|
// danger
|
||||||
|
// }
|
||||||
|
|
||||||
|
// class GarbageData{
|
||||||
|
// int? id;
|
||||||
|
// late int iid;
|
||||||
|
// late int ackiid;
|
||||||
|
// String? username;
|
||||||
|
// late String type;
|
||||||
|
// bool? active;
|
||||||
|
// GarbageStatus? status;
|
||||||
|
// int? delay;
|
||||||
|
// bool? queued;
|
||||||
|
// late int amt;
|
||||||
|
// late int x;
|
||||||
|
// late int y;
|
||||||
|
// int? size;
|
||||||
|
// late int column;
|
||||||
|
// int? cid;
|
||||||
|
// bool? firstcycle;
|
||||||
|
// int? gid;
|
||||||
|
|
||||||
|
// GarbageData.fromJson(Map<String, dynamic> data){
|
||||||
|
// id = data['id'];
|
||||||
|
// iid = data['iid'];
|
||||||
|
// ackiid = data['ackiid'];
|
||||||
|
// username = data['username'];
|
||||||
|
// type = data['type'];
|
||||||
|
// active = data['active'];
|
||||||
|
// status = data['status'] != null ? GarbageStatus.values[data['status']] : null;
|
||||||
|
// delay = data['delay'];
|
||||||
|
// queued = data['queued'];
|
||||||
|
// amt = data['amt'];
|
||||||
|
// x = data['x'];
|
||||||
|
// y = data['y'];
|
||||||
|
// size = data['size'];
|
||||||
|
// column = data['column'];
|
||||||
|
// cid = data['cid'];
|
||||||
|
// firstcycle = data['firstcycle'];
|
||||||
|
// gid = data['gid'];
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// class IGEdataTarget extends IGEdata{
|
||||||
|
// late String type;
|
||||||
|
// late List<String> targets;
|
||||||
|
// late int frame;
|
||||||
|
|
||||||
// String gameid
|
// late String gameid;
|
||||||
// GarbageData? data;
|
// GarbageData? data;
|
||||||
// //compatibility for v15 targets event
|
// //compatibility for v15 targets event
|
||||||
// String? sender_id;
|
// String? sender_id;
|
||||||
|
|
||||||
|
// IGEdataTarget.fromJson(Map<String, dynamic> d){
|
||||||
|
// type = d['type'];
|
||||||
|
// targets = d['targets'];
|
||||||
|
// frame = d['targets'];
|
||||||
|
// gameid = d['gameid'];
|
||||||
|
// data = GarbageData.fromJson(d['data']);
|
||||||
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
class IGE{
|
// class IGE{
|
||||||
int id;
|
// int id;
|
||||||
int frame;
|
// int frame;
|
||||||
String type;
|
// String type;
|
||||||
Map<String, dynamic> data;
|
// Map<String, dynamic> data;
|
||||||
|
|
||||||
IGE(this.id, this.frame, this.type, this.data);
|
// IGE(this.id, this.frame, this.type, this.data);
|
||||||
}
|
// }
|
||||||
|
|
||||||
class EventIGE extends Event{
|
// class EventIGE extends Event{
|
||||||
IGE data;
|
// IGE data;
|
||||||
|
|
||||||
EventIGE(super.id, super.frame, super.type, this.data);
|
// EventIGE(super.id, super.frame, super.type, this.data);
|
||||||
}
|
// }
|
||||||
|
|
||||||
class EndData {
|
// class EndData {
|
||||||
String reason;
|
// String reason;
|
||||||
DataFull export;
|
// DataFull export;
|
||||||
|
|
||||||
EndData(this.reason, this.export);
|
// EndData(this.reason, this.export);
|
||||||
}
|
// }
|
||||||
|
|
||||||
class EventEnd extends Event{
|
// class EventEnd extends Event{
|
||||||
EndData data;
|
// EndData data;
|
||||||
|
|
||||||
EventEnd(super.id, super.frame, super.type, this.data);
|
// EventEnd(super.id, super.frame, super.type, this.data);
|
||||||
}
|
// }
|
||||||
|
|
||||||
class Hold
|
// class Hold
|
||||||
{
|
// {
|
||||||
String? piece;
|
// String? piece;
|
||||||
bool locked;
|
// bool locked;
|
||||||
|
|
||||||
Hold(this.piece, this.locked);
|
// Hold(this.piece, this.locked);
|
||||||
}
|
// }
|
||||||
|
|
||||||
class DataFullOptions{
|
// class DataFullOptions{
|
||||||
int? version;
|
// int? version;
|
||||||
bool? seedRandom;
|
// bool? seedRandom;
|
||||||
int? seed;
|
// int? seed;
|
||||||
double? g;
|
// double? g;
|
||||||
int? stock;
|
// int? stock;
|
||||||
int? gMargin;
|
// int? gMargin;
|
||||||
double? gIncrease;
|
// double? gIncrease;
|
||||||
double? garbageMultiplier;
|
// double? garbageMultiplier;
|
||||||
int? garbageMargin;
|
// int? garbageMargin;
|
||||||
double? garbageIncrease;
|
// double? garbageIncrease;
|
||||||
int? garbageCap;
|
// int? garbageCap;
|
||||||
double? garbageCapIncrease;
|
// double? garbageCapIncrease;
|
||||||
int? garbageCapMax;
|
// int? garbageCapMax;
|
||||||
int? garbageHoleSize;
|
// int? garbageHoleSize;
|
||||||
String? garbageBlocking; // TODO: enum
|
// String? garbageBlocking; // TODO: enum
|
||||||
bool? hasGarbage;
|
// bool? hasGarbage;
|
||||||
int? locktime;
|
// int? locktime;
|
||||||
int? garbageSpeed;
|
// int? garbageSpeed;
|
||||||
int? forfeitTime;
|
// int? forfeitTime;
|
||||||
int? are;
|
// int? are;
|
||||||
int? areLineclear;
|
// int? areLineclear;
|
||||||
bool? infiniteMovement;
|
// bool? infiniteMovement;
|
||||||
int? lockresets;
|
// int? lockresets;
|
||||||
bool? allow180;
|
// bool? allow180;
|
||||||
bool? btbChaining;
|
// bool? btbChaining;
|
||||||
bool? allclears;
|
// bool? allclears;
|
||||||
bool? clutch;
|
// bool? clutch;
|
||||||
bool? noLockout;
|
// bool? noLockout;
|
||||||
String? passthrough;
|
// String? passthrough;
|
||||||
int? boardwidth;
|
// int? boardwidth;
|
||||||
int? boardheight;
|
// int? boardheight;
|
||||||
Handling? handling;
|
// Handling? handling;
|
||||||
int? boardbuffer;
|
// int? boardbuffer;
|
||||||
|
|
||||||
DataFullOptions.fromJson(Map<String, dynamic> json){
|
// DataFullOptions.fromJson(Map<String, dynamic> json){
|
||||||
version = json["version"];
|
// version = json["version"];
|
||||||
seedRandom = json["seed_random"];
|
// seedRandom = json["seed_random"];
|
||||||
seed = json["seed"];
|
// seed = json["seed"];
|
||||||
g = json["g"];
|
// g = json["g"];
|
||||||
stock = json["stock"];
|
// stock = json["stock"];
|
||||||
gMargin = json["gmargin"];
|
// gMargin = json["gmargin"];
|
||||||
gIncrease = json["gincrease"];
|
// gIncrease = json["gincrease"];
|
||||||
garbageMultiplier = json["garbagemultiplier"].toDouble();
|
// garbageMultiplier = json["garbagemultiplier"].toDouble();
|
||||||
garbageCapIncrease = json["garbagecapincrease"].toDouble();
|
// garbageCapIncrease = json["garbagecapincrease"].toDouble();
|
||||||
garbageCapMax = json["garbagecapmax"];
|
// garbageCapMax = json["garbagecapmax"];
|
||||||
garbageHoleSize = json["garbageholesize"];
|
// garbageHoleSize = json["garbageholesize"];
|
||||||
garbageBlocking = json["garbageblocking"];
|
// garbageBlocking = json["garbageblocking"];
|
||||||
hasGarbage = json["hasgarbage"];
|
// hasGarbage = json["hasgarbage"];
|
||||||
locktime = json["locktime"];
|
// locktime = json["locktime"];
|
||||||
garbageSpeed = json["garbagespeed"];
|
// garbageSpeed = json["garbagespeed"];
|
||||||
forfeitTime = json["forfeit_time"];
|
// forfeitTime = json["forfeit_time"];
|
||||||
are = json["are"];
|
// are = json["are"];
|
||||||
areLineclear = json["lineclear_are"];
|
// areLineclear = json["lineclear_are"];
|
||||||
infiniteMovement = json["infinitemovement"];
|
// infiniteMovement = json["infinitemovement"];
|
||||||
lockresets = json["lockresets"];
|
// lockresets = json["lockresets"];
|
||||||
allow180 = json["allow180"];
|
// allow180 = json["allow180"];
|
||||||
btbChaining = json["b2bchaining"];
|
// btbChaining = json["b2bchaining"];
|
||||||
allclears = json["allclears"];
|
// allclears = json["allclears"];
|
||||||
clutch = json["clutch"];
|
// clutch = json["clutch"];
|
||||||
noLockout = json["nolockout"];
|
// noLockout = json["nolockout"];
|
||||||
passthrough = json["passthrough"];
|
// passthrough = json["passthrough"];
|
||||||
boardwidth = json["boardwidth"];
|
// boardwidth = json["boardwidth"];
|
||||||
boardheight = json["boardheight"];
|
// boardheight = json["boardheight"];
|
||||||
handling = Handling.fromJson(json["handling"]);
|
// handling = Handling.fromJson(json["handling"]);
|
||||||
boardbuffer = json["boardbuffer"];
|
// boardbuffer = json["boardbuffer"];
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
class DataFullStats
|
// class DataFullStats
|
||||||
{
|
// {
|
||||||
int? seed;
|
// int? seed;
|
||||||
int? lines;
|
// int? lines;
|
||||||
int? levelLines;
|
// int? levelLines;
|
||||||
int? levelLinesNeeded;
|
// int? levelLinesNeeded;
|
||||||
int? inputs;
|
// int? inputs;
|
||||||
int? holds;
|
// int? holds;
|
||||||
int? score;
|
// int? score;
|
||||||
int? zenLevel;
|
// int? zenLevel;
|
||||||
int? zenProgress;
|
// int? zenProgress;
|
||||||
int? level;
|
// int? level;
|
||||||
int? combo;
|
// int? combo;
|
||||||
int? currentComboPower;
|
// int? currentComboPower;
|
||||||
int? topCombo;
|
// int? topCombo;
|
||||||
int? btb;
|
// int? btb;
|
||||||
int? topbtb;
|
// int? topbtb;
|
||||||
int? tspins;
|
// int? tspins;
|
||||||
int? piecesPlaced;
|
// int? piecesPlaced;
|
||||||
Clears? clears;
|
// Clears? clears;
|
||||||
Garbage? garbage;
|
// Garbage? garbage;
|
||||||
int? kills;
|
// int? kills;
|
||||||
Finesse? finesse;
|
// Finesse? finesse;
|
||||||
|
|
||||||
DataFullStats.fromJson(Map<String, dynamic> json){
|
// DataFullStats.fromJson(Map<String, dynamic> json){
|
||||||
seed = json["seed"];
|
// seed = json["seed"];
|
||||||
lines = json["lines"];
|
// lines = json["lines"];
|
||||||
levelLines = json["level_lines"];
|
// levelLines = json["level_lines"];
|
||||||
levelLinesNeeded = json["level_lines_needed"];
|
// levelLinesNeeded = json["level_lines_needed"];
|
||||||
inputs = json["inputs"];
|
// inputs = json["inputs"];
|
||||||
holds = json["holds"];
|
// holds = json["holds"];
|
||||||
score = json["score"];
|
// score = json["score"];
|
||||||
zenLevel = json["zenlevel"];
|
// zenLevel = json["zenlevel"];
|
||||||
zenProgress = json["zenprogress"];
|
// zenProgress = json["zenprogress"];
|
||||||
level = json["level"];
|
// level = json["level"];
|
||||||
combo = json["combo"];
|
// combo = json["combo"];
|
||||||
currentComboPower = json["currentcombopower"];
|
// currentComboPower = json["currentcombopower"];
|
||||||
topCombo = json["topcombo"];
|
// topCombo = json["topcombo"];
|
||||||
btb = json["btb"];
|
// btb = json["btb"];
|
||||||
topbtb = json["topbtb"];
|
// topbtb = json["topbtb"];
|
||||||
tspins = json["tspins"];
|
// tspins = json["tspins"];
|
||||||
piecesPlaced = json["piecesplaced"];
|
// piecesPlaced = json["piecesplaced"];
|
||||||
clears = Clears.fromJson(json["clears"]);
|
// clears = Clears.fromJson(json["clears"]);
|
||||||
garbage = Garbage.fromJson(json["garbage"]);
|
// garbage = Garbage.fromJson(json["garbage"]);
|
||||||
kills = json["kills"];
|
// kills = json["kills"];
|
||||||
finesse = Finesse.fromJson(json["finesse"]);
|
// finesse = Finesse.fromJson(json["finesse"]);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
class DataFullGame
|
// class DataFullGame
|
||||||
{
|
// {
|
||||||
List<dynamic>? board;
|
// List<dynamic>? board;
|
||||||
List<dynamic>? bag;
|
// List<dynamic>? bag;
|
||||||
double? g;
|
// double? g;
|
||||||
bool? playing;
|
// bool? playing;
|
||||||
Hold? hold;
|
// Hold? hold;
|
||||||
String? piece;
|
// String? piece;
|
||||||
Handling? handling;
|
// Handling? handling;
|
||||||
|
|
||||||
DataFullGame.fromJson(Map<String, dynamic> json){
|
// DataFullGame.fromJson(Map<String, dynamic> json){
|
||||||
board = json["board"];
|
// board = json["board"];
|
||||||
bag = json["bag"];
|
// bag = json["bag"];
|
||||||
hold = Hold(json["hold"]["piece"], json["hold"]["locked"]);
|
// hold = Hold(json["hold"]["piece"], json["hold"]["locked"]);
|
||||||
g = json["g"];
|
// g = json["g"];
|
||||||
handling = Handling.fromJson(json["handling"]);
|
// handling = Handling.fromJson(json["handling"]);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
class DataFull{
|
// class DataFull{
|
||||||
bool? successful;
|
// bool? successful;
|
||||||
String? gameOverReason;
|
// String? gameOverReason;
|
||||||
int? fire;
|
// int? fire;
|
||||||
DataFullOptions? options;
|
// DataFullOptions? options;
|
||||||
DataFullStats? stats;
|
// DataFullStats? stats;
|
||||||
DataFullGame? game;
|
// DataFullGame? game;
|
||||||
|
|
||||||
DataFull.fromJson(Map<String, dynamic> json){
|
// DataFull.fromJson(Map<String, dynamic> json){
|
||||||
successful = json["successful"];
|
// successful = json["successful"];
|
||||||
gameOverReason = json["gameoverreason"];
|
// gameOverReason = json["gameoverreason"];
|
||||||
fire = json["fire"];
|
// fire = json["fire"];
|
||||||
options = DataFullOptions.fromJson(json["options"]);
|
// options = DataFullOptions.fromJson(json["options"]);
|
||||||
stats = DataFullStats.fromJson(json["stats"]);
|
// stats = DataFullStats.fromJson(json["stats"]);
|
||||||
game = DataFullGame.fromJson(json["game"]);
|
// game = DataFullGame.fromJson(json["game"]);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
class EventFull extends Event{
|
// class EventFull extends Event{
|
||||||
DataFull data;
|
// DataFull data;
|
||||||
|
|
||||||
EventFull(super.id, super.frame, super.type, this.data);
|
// EventFull(super.id, super.frame, super.type, this.data);
|
||||||
}
|
// }
|
||||||
|
|
||||||
class TetrioRNG{
|
// class TetrioRNG{
|
||||||
late double _t;
|
// late double _t;
|
||||||
|
|
||||||
TetrioRNG(int seed){
|
// TetrioRNG(int seed){
|
||||||
_t = seed % 2147483647;
|
// _t = seed % 2147483647;
|
||||||
if (_t <= 0) _t += 2147483646;
|
// if (_t <= 0) _t += 2147483646;
|
||||||
}
|
// }
|
||||||
|
|
||||||
int next(){
|
// int next(){
|
||||||
_t = 16807 * _t % 2147483647;
|
// _t = 16807 * _t % 2147483647;
|
||||||
return _t.toInt();
|
// return _t.toInt();
|
||||||
}
|
// }
|
||||||
|
|
||||||
double nextFloat(){
|
// double nextFloat(){
|
||||||
return (next() - 1) / 2147483646;
|
// return (next() - 1) / 2147483646;
|
||||||
}
|
// }
|
||||||
|
|
||||||
List<Tetromino> shuffleList(List<Tetromino> array){
|
// List<Tetromino> shuffleList(List<Tetromino> array){
|
||||||
int length = array.length;
|
// int length = array.length;
|
||||||
if (length == 0) return [];
|
// if (length == 0) return [];
|
||||||
|
|
||||||
for (; --length > 0;){
|
// for (; --length > 0;){
|
||||||
int swapIndex = ((nextFloat()) * (length + 1)).toInt();
|
// int swapIndex = ((nextFloat()) * (length + 1)).toInt();
|
||||||
Tetromino tmp = array[length];
|
// Tetromino tmp = array[length];
|
||||||
array[length] = array[swapIndex];
|
// array[length] = array[swapIndex];
|
||||||
array[swapIndex] = tmp;
|
// array[swapIndex] = tmp;
|
||||||
}
|
// }
|
||||||
return array;
|
// return array;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
enum Tetromino{
|
// enum Tetromino{
|
||||||
Z,
|
// Z,
|
||||||
L,
|
// L,
|
||||||
O,
|
// O,
|
||||||
S,
|
// S,
|
||||||
I,
|
// I,
|
||||||
J,
|
// J,
|
||||||
T,
|
// T,
|
||||||
garbage,
|
// garbage,
|
||||||
empty
|
// empty
|
||||||
}
|
// }
|
||||||
|
|
||||||
List<Tetromino> tetrominoes = [Tetromino.Z, Tetromino.L, Tetromino.O, Tetromino.S, Tetromino.I, Tetromino.J, Tetromino.T];
|
// List<Tetromino> tetrominoes = [Tetromino.Z, Tetromino.L, Tetromino.O, Tetromino.S, Tetromino.I, Tetromino.J, Tetromino.T];
|
||||||
List<List<List<Vector2>>> shapes = [
|
// List<List<List<Vector2>>> shapes = [
|
||||||
[ // Z
|
// [ // Z
|
||||||
[Vector2(0, 0), Vector2(1, 0), Vector2(1, 1), Vector2(2, 1)],
|
// [Vector2(0, 0), Vector2(1, 0), Vector2(1, 1), Vector2(2, 1)],
|
||||||
[Vector2(2, 0), Vector2(1, 1), Vector2(2, 1), Vector2(1, 2)],
|
// [Vector2(2, 0), Vector2(1, 1), Vector2(2, 1), Vector2(1, 2)],
|
||||||
[Vector2(0, 1), Vector2(1, 1), Vector2(1, 2), Vector2(2, 2)],
|
// [Vector2(0, 1), Vector2(1, 1), Vector2(1, 2), Vector2(2, 2)],
|
||||||
[Vector2(1, 0), Vector2(0, 1), Vector2(1, 1), Vector2(0, 2)]
|
// [Vector2(1, 0), Vector2(0, 1), Vector2(1, 1), Vector2(0, 2)]
|
||||||
],
|
// ],
|
||||||
[ // L
|
// [ // L
|
||||||
[Vector2(2, 0), Vector2(0, 1), Vector2(1, 1), Vector2(2, 1)],
|
// [Vector2(2, 0), Vector2(0, 1), Vector2(1, 1), Vector2(2, 1)],
|
||||||
[Vector2(1, 0), Vector2(1, 1), Vector2(1, 2), Vector2(2, 2)],
|
// [Vector2(1, 0), Vector2(1, 1), Vector2(1, 2), Vector2(2, 2)],
|
||||||
[Vector2(0, 1), Vector2(1, 1), Vector2(2, 1), Vector2(0, 2)],
|
// [Vector2(0, 1), Vector2(1, 1), Vector2(2, 1), Vector2(0, 2)],
|
||||||
[Vector2(0, 0), Vector2(1, 0), Vector2(1, 1), Vector2(1, 2)]
|
// [Vector2(0, 0), Vector2(1, 0), Vector2(1, 1), Vector2(1, 2)]
|
||||||
],
|
// ],
|
||||||
[ // O
|
// [ // O
|
||||||
[Vector2(0, 0), Vector2(1, 0), Vector2(0, 1), Vector2(1, 1)],
|
// [Vector2(0, 0), Vector2(1, 0), Vector2(0, 1), Vector2(1, 1)],
|
||||||
[Vector2(0, 0), Vector2(1, 0), Vector2(0, 1), Vector2(1, 1)],
|
// [Vector2(0, 0), Vector2(1, 0), Vector2(0, 1), Vector2(1, 1)],
|
||||||
[Vector2(0, 0), Vector2(1, 0), Vector2(0, 1), Vector2(1, 1)],
|
// [Vector2(0, 0), Vector2(1, 0), Vector2(0, 1), Vector2(1, 1)],
|
||||||
[Vector2(0, 0), Vector2(1, 0), Vector2(0, 1), Vector2(1, 1)]
|
// [Vector2(0, 0), Vector2(1, 0), Vector2(0, 1), Vector2(1, 1)]
|
||||||
],
|
// ],
|
||||||
[ // S
|
// [ // S
|
||||||
[Vector2(1, 0), Vector2(2, 0), Vector2(0, 1), Vector2(1, 1)],
|
// [Vector2(1, 0), Vector2(2, 0), Vector2(0, 1), Vector2(1, 1)],
|
||||||
[Vector2(1, 0), Vector2(1, 1), Vector2(2, 1), Vector2(2, 2)],
|
// [Vector2(1, 0), Vector2(1, 1), Vector2(2, 1), Vector2(2, 2)],
|
||||||
[Vector2(1, 1), Vector2(2, 1), Vector2(0, 2), Vector2(1, 2)],
|
// [Vector2(1, 1), Vector2(2, 1), Vector2(0, 2), Vector2(1, 2)],
|
||||||
[Vector2(0, 0), Vector2(0, 1), Vector2(1, 1), Vector2(1, 2)]
|
// [Vector2(0, 0), Vector2(0, 1), Vector2(1, 1), Vector2(1, 2)]
|
||||||
],
|
// ],
|
||||||
[ // I
|
// [ // I
|
||||||
[Vector2(0, 1), Vector2(1, 1), Vector2(2, 1), Vector2(3, 1)],
|
// [Vector2(0, 1), Vector2(1, 1), Vector2(2, 1), Vector2(3, 1)],
|
||||||
[Vector2(2, 0), Vector2(2, 1), Vector2(2, 2), Vector2(2, 3)],
|
// [Vector2(2, 0), Vector2(2, 1), Vector2(2, 2), Vector2(2, 3)],
|
||||||
[Vector2(0, 2), Vector2(1, 2), Vector2(2, 2), Vector2(3, 2)],
|
// [Vector2(0, 2), Vector2(1, 2), Vector2(2, 2), Vector2(3, 2)],
|
||||||
[Vector2(1, 0), Vector2(1, 1), Vector2(1, 2), Vector2(1, 3)]
|
// [Vector2(1, 0), Vector2(1, 1), Vector2(1, 2), Vector2(1, 3)]
|
||||||
],
|
// ],
|
||||||
[ // J
|
// [ // J
|
||||||
[Vector2(0, 0), Vector2(0, 1), Vector2(1, 1), Vector2(2, 1)],
|
// [Vector2(0, 0), Vector2(0, 1), Vector2(1, 1), Vector2(2, 1)],
|
||||||
[Vector2(1, 0), Vector2(2, 0), Vector2(1, 1), Vector2(1, 2)],
|
// [Vector2(1, 0), Vector2(2, 0), Vector2(1, 1), Vector2(1, 2)],
|
||||||
[Vector2(0, 1), Vector2(1, 1), Vector2(2, 1), Vector2(2, 2)],
|
// [Vector2(0, 1), Vector2(1, 1), Vector2(2, 1), Vector2(2, 2)],
|
||||||
[Vector2(1, 0), Vector2(1, 1), Vector2(0, 2), Vector2(1, 2)]
|
// [Vector2(1, 0), Vector2(1, 1), Vector2(0, 2), Vector2(1, 2)]
|
||||||
],
|
// ],
|
||||||
[ // T
|
// [ // T
|
||||||
[Vector2(1, 0), Vector2(0, 1), Vector2(1, 1), Vector2(2, 1)],
|
// [Vector2(1, 0), Vector2(0, 1), Vector2(1, 1), Vector2(2, 1)],
|
||||||
[Vector2(1, 0), Vector2(1, 1), Vector2(2, 1), Vector2(1, 2)],
|
// [Vector2(1, 0), Vector2(1, 1), Vector2(2, 1), Vector2(1, 2)],
|
||||||
[Vector2(0, 1), Vector2(1, 1), Vector2(2, 1), Vector2(1, 2)],
|
// [Vector2(0, 1), Vector2(1, 1), Vector2(2, 1), Vector2(1, 2)],
|
||||||
[Vector2(1, 0), Vector2(0, 1), Vector2(1, 1), Vector2(1, 2)]
|
// [Vector2(1, 0), Vector2(0, 1), Vector2(1, 1), Vector2(1, 2)]
|
||||||
]
|
// ]
|
||||||
];
|
// ];
|
||||||
List<Vector2> spawnPositionFixes = [Vector2(1, 1), Vector2(1, 1), Vector2(0, 1), Vector2(1, 1), Vector2(1, 1), Vector2(1, 1), Vector2(1, 1)];
|
// List<Vector2> spawnPositionFixes = [Vector2(1, 1), Vector2(1, 1), Vector2(0, 1), Vector2(1, 1), Vector2(1, 1), Vector2(1, 1), Vector2(1, 1)];
|
||||||
|
|
||||||
const Map<String, double> garbage = {
|
// const Map<String, double> garbage = {
|
||||||
"single": 0,
|
// "single": 0,
|
||||||
"double": 1,
|
// "double": 1,
|
||||||
"triple": 2,
|
// "triple": 2,
|
||||||
"quad": 4,
|
// "quad": 4,
|
||||||
"penta": 5,
|
// "penta": 5,
|
||||||
"t-spin": 0,
|
// "t-spin": 0,
|
||||||
"t-spin single": 2,
|
// "t-spin single": 2,
|
||||||
"t-spin double": 4,
|
// "t-spin double": 4,
|
||||||
"t-spin triple": 6,
|
// "t-spin triple": 6,
|
||||||
"t-spin quad": 10,
|
// "t-spin quad": 10,
|
||||||
"t-spin penta": 12,
|
// "t-spin penta": 12,
|
||||||
"t-spin mini": 0,
|
// "t-spin mini": 0,
|
||||||
"t-spin mini single": 0,
|
// "t-spin mini single": 0,
|
||||||
"t-spin mini double": 1,
|
// "t-spin mini double": 1,
|
||||||
"allclear": 10
|
// "allclear": 10
|
||||||
};
|
// };
|
||||||
int btbBonus = 1;
|
// int btbBonus = 1;
|
||||||
double btbLog = 0.8;
|
// double btbLog = 0.8;
|
||||||
double comboBonus = 0.25;
|
// double comboBonus = 0.25;
|
||||||
int comboMinifier = 1;
|
// int comboMinifier = 1;
|
||||||
double comboMinifierLog = 1.25;
|
// double comboMinifierLog = 1.25;
|
||||||
List<int> comboTable = [0, 1, 1, 2, 2, 3, 3, 4, 4, 4, 5];
|
// List<int> comboTable = [0, 1, 1, 2, 2, 3, 3, 4, 4, 4, 5];
|
||||||
|
|
|
@ -379,7 +379,6 @@ class TetrioService extends DB {
|
||||||
TopTr result = TopTr(id, null);
|
TopTr result = TopTr(id, null);
|
||||||
developer.log("fetchTopTR: Probably, player doesn't have top TR", name: "services/tetrio_crud", error: response.statusCode);
|
developer.log("fetchTopTR: Probably, player doesn't have top TR", name: "services/tetrio_crud", error: response.statusCode);
|
||||||
_cache.store(result, DateTime.now().millisecondsSinceEpoch + 300000);
|
_cache.store(result, DateTime.now().millisecondsSinceEpoch + 300000);
|
||||||
//_topTRcache[(DateTime.now().millisecondsSinceEpoch + 300000).toString()] = {id: null};
|
|
||||||
return result;
|
return result;
|
||||||
// if not 200 or 404 - throw a unique for each code exception
|
// if not 200 or 404 - throw a unique for each code exception
|
||||||
case 403:
|
case 403:
|
||||||
|
@ -392,7 +391,10 @@ class TetrioService extends DB {
|
||||||
case 502:
|
case 502:
|
||||||
case 503:
|
case 503:
|
||||||
case 504:
|
case 504:
|
||||||
throw P1nkl0bst3rInternalProblem();
|
TopTr result = TopTr(id, null);
|
||||||
|
developer.log("fetchTopTR: API returned ${response.statusCode}", name: "services/tetrio_crud", error: response.statusCode);
|
||||||
|
//_cache.store(result, DateTime.now().millisecondsSinceEpoch + 300000);
|
||||||
|
return result;
|
||||||
default:
|
default:
|
||||||
developer.log("fetchTopTR: Failed to fetch top TR", name: "services/tetrio_crud", error: response.statusCode);
|
developer.log("fetchTopTR: Failed to fetch top TR", name: "services/tetrio_crud", error: response.statusCode);
|
||||||
throw ConnectionIssue(response.statusCode, response.reasonPhrase??"No reason");
|
throw ConnectionIssue(response.statusCode, response.reasonPhrase??"No reason");
|
||||||
|
@ -445,7 +447,8 @@ class TetrioService extends DB {
|
||||||
case 502:
|
case 502:
|
||||||
case 503:
|
case 503:
|
||||||
case 504:
|
case 504:
|
||||||
throw P1nkl0bst3rInternalProblem();
|
developer.log("fetchCutoffs: Cutoffs are unavalable (${response.statusCode})", name: "services/tetrio_crud", error: response.statusCode);
|
||||||
|
return null;
|
||||||
default:
|
default:
|
||||||
developer.log("fetchCutoffs: Failed to fetch top Cutoffs", name: "services/tetrio_crud", error: response.statusCode);
|
developer.log("fetchCutoffs: Failed to fetch top Cutoffs", name: "services/tetrio_crud", error: response.statusCode);
|
||||||
throw ConnectionIssue(response.statusCode, response.reasonPhrase??"No reason");
|
throw ConnectionIssue(response.statusCode, response.reasonPhrase??"No reason");
|
||||||
|
|
Loading…
Reference in New Issue