fife_rpg Package

fife_rpg Package

The goal of fife-rpg is to create an rpg-framework using the FIFEngine and bGrease. It will use the source of PARPG as a basis and build upon it.

console_commands Module

This module manages commands for the console.

fife_rpg.console_commands.get_commands()[source]

Returns a copy of the commands

fife_rpg.console_commands.register_command(name, function)[source]

Registers a function as a command

Args:
name: The keyword for the command function: The function to call

dialogue Module

This module contains the the functions and classes for playing dialogues.

class fife_rpg.dialogue.Dialogue(world, dialogue_data)[source]

Bases: object

Represents a single dialogue

Properties:

world: RPGWorld that the dialogue is run on

sections: A list of DialogueSection

current_section: The DialogueSection that is currently active

create_section(section_data)[source]

Create a section and return it

Args:
section_data: A dictionary containing the data of a section
create_sections(sections_data)[source]

Create the dialogue sections

Args:
sections_data: A dictionary containing the data of the sections
get_dialogue_variables(section)[source]

Returns the game variables combined with dialogue specific variables.

Args:
section: A DialogueSection. This will be used to get dialogue variables
is_dialogue_finished[source]

Returns whether the dialogue is finished or not

possible_responses[source]

Returns a dictionary of the possible responses of the current section

run_section(section)[source]

Runs the commands of the section

Args:
section: A DialogueSection
select_greeting(greetings_data)[source]

Selects the first greeting which conditions passes

Args:
greetings_data: A dictionary containing the data of the greetings
select_response(response_name)[source]

Selects the given response and performs its actions

Args:
response_name: The name of the response
class fife_rpg.dialogue.DialogueController(view, application, dialogue)[source]

Bases: fife_rpg.mvc.ControllerBase

Controller that handles Dialogues

Properties:

application: The RPGApplication that created this controller

view: The View that is used by this controller

dialogue: The active Dialogue

current_section[source]

Returns the current section of the active dialogue

is_dialogue_finished[source]

Returns whether the active dialogue is finished or not

possible_responses[source]

Returns a dictionary of the possible responses of the active dialogue

pump(time_delta)[source]

Performs actions every frame

Args:
time_delta: Time that passed since the last call
select_response(response_name)[source]

Selects the given response and performs its actions

Args:
response_name: The name of the response
class fife_rpg.dialogue.DialogueSection(talker, text, conditions=None, commands=None, responses=None)[source]

Bases: object

Represents a section of a dialogue

Properties:

talker: The Entity that is talking

text: The text that is being said

conditions: List of conditions that are evaluated

commands: Commands that are to be executed when the section is displayed

responses: Possible responses for this section

exceptions Module

This module contains the exceptions from fife-rpg.

exception fife_rpg.exceptions.AlreadyRegisteredError(name, obj_type)[source]

Bases: exceptions.Exception

Exception that gets raised when an object with the name is already registered

Properties:

name: The name of the action that was already registered

obj_type: The obj_type of the object

exception fife_rpg.exceptions.NoSuchCommandError(name)[source]

Bases: exceptions.Exception

Exception that gets raised when the command is not found

Properties:
name: The name of the command that was being tried to execute
exception fife_rpg.exceptions.NotRegisteredError(obj_type)[source]

Bases: exceptions.Exception

Exception that gets raised when a class is not registered

Properties:
obj_type: The obj_type of the object

game_scene Module

This module contains the generic controller and view to display a fife_rpg.map.GameMap.

class fife_rpg.game_scene.BaseOutliner[source]

Bases: object

Determines the outline of an instance

get_data(world, identifier)[source]

Determines whether an instance should be outline and the data used for the outline.

Args:

world: The world

identifier: The name of the instance

Returns: The data as a list, if the instance should be outlined. None, if it should not.

class fife_rpg.game_scene.GameSceneController(view, application, outliner=None, listener=None)[source]

Bases: fife_rpg.mvc.ControllerBase

Handles the input for a game scene

Properties:

view: A fife_rpg.game_scene.GameSceneView

