feat: author world events and social effects
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
class_name DefinitionParameterValidator
|
||||
extends RefCounted
|
||||
|
||||
|
||||
static func validate(parameters: Dictionary, owner: String) -> Array[String]:
|
||||
var errors: Array[String] = []
|
||||
for raw_key in parameters:
|
||||
if not raw_key is String and not raw_key is StringName:
|
||||
errors.append("%s has a non-string parameter key" % owner)
|
||||
continue
|
||||
var key := StringName(raw_key)
|
||||
if key.is_empty():
|
||||
errors.append("%s has an empty parameter key" % owner)
|
||||
var value: Variant = parameters[raw_key]
|
||||
if not _is_primitive(value):
|
||||
errors.append("%s parameter '%s' must be primitive" % [owner, key])
|
||||
elif value is float and not is_finite(value):
|
||||
errors.append("%s parameter '%s' must be finite" % [owner, key])
|
||||
errors.sort()
|
||||
return errors
|
||||
|
||||
|
||||
static func _is_primitive(value: Variant) -> bool:
|
||||
return value is bool or value is int or value is float or value is String or value is StringName
|
||||
Reference in New Issue
Block a user