Skip to content

Commit 42de52a

Browse files
author
CSDotNET
committed
add converter to handle exit event
1 parent b220c96 commit 42de52a

36 files changed

+176
-221
lines changed

ConsoleApp/Program.cs

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
1-
using System.Security.Cryptography.X509Certificates;
2-
using System.Text;
1+
using System.Text;
32
using TetrLoader;
43
using TetrLoader.Enum;
4+
using TetrLoader.JsonClass;
55

66
string jsonData = string.Empty;
7-
using (StreamReader reader = new StreamReader(@"path\sample.ttrm", Encoding.UTF8))
7+
using (StreamReader reader = new StreamReader(@"C:\Users\CSDotNET\Downloads\ew\minest3.17replay.ttrm", Encoding.UTF8))
88
{
99
jsonData = reader.ReadToEnd();
1010
}
1111

1212
var IReplayData = ReplayLoader.ParseReplay(jsonData, ReplayKind.TTRM);
13+
//保存先のファイル名
14+
string fileName = "C:\\Users\\CSDotNET\\Downloads\\ew\\data.ttrmx";
15+
16+
17+
1318

1419
Console.WriteLine("a");

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# TetrLoader.NET
2-
TetrLoader.NET convert json string of replay to C# data structure
2+
TetrLoader.NET convert json string of replay to C# data structure.
3+

TetrLoader/Converter/BagTypeConverter.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System.Diagnostics;
2-
using System.Text.Json;
1+
using System.Text.Json;
32
using System.Text.Json.Serialization;
43
using TetrLoader.Enum;
54

TetrLoader/Converter/EventTypeConverter.cs

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System.Diagnostics;
2-
using System.Text.Json;
1+
using System.Text.Json;
32
using System.Text.Json.Serialization;
43
using TetrLoader.Enum;
54

@@ -26,6 +25,8 @@ public override EventType Read(ref Utf8JsonReader reader, Type typeToConvert,
2625
return EventType.Targets;
2726
case "ige":
2827
return EventType.Ige;
28+
case "exit":
29+
return EventType.Exit;
2930
default:
3031
throw new JsonException("Unknown event type.");
3132
}
@@ -56,6 +57,9 @@ public override void Write(Utf8JsonWriter writer, EventType value, JsonSerialize
5657
case EventType.Targets:
5758
writer.WriteStringValue("targets");
5859
return;
60+
case EventType.Exit:
61+
writer.WriteStringValue("exit");
62+
return;
5963
default:
6064
throw new JsonException("Unknown event type.");
6165
}

TetrLoader/Converter/GarbageBlockingTypeConverter.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System.Diagnostics;
2-
using System.Text.Json;
1+
using System.Text.Json;
32
using System.Text.Json.Serialization;
43
using TetrLoader.Enum;
54

TetrLoader/Converter/KeyTypeConverter.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
using System.Diagnostics;
2-
using System.Text.Json;
1+
using System.Text.Json;
32
using System.Text.Json.Serialization;
43
using TetrLoader.Enum;
5-
using TetrLoader.JsonClass;
64

75
namespace TetrLoader.Converter;
86

TetrLoader/Converter/KicksetTypeConverter.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System.Diagnostics;
2-
using System.Text.Json;
1+
using System.Text.Json;
32
using System.Text.Json.Serialization;
43
using TetrLoader.Enum;
54

TetrLoader/Converter/PassthroughTypeConverter.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System.Diagnostics;
2-
using System.Text.Json;
1+
using System.Text.Json;
32
using System.Text.Json.Serialization;
43
using TetrLoader.Enum;
54

TetrLoader/Converter/SpinBonusesTypeConverter.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System.Diagnostics;
2-
using System.Text.Json;
1+
using System.Text.Json;
32
using System.Text.Json.Serialization;
43
using TetrLoader.Enum;
54

TetrLoader/Enum/EventType.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ public enum EventType
1212
Keydown,
1313
Keyup,
1414
Targets,
15-
Ige
15+
Ige,
16+
Exit
1617
}

TetrLoader/Enum/GarbageType.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
using System.Text.Json.Serialization;
2-
using TetrLoader.Converter;
3-
4-
namespace TetrLoader.Enum;
1+
namespace TetrLoader.Enum;
52
//
63
// [JsonConverter(typeof())]
74
// public enum GarbageType

