text_game_maker.game_objects package¶
Submodules¶
-
class
text_game_maker.game_objects.base.
GameEntity
¶ Bases:
object
Base class for anything that the player can interact with in the game, like usable items, food, people, etc.
Variables: - inanimate (bool) – defines whether this item is an inanimate object
- combustible (bool) – defines whether this item can be destroyed by fire
- scenery (bool) – defines whether this item is scenery; an immovable prop in the scene that should be mentioned before smaller interactive items when describing a room, e.g. furniture, architectural features of the room
- edible (bool) – defines whether this item is edible
- alive (bool) – defines whether this item is currently alive
- energy (int) – defines how much energy player gains by consuming this item
- damage (int) – defines how much health player loses if damaged by this item
- value (int) – defines how much money player will make by selling this item
- name (str) – name that this item will be referred to as in the game (e.g. “metal key”)
- prefix (str) – preceding word required when mentioning item, e.g. “a” for “a metal key”, and “an” for “an apple”
- home (list) – list that this Item instance lives inside; required for the deleting/moving items within the game world
- is_container (bool) – defines whether this item can contain other items
- is_electricity_source (bool) – defines whether this item is an electricity source
- requires_electricity (bool) – defines whether this item requires an electricity source to operate
- is_flame_source (bool) – defines whether this item can be used as a flame source
- is_light_source (bool) – defines whether this item can be used as a light source
- material (Material) – material this item is made of
- capacity (int) – number of items this item can contain (if container)
- items (list) – items contained inside this item (if container)
- size (int) – size of this item; containers cannot contain items with a larger size than themselves
- verb (str) – singluar verb e.g. “the key is on the floor”, or plural e.g. “the coins are on the floor”
-
__init__
()¶ x.__init__(…) initializes x; see help(type(x)) for signature
-
add_item
(item)¶ Put an item inside this item
Parameters: item (text_game_maker.game_objects.base.GameEntity) – item to add Returns: the item that was added
-
add_items
(items)¶ Put multiple items inside this item
Parameters: items ([text_game_maker.game_objects.base.GameEntity]) – list of items to add
-
add_migration
(from_version, to_version, migration_function)¶ Add function to migrate a serialized version of this object to a new object model version
Parameters: - from_version (str) – version to migrate from
- to_version (str) – version to migrate to
- migration_function – function to perform migration
-
add_to_player_inventory
(player)¶ Put this item inside player’s inventory. If add_to_player_inventory returns True, execution of the current command will continue normally. If False, execution of the current command will stop immediately.
Parameters: player (text_game_maker.player.player.Player) – player object Returns: the object that was added
-
copy
()¶
-
delete
()¶ Delete the instance of this item from whatever location list it lives in (if any)
-
full_class_name
= u'text_game_maker.game_objects.base.GameEntity'¶
-
get_attrs
()¶ Recursively serialize all attributes of this item and any contained items
Returns: serializable dict of item and contained items Return type: dict
-
get_special_attrs
()¶ Serialize any attributes that you want to handle specially here. Any attributes present in the dict returned by this function will not be serialized by the main get_attrs method. Intended for subclasses to override
Returns: serializable dict of special attributes Return type: dict
-
global_skip_attrs
= ['home', '_migrations']¶
-
matches_name
(name)¶ Tests if name matches this item’s name. Will accept substrings of a matching name, e.g. Item(name=”metal key”).matches_name(“key”) will return True.
Parameters: name (str) – name to compare against this item’s name Returns: True if name matches this items name Return type: bool
-
migrate
(old_version, attrs)¶ Migrate serialized version of this object to the current object model version
Parameters: - old_version (str) – object model version to migrate from
- attrs – object to migrate as a serialized dict
Returns: migrated serialized dict
-
move
(location)¶ Move this item to a different location list
Parameters: location (list) – location list to move item to Returns: item that was moved
-
on_attack
(player, item)¶ Called when player attacks this item
Parameters: - player (text_game_maker.player.player.Player) – player instance
- item (text_game_maker.game_objects.base.GameEntity) – item that player is using to attack this item
-
on_burn
(player)¶ Called when player burns this item.
Parameters: player (text_game_maker.player.player.Player) – player object
-
on_eat
(player, word)¶ Called when player eats this item
Parameters: - player (text_game_maker.player.player.Player) – player object
- word (str) – command word used by player
-
on_equip
(player)¶ Called when player equips this item from inventory
Parameters: player (text_game_maker.player.player.Player) – player object
-
on_look
(player)¶ Called when player looks at this item
Parameters: player (text_game_maker.player.player.Player) – player object
-
on_look_under
(player)¶ Called when player looks under this item
Parameters: player (text_game_maker.player.player.Player) – player object
-
on_open
(player)¶ Called when player opens this item
Parameters: player (text_game_maker.player.player.Player) – player object
-
on_read
(player)¶ Called when player reads this item
Parameters: player (text_game_maker.player.player.Player) – player object
-
on_smell
(player)¶ Called when player smells this item
Parameters: player (text_game_maker.player.player.Player) – player object
-
on_speak
(player)¶ Called when player speaks to this item
Parameters: player (text_game_maker.player.player.Player) – player object
-
on_take
(player)¶ Called when player attempts to take this item. If on_take returns True, this item will be added to player’s inventory. If False, this item will not be added to player’s inventory.
Parameters: player (text_game_maker.player.player.Player) – player object
-
on_taste
(player)¶ Called when player tastes this item
Parameters: player (text_game_maker.player.player.Player) – player object
-
on_unequip
(player)¶ Called when player unequips this item from inventory (by unequipping explicitly, by dropping or by equipping a different item)
Parameters: player (text_game_maker.player.player.Player) – player object
-
prep
¶
-
set_attrs
(attrs, version)¶ Recursively deserialize all attributes of this item and any contained items
Parameters: - attrs (dict) – item attributes
- version (str) – object model version of item attributes
-
set_special_attrs
(attrs, version)¶ Deserialize any attributes that you want to handle specially here. Make sure to delete any specially handled attributes from the return dict so that they are not deserialized by the main set_attrs method
Parameters: - attrs (dict) – all serialized attributes for this object
- version (str) – object model version of serialized attributes
Returns: all attributes not serialized by this method
Return type: dict
-
skip_attrs
= []¶
-
class
text_game_maker.game_objects.base.
ObjectModelMigration
(from_version, to_version, migration_function)¶ Bases:
object
-
__init__
(from_version, to_version, migration_function)¶ x.__init__(…) initializes x; see help(type(x)) for signature
-
migrate
(attrs)¶
-
-
text_game_maker.game_objects.base.
build_instance
(type_key)¶ Build an instance of a registered serializable class, by the registered class name
Parameters: type_key – registered class name Returns: instance of class associated with class name
-
text_game_maker.game_objects.base.
deserialize
(data, version)¶ Recursively deserialize item and all contained items
Parameters: - data (dict) – serialized item data
- version (str) – object model version of serialized data
Returns: deserialized object
-
text_game_maker.game_objects.base.
is_deserializable_type
(obj)¶
-
text_game_maker.game_objects.base.
serialize
(attr)¶ Recursively serialize item and return a serializable dict representing the item and all contained items
Parameters: attr – object to serialize Returns: serialized object Return type: dict
-
class
text_game_maker.game_objects.generic.
Container
(*args, **kwargs)¶ Bases:
text_game_maker.game_objects.generic.Item
Generic container with limited capacity and item size
-
__init__
(*args, **kwargs)¶ Initialises an Item instance
Parameters: - prefix (str) – Generally either “a” or “an”
- name (str) – Item name, e.g. “apple”
- location (str) – Item location, e.g. “on the floor”
- value (int) – Item value in coins
-
add_item
(item)¶ Put an item inside this item
Parameters: item (text_game_maker.game_objects.base.GameEntity) – item to add Returns: the item that was added
-
full_class_name
= u'text_game_maker.game_objects.generic.Container'¶
-
-
class
text_game_maker.game_objects.generic.
ElectricLightSource
(*args, **kwargs)¶ Bases:
text_game_maker.game_objects.generic.LightSource
Base class for an item that can be used as a light source, and can be rejuvenated with batteries when dead
-
__init__
(*args, **kwargs)¶ Initialises an Item instance
Parameters: - prefix (str) – Generally either “a” or “an”
- name (str) – Item name, e.g. “apple”
- location (str) – Item location, e.g. “on the floor”
- value (int) – Item value in coins
-
add_item
(item)¶ Put an item inside this item
Parameters: item (text_game_maker.game_objects.base.GameEntity) – item to add Returns: the item that was added
-
full_class_name
= u'text_game_maker.game_objects.generic.ElectricLightSource'¶
-
get_fuel
()¶
-
set_fuel
(value)¶
-
-
class
text_game_maker.game_objects.generic.
FlameSource
(*args, **kwargs)¶ Bases:
text_game_maker.game_objects.generic.LightSource
Base class for anything that can be used as a flame source
-
__init__
(*args, **kwargs)¶ Initialises an Item instance
Parameters: - prefix (str) – Generally either “a” or “an”
- name (str) – Item name, e.g. “apple”
- location (str) – Item location, e.g. “on the floor”
- value (int) – Item value in coins
-
full_class_name
= u'text_game_maker.game_objects.generic.FlameSource'¶
-
-
class
text_game_maker.game_objects.generic.
FuelConsumer
(*args, **kwargs)¶ Bases:
text_game_maker.game_objects.generic.Item
-
__init__
(*args, **kwargs)¶ Initialises an Item instance
Parameters: - prefix (str) – Generally either “a” or “an”
- name (str) – Item name, e.g. “apple”
- location (str) – Item location, e.g. “on the floor”
- value (int) – Item value in coins
-
decrement_fuel
()¶
-
full_class_name
= u'text_game_maker.game_objects.generic.FuelConsumer'¶
-
get_fuel
()¶
-
make_spent
(print_output=True)¶
-
on_fuel_empty
()¶
-
on_refuel
()¶
-
refuel
(fuel=None)¶
-
set_fuel
(value)¶
-
-
class
text_game_maker.game_objects.generic.
InventoryBag
(*args, **kwargs)¶ Bases:
text_game_maker.game_objects.generic.Container
Class to represent a small bag used to carry player items
-
__init__
(*args, **kwargs)¶ Initialises an Item instance
Parameters: - prefix (str) – Generally either “a” or “an”
- name (str) – Item name, e.g. “apple”
- location (str) – Item location, e.g. “on the floor”
- value (int) – Item value in coins
-
add_to_player_inventory
(player)¶ Put this item inside player’s inventory. If add_to_player_inventory returns True, execution of the current command will continue normally. If False, execution of the current command will stop immediately.
Parameters: player (text_game_maker.player.player.Player) – player object Returns: the object that was added
-
full_class_name
= u'text_game_maker.game_objects.generic.InventoryBag'¶
-
-
class
text_game_maker.game_objects.generic.
Item
(prefix='', name='', **kwargs)¶ Bases:
text_game_maker.game_objects.base.GameEntity
Base class for collectable item
-
__init__
(prefix='', name='', **kwargs)¶ Initialises an Item instance
Parameters: - prefix (str) – Generally either “a” or “an”
- name (str) – Item name, e.g. “apple”
- location (str) – Item location, e.g. “on the floor”
- value (int) – Item value in coins
-
full_class_name
= u'text_game_maker.game_objects.generic.Item'¶
-
on_eat
(player, word)¶ Called when player eats this item
Parameters: - player (text_game_maker.player.player.Player) – player object
- word (str) – command word used by player
-
set_location
(desc)¶ Set the location description of the item, e.g. “on the floor”. Items with the same location description will automatically be grouped when described to the player, e.g.”an apple, a key and a knife are on the floor”
Parameters: desc (str) – item location description
-
set_name
(name)¶ Set the name of this item
Parameters: name (str) – object name
-
set_prefix
(prefix)¶ Set item prefix word (usually ‘an’ or ‘a’)
-
set_value
(value)¶ Set the value of this item in coins
Parameters: value (int) – item value in coins
-
-
class
text_game_maker.game_objects.generic.
ItemSize
¶ Bases:
object
-
LARGE
= 3¶
-
MEDIUM
= 2¶
-
SMALL
= 1¶
-
VERY_LARGE
= 4¶
-
-
class
text_game_maker.game_objects.generic.
LargeContainer
(*args, **kwargs)¶ Bases:
text_game_maker.game_objects.generic.Container
Generic container with limited capacity and item size
-
__init__
(*args, **kwargs)¶ Initialises an Item instance
Parameters: - prefix (str) – Generally either “a” or “an”
- name (str) – Item name, e.g. “apple”
- location (str) – Item location, e.g. “on the floor”
- value (int) – Item value in coins
-
full_class_name
= u'text_game_maker.game_objects.generic.LargeContainer'¶
-
-
class
text_game_maker.game_objects.generic.
LightSource
(*args, **kwargs)¶ Bases:
text_game_maker.game_objects.generic.FuelConsumer
Base class for any item that can act as a light source
-
__init__
(*args, **kwargs)¶ Initialises an Item instance
Parameters: - prefix (str) – Generally either “a” or “an”
- name (str) – Item name, e.g. “apple”
- location (str) – Item location, e.g. “on the floor”
- value (int) – Item value in coins
-
full_class_name
= u'text_game_maker.game_objects.generic.LightSource'¶
-
on_equip
(player)¶ Called when player equips this item from inventory
Parameters: player (text_game_maker.player.player.Player) – player object
-
on_fuel_empty
(print_output=True)¶
-
on_refuel
()¶
-
on_unequip
(player)¶ Called when player unequips this item from inventory (by unequipping explicitly, by dropping or by equipping a different item)
Parameters: player (text_game_maker.player.player.Player) – player object
-
-
class
text_game_maker.game_objects.items.
AdvancedLockpick
(*args, **kwargs)¶ Bases:
text_game_maker.game_objects.generic.Item
A lockpick that can be used to unlock a finite number of locked doors.
-
__init__
(*args, **kwargs)¶ Initialises an Item instance
Parameters: - prefix (str) – Generally either “a” or “an”
- name (str) – Item name, e.g. “apple”
- location (str) – Item location, e.g. “on the floor”
- value (int) – Item value in coins
-
full_class_name
= u'text_game_maker.game_objects.items.AdvancedLockpick'¶
-
-
class
text_game_maker.game_objects.items.
Bag
(*args, **kwargs)¶ Bases:
text_game_maker.game_objects.generic.InventoryBag
A player inventory bag that can hold a medium number of items.
-
__init__
(*args, **kwargs)¶ Initialises an Item instance
Parameters: - prefix (str) – Generally either “a” or “an”
- name (str) – Item name, e.g. “apple”
- location (str) – Item location, e.g. “on the floor”
- value (int) – Item value in coins
-
full_class_name
= u'text_game_maker.game_objects.items.Bag'¶
-
-
class
text_game_maker.game_objects.items.
BaseballBat
(*args, **kwargs)¶ Bases:
text_game_maker.game_objects.items.Weapon
A baseball bat
-
__init__
(*args, **kwargs)¶ Initialises an Item instance
Parameters: - prefix (str) – Generally either “a” or “an”
- name (str) – Item name, e.g. “apple”
- location (str) – Item location, e.g. “on the floor”
- value (int) – Item value in coins
-
full_class_name
= u'text_game_maker.game_objects.items.BaseballBat'¶
-
-
class
text_game_maker.game_objects.items.
Battery
(*args, **kwargs)¶ Bases:
text_game_maker.game_objects.generic.Item
A single-use battery. Can be inserted into flashlights or other items requiring electric power.
-
__init__
(*args, **kwargs)¶ Initialises an Item instance
Parameters: - prefix (str) – Generally either “a” or “an”
- name (str) – Item name, e.g. “apple”
- location (str) – Item location, e.g. “on the floor”
- value (int) – Item value in coins
-
full_class_name
= u'text_game_maker.game_objects.items.Battery'¶
-
set_fuel
(value)¶
-
-
class
text_game_maker.game_objects.items.
Blueprint
(ingredients=[], item=None, **kwargs)¶ Bases:
text_game_maker.game_objects.generic.Item
A blueprint for crafting one new item from a fixed set of other items.
-
__init__
(ingredients=[], item=None, **kwargs)¶ Initialises an Item instance
Parameters: - prefix (str) – Generally either “a” or “an”
- name (str) – Item name, e.g. “apple”
- location (str) – Item location, e.g. “on the floor”
- value (int) – Item value in coins
-
add_to_player_inventory
(player)¶ Put this item inside player’s inventory. If add_to_player_inventory returns True, execution of the current command will continue normally. If False, execution of the current command will stop immediately.
Parameters: player (text_game_maker.player.player.Player) – player object Returns: the object that was added
-
full_class_name
= u'text_game_maker.game_objects.items.Blueprint'¶
-
on_take
(player)¶ Called when player attempts to take this item. If on_take returns True, this item will be added to player’s inventory. If False, this item will not be added to player’s inventory.
Parameters: player (text_game_maker.player.player.Player) – player object
-
-
class
text_game_maker.game_objects.items.
BoxOfMatches
(*args, **kwargs)¶ Bases:
text_game_maker.game_objects.generic.FlameSource
A box of matches. Can be used as a light source. Can also be used to burn things. When the fuel runs out, there are no more matches in the box.
-
__init__
(*args, **kwargs)¶ Initialises an Item instance
Parameters: - prefix (str) – Generally either “a” or “an”
- name (str) – Item name, e.g. “apple”
- location (str) – Item location, e.g. “on the floor”
- value (int) – Item value in coins
-
full_class_name
= u'text_game_maker.game_objects.items.BoxOfMatches'¶
-
-
class
text_game_maker.game_objects.items.
Coins
(**kwargs)¶ Bases:
text_game_maker.game_objects.generic.Item
One or more coins
-
__init__
(**kwargs)¶ Initialises an Item instance
Parameters: - prefix (str) – Generally either “a” or “an”
- name (str) – Item name, e.g. “apple”
- location (str) – Item location, e.g. “on the floor”
- value (int) – Item value in coins
-
add_to_player_inventory
(player)¶ Put this item inside player’s inventory. If add_to_player_inventory returns True, execution of the current command will continue normally. If False, execution of the current command will stop immediately.
Parameters: player (text_game_maker.player.player.Player) – player object Returns: the object that was added
-
decrement
(value=1)¶
-
full_class_name
= u'text_game_maker.game_objects.items.Coins'¶
-
increment
(value=1)¶
-
on_smell
(player)¶ Called when player smells this item
Parameters: player (text_game_maker.player.player.Player) – player object
-
on_taste
(player)¶ Called when player tastes this item
Parameters: player (text_game_maker.player.player.Player) – player object
-
value
¶
-
-
class
text_game_maker.game_objects.items.
Crowbar
(*args, **kwargs)¶ Bases:
text_game_maker.game_objects.items.Weapon
A crowbar
-
__init__
(*args, **kwargs)¶ Initialises an Item instance
Parameters: - prefix (str) – Generally either “a” or “an”
- name (str) – Item name, e.g. “apple”
- location (str) – Item location, e.g. “on the floor”
- value (int) – Item value in coins
-
full_class_name
= u'text_game_maker.game_objects.items.Crowbar'¶
-
-
class
text_game_maker.game_objects.items.
Drawing
(*args, **kwargs)¶ Bases:
text_game_maker.game_objects.generic.Item
-
__init__
(*args, **kwargs)¶ Initialises an Item instance
Parameters: - prefix (str) – Generally either “a” or “an”
- name (str) – Item name, e.g. “apple”
- location (str) – Item location, e.g. “on the floor”
- value (int) – Item value in coins
-
full_class_name
= u'text_game_maker.game_objects.items.Drawing'¶
-
-
class
text_game_maker.game_objects.items.
Flashlight
(*args, **kwargs)¶ Bases:
text_game_maker.game_objects.generic.ElectricLightSource
An electric flashlight. Allows player to see in darkness. Requires a battery.
-
__init__
(*args, **kwargs)¶ Initialises an Item instance
Parameters: - prefix (str) – Generally either “a” or “an”
- name (str) – Item name, e.g. “apple”
- location (str) – Item location, e.g. “on the floor”
- value (int) – Item value in coins
-
full_class_name
= u'text_game_maker.game_objects.items.Flashlight'¶
-
on_take
(player)¶ Called when player attempts to take this item. If on_take returns True, this item will be added to player’s inventory. If False, this item will not be added to player’s inventory.
Parameters: player (text_game_maker.player.player.Player) – player object
-
-
class
text_game_maker.game_objects.items.
Food
(*args, **kwargs)¶ Bases:
text_game_maker.game_objects.generic.Item
Generic food item
-
__init__
(*args, **kwargs)¶ Initialises an Item instance
Parameters: - prefix (str) – Generally either “a” or “an”
- name (str) – Item name, e.g. “apple”
- location (str) – Item location, e.g. “on the floor”
- value (int) – Item value in coins
-
full_class_name
= u'text_game_maker.game_objects.items.Food'¶
-
-
class
text_game_maker.game_objects.items.
Furniture
(prefix='', name='', **kwargs)¶ Bases:
text_game_maker.game_objects.generic.Item
An immovable object that the player cannot take or destroy.
-
__init__
(prefix='', name='', **kwargs)¶ Initialises an Item instance
Parameters: - prefix (str) – Generally either “a” or “an”
- name (str) – Item name, e.g. “apple”
- location (str) – Item location, e.g. “on the floor”
- value (int) – Item value in coins
-
full_class_name
= u'text_game_maker.game_objects.items.Furniture'¶
-
-
class
text_game_maker.game_objects.items.
HuntingKnife
(*args, **kwargs)¶ Bases:
text_game_maker.game_objects.items.Weapon
A larger knife. Higher damage.
-
__init__
(*args, **kwargs)¶ Initialises an Item instance
Parameters: - prefix (str) – Generally either “a” or “an”
- name (str) – Item name, e.g. “apple”
- location (str) – Item location, e.g. “on the floor”
- value (int) – Item value in coins
-
full_class_name
= u'text_game_maker.game_objects.items.HuntingKnife'¶
-
-
class
text_game_maker.game_objects.items.
LargeBag
(*args, **kwargs)¶ Bases:
text_game_maker.game_objects.generic.InventoryBag
A player inventory bag that can hold a large number of items.
-
__init__
(*args, **kwargs)¶ Initialises an Item instance
Parameters: - prefix (str) – Generally either “a” or “an”
- name (str) – Item name, e.g. “apple”
- location (str) – Item location, e.g. “on the floor”
- value (int) – Item value in coins
-
full_class_name
= u'text_game_maker.game_objects.items.LargeBag'¶
-
-
class
text_game_maker.game_objects.items.
Lighter
(*args, **kwargs)¶ Bases:
text_game_maker.game_objects.generic.FlameSource
A disposable lighter. Can be used as a light source. Can also be used to burn things. When the fuel runs out, the lighter is useless.
-
__init__
(*args, **kwargs)¶ Initialises an Item instance
Parameters: - prefix (str) – Generally either “a” or “an”
- name (str) – Item name, e.g. “apple”
- location (str) – Item location, e.g. “on the floor”
- value (int) – Item value in coins
-
full_class_name
= u'text_game_maker.game_objects.items.Lighter'¶
-
-
class
text_game_maker.game_objects.items.
Lockpick
(*args, **kwargs)¶ Bases:
text_game_maker.game_objects.generic.Item
A lockpick that can be used to unlock a finite number of locked doors.
-
__init__
(*args, **kwargs)¶ Initialises an Item instance
Parameters: - prefix (str) – Generally either “a” or “an”
- name (str) – Item name, e.g. “apple”
- location (str) – Item location, e.g. “on the floor”
- value (int) – Item value in coins
-
full_class_name
= u'text_game_maker.game_objects.items.Lockpick'¶
-
-
class
text_game_maker.game_objects.items.
Machete
(*args, **kwargs)¶ Bases:
text_game_maker.game_objects.items.Weapon
A machete
-
__init__
(*args, **kwargs)¶ Initialises an Item instance
Parameters: - prefix (str) – Generally either “a” or “an”
- name (str) – Item name, e.g. “apple”
- location (str) – Item location, e.g. “on the floor”
- value (int) – Item value in coins
-
full_class_name
= u'text_game_maker.game_objects.items.Machete'¶
-
-
class
text_game_maker.game_objects.items.
Paper
(prefix='', name='', **kwargs)¶ Bases:
text_game_maker.game_objects.generic.Item
A sheet of paper that can contain information for the player to read
-
__init__
(prefix='', name='', **kwargs)¶ Initialises an Item instance
Parameters: - prefix (str) – Generally either “a” or “an”
- name (str) – Item name, e.g. “apple”
- location (str) – Item location, e.g. “on the floor”
- value (int) – Item value in coins
-
full_class_name
= u'text_game_maker.game_objects.items.Paper'¶
-
header_text
()¶
-
on_look
(player)¶ Called when player looks at this item
Parameters: player (text_game_maker.player.player.Player) – player object
-
on_read
(player)¶ Called when player reads this item
Parameters: player (text_game_maker.player.player.Player) – player object
-
paragraphs_text
()¶
-
-
class
text_game_maker.game_objects.items.
PaperBag
(*args, **kwargs)¶ Bases:
text_game_maker.game_objects.generic.Container
A small paper bag that can hold a small number of items.
-
__init__
(*args, **kwargs)¶ Initialises an Item instance
Parameters: - prefix (str) – Generally either “a” or “an”
- name (str) – Item name, e.g. “apple”
- location (str) – Item location, e.g. “on the floor”
- value (int) – Item value in coins
-
full_class_name
= u'text_game_maker.game_objects.items.PaperBag'¶
-
-
class
text_game_maker.game_objects.items.
PocketKnife
(*args, **kwargs)¶ Bases:
text_game_maker.game_objects.items.Weapon
A small knife. Low damage.
-
__init__
(*args, **kwargs)¶ Initialises an Item instance
Parameters: - prefix (str) – Generally either “a” or “an”
- name (str) – Item name, e.g. “apple”
- location (str) – Item location, e.g. “on the floor”
- value (int) – Item value in coins
-
full_class_name
= u'text_game_maker.game_objects.items.PocketKnife'¶
-
-
class
text_game_maker.game_objects.items.
SmallBag
(*args, **kwargs)¶ Bases:
text_game_maker.game_objects.generic.InventoryBag
A player inventory bag that can hold a small number of items.
-
__init__
(*args, **kwargs)¶ Initialises an Item instance
Parameters: - prefix (str) – Generally either “a” or “an”
- name (str) – Item name, e.g. “apple”
- location (str) – Item location, e.g. “on the floor”
- value (int) – Item value in coins
-
full_class_name
= u'text_game_maker.game_objects.items.SmallBag'¶
-
-
class
text_game_maker.game_objects.items.
SmallTin
(*args, **kwargs)¶ Bases:
text_game_maker.game_objects.generic.Container
A small tin that can contain a small number of items.
-
__init__
(*args, **kwargs)¶ Initialises an Item instance
Parameters: - prefix (str) – Generally either “a” or “an”
- name (str) – Item name, e.g. “apple”
- location (str) – Item location, e.g. “on the floor”
- value (int) – Item value in coins
-
full_class_name
= u'text_game_maker.game_objects.items.SmallTin'¶
-
-
class
text_game_maker.game_objects.items.
StrongLockpick
(*args, **kwargs)¶ Bases:
text_game_maker.game_objects.generic.Item
A lockpick that can be used to unlock a finite number of locked doors.
-
__init__
(*args, **kwargs)¶ Initialises an Item instance
Parameters: - prefix (str) – Generally either “a” or “an”
- name (str) – Item name, e.g. “apple”
- location (str) – Item location, e.g. “on the floor”
- value (int) – Item value in coins
-
full_class_name
= u'text_game_maker.game_objects.items.StrongLockpick'¶
-
-
class
text_game_maker.game_objects.items.
Weapon
(prefix='', name='', **kwargs)¶ Bases:
text_game_maker.game_objects.generic.Item
Class to represent a weapon
-
__init__
(prefix='', name='', **kwargs)¶ Initialises an Item instance
Parameters: - prefix (str) – Generally either “a” or “an”
- name (str) – Item name, e.g. “apple”
- location (str) – Item location, e.g. “on the floor”
- value (int) – Item value in coins
-
full_class_name
= u'text_game_maker.game_objects.items.Weapon'¶
-
-
class
text_game_maker.game_objects.living.
Living
¶ Bases:
object
Base class to represent a living thing with a health metric
-
__init__
()¶ x.__init__(…) initializes x; see help(type(x)) for signature
-
decrement_health
(val=1)¶ Decrement health
Parameters: val (int) – number to decrement health by
-
increment_health
(val=1)¶ Increment health
Parameters: val (int) – number to increment health by
-
is_dead
()¶ Check if health has been depleted
Returns: True if health has been depleted, False otherwise Return type: bool
-
-
class
text_game_maker.game_objects.living.
LivingGameEntity
¶ Bases:
text_game_maker.game_objects.living.Living
,text_game_maker.game_objects.base.GameEntity
-
__init__
()¶ x.__init__(…) initializes x; see help(type(x)) for signature
-
full_class_name
= u'text_game_maker.game_objects.living.LivingGameEntity'¶
-
-
class
text_game_maker.game_objects.living.
LivingItem
(prefix='', name='', **kwargs)¶ Bases:
text_game_maker.game_objects.living.Living
,text_game_maker.game_objects.generic.Item
-
__init__
(prefix='', name='', **kwargs)¶ Initialises an Item instance
Parameters: - prefix (str) – Generally either “a” or “an”
- name (str) – Item name, e.g. “apple”
- location (str) – Item location, e.g. “on the floor”
- value (int) – Item value in coins
-
full_class_name
= u'text_game_maker.game_objects.living.LivingItem'¶
-
-
class
text_game_maker.game_objects.person.
Context
(*args, **kwargs)¶ Bases:
text_game_maker.game_objects.base.GameEntity
,text_game_maker.chatbot_utils.responder.Context
See text_game_maker.chatbot_utils.responder.Context
-
__init__
(*args, **kwargs)¶ x.__init__(…) initializes x; see help(type(x)) for signature
-
full_class_name
= u'text_game_maker.game_objects.person.Context'¶
-
get_special_attrs
()¶ Serialize any attributes that you want to handle specially here. Any attributes present in the dict returned by this function will not be serialized by the main get_attrs method. Intended for subclasses to override
Returns: serializable dict of special attributes Return type: dict
-
set_special_attrs
(attrs, version)¶ Deserialize any attributes that you want to handle specially here. Make sure to delete any specially handled attributes from the return dict so that they are not deserialized by the main set_attrs method
Parameters: - attrs (dict) – all serialized attributes for this object
- version (str) – object model version of serialized attributes
Returns: all attributes not serialized by this method
Return type: dict
-
-
class
text_game_maker.game_objects.person.
Person
(prefix='', name='', **kwargs)¶ Bases:
text_game_maker.game_objects.living.LivingItem
Represents a person that the player can interact with
-
__init__
(prefix='', name='', **kwargs)¶ Initialises a Person instance
Parameters: - name (str) – name of Person, e.g. “John”
- description (str) – location description of Person, e.g. “squatting in the corner”
- items (list) – List of Items held by this person
-
add_coins
(value=1)¶ Give person some coins
Parameters: value (int) – number of coins to add
-
add_context
(context)¶ Add a discussion context to this person. See text_game_maker.chatbot_utils.responder.Context.add_context
-
add_contexts
(*contexts)¶ Add multiple discussion contexts to this person. See text_game_maker.chatbot_utils.responder.Context.add_contexts
-
add_default_responses
(*responses)¶ Set responses to reply with when the player types something does not match any of the added patterns when speaking to this person
Parameters: responses – one or more responses to pick randomly from. Responses may be either a string of text to speak, or a callback of the form callback(person, player)
, whereperson
is the Person object the player is speaking to, andplayer
is the Player object
-
add_response
(patterns, response)¶ Set responses to reply with when player types a specific pattern when talking to this person
Parameters: - patterns (list) – list of regular expressions that will be used to check player input
- responses (list) – list of responses to pick randomly from if the player says something that matches one of the patterns in
patterns
. Responses may be either a string of text to speak, or a callback of the formcallback(person, player)
, whereperson
is the Person object the player is speaking to, andplayer
is the Player object
-
add_responses
(*pattern_response_pairs)¶ Set multiple pattern/response pairs at once
Parameters: responses – one or more response pairs, where each pair is a tuple containing arguments for a single add_response
call, e.g.add_responses((['cat.*'], ['meow']), (['dog.*], ['woof']))
-
add_shopping_list
(*item_value_pairs)¶ Add the names of items this person is willing to buy from the player if the player asks, and the price person is willing to pay for them
Parameters: item_value_pairs – one or more tuples of the form (item_name, value)
, whereitem_name
is the item name as a string, andvalue
is an integer representing the price in coins
-
clear_shopping_list
()¶ Clear this persons current shopping list
-
die
(player, msg=None)¶ Kill this person, and print a message to inform the player of this person’s death.
Parameters: - player (text_game_maker.player.player.Player) – player instance
- msg (str) – message to print informing player of person’s death
-
find_item_class
(classobj)¶ Find an item held by this person which is an instance of a specific class
Parameters: classobj – class to look for an instance of Returns: instance of classobj if found, otherwise None
-
full_class_name
= u'text_game_maker.game_objects.person.Person'¶
-
get_response
(text)¶ Get the response this person should speak back to the player, for a given input string typed by the player
Parameters: text (str) – input string to respond to Returns: tuple of the form (response, groups) where response
is the response text as a string, andgroups
is a tuple of subgroups from the regular expression match (as returned by re.MatchObject.groups), if any, otherwise None.
-
get_special_attrs
()¶ Serialize any attributes that you want to handle specially here. Any attributes present in the dict returned by this function will not be serialized by the main get_attrs method. Intended for subclasses to override
Returns: serializable dict of special attributes Return type: dict
-
on_attack
(player, item)¶ Called when player attacks this item
Parameters: - player (text_game_maker.player.player.Player) – player instance
- item (text_game_maker.game_objects.base.GameEntity) – item that player is using to attack this item
-
on_eat
(player, word)¶ Called when player eats this item
Parameters: - player (text_game_maker.player.player.Player) – player object
- word (str) – command word used by player
-
on_look
(player)¶ Called when player looks at this item
Parameters: player (text_game_maker.player.player.Player) – player object
-
on_speak
(player)¶ Called when player speaks to this item
Parameters: player (text_game_maker.player.player.Player) – player object
-
say
(msg)¶ Speak to the player
Parameters: msg (str) – message to speak
-
set_introduction
(msg)¶ Set some text for the person to say unprompted, immediately, when the player initates a conversation
Parameters: msg (str) – text to speak
-
set_special_attrs
(attrs, version)¶ Deserialize any attributes that you want to handle specially here. Make sure to delete any specially handled attributes from the return dict so that they are not deserialized by the main set_attrs method
Parameters: - attrs (dict) – all serialized attributes for this object
- version (str) – object model version of serialized attributes
Returns: all attributes not serialized by this method
Return type: dict
-
-
class
text_game_maker.game_objects.person.
Responder
(*args, **kwargs)¶ Bases:
text_game_maker.game_objects.base.GameEntity
,text_game_maker.chatbot_utils.responder.Responder
See text_game_maker.chatbot_utils.responder.Responder
-
__init__
(*args, **kwargs)¶ x.__init__(…) initializes x; see help(type(x)) for signature
-
full_class_name
= u'text_game_maker.game_objects.person.Responder'¶
-
get_special_attrs
()¶ Serialize any attributes that you want to handle specially here. Any attributes present in the dict returned by this function will not be serialized by the main get_attrs method. Intended for subclasses to override
Returns: serializable dict of special attributes Return type: dict
-
set_special_attrs
(attrs, version)¶ Deserialize any attributes that you want to handle specially here. Make sure to delete any specially handled attributes from the return dict so that they are not deserialized by the main set_attrs method
Parameters: - attrs (dict) – all serialized attributes for this object
- version (str) – object model version of serialized attributes
Returns: all attributes not serialized by this method
Return type: dict
-