-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparser_test.go
327 lines (260 loc) · 16.8 KB
/
parser_test.go
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
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
package palworld_settings_test
import (
"testing"
palworld_settings "github.com/juunini/palworld-settings"
)
func TestParse(t *testing.T) {
configString := `[/Script/Pal.PalGameWorldSettings]
OptionSettings=(Difficulty=Normal, DayTimeSpeedRate=1.0, NightTimeSpeedRate=1.0, ExpRate=1.0, PalCaptureRate=1.0, PalSpawnNumRate=1.0, PalDamageRateAttack=1.0, PalDamageRateDefense=1.0, PlayerDamageRateAttack=1.0, PlayerDamageRateDefense=1.0, PlayerStomachDecreaceRate=1.0, PlayerStaminaDecreaceRate=1.0, PlayerAutoHPRegeneRate=1.0, PlayerAutoHpRegeneRateInSleep=1.0, PalStomachDecreaceRate=1.0, PalStaminaDecreaceRate=1.0, PalAutoHPRegeneRate=1.0, PalAutoHpRegeneRateInSleep=1.0, BuildObjectDamageRate=1.0, BuildObjectDeteriorationDamageRate=1.0, CollectionDropRate=1.0, CollectionObjectHpRate=1.0, CollectionObjectRespawnSpeedRate=1.0, EnemyDropItemRate=1.0, DeathPenalty=DropAll, bEnablePlayerToPlayerDamage=true, bEnableFriendlyFire=true, bEnableInvaderEnemy=true, bActiveUNKO=true, bEnableAimAssistPad=true, bEnableAimAssistKeyboard=true, DropItemMaxNum=100, DropItemMaxNum_UNKO=100, BaseCampMaxNum=100, BaseCampWorkerMaxNum=100, DropItemAliveMaxHours=24.0, bAutoResetGuildNoOnlinePlayers=true, AutoResetGuildTimeNoOnlinePlayers=24.0, GuildPlayerMaxNum=100, PalEggDefaultHatchingTime=24.0, WorkSpeedRate=1.0, bIsMultiplay=true, bIsPvP=true, bCanPickupOtherGuildDeathPenaltyDrop=true, bEnableNonLoginPenalty=true, bEnableFastTravel=true, bIsStartLocationSelectByMap=true, bExistPlayerAfterLogout=true, bEnableDefenseOtherGuildPlayer=true, CoopPlayerMaxNum=100, ServerPlayerMaxNum=100, ServerName=MyServer, ServerDescription=MyServerDescription, AdminPassword=MyAdminPassword, ServerPassword=MyServerPassword, PublicPort=8080, PublicIP=127.0.0.1, RCONEnabled=true, RCONPort=9000, Region=US, bUseAuth=true, BanListURL=http://example.com/banlist)`
expectedConfig := &palworld_settings.Setting{
Difficulty: "Normal",
DayTimeSpeedRate: 1.0,
NightTimeSpeedRate: 1.0,
ExpRate: 1.0,
PalCaptureRate: 1.0,
PalSpawnNumRate: 1.0,
PalDamageRateAttack: 1.0,
PalDamageRateDefense: 1.0,
PlayerDamageRateAttack: 1.0,
PlayerDamageRateDefense: 1.0,
PlayerStomachDecreaceRate: 1.0,
PlayerStaminaDecreaceRate: 1.0,
PlayerAutoHPRegeneRate: 1.0,
PlayerAutoHpRegeneRateInSleep: 1.0,
PalStomachDecreaceRate: 1.0,
PalStaminaDecreaceRate: 1.0,
PalAutoHPRegeneRate: 1.0,
PalAutoHpRegeneRateInSleep: 1.0,
BuildObjectDamageRate: 1.0,
BuildObjectDeteriorationDamageRate: 1.0,
CollectionDropRate: 1.0,
CollectionObjectHpRate: 1.0,
CollectionObjectRespawnSpeedRate: 1.0,
EnemyDropItemRate: 1.0,
DeathPenalty: "DropAll",
EnablePlayerToPlayerDamage: true,
EnableFriendlyFire: true,
EnableInvaderEnemy: true,
ActiveUNKO: true,
EnableAimAssistPad: true,
EnableAimAssistKeyboard: true,
DropItemMaxNum: 100,
DropItemMaxNum_UNKO: 100,
BaseCampMaxNum: 100,
BaseCampWorkerMaxNum: 100,
DropItemAliveMaxHours: 24.0,
AutoResetGuildNoOnlinePlayers: true,
AutoResetGuildTimeNoOnlinePlayers: 24.0,
GuildPlayerMaxNum: 100,
PalEggDefaultHatchingTime: 24.0,
WorkSpeedRate: 1.0,
IsMultiplay: true,
IsPvP: true,
CanPickupOtherGuildDeathPenaltyDrop: true,
EnableNonLoginPenalty: true,
EnableFastTravel: true,
IsStartLocationSelectByMap: true,
ExistPlayerAfterLogout: true,
EnableDefenseOtherGuildPlayer: true,
CoopPlayerMaxNum: 100,
ServerPlayerMaxNum: 100,
ServerName: "MyServer",
ServerDescription: "MyServerDescription",
AdminPassword: "MyAdminPassword",
ServerPassword: "MyServerPassword",
PublicPort: 8080,
PublicIP: "127.0.0.1",
RCONEnabled: true,
RCONPort: 9000,
Region: "US",
UseAuth: true,
BanListURL: "http://example.com/banlist",
}
config, _ := palworld_settings.Parse(configString)
if config.Difficulty != expectedConfig.Difficulty {
t.Errorf("Expected Difficulty to be %s, but got %s", expectedConfig.Difficulty, config.Difficulty)
}
if config.DayTimeSpeedRate != expectedConfig.DayTimeSpeedRate {
t.Errorf("Expected DayTimeSpeedRate to be %f, but got %f", expectedConfig.DayTimeSpeedRate, config.DayTimeSpeedRate)
}
if config.NightTimeSpeedRate != expectedConfig.NightTimeSpeedRate {
t.Errorf("Expected NightTimeSpeedRate to be %f, but got %f", expectedConfig.NightTimeSpeedRate, config.NightTimeSpeedRate)
}
if config.ExpRate != expectedConfig.ExpRate {
t.Errorf("Expected ExpRate to be %f, but got %f", expectedConfig.ExpRate, config.ExpRate)
}
if config.PalCaptureRate != expectedConfig.PalCaptureRate {
t.Errorf("Expected PalCaptureRate to be %f, but got %f", expectedConfig.PalCaptureRate, config.PalCaptureRate)
}
if config.PalSpawnNumRate != expectedConfig.PalSpawnNumRate {
t.Errorf("Expected PalSpawnNumRate to be %f, but got %f", expectedConfig.PalSpawnNumRate, config.PalSpawnNumRate)
}
if config.PalDamageRateAttack != expectedConfig.PalDamageRateAttack {
t.Errorf("Expected PalDamageRateAttack to be %f, but got %f", expectedConfig.PalDamageRateAttack, config.PalDamageRateAttack)
}
if config.PalDamageRateDefense != expectedConfig.PalDamageRateDefense {
t.Errorf("Expected PalDamageRateDefense to be %f, but got %f", expectedConfig.PalDamageRateDefense, config.PalDamageRateDefense)
}
if config.PlayerDamageRateAttack != expectedConfig.PlayerDamageRateAttack {
t.Errorf("Expected PlayerDamageRateAttack to be %f, but got %f", expectedConfig.PlayerDamageRateAttack, config.PlayerDamageRateAttack)
}
if config.PlayerDamageRateDefense != expectedConfig.PlayerDamageRateDefense {
t.Errorf("Expected PlayerDamageRateDefense to be %f, but got %f", expectedConfig.PlayerDamageRateDefense, config.PlayerDamageRateDefense)
}
if config.PlayerStomachDecreaceRate != expectedConfig.PlayerStomachDecreaceRate {
t.Errorf("Expected PlayerStomachDecreaceRate to be %f, but got %f", expectedConfig.PlayerStomachDecreaceRate, config.PlayerStomachDecreaceRate)
}
if config.PlayerStaminaDecreaceRate != expectedConfig.PlayerStaminaDecreaceRate {
t.Errorf("Expected PlayerStaminaDecreaceRate to be %f, but got %f", expectedConfig.PlayerStaminaDecreaceRate, config.PlayerStaminaDecreaceRate)
}
if config.PlayerAutoHPRegeneRate != expectedConfig.PlayerAutoHPRegeneRate {
t.Errorf("Expected PlayerAutoHPRegeneRate to be %f, but got %f", expectedConfig.PlayerAutoHPRegeneRate, config.PlayerAutoHPRegeneRate)
}
if config.PlayerAutoHpRegeneRateInSleep != expectedConfig.PlayerAutoHpRegeneRateInSleep {
t.Errorf("Expected PlayerAutoHpRegeneRateInSleep to be %f, but got %f", expectedConfig.PlayerAutoHpRegeneRateInSleep, config.PlayerAutoHpRegeneRateInSleep)
}
if config.PalStomachDecreaceRate != expectedConfig.PalStomachDecreaceRate {
t.Errorf("Expected PalStomachDecreaceRate to be %f, but got %f", expectedConfig.PalStomachDecreaceRate, config.PalStomachDecreaceRate)
}
if config.PalStaminaDecreaceRate != expectedConfig.PalStaminaDecreaceRate {
t.Errorf("Expected PalStaminaDecreaceRate to be %f, but got %f", expectedConfig.PalStaminaDecreaceRate, config.PalStaminaDecreaceRate)
}
if config.PalAutoHPRegeneRate != expectedConfig.PalAutoHPRegeneRate {
t.Errorf("Expected PalAutoHPRegeneRate to be %f, but got %f", expectedConfig.PalAutoHPRegeneRate, config.PalAutoHPRegeneRate)
}
if config.PalAutoHpRegeneRateInSleep != expectedConfig.PalAutoHpRegeneRateInSleep {
t.Errorf("Expected PalAutoHpRegeneRateInSleep to be %f, but got %f", expectedConfig.PalAutoHpRegeneRateInSleep, config.PalAutoHpRegeneRateInSleep)
}
if config.BuildObjectDamageRate != expectedConfig.BuildObjectDamageRate {
t.Errorf("Expected BuildObjectDamageRate to be %f, but got %f", expectedConfig.BuildObjectDamageRate, config.BuildObjectDamageRate)
}
if config.BuildObjectDeteriorationDamageRate != expectedConfig.BuildObjectDeteriorationDamageRate {
t.Errorf("Expected BuildObjectDeteriorationDamageRate to be %f, but got %f", expectedConfig.BuildObjectDeteriorationDamageRate, config.BuildObjectDeteriorationDamageRate)
}
if config.CollectionDropRate != expectedConfig.CollectionDropRate {
t.Errorf("Expected CollectionDropRate to be %f, but got %f", expectedConfig.CollectionDropRate, config.CollectionDropRate)
}
if config.CollectionObjectHpRate != expectedConfig.CollectionObjectHpRate {
t.Errorf("Expected CollectionObjectHpRate to be %f, but got %f", expectedConfig.CollectionObjectHpRate, config.CollectionObjectHpRate)
}
if config.CollectionObjectRespawnSpeedRate != expectedConfig.CollectionObjectRespawnSpeedRate {
t.Errorf("Expected CollectionObjectRespawnSpeedRate to be %f, but got %f", expectedConfig.CollectionObjectRespawnSpeedRate, config.CollectionObjectRespawnSpeedRate)
}
if config.EnemyDropItemRate != expectedConfig.EnemyDropItemRate {
t.Errorf("Expected EnemyDropItemRate to be %f, but got %f", expectedConfig.EnemyDropItemRate, config.EnemyDropItemRate)
}
if config.DeathPenalty != expectedConfig.DeathPenalty {
t.Errorf("Expected DeathPenalty to be %s, but got %s", expectedConfig.DeathPenalty, config.DeathPenalty)
}
if config.EnablePlayerToPlayerDamage != expectedConfig.EnablePlayerToPlayerDamage {
t.Errorf("Expected EnablePlayerToPlayerDamage to be %t, but got %t", expectedConfig.EnablePlayerToPlayerDamage, config.EnablePlayerToPlayerDamage)
}
if config.EnableFriendlyFire != expectedConfig.EnableFriendlyFire {
t.Errorf("Expected EnableFriendlyFire to be %t, but got %t", expectedConfig.EnableFriendlyFire, config.EnableFriendlyFire)
}
if config.EnableInvaderEnemy != expectedConfig.EnableInvaderEnemy {
t.Errorf("Expected EnableInvaderEnemy to be %t, but got %t", expectedConfig.EnableInvaderEnemy, config.EnableInvaderEnemy)
}
if config.ActiveUNKO != expectedConfig.ActiveUNKO {
t.Errorf("Expected ActiveUNKO to be %t, but got %t", expectedConfig.ActiveUNKO, config.ActiveUNKO)
}
if config.EnableAimAssistPad != expectedConfig.EnableAimAssistPad {
t.Errorf("Expected EnableAimAssistPad to be %t, but got %t", expectedConfig.EnableAimAssistPad, config.EnableAimAssistPad)
}
if config.EnableAimAssistKeyboard != expectedConfig.EnableAimAssistKeyboard {
t.Errorf("Expected EnableAimAssistKeyboard to be %t, but got %t", expectedConfig.EnableAimAssistKeyboard, config.EnableAimAssistKeyboard)
}
if config.DropItemMaxNum != expectedConfig.DropItemMaxNum {
t.Errorf("Expected DropItemMaxNum to be %d, but got %d", expectedConfig.DropItemMaxNum, config.DropItemMaxNum)
}
if config.DropItemMaxNum_UNKO != expectedConfig.DropItemMaxNum_UNKO {
t.Errorf("Expected DropItemMaxNum_UNKO to be %d, but got %d", expectedConfig.DropItemMaxNum_UNKO, config.DropItemMaxNum_UNKO)
}
if config.BaseCampMaxNum != expectedConfig.BaseCampMaxNum {
t.Errorf("Expected BaseCampMaxNum to be %d, but got %d", expectedConfig.BaseCampMaxNum, config.BaseCampMaxNum)
}
if config.BaseCampWorkerMaxNum != expectedConfig.BaseCampWorkerMaxNum {
t.Errorf("Expected BaseCampWorkerMaxNum to be %d, but got %d", expectedConfig.BaseCampWorkerMaxNum, config.BaseCampWorkerMaxNum)
}
if config.DropItemAliveMaxHours != expectedConfig.DropItemAliveMaxHours {
t.Errorf("Expected DropItemAliveMaxHours to be %f, but got %f", expectedConfig.DropItemAliveMaxHours, config.DropItemAliveMaxHours)
}
if config.AutoResetGuildNoOnlinePlayers != expectedConfig.AutoResetGuildNoOnlinePlayers {
t.Errorf("Expected AutoResetGuildNoOnlinePlayers to be %t, but got %t", expectedConfig.AutoResetGuildNoOnlinePlayers, config.AutoResetGuildNoOnlinePlayers)
}
if config.AutoResetGuildTimeNoOnlinePlayers != expectedConfig.AutoResetGuildTimeNoOnlinePlayers {
t.Errorf("Expected AutoResetGuildTimeNoOnlinePlayers to be %f, but got %f", expectedConfig.AutoResetGuildTimeNoOnlinePlayers, config.AutoResetGuildTimeNoOnlinePlayers)
}
if config.GuildPlayerMaxNum != expectedConfig.GuildPlayerMaxNum {
t.Errorf("Expected GuildPlayerMaxNum to be %d, but got %d", expectedConfig.GuildPlayerMaxNum, config.GuildPlayerMaxNum)
}
if config.PalEggDefaultHatchingTime != expectedConfig.PalEggDefaultHatchingTime {
t.Errorf("Expected PalEggDefaultHatchingTime to be %f, but got %f", expectedConfig.PalEggDefaultHatchingTime, config.PalEggDefaultHatchingTime)
}
if config.WorkSpeedRate != expectedConfig.WorkSpeedRate {
t.Errorf("Expected WorkSpeedRate to be %f, but got %f", expectedConfig.WorkSpeedRate, config.WorkSpeedRate)
}
if config.IsMultiplay != expectedConfig.IsMultiplay {
t.Errorf("Expected IsMultiplay to be %t, but got %t", expectedConfig.IsMultiplay, config.IsMultiplay)
}
if config.IsPvP != expectedConfig.IsPvP {
t.Errorf("Expected IsPvP to be %t, but got %t", expectedConfig.IsPvP, config.IsPvP)
}
if config.CanPickupOtherGuildDeathPenaltyDrop != expectedConfig.CanPickupOtherGuildDeathPenaltyDrop {
t.Errorf("Expected CanPickupOtherGuildDeathPenaltyDrop to be %t, but got %t", expectedConfig.CanPickupOtherGuildDeathPenaltyDrop, config.CanPickupOtherGuildDeathPenaltyDrop)
}
if config.EnableNonLoginPenalty != expectedConfig.EnableNonLoginPenalty {
t.Errorf("Expected EnableNonLoginPenalty to be %t, but got %t", expectedConfig.EnableNonLoginPenalty, config.EnableNonLoginPenalty)
}
if config.EnableFastTravel != expectedConfig.EnableFastTravel {
t.Errorf("Expected EnableFastTravel to be %t, but got %t", expectedConfig.EnableFastTravel, config.EnableFastTravel)
}
if config.IsStartLocationSelectByMap != expectedConfig.IsStartLocationSelectByMap {
t.Errorf("Expected IsStartLocationSelectByMap to be %t, but got %t", expectedConfig.IsStartLocationSelectByMap, config.IsStartLocationSelectByMap)
}
if config.ExistPlayerAfterLogout != expectedConfig.ExistPlayerAfterLogout {
t.Errorf("Expected ExistPlayerAfterLogout to be %t, but got %t", expectedConfig.ExistPlayerAfterLogout, config.ExistPlayerAfterLogout)
}
if config.EnableDefenseOtherGuildPlayer != expectedConfig.EnableDefenseOtherGuildPlayer {
t.Errorf("Expected EnableDefenseOtherGuildPlayer to be %t, but got %t", expectedConfig.EnableDefenseOtherGuildPlayer, config.EnableDefenseOtherGuildPlayer)
}
if config.CoopPlayerMaxNum != expectedConfig.CoopPlayerMaxNum {
t.Errorf("Expected CoopPlayerMaxNum to be %d, but got %d", expectedConfig.CoopPlayerMaxNum, config.CoopPlayerMaxNum)
}
if config.ServerPlayerMaxNum != expectedConfig.ServerPlayerMaxNum {
t.Errorf("Expected ServerPlayerMaxNum to be %d, but got %d", expectedConfig.ServerPlayerMaxNum, config.ServerPlayerMaxNum)
}
if config.ServerName != expectedConfig.ServerName {
t.Errorf("Expected ServerName to be %s, but got %s", expectedConfig.ServerName, config.ServerName)
}
if config.ServerDescription != expectedConfig.ServerDescription {
t.Errorf("Expected ServerDescription to be %s, but got %s", expectedConfig.ServerDescription, config.ServerDescription)
}
if config.AdminPassword != expectedConfig.AdminPassword {
t.Errorf("Expected AdminPassword to be %s, but got %s", expectedConfig.AdminPassword, config.AdminPassword)
}
if config.ServerPassword != expectedConfig.ServerPassword {
t.Errorf("Expected ServerPassword to be %s, but got %s", expectedConfig.ServerPassword, config.ServerPassword)
}
if config.PublicPort != expectedConfig.PublicPort {
t.Errorf("Expected PublicPort to be %d, but got %d", expectedConfig.PublicPort, config.PublicPort)
}
if config.PublicIP != expectedConfig.PublicIP {
t.Errorf("Expected PublicIP to be %s, but got %s", expectedConfig.PublicIP, config.PublicIP)
}
if config.RCONEnabled != expectedConfig.RCONEnabled {
t.Errorf("Expected RCONEnabled to be %t, but got %t", expectedConfig.RCONEnabled, config.RCONEnabled)
}
if config.RCONPort != expectedConfig.RCONPort {
t.Errorf("Expected RCONPort to be %d, but got %d", expectedConfig.RCONPort, config.RCONPort)
}
if config.Region != expectedConfig.Region {
t.Errorf("Expected Region to be %s, but got %s", expectedConfig.Region, config.Region)
}
if config.UseAuth != expectedConfig.UseAuth {
t.Errorf("Expected UseAuth to be %t, but got %t", expectedConfig.UseAuth, config.UseAuth)
}
if config.BanListURL != expectedConfig.BanListURL {
t.Errorf("Expected BanListURL to be %s, but got %s", expectedConfig.BanListURL, config.BanListURL)
}
}