Skip to content

Commit 8ed1cda

Browse files
committed
Add properties for LevelDto object
Thanks for reference: https://docs.gdprogra.me/#/resources/server/level It saved me a lot of time
1 parent 81d9ca8 commit 8ed1cda

File tree

6 files changed

+124
-22
lines changed

6 files changed

+124
-22
lines changed

GeometryDashAPI/GeometryDashAPI.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<RepositoryUrl>https://github.com/Folleach/GeometryDashAPI</RepositoryUrl>
1212
<RepositoryType>git</RepositoryType>
1313
<PackageTags>api, geometry, dash</PackageTags>
14-
<PackageVersion>0.1.10</PackageVersion>
14+
<PackageVersion>0.1.11</PackageVersion>
1515
<LangVersion>9</LangVersion>
1616
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
1717
</PropertyGroup>

GeometryDashAPI/GeometryDashApi.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ public static Func<string, object> GetStringParser(Type type)
100100
return raw => ObjectParser.Decode(type, raw);
101101
if (td!.IsGameStruct)
102102
return raw => StructParser.Decode(type, raw);
103+
if (type.IsEnum)
104+
return raw => Enum.Parse(type, raw);
103105
// if (td!.IsArray)
104106
// return raw => ArrayParser.Decode(type, arraySeperators[type], raw);
105107
throw new Exception($"Couldn't parse: {type}");

GeometryDashAPI/Parsers/TypeDescription.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,13 @@ private static IEnumerable<MemberInfo> GetPropertiesAndFields(Type type)
3232
{
3333
foreach (var property in type.GetProperties())
3434
yield return property;
35-
foreach (var field in type.GetFields(BindingFlags.Instance | BindingFlags.NonPublic))
36-
yield return field;
35+
var current = type;
36+
while (current != null && current != typeof(object))
37+
{
38+
foreach (var field in current.GetFields(BindingFlags.Instance | BindingFlags.NonPublic))
39+
yield return field;
40+
current = current.BaseType;
41+
}
3742
}
3843
}
3944
}

GeometryDashAPI/Server/Dtos/LevelDto.cs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,28 @@
22
{
33
public class LevelDto : LevelPreviewDto
44
{
5-
[GameProperty("4")] public string LevelString { get; set; }
5+
[GameProperty("4")]
6+
public string LevelString { get; set; }
7+
8+
[GameProperty("27")]
9+
private string rawPassword;
10+
public string RawPassword // Are you need decrypt? I can do it later. On the clock 12:25 am
11+
{
12+
get => rawPassword;
13+
set => rawPassword = value;
14+
}
15+
16+
[GameProperty("28")]
17+
public string UploadDateTime { get; set; }
18+
19+
[GameProperty("29")]
20+
public string SecondDateTime { get; set; }
21+
22+
[GameProperty("36")]
23+
public string ExtraString { get; set; }
624

7-
[GameProperty("28")] public string UploadDateTime { get; set; }
8-
[GameProperty("29")] public string SecondDateTime { get; set; }
25+
[GameProperty("40")]
26+
public bool LowDetail { get; set; }
927

1028
public override string GetParserSense() => ":";
1129
}

GeometryDashAPI/Server/Dtos/LevelPreviewDto.cs

Lines changed: 88 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,99 @@
1-
namespace GeometryDashAPI.Server.Dtos
1+
using System;
2+
using GeometryDashAPI.Server.Enums;
3+
4+
namespace GeometryDashAPI.Server.Dtos
25
{
36
public class LevelPreviewDto : GameObject
47
{
5-
[GameProperty("1")] public int Id { get; set; }
6-
[GameProperty("2")] public string Name { get; set; }
7-
[GameProperty("3")] private string description;
8+
[GameProperty("1")]
9+
public int Id { get; set; }
10+
11+
[GameProperty("2")]
12+
public string Name { get; set; }
13+
14+
[GameProperty("3")]
15+
private string description;
816
public string Description
917
{
1018
get => GameConvert.FromBase64S(description);
1119
set => description = GameConvert.ToBase64S(value);
1220
}
13-
[GameProperty("5")] public int Version { get; set; }
14-
[GameProperty("6")] public int AuthorUserId { get; set; }
15-
[GameProperty("10")] public int Downloads { get; set; }
16-
[GameProperty("14")] public int Likes { get; set; }
17-
[GameProperty("18")] public int Difficult { get; set; }
18-
[GameProperty("35")] public int MusicId { get; set; }
19-
[GameProperty("42")] public bool Epic { get; set; }
21+
22+
[GameProperty("5")]
23+
public int Version { get; set; }
24+
25+
[GameProperty("6")]
26+
public int AuthorUserId { get; set; }
27+
28+
[GameProperty("8")]
29+
public int Difficulty { get; set; }
30+
31+
[GameProperty("9")]
32+
public int SlaveDifficulty { get; set; }
33+
34+
[GameProperty("10")]
35+
public int Downloads { get; set; }
36+
37+
[Obsolete]
38+
[GameProperty("11")]
39+
public int Completes { get; set; }
40+
41+
[GameProperty("12")]
42+
public int OfficialSong { get; set; }
43+
44+
[GameProperty("13")]
45+
public int GameVersion { get; set; }
46+
47+
[GameProperty("14")]
48+
public int Likes { get; set; }
49+
50+
[GameProperty("15")]
51+
public LengthType Length { get; set; }
52+
53+
[GameProperty("17")]
54+
public bool Demon { get; set; }
55+
56+
[GameProperty("18")]
57+
public int Stars { get; set; }
58+
59+
[GameProperty("19")]
60+
public int FeatureScore { get; set; }
61+
62+
[GameProperty("25")]
63+
public bool Auto { get; set; }
64+
65+
[GameProperty("30")]
66+
public int CopiedId { get; set; }
67+
68+
[GameProperty("31")]
69+
public bool TwoPlayer { get; set; }
70+
71+
[GameProperty("35")]
72+
public int MusicId { get; set; }
73+
74+
[GameProperty("37")]
75+
public int Coins { get; set; }
76+
77+
[GameProperty("38")]
78+
public bool CoinsVerified { get; set; }
79+
80+
[GameProperty("39")]
81+
public int StarsRequested { get; set; }
82+
83+
[GameProperty("42")]
84+
public bool Epic { get; set; }
85+
86+
[GameProperty("43")]
87+
public int DemonDifficulty { get; set; }
88+
89+
[GameProperty("45")]
90+
public int Objects { get; set; }
91+
92+
[GameProperty("46")]
93+
public int EditorTime { get; set; }
94+
95+
[GameProperty("47")]
96+
public int EditorTimeCopies { get; set; }
2097

2198
public override string GetParserSense() => ":";
2299
}

GeometryDashAPI/Server/Enums/LengthType.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
{
33
public enum LengthType
44
{
5-
Tiny,
6-
Short,
7-
Medium,
8-
Long,
9-
XL
5+
Tiny = 0,
6+
Short = 1,
7+
Medium = 2,
8+
Long = 3,
9+
XL = 4
1010
}
1111
}

0 commit comments

Comments
 (0)