-
Notifications
You must be signed in to change notification settings - Fork 0
/
JsonBonusNode.cs
51 lines (38 loc) · 1.88 KB
/
JsonBonusNode.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System.Collections.Generic;
using System.Linq;
using YetAnotherPacketParser.Ast;
namespace YetAnotherPacketParser.Compiler.Json
{
internal class JsonBonusNode
{
public JsonBonusNode(BonusNode bonusNode)
{
this.Leadin = JsonTextFormatter.ToStringWithTags(bonusNode.Leadin);
this.Leadin_sanitized = JsonTextFormatter.ToStringWithoutTags(bonusNode.Leadin);
IEnumerable<BonusPartNode> partNodes = bonusNode.Parts;
this.Answers = new List<string>();
this.Answers_sanitized = new List<string>();
this.Parts = new List<string>();
this.Parts_sanitized = new List<string>();
this.Values = new List<int>();
this.DifficultyModifiers = partNodes.Any(node => node.DifficultyModifier.HasValue) ? new List<char?>() : null;
foreach (BonusPartNode partNode in partNodes)
{
this.Answers.Add(JsonTextFormatter.ToStringWithTags(partNode.Question.Answer));
this.Answers_sanitized.Add(JsonTextFormatter.ToStringWithoutTags(partNode.Question.Answer));
this.Parts.Add(JsonTextFormatter.ToStringWithTags(partNode.Question.Question));
this.Parts_sanitized.Add(JsonTextFormatter.ToStringWithoutTags(partNode.Question.Question));
this.Values.Add(partNode.Value);
this.DifficultyModifiers?.Add(partNode.DifficultyModifier);
}
}
public string Leadin { get; }
public string Leadin_sanitized { get; }
public ICollection<string> Answers { get; }
public ICollection<string> Answers_sanitized { get; }
public ICollection<string> Parts { get; }
public ICollection<string> Parts_sanitized { get; }
public ICollection<int> Values { get; }
public ICollection<char?>? DifficultyModifiers { get; }
}
}