TetrLoader/JsonClass/ConfigData.cs

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
namespace TetrLoader.JsonClass
22
{
3+
34
public class ConfigData
45
{
56

67
}
7-
8+
89
// Root myDeserializedClass = JsonConvert.DeserializeObject<Root>(myJsonResponse);
910
public class Bgmtweak
1011
{
1112
}
12-
13+
1314
public class Controls
1415
{
1516
public string? style { get; set; }
1617
public Custom? custom { get; set; }
1718
public double? sensitivity { get; set; }
1819
public string? vibration { get; set; }
1920
}
20-
21+
2122
public class Custom
2223
{
2324
public List<string>? moveLeft { get; set; }
@@ -43,7 +44,7 @@ public class Custom
4344
public List<string>? menuConfirm { get; set; }
4445
public List<object>? openSocial { get; set; }
4546
}
46-
47+
4748
public class Electron
4849
{
4950
public string? loginskip { get; set; }
@@ -53,7 +54,7 @@ public class Electron
5354
public bool? anglecompat { get; set; }
5455
public bool? adblock { get; set; }
5556
}
56-
57+
5758
public class Gameoptions
5859
{
5960
public bool? pro_40l { get; set; }
@@ -67,7 +68,7 @@ public class Gameoptions
6768
}
6869

6970

70-
71+
7172
public class Notifications
7273
{
7374
public bool? suppress { get; set; }
@@ -79,7 +80,7 @@ public class Notifications
7980
public string? invite { get; set; }
8081
public string? other { get; set; }
8182
}
82-
83+
8384
public class Root
8485
{
8586
public Controls? controls { get; set; }
@@ -90,7 +91,7 @@ public class Root
9091
public Electron? electron { get; set; }
9192
public Notifications? notifications { get; set; }
9293
}
93-
94+
9495
public class Video
9596
{
9697
public string? graphics { get; set; }
@@ -135,7 +136,7 @@ public class Video
135136
public double? chroma { get; set; }
136137
public int? flashwave { get; set; }
137138
}
138-
139+
139140
public class Volume
140141
{
141142
public bool? disable { get; set; }

TetrLoader/JsonClass/EndContext.cs

+34-39
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,40 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
6-
7-
namespace TetrLoader.JsonClass
1+
namespace TetrLoader.JsonClass
82
{
9-
public class EndContext
10-
{
11-
//TTRM
12-
public int? naturalorder { get; set; } = null;
13-
public User? user { get; set; } = null;
14-
public bool? active { get; set; } = null;
15-
public int? wins { get; set; } = null;
16-
// public int? inputs { get; set; } = null;
17-
public int? piecesplaced { get; set; } = null;
18-
public Points? points { get; set; }
3+
4+
public class EndContext
5+
{
6+
//TTRM
7+
public int? naturalorder { get; set; } = null;
8+
public User? user { get; set; } = null;
9+
public bool? active { get; set; } = null;
1910

11+
public int? wins { get; set; } = null;
2012

21-
//TTR
22-
public double? seed { get; set; } = null;
23-
public int? lines { get; set; } = null;
24-
public int? level_lines { get; set; } = null;
25-
public int? level_lines_needed { get; set; } = null;
26-
public int? holds { get; set; } = null;
27-
public int? score { get; set; } = null;
28-
public int? zenlevel { get; set; } = null;
29-
public int? zenprogress { get; set; } = null;
30-
public int? level { get; set; } = null;
31-
public int? combo { get; set; } = null;
32-
public int? currentcombopower { get; set; } = null;
33-
public int? topcombo { get; set; } = null;
34-
public int? btb { get; set; } = null;
35-
public int? topbtb { get; set; } = null;
36-
public int? tspins { get; set; } = null;
37-
public int? pieceplaced { get; set; } = null;
38-
public int? kills { get; set; } = null;
13+
// public int? inputs { get; set; } = null;
14+
public int? piecesplaced { get; set; } = null;
15+
public Points? points { get; set; }
3916

40-
//BOTH
41-
public int? inputs { get; set; } = null;
4217

43-
}
18+
//TTR
19+
public double? seed { get; set; } = null;
20+
public int? lines { get; set; } = null;
21+
public int? level_lines { get; set; } = null;
22+
public int? level_lines_needed { get; set; } = null;
23+
public int? holds { get; set; } = null;
24+
public int? score { get; set; } = null;
25+
public int? zenlevel { get; set; } = null;
26+
public int? zenprogress { get; set; } = null;
27+
public int? level { get; set; } = null;
28+
public int? combo { get; set; } = null;
29+
public int? currentcombopower { get; set; } = null;
30+
public int? topcombo { get; set; } = null;
31+
public int? btb { get; set; } = null;
32+
public int? topbtb { get; set; } = null;
33+
public int? tspins { get; set; } = null;
34+
public int? pieceplaced { get; set; } = null;
35+
public int? kills { get; set; } = null;
4436

45-
}
37+
//BOTH
38+
public int? inputs { get; set; } = null;
39+
}
40+
}

TetrLoader/JsonClass/Event/Event.cs

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1-
using System.Text.Json.Serialization;
2-
using TetrLoader.Converter;
3-
using TetrLoader.Enum;
1+
using TetrLoader.Enum;
42

53
namespace TetrLoader.JsonClass.Event
6-
{
4+
{
75
public class Event : ICloneable
86
{
97
public Event(int? id, int? frame, EventType? type)
108
{
119
this.id = id;
1210
this.frame = frame;
1311
this.type = type;
14-
this.data = null;
12+
data = null;
1513
}
1614

1715
public object Clone()

TetrLoader/JsonClass/Event/EventEnd.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using TetrLoader.Enum;
22

33
namespace TetrLoader.JsonClass.Event
4-
{
4+
{
55
public class EventEnd : Event
66
{
77
public EventEnd(int? id, int frame, EventType? type, EventEndData data) : base(id, frame, type)
@@ -11,7 +11,7 @@ public EventEnd(int? id, int frame, EventType? type, EventEndData data) : base(i
1111

1212
public new EventEndData data { get; set; }
1313
}
14-
14+
1515
public class EventEndData
1616
{
1717
public string? reason { get; set; } = null;

TetrLoader/JsonClass/Event/EventFull.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
using TetrLoader.Enum;
2-
using TetrLoader.JsonClass.Event;
32

43
namespace TetrLoader.JsonClass.Event
5-
{
4+
{
65
public class EventFull : Event
76
{
87
public EventFull(int? id,int frame,EventType? type, EventFullData data) : base(id,frame,type)
@@ -12,7 +11,7 @@ public EventFull(int? id,int frame,EventType? type, EventFullData data) : base(i
1211

1312
public new EventFullData data { get; set; }
1413
}
15-
14+
1615
public class EventFullData
1716
{
1817

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
namespace TetrLoader.JsonClass.Event
22
{
3+
34
public class EventFullGame : Event
45
{
56
public EventFullGame(EventFullGame data) : base(null, null, null)
@@ -9,16 +10,15 @@ public EventFullGame(EventFullGame data) : base(null, null, null)
910

1011
public new EventFullGame data { get; set; }
1112
}
12-
public class EventFullGameData
13+
14+
15+
public class EventFullGameData
1316
{
1417
public List<List<object>>? board { get; set; }
1518
public List<string>? bag { get; set; }
1619
public double? g { get; set; }
1720
public bool? playing { get; set; }
1821
public Hold hold { get; set; }
1922
public Handling? handling { get; set; } = null;
20-
21-
22-
2323
}
24-
}
24+
}

TetrLoader/JsonClass/Event/EventFullOptions.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using TetrLoader.Enum;
22

33
namespace TetrLoader.JsonClass.Event
4-
{
4+
{
55
public class EventFullOptions : Event
66
{
77
public EventFullOptions(EventFullOptionsData data) : base(null, null, null)
@@ -11,7 +11,7 @@ public EventFullOptions(EventFullOptionsData data) : base(null, null, null)
1111

1212
public new EventFullOptionsData data { get; set; }
1313
}
14-
14+
1515
public class EventFullOptionsData
1616
{
1717
public int version { get; set; }

0 commit comments

Comments
 (0)