text_game_maker.tile package¶
Submodules¶
-
class
text_game_maker.tile.tile.
LockedDoor
(prefix='', name='', src_tile='', replacement_tile='')¶ Bases:
text_game_maker.tile.tile.Tile
Locked door with a mechanical lock, requires a key or lockpick to unlock
-
__init__
(prefix='', name='', src_tile='', replacement_tile='')¶ Initialise a Tile instance
Parameters: - name (str) – short description, e.g. “a dark cellar”
- description (str) – long description, printed when player enters the room e.g. “a dark, scary cellar with blah blah blah… “
-
full_class_name
= u'text_game_maker.tile.tile.LockedDoor'¶
-
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
-
is_door
()¶
-
matches_name
(name)¶ Check if a string fuzzily matches the name of this door
Parameters: name (str) – string to check Returns: True if string fuzzily matches this doors name Return type: bool
-
on_enter
(player, src)¶ Called when player tries to move into this tile. If on_enter returns True, the player will be moved to this tile. If False, the move will not be allowed.
Parameters: - player (text_game_maker.player.player.Player) – player object
- src (text_game_maker.tile.tile.Tile) – tile that player is currently on
Returns: True if player move should be allowed
Return type: bool
-
on_open
(player)¶ Called when player attempts to open this door
Parameters: player (text_game_maker.player.player.Player) – player object
-
prep
¶
-
unlock
()¶ Unlocks the door, revealing whichever tile is connected behind it
-
-
class
text_game_maker.tile.tile.
LockedDoorWithKeypad
(unlock_code=None, **kwargs)¶ Bases:
text_game_maker.tile.tile.LockedDoor
Locked door with an electronic lock, can be opened with a numeric code
-
__init__
(unlock_code=None, **kwargs)¶ Initialise a Tile instance
Parameters: - name (str) – short description, e.g. “a dark cellar”
- description (str) – long description, printed when player enters the room e.g. “a dark, scary cellar with blah blah blah… “
-
full_class_name
= u'text_game_maker.tile.tile.LockedDoorWithKeypad'¶
-
on_enter
(player, src)¶ Called when player tries to move into this tile. If on_enter returns True, the player will be moved to this tile. If False, the move will not be allowed.
Parameters: - player (text_game_maker.player.player.Player) – player object
- src (text_game_maker.tile.tile.Tile) – tile that player is currently on
Returns: True if player move should be allowed
Return type: bool
-
on_open
(player)¶ Called when playyer attempts to open this door.
Parameters: player (text_game_maker.player.player.Player) – player object
-
set_prompt
(prompt)¶ Set text to be display when prompting player to input keypad code
Parameters: prompt (str) – text to prompt with
-
-
class
text_game_maker.tile.tile.
Tile
(name=None, description=None)¶ Bases:
text_game_maker.game_objects.base.GameEntity
Represents a single ‘tile’ or ‘room’ in the game
-
__init__
(name=None, description=None)¶ Initialise a Tile instance
Parameters: - name (str) – short description, e.g. “a dark cellar”
- description (str) – long description, printed when player enters the room e.g. “a dark, scary cellar with blah blah blah… “
-
add_item
(item)¶ Add item to this tile
Parameters: item (GameEntity) – item to add Returns: the added item
-
add_person
(person)¶ Add person to this tile
Parameters: text_game_maker.game_objects.person.Person – person to add
-
copy
()¶
-
default_locations
= ['on the ground']¶
-
describe_items
()¶ Return sentences describing all non-scenery items on this tile
Returns: description of non-scenery on this tile Return type: str
-
describe_people
()¶ Return sentences describing all people on this tile
Returns: description of all people (NPCs) on this tile Return type: str
-
describe_scene
()¶ Return sentences describing all scenery items on this tile
Returns: description of scenery on this tile Return type: str
-
direction_from
(tile)¶ Get the direction from the given tile to this tile
Parameters: tile (Tile) – tile to check the direction from Returns: direction from the given tile to this tile Return type: str
-
direction_to
(tile)¶ Get the direction from this tile to the given tile
Parameters: tile (Tile) – tile to check the direction to Returns: direction to the given tile Return type: str
-
full_class_name
= u'text_game_maker.tile.tile.Tile'¶
-
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
-
is_connected_to
(tile)¶ Checks if this tile is connected to the given tile
Parameters: tile (Tile) – tile to check against this tile Returns: True if tile is connected to this tile, False otherwise Return type: bool
-
is_door
()¶
-
iterate_directions
()¶ Iterator for all tiles connected to this tile
Returns: tile iterator Return type: Iterator[ text_game_maker.tile.tile.Tile
]
-
map_identifier
¶
-
matches_name
(name)¶ Check if a string fuzzily matches the name of this tile
Parameters: name (str) – string to check Returns: True if string fuzzily matches this tiles name Return type: bool
-
on_enter
(player, src)¶ Called when player tries to move into this tile. If on_enter returns True, the player will be moved to this tile. If False, the move will not be allowed.
Parameters: - player (text_game_maker.player.player.Player) – player object
- src (text_game_maker.tile.tile.Tile) – tile that player is currently on
Returns: True if player move should be allowed
Return type: bool
-
on_exit
(player, dest)¶ Called when player tries to move out of this tile. If on_exit returns True, the player will be moved to
dest
. If False, the move will not be allowed.Parameters: - player (text_game_maker.player.player.Player) – player object
- dest (text_game_maker.tile.tile.Tile) – tile that player is trying to move to
Returns: True if player move should be allowed
Return type: bool
-
on_smell
()¶ Called when player types ‘smell’ or equivalent on this tile
-
on_smell_ground
()¶ Called when player types ‘smell ground’ or equivalent on this tile
-
on_taste_ground
()¶ Called when player types ‘taste ground’ or equivalent on this tile
-
set_name_from_east
(name)¶ Set the name that will be shown when player looks at this tile from an adjacent tile east from this tile
Parameters: desc (str) – description text
-
set_name_from_north
(name)¶ Set the name that will be shown when player looks at this tile from an adjacent tile north from this tile
Parameters: desc (str) – description text
-
set_name_from_south
(name)¶ Set the name that will be shown when player looks at this tile from an adjacent tile south from this tile
Parameters: desc (str) – description text
-
set_name_from_west
(name)¶ Set the name that will be shown when player looks at this tile from an adjacent tile west from this tile
Parameters: desc (str) – description text
-
set_special_attrs
(data, 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
-
set_tile_id
(tile_id)¶ Sets the ID for this tile. This ID will be used to represent the tile in save files. Setting explicit tile names is recommended, as it ensures that the tile IDs will not change. If the ID of a tile changes, save files created with previous tile IDs will no longer work as expected.
Parameters: tile_id – tile ID
-
summary
()¶ Return a description of all available directions from this tile that the player can see
Returns: description of all available directions from this tile Return type: str
-
tile_id
= 0¶
-
-
text_game_maker.tile.tile.
builder
(tiledata, start_tile_id, version, clear_old_tiles=True)¶ Deserialize a list of serialized tiles, then re-link all the tiles to re-create the map described by the tile links
Parameters: - tiledata (list) – list of serialized tiles
- start_tile_id – tile ID of tile that should be used as the start tile
- version (str) – object model version of the tile data to be deserialized
Returns: starting tile of built map
Return type:
-
text_game_maker.tile.tile.
crawler
(start)¶ Crawl over a map and serialize all tiles and contained items
Parameters: start (text_game_maker.tile.tile.Tile) – map starting tile Returns: serializable dict representing all tiles and contained items Return type: dict
-
text_game_maker.tile.tile.
get_tile_by_id
(tile_id)¶ Get Tile instance by tile ID
Parameters: tile_id – ID of tile to fetch Returns: tile instance Return type: text_game_maker.tile.tile.Tile
-
text_game_maker.tile.tile.
reverse_direction
(direction)¶ Returns the opposite direction for a given direction, e.g. “north” becomes “south”
Parameters: direction (str) – direction to reverse Returns: opposite direction. None if invalid direction is provided Return type: str
-
text_game_maker.tile.tile.
unregister_tile_id
(tile_id)¶ Unregister a tile ID so it can be used again. Should only be used if you are deleting all instances of a tile object.
Parameters: tile_id – tile ID to unregister