-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest.cs
More file actions
242 lines (222 loc) · 9.84 KB
/
Test.cs
File metadata and controls
242 lines (222 loc) · 9.84 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
using System.IO;
using CommandForgeGenerator.Generator.CodeGenerate;
using CommandForgeGenerator.Generator.Json;
using CommandForgeGenerator.Generator.Semantic;
using UnityEngine;
using Xunit;
namespace CommandForgeGenerator.Tests;
public class Test
{
[Fact]
public void JsonTokenizerTest()
{
var json = """
{
"hoge": "fuga",
"piyo": [
"puyo",
"poyo"
]
}
""";
Token[] answer =
[
new(TokenType.LBrace, "{"),
new(TokenType.String, "hoge"),
new(TokenType.Colon, ":"),
new(TokenType.String, "fuga"),
new(TokenType.Comma, ","),
new(TokenType.String, "piyo"),
new(TokenType.Colon, ":"),
new(TokenType.LSquare, "["),
new(TokenType.String, "puyo"),
new(TokenType.Comma, ","),
new(TokenType.String, "poyo"),
new(TokenType.RSquare, "]"),
new(TokenType.RBrace, "}")
];
var tokens = JsonTokenizer.GetTokens(json);
Assert.Equivalent(tokens, answer, true);
}
[Fact]
public void JsonParserTest()
{
var json = """
{
"hoge": "fuga",
"piyo": [
"puyo",
"poyo"
]
}
""";
}
[Fact]
public void GenerateTest()
{
var yaml = GetSampleYaml();
var commandsSchema = CommandSemanticsLoader.GetCommandSemantics(yaml);
var codeFiles = CodeGenerator.Generate(commandsSchema);
Assert.Equal(16, codeFiles.Count);
#region Internal
string GetSampleYaml()
{
return """
version: 1
commands:
- id: text
label: テキスト
description: 台詞を表示
commandListLabelFormat: "{character}「{body}」"
properties:
character:
type: enum
options: ["キャラA", "キャラB", "キャラC", "キャラD", "先生", "店員"]
required: true
body:
type: string
multiline: true
required: true
- id: emote
label: エモート
description: 立ち絵・表情切替
commandListLabelFormat: "EMOTE: {character}, {emotion}"
properties:
character:
type: enum
options: ["キャラA", "キャラB", "キャラC", "キャラD", "先生", "店員"]
required: true
emotion:
type: enum
options: ["通常", "笑顔", "驚き", "怒り", "悲しみ", "困惑", "照れ", "恐怖", "喜び", "真剣"]
required: true
- id: wait
label: 待機
description: 指定秒数だけウェイト
commandListLabelFormat: "WAIT: {seconds}"
defaultBackgroundColor: '#57e317'
properties:
seconds:
type: number
default: 0.5
constraints:
min: 0
- id: bgm
label: BGM
description: 背景音楽を変更
commandListLabelFormat: "BGM: {track}, volume={volume}"
properties:
track:
type: enum
options: ["なし", "日常", "緊張", "悲しい", "楽しい", "神秘的", "アクション", "ロマンティック", "エンディング"]
required: true
volume:
type: number
default: 1.0
constraints:
min: 0
max: 1.0
- id: sound
label: 効果音
description: 効果音を再生
commandListLabelFormat: "SOUND: {effect}, volume={volume}"
properties:
effect:
type: enum
options: ["ドア", "足音", "衝撃", "爆発", "鐘", "拍手", "警報", "雨", "雷", "風"]
required: true
volume:
type: number
default: 1.0
constraints:
min: 0
max: 1.0
- id: background
label: 背景
description: 背景画像を変更
commandListLabelFormat: "BG: {scene}, effect={transition}"
properties:
scene:
type: enum
options: ["教室", "廊下", "体育館", "屋上", "公園", "駅", "カフェ", "自宅", "図書館", "商店街"]
required: true
transition:
type: enum
options: ["なし", "フェード", "ワイプ", "クロスフェード", "フラッシュ"]
default: "なし"
- id: camera
label: カメラ
description: カメラワークを指定
commandListLabelFormat: "CAMERA: {action}, target={target}"
properties:
action:
type: enum
options: ["ズームイン", "ズームアウト", "パン左", "パン右", "シェイク", "フォーカス", "リセット"]
required: true
target:
type: enum
options: ["全体", "キャラA", "キャラB", "キャラC", "キャラD", "先生", "店員", "背景"]
default: "全体"
- id: choice
label: 選択肢
description: 選択肢を表示
commandListLabelFormat: "CHOICE: {options}"
properties:
options:
type: string
multiline: true
description: "選択肢を1行に1つずつ記述"
required: true
timeout:
type: number
default: 0
description: "自動選択までの秒数(0で無制限)"
- id: action
label: アクション
description: キャラクターのアクションを実行
commandListLabelFormat: "ACTION: {character}, {action}"
properties:
character:
type: enum
options: ["キャラA", "キャラB", "キャラC", "キャラD", "先生", "店員"]
required: true
action:
type: enum
options: ["歩く", "走る", "座る", "立つ", "ジャンプ", "踊る", "倒れる", "手を振る", "指さす", "抱きしめる"]
required: true
direction:
type: enum
options: ["左", "右", "上", "下", "中央"]
default: "中央"
- id: narration
label: ナレーション
description: ナレーションテキストを表示
commandListLabelFormat: "NARRATION: {text}"
properties:
text:
type: string
multiline: true
required: true
style:
type: enum
options: ["通常", "強調", "小さく", "斜体", "点滅"]
default: "通常"
- id: branch
label: 分岐
description: 他のコマンドを参照する分岐
commandListLabelFormat: "BRANCH: Target {targetCommand}"
defaultBackgroundColor: "#f9f0ff"
properties:
targetCommand:
type: command
required: true
commandTypes: ["text", "narration"] # Only allow text and narration commands
condition:
type: string
required: true
multiline: true
""";
}
#endregion
}
}