text_game_maker.builder package¶
Submodules¶
-
class
text_game_maker.builder.map_builder.
MapBuilder
(parser)¶ Bases:
object
Base class for building a tile-based map
-
__init__
(parser)¶ Initialises a MapBuilder instance.
Parameters: text_game_maker.parser.parser.CommandParser – command parser
-
add_door
(prefix, name, direction, doorclass=<class 'text_game_maker.tile.tile.LockedDoor'>, door_id=None)¶ Add a locked door that blocks the player from exiting the current room
Parameters: - prefix (str) – prefix for door name, e.g. “a”
- name (str) – door name, e.g. “locked door”
- direction (str) – direction to locked door from current tile, e.g. “north”
- doorclass – class object to instantiate for door
- door_id – unique ID to represent door in save files
-
add_enter_event_handler
(handler)¶ Add a handler to be invoked when player enters the current tile
Parameters: handler – handler of the form handler(player, src, dest)
, whereplayer
is thetext_game_maker.player.player.Player
instance,src
is thetext_game_maker.tile.tile.Tile
instance that the player just exited, anddest
is thetext_game_maker.tile.tile.Tile
instance the player has just entered
-
add_exit_event_handler
(handler)¶ Add a handler to be invoked when player exits the current tile
Parameters: handler – handler of the form handler(player, src, dest)
, whereplayer
is thetext_game_maker.player.player.Player
instance,src
is thetext_game_maker.tile.tile.Tile
instance that the player just exited, anddest
is thetext_game_maker.tile.tile.Tile
instance the player has just entered
-
add_item
(item)¶ Add item to current tile (see text_game_maker.tile.tile.Tile.add_item)
Parameters: item (text_game_maker.game_objects.base.Item) – the item to add
-
add_items
(items)¶ Add multiple items to current tile
Parameters: items ([text_game_maker.game_objects.item.Item]) – list of items to add
-
add_keypad_door
(prefix, name, direction, code, doorclass=<class 'text_game_maker.tile.tile.LockedDoorWithKeypad'>, door_id=None, prompt=None)¶ Add a locked door that blocks the player from exiting the current room, and requires a specific code to be entered on the keypad to unlock it.
Parameters: - prefix (str) – prefix for door name, e.g. “a”
- name (str) – door name, e.g. “locked door”
- direction (str) – direction to locked door from current tile, e.g. “north”
- code (int) – keypad code required to unlock door
- doorclass – class object to instantiate for door
- door_id – unique ID to represent door in save files
-
add_new_game_start_event_handler
(handler)¶ Add a handler to be invoked when a new game is started
Parameters: handler – handler to be invoked when a new game is started. Handler should be of the form handler(player)
whereplayer
is thetext_game_maker.player.player.Player
instance
-
add_person
(person)¶ Add person to current tile (see text_game_maker.tile.tile.Tile.add_person)
Parameters: person (text_game_maker.game_objects.person.Person) – person to add
-
clear_enter_event_handler
(handler)¶ Clear specific enter event handler attached to the current tile
Parameters: handler – enter event handler that was previously added to the current tile
-
clear_enter_event_handlers
()¶ Clear all enter event handler attached to the current tile
-
clear_exit_event_handler
(handler)¶ Clear specific exit event handler attached to the current tile
Parameters: handler – exit event handler that was previously added to the current tile
-
clear_exit_event_handlers
()¶ Clear all exit event handler attached to the current tile
-
inject_input
(data)¶ Inject data into the game’s input stream (as if player had typed it)
Parameters: data (str) – string of text to inject
-
load_map_data_from_file
(filename)¶ Load a map file saved from the map editor GUI
Parameters: filename (str) – name of map editor save file to load
-
load_map_data_from_string
(map_data)¶ Load a string containing uncompressed contents of a .tgmdata file
Parameters: filename (str) – string containing uncompressed .tgmdata
-
move_east
(num=1, name=None, description=None, tileclass=<class 'text_game_maker.tile.tile.Tile'>)¶ Move east by one or more tiles. On each move, if a tile does not already exist at the current position, a new tile will be created and set as the current tile to build on. If a tile already exists at the current position, it will be set to the current tile and no new tile will be created.
Parameters: - name (str) – short description of tile
- description (str) – long description of tile
- tileclass – class object to create tile from
- num (int) – distance ot move in tiles
-
move_north
(num=1, name=None, description=None, tileclass=<class 'text_game_maker.tile.tile.Tile'>)¶ Move north by one or more tiles. On each move, if a tile does not already exist at the current position, a new tile will be created and set as the current tile to build on. If a tile already exists at the current position, it will be set to the current tile and no new tile will be created.
Parameters: - name (str) – short description of tile
- description (str) – long description of tile
- tileclass – class object to create tile from
- num (int) – distance ot move in tiles
-
move_south
(num=1, name=None, description=None, tileclass=<class 'text_game_maker.tile.tile.Tile'>)¶ Move south by one or more tiles. On each move, if a tile does not already exist at the current position, a new tile will be created and set as the current tile to build on. If a tile already exists at the current position, it will be set to the current tile and no new tile will be created.
Parameters: - name (str) – short description of tile
- description (str) – long description of tile
- tileclass – class object to create tile from
- num (int) – distance ot move in tiles
-
move_west
(num=1, name=None, description=None, tileclass=<class 'text_game_maker.tile.tile.Tile'>)¶ Move west by one or more tiles. On each move, if a tile does not already exist at the current position, a new tile will be created and set as the current tile to build on. If a tile already exists at the current position, it will be set to the current tile and no new tile will be created.
Parameters: - name (str) – short description of tile
- description (str) – long description of tile
- tileclass – class object to create tile from
- num (int) – distance ot move in tiles
-
run_game
()¶ Start running the game
-
set_current_tile
(tile_id)¶ Set the current tile to build on by tile ID
Parameters: tile_id (str) – tile ID of tile to set as current tile
-
set_dark
(value)¶ Set whether this tile is dark or not. Dark tiles require player to equip a light source
Parameters: value (bool) – True for dark, False for not dark
-
set_description
(desc)¶ Add long description for current tile (see text_game_maker.tile.tile.Tile.set_description)
Parameters: desc (str) – description text
-
set_first_visit_message
(message)¶ Add text to be printed only once, on the player’s first visit to the current tile
Parameters: messsage (str) – message to show on first player visit
-
set_first_visit_message_in_dark
(value)¶ Defines whether the current tile shows a first visit message in the dark. if False, first visit message for current tile will be shown the first player is on the current tile and has a light source.
Parameters: value (bool) – value to set
-
set_ground_material
(material)¶ Set the material type of the ground on this tile :param Material material: material type
-
set_ground_smell
(text)¶ Set the text that will be printed when player types ‘smell ground’ or equivalent on this tile
Parameters: text (str) – text to be printed on smell ground command
-
set_input_prompt
(prompt)¶ Set the message to print when prompting a player for game input
Parameters: prompt (str) – message to print
-
set_name
(name)¶ Add short description for current tile (see text_game_maker.tile.tile.Tile.set_tile_id)
Parameters: desc (str) – description text
-
set_name_from_east
(name)¶ Set the name that will be shown when player looks at the current tile from an adjacent tile to the east
Parameters: desc (str) – description text
-
set_name_from_north
(name)¶ Set the name that will be shown when player looks at the current tile from an adjacent tile to the north
Parameters: desc (str) – description text
-
set_name_from_south
(name)¶ Set the name that will be shown when player looks at the current tile from an adjacent tile to the south
Parameters: desc (str) – description text
-
set_name_from_west
(name)¶ Set the name that will be shown when player looks at the current tile from an adjacent tile to the west
Parameters: desc (str) – description text
-
set_on_game_run
(callback)¶ Set callback function to be invoked when player starts a new game (i.e. not from a save file). Callback function should accept one parameter:
- def callback(player):
- pass
Callback parameters:
- player (text_game_maker.player.player.Player): player instance
Parameters: callback – callback function
-
set_smell
(text)¶ Set the text that will be printed when player types ‘smell’ or equivalent on this tile
Parameters: text (str) – text to be printed on smell command
-
set_tile_id
(tile_id)¶ Set tile ID for current tile (see text_game_maker.tile.tile.Tile.set_tile_id)
Parameters: tile_id – tile ID
-
start_map
(name=u'', description=u'')¶ Start building the map; create the first tile
Parameters: - name (str) – short name for starting Tile
- description (str) – short name for starting Tile
-
-
class
text_game_maker.builder.map_builder.
StopWaitingForInput
¶ Bases:
object
-
text_game_maker.builder.map_builder.
add_format_tokens
()¶
-
text_game_maker.builder.map_builder.
clear_instance
()¶
-
text_game_maker.builder.map_builder.
get_instance
()¶