dork package¶
Subpackages¶
Submodules¶
dork.repl module¶
This is the REPL which parses commands and passes them to a Game object.
dork.types module¶
Base types for the Dork game
-
class
dork.types.
Adjacent
[source]¶ Bases:
dork.types.Grandparent
adjacency object for rooms
-
class
dork.types.
Attackable
[source]¶ Bases:
dork.types.Usable
Any object that can be swung will say it was swung
-
static
use
(target, name)[source]¶ Concrete use call for weapons
This method is called by weapons to be attack. Changes state of target player by calling the target’s damage method.
Parameters: - target (Player) – passes Player as target to attack
- name (str) – passed as name of item used
Returns: returns that player swings weapon at target
Return type: blurb (str)
-
static
-
class
dork.types.
Coord
[source]¶ Bases:
dork.types.Grandparent
coordinate object for rooms
-
class
dork.types.
Gamebuilder
[source]¶ Bases:
object
Build an instance of Game
-
static
build
(player_name)[source]¶ Instantiate a game of Dork from dictionary
Creates an instance of a game from a dictionary of game data
Parameters: - data (dict) – Saves the state of the game, player, and items
- () (game) – Class instance of the game
Returns: returns the state of the current game game (): returns the updated location, player, and items
Return type: data (dict)
-
static
load_game
(player)[source]¶ Load the save file associated with player
Loads a saved yaml file based on what the user named their player
Parameters: data (dict) – dictionary of the game state from yaml file Returns: returns the game state based upon the player’s name Return type: data (dict)
-
static
save_game
(player, data)[source]¶ Save a game instance to a yaml file if it exists, else create one
Gets data on game state from saved yaml file
Parameters: - data (dict) – dictionary of game state
- player (str) – string of the player’s name
Returns: returns the dictionary state of the game from yaml player (str): returns the yaml file depending on the player’s name
Return type: data (dict)
-
static
-
class
dork.types.
Holder
[source]¶ Bases:
dork.types.Grandparent
A holder/container of items
-
get_items
(caller, data, verbose)[source]¶ Print all inventory items
Displays all items held by self<player instance> or not. Verbose print displays more information about inventory.
Parameters: - out (str) – Inventory
- verbose (str) – Displays detailed inventory
Returns: Returns a formated/detailed inventory of player.
Return type: verbose (str)
-
-
class
dork.types.
Item
[source]¶ Bases:
dork.types.Stats
An obtainable/usable item
-
make
(item)[source]¶ Make an item
Creates the name, description, and type of item in game world
Parameters: - name (str) – Generates a random item name
- description (str) – Generates a random item description
- type (str) – Generates a definition what type of item is generated
- usable (str) – Is the item usable or not
Returns: returns the item name description (str): returns item description type (str): returns the type of item usable (str): returns the usability of item
Return type: name (str)
-
set_usable
(new_use)[source]¶ method that sets usable on runtime
This method changes the use behavior, provide usable class as argument
Defines whether an item’s type is usable or not
Parameters: new_use (dict) – checks if item’s type is usable or not
-
use
(target, name)[source]¶ Strategy pattern call
This method is called by items to be used
Calls its own behavior class called a Usable
Parameters: - target (Player) – passes Player as target to be used on
- name (str) – passed as name of item used
Returns: returns output for repl from specific usage
Return type: blurb (str)
-
-
class
dork.types.
NotUsable
[source]¶ Bases:
dork.types.Usable
Any object that cannot be used
-
static
use
(target, name)[source]¶ Useless use method
This method is called by filler items to be used
Concrete unusable item class use method
Parameters: - target (Player) – passes Player as target to be used on
- name (str) – passed as name of item used
Returns: returns “You find no use of this item”
Return type: blurb (str)
-
static
-
class
dork.types.
Openable
[source]¶ Bases:
dork.types.Usable
Object opening behavior class
-
class
dork.types.
Payable
[source]¶ Bases:
dork.types.Usable
Any object that can be used as gold
-
class
dork.types.
Player
[source]¶ Bases:
dork.types.Holder
A player or npc in the game
-
blurbs
= {'Calm': {'damage': 'Ouch..Your gonna get it!', 'talk': 'Hello'}, 'Dead': {'damage': 'You monster, stop hitting the dead!', 'talk': 'That person is dead...blab away'}, 'Hostile': {'damage': 'UGH\nYou dealt a death blow', 'talk': "I guess you are ok...I'll calm down"}}¶
-
damage
()[source]¶ damage method called by items to inflict damage on players
This method is by items and changes the state of the callee player and returns blurb associated.
Returns: returns blurb from hitting player Return type: uses (str)
-
instances
= []¶
-
move
(cardinal, maze)[source]¶ walk this way
Moves the player from one location to another in the game/maze
Parameters: Out (str) – describes where the player is located Returns: returns if the player can move to next location Return type: out (str)
-
next_state
(action)[source]¶ Method that changes state of Player This method updates players state based on name of method called
Parameters: uses (str) – passed as name action or method used on player
-
states
= {'damage': {'Calm': 'Hostile', 'Dead': 'Dead', 'Hostile': 'Dead'}, 'talk': {'Calm': 'Calm', 'Dead': 'Dead', 'Hostile': 'Calm'}}¶
-
-
class
dork.types.
Room
[source]¶ Bases:
dork.types.Adjacent
,dork.types.Coord
,dork.types.Holder
A room on the worldmap
-
instances
= []¶
-
-
class
dork.types.
Statable
[source]¶ Bases:
dork.types.Usable
Any object that can change stats
Module contents¶
Dork game main module