Change save/search_prototype, extend unittests

This commit is contained in:
Griatch 2019-02-09 16:52:02 +01:00
parent dac10eef2b
commit 0dfea46d5c
12 changed files with 154 additions and 39 deletions

View file

@ -23,7 +23,7 @@ prot = {
"attrs": [("weapon", "sword")]
}
prot = prototypes.create_prototype(**prot)
prot = prototypes.create_prototype(prot)
```
@ -662,8 +662,9 @@ def spawn(*prototypes, **kwargs):
Spawn a number of prototyped objects.
Args:
prototypes (dict): Each argument should be a prototype
dictionary.
prototypes (str or dict): Each argument should either be a
prototype_key (will be used to find the prototype) or a full prototype
dictionary. These will be batched-spawned as one object each.
Kwargs:
prototype_modules (str or list): A python-path to a prototype
module, or a list of such paths. These will be used to build
@ -686,6 +687,11 @@ def spawn(*prototypes, **kwargs):
`return_parents` is set, instead return dict of prototype parents.
"""
# search string (=prototype_key) from input
prototypes = [protlib.search_prototype(prot, require_single=True)[0]
if isinstance(prot, basestring) else prot
for prot in prototypes]
# get available protparents
protparents = {prot['prototype_key'].lower(): prot for prot in protlib.search_prototype()}