diff --git a/src/__pycache__/define.cpython-34.pyc b/src/__pycache__/define.cpython-34.pyc new file mode 100644 index 0000000..66494b8 --- /dev/null +++ b/src/__pycache__/define.cpython-34.pyc Binary files differ diff --git a/src/__pycache__/define.cpython-34.pyc b/src/__pycache__/define.cpython-34.pyc new file mode 100644 index 0000000..66494b8 --- /dev/null +++ b/src/__pycache__/define.cpython-34.pyc Binary files differ diff --git a/src/__pycache__/interpreter.cpython-34.pyc b/src/__pycache__/interpreter.cpython-34.pyc index dac27af..cdad395 100644 --- a/src/__pycache__/interpreter.cpython-34.pyc +++ b/src/__pycache__/interpreter.cpython-34.pyc Binary files differ diff --git a/src/__pycache__/define.cpython-34.pyc b/src/__pycache__/define.cpython-34.pyc new file mode 100644 index 0000000..66494b8 --- /dev/null +++ b/src/__pycache__/define.cpython-34.pyc Binary files differ diff --git a/src/__pycache__/interpreter.cpython-34.pyc b/src/__pycache__/interpreter.cpython-34.pyc index dac27af..cdad395 100644 --- a/src/__pycache__/interpreter.cpython-34.pyc +++ b/src/__pycache__/interpreter.cpython-34.pyc Binary files differ diff --git a/src/__pycache__/place.cpython-34.pyc b/src/__pycache__/place.cpython-34.pyc index 5eaa6ef..53dd235 100644 --- a/src/__pycache__/place.cpython-34.pyc +++ b/src/__pycache__/place.cpython-34.pyc Binary files differ diff --git a/src/__pycache__/define.cpython-34.pyc b/src/__pycache__/define.cpython-34.pyc new file mode 100644 index 0000000..66494b8 --- /dev/null +++ b/src/__pycache__/define.cpython-34.pyc Binary files differ diff --git a/src/__pycache__/interpreter.cpython-34.pyc b/src/__pycache__/interpreter.cpython-34.pyc index dac27af..cdad395 100644 --- a/src/__pycache__/interpreter.cpython-34.pyc +++ b/src/__pycache__/interpreter.cpython-34.pyc Binary files differ diff --git a/src/__pycache__/place.cpython-34.pyc b/src/__pycache__/place.cpython-34.pyc index 5eaa6ef..53dd235 100644 --- a/src/__pycache__/place.cpython-34.pyc +++ b/src/__pycache__/place.cpython-34.pyc Binary files differ diff --git a/src/__pycache__/server.cpython-34.pyc b/src/__pycache__/server.cpython-34.pyc index 45db28b..a8fe16e 100644 --- a/src/__pycache__/server.cpython-34.pyc +++ b/src/__pycache__/server.cpython-34.pyc Binary files differ diff --git a/src/__pycache__/define.cpython-34.pyc b/src/__pycache__/define.cpython-34.pyc new file mode 100644 index 0000000..66494b8 --- /dev/null +++ b/src/__pycache__/define.cpython-34.pyc Binary files differ diff --git a/src/__pycache__/interpreter.cpython-34.pyc b/src/__pycache__/interpreter.cpython-34.pyc index dac27af..cdad395 100644 --- a/src/__pycache__/interpreter.cpython-34.pyc +++ b/src/__pycache__/interpreter.cpython-34.pyc Binary files differ diff --git a/src/__pycache__/place.cpython-34.pyc b/src/__pycache__/place.cpython-34.pyc index 5eaa6ef..53dd235 100644 --- a/src/__pycache__/place.cpython-34.pyc +++ b/src/__pycache__/place.cpython-34.pyc Binary files differ diff --git a/src/__pycache__/server.cpython-34.pyc b/src/__pycache__/server.cpython-34.pyc index 45db28b..a8fe16e 100644 --- a/src/__pycache__/server.cpython-34.pyc +++ b/src/__pycache__/server.cpython-34.pyc Binary files differ diff --git a/src/__pycache__/world.cpython-34.pyc b/src/__pycache__/world.cpython-34.pyc index 6102fe5..acde556 100644 --- a/src/__pycache__/world.cpython-34.pyc +++ b/src/__pycache__/world.cpython-34.pyc Binary files differ diff --git a/src/__pycache__/define.cpython-34.pyc b/src/__pycache__/define.cpython-34.pyc new file mode 100644 index 0000000..66494b8 --- /dev/null +++ b/src/__pycache__/define.cpython-34.pyc Binary files differ diff --git a/src/__pycache__/interpreter.cpython-34.pyc b/src/__pycache__/interpreter.cpython-34.pyc index dac27af..cdad395 100644 --- a/src/__pycache__/interpreter.cpython-34.pyc +++ b/src/__pycache__/interpreter.cpython-34.pyc Binary files differ diff --git a/src/__pycache__/place.cpython-34.pyc b/src/__pycache__/place.cpython-34.pyc index 5eaa6ef..53dd235 100644 --- a/src/__pycache__/place.cpython-34.pyc +++ b/src/__pycache__/place.cpython-34.pyc Binary files differ diff --git a/src/__pycache__/server.cpython-34.pyc b/src/__pycache__/server.cpython-34.pyc index 45db28b..a8fe16e 100644 --- a/src/__pycache__/server.cpython-34.pyc +++ b/src/__pycache__/server.cpython-34.pyc Binary files differ diff --git a/src/__pycache__/world.cpython-34.pyc b/src/__pycache__/world.cpython-34.pyc index 6102fe5..acde556 100644 --- a/src/__pycache__/world.cpython-34.pyc +++ b/src/__pycache__/world.cpython-34.pyc Binary files differ diff --git a/src/define.py b/src/define.py new file mode 100644 index 0000000..7111301 --- /dev/null +++ b/src/define.py @@ -0,0 +1,64 @@ +#!/usr/bin/python3 +# +# Atlantis is a framework for creating multi-user dungeon worlds. +# This module houses the code for the define blocks of the Atlantis +# ATL language. +# +# Licensed under the terms of the GPLv3 +# author: Daniel Vedder +# date: 04/05/2015 +# + + +class DefineCommand(object): + ''' + This is the super class for all define commands. It should be extended + for each individual command, like define-place, define-monster, etc. + + Each define command works by creating the relevant object, then fleshing + it out as more options are passed to it. Finally, the finished object is + returned. + ''' + + def __init__(self, name, doc_string): + self.name = name + self.doc_string = doc_string + self.option_registry = dict() + + def init_object(self, object_name): + ''' + Initialize the object this command creates + ''' + raise NotImplementedError + + def return_object(self): + ''' + Return the type of the game object ('place', 'npc', 'item' or + 'monster') and the object itself + ''' + raise NotImplementedError + + def pass_option(self, option_name, option_argument): + ''' + Pass this define command one of its options and the relevant argument + ''' + self.option_registry[option_name]["function"](option_argument) + + def add_option(self, option_name, option_docstring, option_function): + ''' + Add an option for this define command. Arguments: + option_name: The name of this option as it would appear in + an atl source file + option_docstring: A description of this option + option_function: The function that this option calls + (this function should take exactly one string argument) + ''' + option_dict = dict(docstring=option_docstring, function=option_function) + self.option_registry[option_name] = option_dict + + +define_command_registry = dict() + +def register_define_command(def_com): + define_command_registry[def_com.name] = def_com + diff --git a/src/__pycache__/define.cpython-34.pyc b/src/__pycache__/define.cpython-34.pyc new file mode 100644 index 0000000..66494b8 --- /dev/null +++ b/src/__pycache__/define.cpython-34.pyc Binary files differ diff --git a/src/__pycache__/interpreter.cpython-34.pyc b/src/__pycache__/interpreter.cpython-34.pyc index dac27af..cdad395 100644 --- a/src/__pycache__/interpreter.cpython-34.pyc +++ b/src/__pycache__/interpreter.cpython-34.pyc Binary files differ diff --git a/src/__pycache__/place.cpython-34.pyc b/src/__pycache__/place.cpython-34.pyc index 5eaa6ef..53dd235 100644 --- a/src/__pycache__/place.cpython-34.pyc +++ b/src/__pycache__/place.cpython-34.pyc Binary files differ diff --git a/src/__pycache__/server.cpython-34.pyc b/src/__pycache__/server.cpython-34.pyc index 45db28b..a8fe16e 100644 --- a/src/__pycache__/server.cpython-34.pyc +++ b/src/__pycache__/server.cpython-34.pyc Binary files differ diff --git a/src/__pycache__/world.cpython-34.pyc b/src/__pycache__/world.cpython-34.pyc index 6102fe5..acde556 100644 --- a/src/__pycache__/world.cpython-34.pyc +++ b/src/__pycache__/world.cpython-34.pyc Binary files differ diff --git a/src/define.py b/src/define.py new file mode 100644 index 0000000..7111301 --- /dev/null +++ b/src/define.py @@ -0,0 +1,64 @@ +#!/usr/bin/python3 +# +# Atlantis is a framework for creating multi-user dungeon worlds. +# This module houses the code for the define blocks of the Atlantis +# ATL language. +# +# Licensed under the terms of the GPLv3 +# author: Daniel Vedder +# date: 04/05/2015 +# + + +class DefineCommand(object): + ''' + This is the super class for all define commands. It should be extended + for each individual command, like define-place, define-monster, etc. + + Each define command works by creating the relevant object, then fleshing + it out as more options are passed to it. Finally, the finished object is + returned. + ''' + + def __init__(self, name, doc_string): + self.name = name + self.doc_string = doc_string + self.option_registry = dict() + + def init_object(self, object_name): + ''' + Initialize the object this command creates + ''' + raise NotImplementedError + + def return_object(self): + ''' + Return the type of the game object ('place', 'npc', 'item' or + 'monster') and the object itself + ''' + raise NotImplementedError + + def pass_option(self, option_name, option_argument): + ''' + Pass this define command one of its options and the relevant argument + ''' + self.option_registry[option_name]["function"](option_argument) + + def add_option(self, option_name, option_docstring, option_function): + ''' + Add an option for this define command. Arguments: + option_name: The name of this option as it would appear in + an atl source file + option_docstring: A description of this option + option_function: The function that this option calls + (this function should take exactly one string argument) + ''' + option_dict = dict(docstring=option_docstring, function=option_function) + self.option_registry[option_name] = option_dict + + +define_command_registry = dict() + +def register_define_command(def_com): + define_command_registry[def_com.name] = def_com + diff --git a/src/interpreter.py b/src/interpreter.py index 1da4220..ada02df 100644 --- a/src/interpreter.py +++ b/src/interpreter.py @@ -10,59 +10,7 @@ # from world import World - - -class DefineCommand(object): - ''' - This is the super class for all define commands. It should be extended - for each individual command, like define-place, define-monster, etc. - - Each define command works by creating the relevant object, then fleshing - it out as more options are passed to it. Finally, the finished object is - returned. - ''' - - def __init__(self, name, doc_string): - self.name = name - self.doc_string = doc_string - self.option_registry = dict() - - def init_object(self, object_name): - ''' - Initialize the object this command creates - ''' - raise NotImplementedError - - def return_object(self): - ''' - Return the type of the game object ('place', 'npc', 'item' or - 'monster') and the object itself - ''' - raise NotImplementedError - - def pass_option(self, option_name, option_argument): - ''' - Pass this define command one of its options and the relevant argument - ''' - self.option_registry[option_name]["function"](option_argument) - - def add_option(self, option_name, option_docstring, option_function): - ''' - Add an option for this define command. Arguments: - option_name: The name of this option as it would appear in - an atl source file - option_docstring: A description of this option - option_function: The function that this option calls - (this function should take exactly one string argument) - ''' - option_dict = dict(docstring=option_docstring, function=option_function) - self.option_registry[option_name] = option_dict - - -define_command_registry = dict() - -def register_define_command(def_com): - define_command_registry[def_com.name] = def_com +from define import DefineCommand, define_command_registry class Parser(object): diff --git a/src/__pycache__/define.cpython-34.pyc b/src/__pycache__/define.cpython-34.pyc new file mode 100644 index 0000000..66494b8 --- /dev/null +++ b/src/__pycache__/define.cpython-34.pyc Binary files differ diff --git a/src/__pycache__/interpreter.cpython-34.pyc b/src/__pycache__/interpreter.cpython-34.pyc index dac27af..cdad395 100644 --- a/src/__pycache__/interpreter.cpython-34.pyc +++ b/src/__pycache__/interpreter.cpython-34.pyc Binary files differ diff --git a/src/__pycache__/place.cpython-34.pyc b/src/__pycache__/place.cpython-34.pyc index 5eaa6ef..53dd235 100644 --- a/src/__pycache__/place.cpython-34.pyc +++ b/src/__pycache__/place.cpython-34.pyc Binary files differ diff --git a/src/__pycache__/server.cpython-34.pyc b/src/__pycache__/server.cpython-34.pyc index 45db28b..a8fe16e 100644 --- a/src/__pycache__/server.cpython-34.pyc +++ b/src/__pycache__/server.cpython-34.pyc Binary files differ diff --git a/src/__pycache__/world.cpython-34.pyc b/src/__pycache__/world.cpython-34.pyc index 6102fe5..acde556 100644 --- a/src/__pycache__/world.cpython-34.pyc +++ b/src/__pycache__/world.cpython-34.pyc Binary files differ diff --git a/src/define.py b/src/define.py new file mode 100644 index 0000000..7111301 --- /dev/null +++ b/src/define.py @@ -0,0 +1,64 @@ +#!/usr/bin/python3 +# +# Atlantis is a framework for creating multi-user dungeon worlds. +# This module houses the code for the define blocks of the Atlantis +# ATL language. +# +# Licensed under the terms of the GPLv3 +# author: Daniel Vedder +# date: 04/05/2015 +# + + +class DefineCommand(object): + ''' + This is the super class for all define commands. It should be extended + for each individual command, like define-place, define-monster, etc. + + Each define command works by creating the relevant object, then fleshing + it out as more options are passed to it. Finally, the finished object is + returned. + ''' + + def __init__(self, name, doc_string): + self.name = name + self.doc_string = doc_string + self.option_registry = dict() + + def init_object(self, object_name): + ''' + Initialize the object this command creates + ''' + raise NotImplementedError + + def return_object(self): + ''' + Return the type of the game object ('place', 'npc', 'item' or + 'monster') and the object itself + ''' + raise NotImplementedError + + def pass_option(self, option_name, option_argument): + ''' + Pass this define command one of its options and the relevant argument + ''' + self.option_registry[option_name]["function"](option_argument) + + def add_option(self, option_name, option_docstring, option_function): + ''' + Add an option for this define command. Arguments: + option_name: The name of this option as it would appear in + an atl source file + option_docstring: A description of this option + option_function: The function that this option calls + (this function should take exactly one string argument) + ''' + option_dict = dict(docstring=option_docstring, function=option_function) + self.option_registry[option_name] = option_dict + + +define_command_registry = dict() + +def register_define_command(def_com): + define_command_registry[def_com.name] = def_com + diff --git a/src/interpreter.py b/src/interpreter.py index 1da4220..ada02df 100644 --- a/src/interpreter.py +++ b/src/interpreter.py @@ -10,59 +10,7 @@ # from world import World - - -class DefineCommand(object): - ''' - This is the super class for all define commands. It should be extended - for each individual command, like define-place, define-monster, etc. - - Each define command works by creating the relevant object, then fleshing - it out as more options are passed to it. Finally, the finished object is - returned. - ''' - - def __init__(self, name, doc_string): - self.name = name - self.doc_string = doc_string - self.option_registry = dict() - - def init_object(self, object_name): - ''' - Initialize the object this command creates - ''' - raise NotImplementedError - - def return_object(self): - ''' - Return the type of the game object ('place', 'npc', 'item' or - 'monster') and the object itself - ''' - raise NotImplementedError - - def pass_option(self, option_name, option_argument): - ''' - Pass this define command one of its options and the relevant argument - ''' - self.option_registry[option_name]["function"](option_argument) - - def add_option(self, option_name, option_docstring, option_function): - ''' - Add an option for this define command. Arguments: - option_name: The name of this option as it would appear in - an atl source file - option_docstring: A description of this option - option_function: The function that this option calls - (this function should take exactly one string argument) - ''' - option_dict = dict(docstring=option_docstring, function=option_function) - self.option_registry[option_name] = option_dict - - -define_command_registry = dict() - -def register_define_command(def_com): - define_command_registry[def_com.name] = def_com +from define import DefineCommand, define_command_registry class Parser(object): diff --git a/src/place.py b/src/place.py index 86ea286..d092c42 100644 --- a/src/place.py +++ b/src/place.py @@ -9,7 +9,7 @@ # date: 02/05/2015 # -from interpreter import DefineCommand, register_define_command +from define import DefineCommand, register_define_command class Place(object): @@ -39,6 +39,9 @@ self.npc = npc self.items = items + def set_description(self, description): + self.description = description + def add_neighbour(self, place_name): if place_name not in self.neighbours: self.neighbours.append(place_name) diff --git a/src/__pycache__/define.cpython-34.pyc b/src/__pycache__/define.cpython-34.pyc new file mode 100644 index 0000000..66494b8 --- /dev/null +++ b/src/__pycache__/define.cpython-34.pyc Binary files differ diff --git a/src/__pycache__/interpreter.cpython-34.pyc b/src/__pycache__/interpreter.cpython-34.pyc index dac27af..cdad395 100644 --- a/src/__pycache__/interpreter.cpython-34.pyc +++ b/src/__pycache__/interpreter.cpython-34.pyc Binary files differ diff --git a/src/__pycache__/place.cpython-34.pyc b/src/__pycache__/place.cpython-34.pyc index 5eaa6ef..53dd235 100644 --- a/src/__pycache__/place.cpython-34.pyc +++ b/src/__pycache__/place.cpython-34.pyc Binary files differ diff --git a/src/__pycache__/server.cpython-34.pyc b/src/__pycache__/server.cpython-34.pyc index 45db28b..a8fe16e 100644 --- a/src/__pycache__/server.cpython-34.pyc +++ b/src/__pycache__/server.cpython-34.pyc Binary files differ diff --git a/src/__pycache__/world.cpython-34.pyc b/src/__pycache__/world.cpython-34.pyc index 6102fe5..acde556 100644 --- a/src/__pycache__/world.cpython-34.pyc +++ b/src/__pycache__/world.cpython-34.pyc Binary files differ diff --git a/src/define.py b/src/define.py new file mode 100644 index 0000000..7111301 --- /dev/null +++ b/src/define.py @@ -0,0 +1,64 @@ +#!/usr/bin/python3 +# +# Atlantis is a framework for creating multi-user dungeon worlds. +# This module houses the code for the define blocks of the Atlantis +# ATL language. +# +# Licensed under the terms of the GPLv3 +# author: Daniel Vedder +# date: 04/05/2015 +# + + +class DefineCommand(object): + ''' + This is the super class for all define commands. It should be extended + for each individual command, like define-place, define-monster, etc. + + Each define command works by creating the relevant object, then fleshing + it out as more options are passed to it. Finally, the finished object is + returned. + ''' + + def __init__(self, name, doc_string): + self.name = name + self.doc_string = doc_string + self.option_registry = dict() + + def init_object(self, object_name): + ''' + Initialize the object this command creates + ''' + raise NotImplementedError + + def return_object(self): + ''' + Return the type of the game object ('place', 'npc', 'item' or + 'monster') and the object itself + ''' + raise NotImplementedError + + def pass_option(self, option_name, option_argument): + ''' + Pass this define command one of its options and the relevant argument + ''' + self.option_registry[option_name]["function"](option_argument) + + def add_option(self, option_name, option_docstring, option_function): + ''' + Add an option for this define command. Arguments: + option_name: The name of this option as it would appear in + an atl source file + option_docstring: A description of this option + option_function: The function that this option calls + (this function should take exactly one string argument) + ''' + option_dict = dict(docstring=option_docstring, function=option_function) + self.option_registry[option_name] = option_dict + + +define_command_registry = dict() + +def register_define_command(def_com): + define_command_registry[def_com.name] = def_com + diff --git a/src/interpreter.py b/src/interpreter.py index 1da4220..ada02df 100644 --- a/src/interpreter.py +++ b/src/interpreter.py @@ -10,59 +10,7 @@ # from world import World - - -class DefineCommand(object): - ''' - This is the super class for all define commands. It should be extended - for each individual command, like define-place, define-monster, etc. - - Each define command works by creating the relevant object, then fleshing - it out as more options are passed to it. Finally, the finished object is - returned. - ''' - - def __init__(self, name, doc_string): - self.name = name - self.doc_string = doc_string - self.option_registry = dict() - - def init_object(self, object_name): - ''' - Initialize the object this command creates - ''' - raise NotImplementedError - - def return_object(self): - ''' - Return the type of the game object ('place', 'npc', 'item' or - 'monster') and the object itself - ''' - raise NotImplementedError - - def pass_option(self, option_name, option_argument): - ''' - Pass this define command one of its options and the relevant argument - ''' - self.option_registry[option_name]["function"](option_argument) - - def add_option(self, option_name, option_docstring, option_function): - ''' - Add an option for this define command. Arguments: - option_name: The name of this option as it would appear in - an atl source file - option_docstring: A description of this option - option_function: The function that this option calls - (this function should take exactly one string argument) - ''' - option_dict = dict(docstring=option_docstring, function=option_function) - self.option_registry[option_name] = option_dict - - -define_command_registry = dict() - -def register_define_command(def_com): - define_command_registry[def_com.name] = def_com +from define import DefineCommand, define_command_registry class Parser(object): diff --git a/src/place.py b/src/place.py index 86ea286..d092c42 100644 --- a/src/place.py +++ b/src/place.py @@ -9,7 +9,7 @@ # date: 02/05/2015 # -from interpreter import DefineCommand, register_define_command +from define import DefineCommand, register_define_command class Place(object): @@ -39,6 +39,9 @@ self.npc = npc self.items = items + def set_description(self, description): + self.description = description + def add_neighbour(self, place_name): if place_name not in self.neighbours: self.neighbours.append(place_name) diff --git a/src/server.py b/src/server.py index c3b1abf..f156805 100644 --- a/src/server.py +++ b/src/server.py @@ -32,4 +32,4 @@ places = self.world.places.keys() for p in places: print("Place: "+self.world.get_place(p).name) - print("Neighbours: "+self.world.get_place(p).neighbours+"\n") + print("Neighbours: "+str(self.world.get_place(p).neighbours)+"\n") diff --git a/src/__pycache__/define.cpython-34.pyc b/src/__pycache__/define.cpython-34.pyc new file mode 100644 index 0000000..66494b8 --- /dev/null +++ b/src/__pycache__/define.cpython-34.pyc Binary files differ diff --git a/src/__pycache__/interpreter.cpython-34.pyc b/src/__pycache__/interpreter.cpython-34.pyc index dac27af..cdad395 100644 --- a/src/__pycache__/interpreter.cpython-34.pyc +++ b/src/__pycache__/interpreter.cpython-34.pyc Binary files differ diff --git a/src/__pycache__/place.cpython-34.pyc b/src/__pycache__/place.cpython-34.pyc index 5eaa6ef..53dd235 100644 --- a/src/__pycache__/place.cpython-34.pyc +++ b/src/__pycache__/place.cpython-34.pyc Binary files differ diff --git a/src/__pycache__/server.cpython-34.pyc b/src/__pycache__/server.cpython-34.pyc index 45db28b..a8fe16e 100644 --- a/src/__pycache__/server.cpython-34.pyc +++ b/src/__pycache__/server.cpython-34.pyc Binary files differ diff --git a/src/__pycache__/world.cpython-34.pyc b/src/__pycache__/world.cpython-34.pyc index 6102fe5..acde556 100644 --- a/src/__pycache__/world.cpython-34.pyc +++ b/src/__pycache__/world.cpython-34.pyc Binary files differ diff --git a/src/define.py b/src/define.py new file mode 100644 index 0000000..7111301 --- /dev/null +++ b/src/define.py @@ -0,0 +1,64 @@ +#!/usr/bin/python3 +# +# Atlantis is a framework for creating multi-user dungeon worlds. +# This module houses the code for the define blocks of the Atlantis +# ATL language. +# +# Licensed under the terms of the GPLv3 +# author: Daniel Vedder +# date: 04/05/2015 +# + + +class DefineCommand(object): + ''' + This is the super class for all define commands. It should be extended + for each individual command, like define-place, define-monster, etc. + + Each define command works by creating the relevant object, then fleshing + it out as more options are passed to it. Finally, the finished object is + returned. + ''' + + def __init__(self, name, doc_string): + self.name = name + self.doc_string = doc_string + self.option_registry = dict() + + def init_object(self, object_name): + ''' + Initialize the object this command creates + ''' + raise NotImplementedError + + def return_object(self): + ''' + Return the type of the game object ('place', 'npc', 'item' or + 'monster') and the object itself + ''' + raise NotImplementedError + + def pass_option(self, option_name, option_argument): + ''' + Pass this define command one of its options and the relevant argument + ''' + self.option_registry[option_name]["function"](option_argument) + + def add_option(self, option_name, option_docstring, option_function): + ''' + Add an option for this define command. Arguments: + option_name: The name of this option as it would appear in + an atl source file + option_docstring: A description of this option + option_function: The function that this option calls + (this function should take exactly one string argument) + ''' + option_dict = dict(docstring=option_docstring, function=option_function) + self.option_registry[option_name] = option_dict + + +define_command_registry = dict() + +def register_define_command(def_com): + define_command_registry[def_com.name] = def_com + diff --git a/src/interpreter.py b/src/interpreter.py index 1da4220..ada02df 100644 --- a/src/interpreter.py +++ b/src/interpreter.py @@ -10,59 +10,7 @@ # from world import World - - -class DefineCommand(object): - ''' - This is the super class for all define commands. It should be extended - for each individual command, like define-place, define-monster, etc. - - Each define command works by creating the relevant object, then fleshing - it out as more options are passed to it. Finally, the finished object is - returned. - ''' - - def __init__(self, name, doc_string): - self.name = name - self.doc_string = doc_string - self.option_registry = dict() - - def init_object(self, object_name): - ''' - Initialize the object this command creates - ''' - raise NotImplementedError - - def return_object(self): - ''' - Return the type of the game object ('place', 'npc', 'item' or - 'monster') and the object itself - ''' - raise NotImplementedError - - def pass_option(self, option_name, option_argument): - ''' - Pass this define command one of its options and the relevant argument - ''' - self.option_registry[option_name]["function"](option_argument) - - def add_option(self, option_name, option_docstring, option_function): - ''' - Add an option for this define command. Arguments: - option_name: The name of this option as it would appear in - an atl source file - option_docstring: A description of this option - option_function: The function that this option calls - (this function should take exactly one string argument) - ''' - option_dict = dict(docstring=option_docstring, function=option_function) - self.option_registry[option_name] = option_dict - - -define_command_registry = dict() - -def register_define_command(def_com): - define_command_registry[def_com.name] = def_com +from define import DefineCommand, define_command_registry class Parser(object): diff --git a/src/place.py b/src/place.py index 86ea286..d092c42 100644 --- a/src/place.py +++ b/src/place.py @@ -9,7 +9,7 @@ # date: 02/05/2015 # -from interpreter import DefineCommand, register_define_command +from define import DefineCommand, register_define_command class Place(object): @@ -39,6 +39,9 @@ self.npc = npc self.items = items + def set_description(self, description): + self.description = description + def add_neighbour(self, place_name): if place_name not in self.neighbours: self.neighbours.append(place_name) diff --git a/src/server.py b/src/server.py index c3b1abf..f156805 100644 --- a/src/server.py +++ b/src/server.py @@ -32,4 +32,4 @@ places = self.world.places.keys() for p in places: print("Place: "+self.world.get_place(p).name) - print("Neighbours: "+self.world.get_place(p).neighbours+"\n") + print("Neighbours: "+str(self.world.get_place(p).neighbours)+"\n") diff --git a/src/world.py b/src/world.py index 1165f30..15263ac 100644 --- a/src/world.py +++ b/src/world.py @@ -10,7 +10,7 @@ import copy #import player -#import place +import place class World(object): @@ -50,13 +50,13 @@ game_object: the actual object ''' if object_type == "place": - add_place(game_object) + self.add_place(game_object) elif object_type == "npc": - add_npc(game_object) + self.add_npc(game_object) elif object_type == "item": - add_item(game_object) + self.add_item(game_object) elif object_type == "monster": - add_monster(game_object) + self.add_monster(game_object) def add_place(self, place): self.places[place.name] = place