application: A fife_rpg.rpg_application.RPGApplication

listener: The listener used by the game scene

outliner: The outliner that will be used to determine outlines

on_activate()[source]

Being called when the Mode is activated

on_deactivate()[source]

Being called when the Mode is deactivated

pump(time_delta)[source]

Performs actions every frame

Args:
time_delta: Time that passed since the last call
class fife_rpg.game_scene.GameSceneListener(engine, gamecontroller=None)[source]

Bases: fife.fife.IMouseListener

The game listener.

Handle mouse events in relation with game process.

Properties:

engine: The FIFE engine

gamecontroller: A fife_rpg.game_scene.GameSceneController

eventmanager: The engines eventmanager. A fife.EventManager

is_outlined: If true then outlines for instances will be drawn.

activate()[source]

Makes the listener receive events

deactivate()[source]

Makes the listener receive events

mouseDragged(event)[source]

Called when the mouse is moved while a button is being pressed.

Args:
event: The mouse event
mouseMoved(event)[source]

Called when the mouse was moved.

Args:
event: The mouse event
mousePressed(event)[source]

Called when a mouse button was pressed.

Args:
event: The mouse event
mouseReleased(event)[source]

Called when a mouse button was released.

Args:
event: The mouse event
mouseWheelMovedDown(event)[source]

Called when the mouse wheel is moved downwards

Args:
event: The mouse event
mouseWheelMovedUp(event)[source]

Called when the mouse wheel is moved upwards

Args:
event: The mouse event
outline_ignore[source]

Returns outline_ignore

class fife_rpg.game_scene.GameSceneView(application)[source]

Bases: fife_rpg.mvc.ViewBase

The view responsible for showing the in-game gui

Properties:
application: A fife_rpg.rpg_application.RPGApplication instance
class fife_rpg.game_scene.SimpleOutliner(outline_data=None, outline_ignore=None)[source]

Bases: fife_rpg.game_scene.BaseOutliner

Outliner that determines the outline based on a list of identifiers to ignore and a single data element for instances that should be outlined.

Properties:

outline_data: A tuple of values for the outlines. It is in the order: (Red, Green, Blue, Width, Threshold)

outline_ignore: A list of identifiers to ignore when drawing outlines

get_data(world, identifier)[source]

Determines whether an instance should be outline and the data used for the outline.

Args:

world: The world

identifier: The name of the instance

Returns: The data as a list, if the instance should be outlined. None, if it should not.

outline_ignore[source]

Returns outline_ignore

helpers Module

Various functions and classes

class fife_rpg.helpers.ClassProperty[source]

Bases: property

Class to make class properties

class fife_rpg.helpers.Enum[source]

Bases: set

A enumeration type

map Module

This module contains everything for handling fife-rpg maps

class fife_rpg.map.Map(fife_map, name, camera, regions, application)[source]

Bases: object

Contains the data of a map

Properties:

fife_map: A fife.Map instance, representing the fife_map

name: The name of the fife_map.

camera: The name of the default camera

regions: A dictionary that defines specific regions on the fife_map, as fife.DoubleRect instances.

is_active: Whether the map is currently active or nor

activate()[source]

Activates the map

add_light_from_animation(group, animation, agent=None, layer=None, location=None, point=None, blend_mode=(-1, -1))[source]

Adds a light that uses an animation lightmap.

Arguments:

group: The name of the group the light should be put in.

animation: The path to a xml file that contains the animation data or a fife.Animation.

agent: The name of the agent the light should be attached too. If empty or None this will be ignored. Please note that the layer and location have to be set if this is empty or None.

layer: The name of the layer the light originates from. Lights will illuminate lower layers, but not higher ones. If empty or None this will be ignored.

location: The relative or absolute location of the agent depending on whether the agent was set or not. A list with two or three values. If None this will be ignored.

point: The relative or absolute window position of the light as a list with 2 values or a fife.Point. This differs from location as it is in pixels and (0, 0) is the upper left position of the window.

