From 5afb5c9638fa71a2593b7cf4948e24d931f2947f Mon Sep 17 00:00:00 2001 From: Griatch Date: Fri, 9 Jan 2015 01:03:04 +0100 Subject: [PATCH] Added some batch and prototype examples. Need to ponder how to handle migrations of proxies under evennia/. --- game_template/world/batch_cmds.ev | 26 +++++++++ game_template/world/prototypes.py | 88 ++++++++++++++++++------------- 2 files changed, 77 insertions(+), 37 deletions(-) create mode 100644 game_template/world/batch_cmds.ev diff --git a/game_template/world/batch_cmds.ev b/game_template/world/batch_cmds.ev new file mode 100644 index 0000000000..2d8c8f819d --- /dev/null +++ b/game_template/world/batch_cmds.ev @@ -0,0 +1,26 @@ +# +# A batch-command file is a way to build a game world +# in a programmatic way, by placing a sequence of +# build commands after one another. This allows for +# using a real text editor to edit e.g. descriptions +# rather than entering text on the command line. +# +# A batch-command file is loaded with @batchprocess in-game: +# +# @batchprocess[/interactive] tutorial_examples.batch_cmds +# +# A # as the first symbol on a line begins a comment and +# marks the end of a previous command definition. This is important, +# - every command must be separated by at least one line of comment. +# +# All supplied commands are given as normal, on their own line +# and accepts arguments in any format up until the first next +# comment line begins. Extra whitespace is removed; an empty +# line in a command definition translates into a newline. +# +# See /contrib/tutorial_examples/batch_cmds.ev for +# an example of a batch-command code. See also the batch-code +# system for loading python-code in this way. +# + + diff --git a/game_template/world/prototypes.py b/game_template/world/prototypes.py index 537616f103..85f750fd53 100644 --- a/game_template/world/prototypes.py +++ b/game_template/world/prototypes.py @@ -1,7 +1,21 @@ """ -Example prototypes read by the @spawn command but is also easily -available to use from code. Each prototype should be a dictionary. Use -the same name as the variable to refer to other prototypes. +Prototypes + +A prototype is a simple way to create individualized instances of a +given Typeclass. For example, you might have a Sword typeclass that +implements everything a Sword would need to do. The only difference +between different individual Swords would be their key, description +and some Attributes. The Prototype system allows to create a range of +such Swords with only minor variations. Prototypes can also inherit +and combine together to form entire hierarchies (such as giving all +Sabres and all Broadswords some common properties). Note that bigger +variations, such as custom commands or functionality belong in a +hierarchy of typeclasses instead. + +Example prototypes are read by the @spawn command but is also easily +available to use from code via evennia.spawn or evennia.utils.spawner. +Each prototype should be a dictionary. Use the same name as the +variable to refer to other prototypes. Possible keywords are: prototype - string pointing to parent prototype of this structure @@ -15,42 +29,42 @@ Possible keywords are: locks - a lock-string aliases - string or list of strings - ndb_ - value of a nattribute (ndb_ is stripped) + ndb_ - value of a nattribute (the "ndb_" part is ignored) any other keywords are interpreted as Attributes and their values. -See the @spawn command and src.utils.spawner for more info. +See the @spawn command and evennia.utils.spawner for more info. """ -from random import randint - -NOBODY = {} - -GOBLIN = { - "key": "goblin grunt", - "health": lambda: randint(20,30), - "resists": ["cold", "poison"], - "attacks": ["fists"], - "weaknesses": ["fire", "light"] - } - -GOBLIN_WIZARD = { - "prototype": "GOBLIN", - "key": "goblin wizard", - "spells": ["fire ball", "lighting bolt"] - } - -GOBLIN_ARCHER = { - "prototype": "GOBLIN", - "key": "goblin archer", - "attacks": ["short bow"] -} - -ARCHWIZARD = { - "attacks": ["archwizard staff"], -} - -GOBLIN_ARCHWIZARD = { - "key": "goblin archwizard", - "prototype" : ("GOBLIN_WIZARD", "ARCHWIZARD") -} +#from random import randint +# +#NOBODY = {} +# +#GOBLIN = { +# "key": "goblin grunt", +# "health": lambda: randint(20,30), +# "resists": ["cold", "poison"], +# "attacks": ["fists"], +# "weaknesses": ["fire", "light"] +# } +# +#GOBLIN_WIZARD = { +# "prototype": "GOBLIN", +# "key": "goblin wizard", +# "spells": ["fire ball", "lighting bolt"] +# } +# +#GOBLIN_ARCHER = { +# "prototype": "GOBLIN", +# "key": "goblin archer", +# "attacks": ["short bow"] +#} +# +#ARCHWIZARD = { +# "attacks": ["archwizard staff"], +#} +# +#GOBLIN_ARCHWIZARD = { +# "key": "goblin archwizard", +# "prototype" : ("GOBLIN_WIZARD", "ARCHWIZARD") +#}