Can read events, but ige events are pain in the ass

This commit is contained in:
dan63047 2024-06-18 23:20:42 +03:00
parent 232aa71e75
commit 1824e353c3
3 changed files with 99 additions and 26 deletions

View File

@ -7,20 +7,20 @@ 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]];
//print(replay.rawJson); List<Event> events = readEventList(replay.rawJson);
events.retainWhere((element) => element.type == EventType.ige);
print(""); print((events[1] as EventIGE).data.data);
exit(0); exit(0);
} }

View File

@ -304,16 +304,24 @@ List<Event> readEventList(Map<dynamic, dynamic> json){
)); ));
break; break;
case EventType.end: case EventType.end:
event.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:
// TODO: Handle this case. events.add(EventIGE(id, frame, type, IGE(
event['data']['id'],
event['data']['frame'],
event['data']['type'],
event['data']['data']
))
);
break;
case EventType.exit: case EventType.exit:
events.add(Event(id, frame, type)); events.add(Event(id, frame, type));
break;
} }
id++; id++;
} }
return []; return events;
} }
enum EventType enum EventType
@ -359,10 +367,12 @@ class Event{
class Keypress{ class Keypress{
KeyType key; KeyType key;
double subframe; late double subframe;
bool released; bool released;
Keypress(this.key, this.subframe, this.released); Keypress(this.key, num sframe, this.released){
subframe = sframe.toDouble();
}
} }
class EventKeyPress extends Event{ class EventKeyPress extends Event{
@ -393,13 +403,76 @@ class EventTargets extends Event{
EventTargets(super.id, super.frame, super.type, this.data); EventTargets(super.id, super.frame, super.type, this.data);
} }
class IGEdata{
}
enum GarbageStatus
{
sleeping,
caution,
spawn,
danger
}
// class GarbageData{
// int id;
// int iid;
// int ackiid;
// String username;
// 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){
// id;
// iid;
// ackiid;
// username;
// type;
// active;
// status;
// delay;
// queued;
// amt;
// x;
// y;
// size;
// column;
// cid;
// firstcycle;
// gid;
// }
// }
// class IGEdataTarget extends {
// String type;
// List<String> targets;
// int frame;
// String gameid
// GarbageData? data;
// //compatibility for v15 targets event
// String? sender_id;
// }
class IGE{ class IGE{
int id; int id;
int frame; int frame;
String type; String type;
int amount; Map<String, dynamic> data;
IGE(this.id, this.frame, this.type, this.amount); IGE(this.id, this.frame, this.type, this.data);
} }
class EventIGE extends Event{ class EventIGE extends Event{
@ -472,8 +545,8 @@ class DataFullOptions{
stock = json["stock"]; stock = json["stock"];
gMargin = json["gmargin"]; gMargin = json["gmargin"];
gIncrease = json["gincrease"]; gIncrease = json["gincrease"];
garbageMultiplier = json["garbagemultiplier"]; garbageMultiplier = json["garbagemultiplier"].toDouble();
garbageCapIncrease = json["garbagecapincrease"]; garbageCapIncrease = json["garbagecapincrease"].toDouble();
garbageCapMax = json["garbagecapmax"]; garbageCapMax = json["garbagecapmax"];
garbageHoleSize = json["garbageholesize"]; garbageHoleSize = json["garbageholesize"];
garbageBlocking = json["garbageblocking"]; garbageBlocking = json["garbageblocking"];
@ -500,7 +573,7 @@ class DataFullOptions{
class DataFullStats class DataFullStats
{ {
double? seed; int? seed;
int? lines; int? lines;
int? levelLines; int? levelLines;
int? levelLinesNeeded; int? levelLinesNeeded;
@ -549,8 +622,8 @@ class DataFullStats
class DataFullGame class DataFullGame
{ {
List<List<String?>>? board; List<dynamic>? board;
List<String>? bag; List<dynamic>? bag;
double? g; double? g;
bool? playing; bool? playing;
Hold? hold; Hold? hold;

View File

@ -57,8 +57,8 @@ class _TLThingyState extends State<TLThingy> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final t = Translations.of(context); final t = Translations.of(context);
String decimalSeparator = f2.symbols.DECIMAL_SEP; String decimalSeparator = f2.symbols.DECIMAL_SEP;
List<String> estTRformated = f2.format(currentTl.estTr!.esttr).split(decimalSeparator); List<String> estTRformated = currentTl.estTr != null ? f2.format(currentTl.estTr!.esttr).split(decimalSeparator) : [];
List<String> estTRaccFormated = intFDiff.format(currentTl.esttracc!).split("."); List<String> estTRaccFormated = currentTl.esttracc != null ? intFDiff.format(currentTl.esttracc!).split(".") : [];
if (currentTl.gamesPlayed == 0) return Center(child: Text(widget.guest ? t.anonTL : widget.bot ? t.botTL : t.neverPlayedTL, style: const TextStyle(fontFamily: "Eurostile Round", fontSize: 28), textAlign: TextAlign.center,)); if (currentTl.gamesPlayed == 0) return Center(child: Text(widget.guest ? t.anonTL : widget.bot ? t.botTL : t.neverPlayedTL, style: const TextStyle(fontFamily: "Eurostile Round", fontSize: 28), textAlign: TextAlign.center,));
return LayoutBuilder(builder: (context, constraints) { return LayoutBuilder(builder: (context, constraints) {
bool bigScreen = constraints.maxWidth >= 768; bool bigScreen = constraints.maxWidth >= 768;