blend_mode: A list with 2 values for the source and destination blend modes. If not passed the default values of FIFE will be used.

Returns:
The light info of the added light
add_light_from_lightmap(group, lightmap, size=None, agent=None, layer=None, location=None, point=None, blend_mode=(-1, -1))[source]

Adds a light that uses a lightmap.

Arguments:

group: The name of the group the light should be put in.

lightmap: The path to the lightmap image file or a fife.Image

size: A list with 2 values that set to what size the lightmap should be resized. If None this will be ignored.

agent: The name of the agent the light should be attached too. If empty or None this will be ignored. Please note that the layer and location have to be set if this is empty or None.

layer: The name of the layer the light originates from. Lights will illuminate lower layers, but not higher ones. If empty or None this will be ignored.

location: The relative or absolute location of the agent depending on whether the agent was set or not. A list with two or three values. If None this will be ignored.

point: The relative or absolute window position of the light as a list with 2 values or a fife.Point. This differs from location as it is in pixels and (0, 0) is the upper left position of the window.

blend_mode: A list with 2 values for the source and destination blend modes. If not passed the default values of FIFE will be used.

Returns:
The light info of the added light
add_simple_light(group, intensity, radius, subdivisions, color, stretch=None, agent=None, layer=None, location=None, point=None, blend_mode=(-1, -1))[source]

Adds a simple light to the map.

Arguments:

group: The name of the group the light should be put in.

intensity: The intensity of the radius as a value between 0 and 255

radius: The radius of the light as a float

subdivisions: The number of subdivisions of the light. More subdivisions mean smoother light.

color: The color of the light either as a list with with three values between 0 and 255 or a fife.Color

stretch: The x and y stretch factor of the light as a list with two float values. If None it will default to both 1.0.

agent: The name of the agent the light should be attached too. If empty or None this will be ignored. Please note that the layer and location have to be set if this is empty or None.

layer: The name of the layer the light originates from. Lights will illuminate lower layers, but not higher ones. If empty or None this will be ignored.

location: The relative or absolute location of the agent depending on whether the agent was set or not. A list with two or three values. If None this will be ignored.

point: The relative or absolute window position of the light as a list with 2 values or a fife.Point. This differs from location as it is in pixels and (0, 0) is the upper left position of the window.

blend_mode: A list with 2 values for the source and destination blend modes. If not passed the default values of FIFE will be used.

Returns:
The light info of the added light
camera[source]

Returns the camera of the map

deactivate()[source]

Deactivates the map

entities[source]

Returns the entities that are on this map

fife_map[source]

Returns the fife.Map

get_instances_at(point, layer)[source]

Query the main camera for instances on the specified layer.

Args:

point: A fife.ScreenPoint

layer: The fife.Layer from which we want the instances

get_layer(layer)[source]

Returns the layer with the given name

Args:
layer: The name of the layer
get_light_renderer()[source]

Returns the light renderer of the current camera

is_active[source]

Returns wheter the map is active or not

is_in_region(location, region)[source]

Checks if a given point is inside the given region

Args:

location: A fife.DoublePoint instance or a tuple with 2 elements

region: The name of the region

Raises:
fife_rpg.map.NoSuchRegionError if the specified region does not exist.
name[source]

Returns the name of the map

regions[source]

Returns the regions of the map

remove_entity(identifier)[source]

Removes an entity from the map

Args:
identifier: The name of the entity
Raises:

KeyError: If the map has no entity with that name

TypeError: If the identifier is not a string

update_entities()[source]

Update the maps entites from the entities of the world

update_entities_fife()[source]

Updates the fife instances to the values of the agent

update_entitities_agent()[source]

Update the values of the agent component of the maps entities

exception fife_rpg.map.NoSuchRegionError(map_name, region_name)[source]

Bases: exceptions.Exception

Gets thrown when the code tried to access a region that does not exits on the map.

Properties:

map_name: The name of the map_name

region_name: The name of the region_name

mvc Module

Contains classes for a Model-View-Controller system

class fife_rpg.mvc.ControllerBase(view, application)[source]

Bases: bGrease.grease_fife.mode.Mode

Base of Controllers

Properties:

application: The fife_rpg.rpg_application.RPGApplication that created this controller

view: The fife_rpg.mcs.ViewBase that is used by this controller

pump(time_delta)[source]

Performs actions every frame

Args:
time_delta: Time that passed since the last call
class fife_rpg.mvc.ViewBase(application)[source]

Bases: object

Base class for views

Properties:
application: A fife_rpg.rpg_application.RPGApplication instance

rpg_application Module

This package contains the main application classes

class fife_rpg.rpg_application.RPGApplicationCEGUI(_)[source]

Bases: object

Just a dummy class that raises an exception

sound_engine Module

This module holds the object code to play sounds and sound effects

class fife_rpg.sound_engine.SoundEngine(fife_engine)[source]

Plays sounds and __music

Properties:
is_music_on: Indicates whether there is currently music playing or not
is_music_on[source]

Indicates whether there is currently music playing or not

pause_music()[source]

Pauses current music playback

play_music(sfile=None)[source]

Play music, with the given file if passed

Args:
sfile: Filename to play
set_volume(volume)[source]

Set the volume of the music

Args:
volume: The volume wanted, 0 to 100
toggle_music()[source]

Toggle status of music, either on or off

world Module

This module contains the world class used used by the entity system.

class fife_rpg.world.RPGWorld(application)[source]

Bases: bGrease.grease_fife.world.World

The Base world for all rpgs.

Sets up the generic systems and components

Properties:

application: The fife_rpg.rpg_application.RPGApplication that uses this engine

object_db: Stores the template data

MAX_ID_NUMBER = 2147483647
configure()[source]

Configure the worlds components and systems

classmethod create_entity_dictionary(entity)[source]

Creates a dictionary containing the values of the Entity

Args:
entity: The Entity instance
Returns:
The created dictionary
create_unique_identifier(identifier)[source]

Returns an unused identifier based on the given identifier

Args:
identifier: The base identifier
Returns:
A unique unused identifier based in the given identifier
entity_constructor(loader, node)[source]

Constructs an Entity from a yaml node

Args:

loader: A yaml BaseConstructor

node: The yaml node

Returns:
The created Entity
entity_representer(dumper, data)[source]

Creates a yaml node representing an entity

Args:

dumper: A yaml BaseRepresenter

data: The Entity

Returns:
The created node
get_entity(identifier)[source]

Returns the entity with the identifier

Args:
identifier: The identifier of the entity
Returns:
The entity with the identifier or None
get_or_create_entity(identifier, info=None, extra=None)[source]

Create an entity if not already present and return it.

Args:

identifier: The identifier of the new object

info: Stores information about the object we want to create

extra: Stores additionally required attributes

Returns:
The entity with the identifier. None: If there is no info dictionary and no entity with the identifier
import_agent_objects(object_path=None)[source]

Import the objects used by agents from the given path

Args:
object_path: The root path in which the objects are. If set to None it the path will be read from the settings
is_identifier_used(identifier)[source]

Checks whether the idenfier is used

Args:
identifier: The identifier to check
Returns:
True if the identifier is used, false if not
load_and_create_entities(entities_file_name=None)[source]

Reads the entities from a file and creates them

Args:
entities_file_name: The path to the entities file. Overwrites the EntitiesFile setting if not set to None
pump(time_delta)[source]

Performs actions every frame

Args:
time_delta: Time that passed since the last call
read_object_db(db_filename=None)[source]

Reads the Object Information Database from a file

Args:
db_filename: The yaml file to read from. Overwrites the ObjectDBFile setting if not set to None.
update_from_template(entity_data, template_name)[source]

Copies missing data from a template into an entity dictionary.

Args:

entity_data: The dictionary in which the data should be put.

template_name: The name of the template to use

Returns:
The modified entity dictionary
update_game_variables(variables)[source]

Called by the game environment when it wants to update its globals

Args:
variables: The globals dictionary of the GameEnvironment that is filled by the GameScene