scripts.engine.core package

Submodules

scripts.engine.core.component module

class Aesthetic(sprites: TraitSpritesData, sprite_paths: List[TraitSpritePathsData], render_layer: RenderLayer, draw_pos: Tuple[float, float])[source]

Bases: scripts.engine.core.component.NQPComponent

An entity’s sprite.

N.B. translation to screen coordinates is handled by the camera

__init__(sprites: TraitSpritesData, sprite_paths: List[TraitSpritePathsData], render_layer: RenderLayer, draw_pos: Tuple[float, float])[source]

Initialize self. See help(type(self)) for accurate signature.

classmethod deserialize(serialised)[source]

Deserialize a serialized instance of this component.

Will get the output of serialize as an argument.

Override this in all your Component classes to make use of snecs’ full-World serialization feature.

serialize()[source]

Serialize an instance of this component into a simpler type.

Override this in all your Component classes to make use of snecs’ full-World serialization feature.

set_current_sprite(sprite_category: SpriteCategoryType)[source]

Set the current sprite. Set current sprite duration to 0.

set_draw_to_target()[source]

Set draw_x and draw_y to their target values

class Afflictions(active: Optional[List[Affliction]] = None)[source]

Bases: scripts.engine.core.component.NQPComponent

An entity’s Boons and Banes. held in .active as a list of Affliction.

__init__(active: Optional[List[Affliction]] = None)[source]

Initialize self. See help(type(self)) for accurate signature.

add(affliction: Affliction)[source]
classmethod deserialize(serialised)[source]

Deserialize a serialized instance of this component.

Will get the output of serialize as an argument.

Override this in all your Component classes to make use of snecs’ full-World serialization feature.

remove(affliction: Affliction)[source]
serialize()[source]

Serialize an instance of this component into a simpler type.

Override this in all your Component classes to make use of snecs’ full-World serialization feature.

class CombatStats(vigour: int, clout: int, skullduggery: int, bustle: int, exactitude: int)[source]

Bases: scripts.engine.core.component.NQPComponent

An entities stats used for combat.

Set primary stats. Secondary stats pulled from library.

__init__(vigour: int, clout: int, skullduggery: int, bustle: int, exactitude: int)[source]

Set primary stats. Secondary stats pulled from library.

property accuracy

An entities likelihood to hit.

add_mod(stat: Union[PrimaryStatType, SecondaryStatType], cause: str, amount: int)bool[source]

Amend the modifier of a stat. Returns True if successfully amended, else False.

amend_base_value(stat: Union[PrimaryStatType, SecondaryStatType], amount: int)[source]

Amend the base value of a stat

property bustle

Influences speedy things. Never below 1.

property clout

Influences forceful things. Never below 1.

classmethod deserialize(serialised)[source]

Deserialize a serialized instance of this component.

Will get the output of serialize as an argument.

Override this in all your Component classes to make use of snecs’ full-World serialization feature.

property exactitude

Influences preciseness. Never below 1.

property max_health

Total damage an entity can take before death.

property max_stamina

An entities energy to take actions.

remove_mod(cause: str)bool[source]

Remove a modifier from a stat. Returns True if successfully removed, else False.

property resist_astral

An entities resistance to astral damage.

property resist_burn

An entities resistance to burn damage.

property resist_chemical

An entities resistance to chemical damage.

property resist_cold

An entities resistance to cold damage.

property resist_mundane

An entities resistance to mundane damage.

property rush

How quickly an entity does things. Reduce time cost of actions.

serialize()[source]

Serialize an instance of this component into a simpler type.

Override this in all your Component classes to make use of snecs’ full-World serialization feature.

property skullduggery

Influences sneaky things. Never below 1.

property vigour

Influences healthiness. Never below 1.

class Exists[source]

Bases: scripts.engine.core.component.NQPComponent

Empty flag for all entities. Used to allow filters to search for a single component i.e. use a single condition.

classmethod deserialize(serialised)[source]

Deserialize a serialized instance of this component.

Will get the output of serialize as an argument.

Override this in all your Component classes to make use of snecs’ full-World serialization feature.

serialize()[source]

Serialize an instance of this component into a simpler type.

Override this in all your Component classes to make use of snecs’ full-World serialization feature.

class FOV[source]

Bases: scripts.engine.core.component.NQPComponent

An entity’s field of view. Always starts blank.

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

classmethod deserialize(serialised)[source]

Deserialize a serialized instance of this component.

Will get the output of serialize as an argument.

Override this in all your Component classes to make use of snecs’ full-World serialization feature.

serialize()[source]

Serialize an instance of this component into a simpler type.

Override this in all your Component classes to make use of snecs’ full-World serialization feature.

class Identity(name: str, description: str = '')[source]

Bases: scripts.engine.core.component.NQPComponent

An entity’s identity, such as name and description.

__init__(name: str, description: str = '')[source]

Initialize self. See help(type(self)) for accurate signature.

classmethod deserialize(serialised)[source]

Deserialize a serialized instance of this component.

Will get the output of serialize as an argument.

Override this in all your Component classes to make use of snecs’ full-World serialization feature.

serialize()[source]

Serialize an instance of this component into a simpler type.

Override this in all your Component classes to make use of snecs’ full-World serialization feature.

class Immunities(immunities: Dict[str, int] = None)[source]

Bases: scripts.engine.core.component.NQPComponent

Holds the details of anything the entity is immune to.

Can be set to INFINITE, which prevents it being reduced each turn.

__init__(immunities: Dict[str, int] = None)[source]

Initialize self. See help(type(self)) for accurate signature.

classmethod deserialize(serialised)[source]

Deserialize a serialized instance of this component.

Will get the output of serialize as an argument.

Override this in all your Component classes to make use of snecs’ full-World serialization feature.

serialize()[source]

Serialize an instance of this component into a simpler type.

Override this in all your Component classes to make use of snecs’ full-World serialization feature.

class IsActive[source]

Bases: scripts.engine.core.component.NQPComponent

Whether the entity is active or not. Used to limit entity processing.

classmethod deserialize(serialised)[source]

Deserialize a serialized instance of this component.

Will get the output of serialize as an argument.

Override this in all your Component classes to make use of snecs’ full-World serialization feature.

serialize()[source]

Serialize an instance of this component into a simpler type.

Override this in all your Component classes to make use of snecs’ full-World serialization feature.

class IsPlayer[source]

Bases: scripts.engine.core.component.NQPComponent

Whether the entity is the player.

classmethod deserialize(serialised)[source]

Deserialize a serialized instance of this component.

Will get the output of serialize as an argument.

Override this in all your Component classes to make use of snecs’ full-World serialization feature.

serialize()[source]

Serialize an instance of this component into a simpler type.

Override this in all your Component classes to make use of snecs’ full-World serialization feature.

class Knowledge(skills: List[Type[Skill]], skill_order: Optional[List[str]] = None, cooldowns: Optional[Dict[str, int]] = None)[source]

Bases: scripts.engine.core.component.NQPComponent

An entity’s knowledge, including skills.

__init__(skills: List[Type[Skill]], skill_order: Optional[List[str]] = None, cooldowns: Optional[Dict[str, int]] = None)[source]

Initialize self. See help(type(self)) for accurate signature.

add(skill: Type[Skill], add_to_order: bool = True, set_cooldown: bool = True)[source]

Learn a new skill.

add_blessing(skill: Type[Skill], blessing: SkillModifier)bool[source]

Add a blessing to a skill.

can_add_blessing(skill: Type[Skill], blessing: SkillModifier)bool[source]

Check if a blessing can be added to a skill.

classmethod deserialize(serialised)[source]

Deserialize a serialized instance of this component.

Will get the output of serialize as an argument.

Override this in all your Component classes to make use of snecs’ full-World serialization feature.

remove_blessing(skill: Type[Skill], remove_blessing: Type[SkillModifier])bool[source]

Attempt to remove a blessing.

serialize()[source]

Serialize an instance of this component into a simpler type.

Override this in all your Component classes to make use of snecs’ full-World serialization feature.

set_skill_cooldown(name: str, value: int)[source]

Sets the cooldown of a skill

class Lifespan(duration: int)[source]

Bases: scripts.engine.core.component.NQPComponent

Holds info relating to the limited lifespan of an entity. E.g. temporary summons.

Can be set to INFINITE, which prevents it being reduced each turn.

__init__(duration: int)[source]

Initialize self. See help(type(self)) for accurate signature.

classmethod deserialize(serialised)[source]

Deserialize a serialized instance of this component.

Will get the output of serialize as an argument.

Override this in all your Component classes to make use of snecs’ full-World serialization feature.

serialize()[source]

Serialize an instance of this component into a simpler type.

Override this in all your Component classes to make use of snecs’ full-World serialization feature.

class LightSource(light_id: str, radius: int)[source]

Bases: scripts.engine.core.component.NQPComponent

An emitter of light. Takes the light_id from a Light. The Light must be added to the Lightbox of the Gamemap separately.

__init__(light_id: str, radius: int)[source]

Initialize self. See help(type(self)) for accurate signature.

classmethod deserialize(serialised)[source]

Deserialize a serialized instance of this component.

Will get the output of serialize as an argument.

Override this in all your Component classes to make use of snecs’ full-World serialization feature.

on_delete()[source]

Delete the associated light from the Gamemap’s Lightbox

serialize()[source]

Serialize an instance of this component into a simpler type.

Override this in all your Component classes to make use of snecs’ full-World serialization feature.

class MapCondition[source]

Bases: scripts.engine.core.component.NQPComponent

A flag to show that an entity will take the player to the next map

classmethod deserialize(serialised)[source]

Deserialize a serialized instance of this component.

Will get the output of serialize as an argument.

Override this in all your Component classes to make use of snecs’ full-World serialization feature.

serialize()[source]

Serialize an instance of this component into a simpler type.

Override this in all your Component classes to make use of snecs’ full-World serialization feature.

class NQPComponent[source]

Bases: snecs.component.RegisteredComponent

Subclass snecs’ RegisteredComponent to extend with an on_delete method

on_delete()[source]
class Opinion(attitudes: Dict[ReactionTriggerType, int], opinions: Optional[Dict[EntityID, int]] = None)[source]

Bases: scripts.engine.core.component.NQPComponent

An entity’s views on other entities. {entity, opinion}

__init__(attitudes: Dict[ReactionTriggerType, int], opinions: Optional[Dict[EntityID, int]] = None)[source]

Initialize self. See help(type(self)) for accurate signature.

classmethod deserialize(serialised)[source]

Deserialize a serialized instance of this component.

Will get the output of serialize as an argument.

Override this in all your Component classes to make use of snecs’ full-World serialization feature.

serialize()[source]

Serialize an instance of this component into a simpler type.

Override this in all your Component classes to make use of snecs’ full-World serialization feature.

class Physicality(blocks_movement: bool, height: HeightType)[source]

Bases: scripts.engine.core.component.NQPComponent

An entity’s physical existence within the world.

__init__(blocks_movement: bool, height: HeightType)[source]

Initialize self. See help(type(self)) for accurate signature.

classmethod deserialize(serialised)[source]

Deserialize a serialized instance of this component.

Will get the output of serialize as an argument.

Override this in all your Component classes to make use of snecs’ full-World serialization feature.

serialize()[source]

Serialize an instance of this component into a simpler type.

Override this in all your Component classes to make use of snecs’ full-World serialization feature.

class Position(*positions: Tuple[int, int])[source]

Bases: scripts.engine.core.component.NQPComponent

An entity’s position on the map. At initiation provide all positions the entity holds. After initiation only need

to set the top left, or reference position as the other coordinates are held as offsets.

__init__(*positions: Tuple[int, int])[source]

Initialize self. See help(type(self)) for accurate signature.

property coordinates

The list of coordinates that this Position represents

Type

return

classmethod deserialize(serialised)[source]

Deserialize a serialized instance of this component.

Will get the output of serialize as an argument.

Override this in all your Component classes to make use of snecs’ full-World serialization feature.

get_outermost(direction: Tuple[int, int])Tuple[int, int][source]

Calculate the outermost tile in the direction provided :param direction: Direction to use :return: The position of the outermost tile

serialize()[source]

Serialize an instance of this component into a simpler type.

Override this in all your Component classes to make use of snecs’ full-World serialization feature.

set(x: int, y: int)[source]
property x

The x component of the top-left position

Type

return

property y

The y component of the top-left position

Type

return

class Reaction(reactions: Dict[ReactionTriggerType, ReactionData])[source]

Bases: scripts.engine.core.component.NQPComponent

Holds info about what triggers are in place and what happens as a result

__init__(reactions: Dict[ReactionTriggerType, ReactionData])[source]

Initialize self. See help(type(self)) for accurate signature.

classmethod deserialize(serialised)[source]

Deserialize a serialized instance of this component.

Will get the output of serialize as an argument.

Override this in all your Component classes to make use of snecs’ full-World serialization feature.

serialize()[source]

Serialize an instance of this component into a simpler type.

Override this in all your Component classes to make use of snecs’ full-World serialization feature.

class Resources(health: int = 1, stamina: int = 1)[source]

Bases: scripts.engine.core.component.NQPComponent

An entity’s resources. Members align to Resource constants.

__init__(health: int = 1, stamina: int = 1)[source]

Initialize self. See help(type(self)) for accurate signature.

classmethod deserialize(serialised)[source]

Deserialize a serialized instance of this component.

Will get the output of serialize as an argument.

Override this in all your Component classes to make use of snecs’ full-World serialization feature.

serialize()[source]

Serialize an instance of this component into a simpler type.

Override this in all your Component classes to make use of snecs’ full-World serialization feature.

class Shrine[source]

Bases: scripts.engine.core.component.NQPComponent

The component for tracking information relevant to shrines.

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

classmethod deserialize(serialised)[source]

Deserialize a serialized instance of this component.

Will get the output of serialize as an argument.

Override this in all your Component classes to make use of snecs’ full-World serialization feature.

interact()[source]
serialize()[source]

Serialize an instance of this component into a simpler type.

Override this in all your Component classes to make use of snecs’ full-World serialization feature.

class Sight(sight_range: int)[source]

Bases: scripts.engine.core.component.NQPComponent

An entity’s ability to see.

__init__(sight_range: int)[source]

Initialize self. See help(type(self)) for accurate signature.

classmethod deserialize(serialised)[source]

Deserialize a serialized instance of this component.

Will get the output of serialize as an argument.

Override this in all your Component classes to make use of snecs’ full-World serialization feature.

serialize()[source]

Serialize an instance of this component into a simpler type.

Override this in all your Component classes to make use of snecs’ full-World serialization feature.

class Thought(behaviour: Behaviour)[source]

Bases: scripts.engine.core.component.NQPComponent

An ai behaviour to control an entity.

__init__(behaviour: Behaviour)[source]

Initialize self. See help(type(self)) for accurate signature.

classmethod deserialize(serialised)[source]

Deserialize a serialized instance of this component.

Will get the output of serialize as an argument.

Override this in all your Component classes to make use of snecs’ full-World serialization feature.

serialize()[source]

Serialize an instance of this component into a simpler type.

Override this in all your Component classes to make use of snecs’ full-World serialization feature.

class Tracked(time_spent: int = 0)[source]

Bases: scripts.engine.core.component.NQPComponent

A component to hold info on activities of an entity

__init__(time_spent: int = 0)[source]

Initialize self. See help(type(self)) for accurate signature.

classmethod deserialize(serialised)[source]

Deserialize a serialized instance of this component.

Will get the output of serialize as an argument.

Override this in all your Component classes to make use of snecs’ full-World serialization feature.

serialize()[source]

Serialize an instance of this component into a simpler type.

Override this in all your Component classes to make use of snecs’ full-World serialization feature.

class Traits(trait_names: List[str])[source]

Bases: scripts.engine.core.component.NQPComponent

An entity’s traits. Class, archetype, skill set or otherwise defining group.

__init__(trait_names: List[str])[source]

Initialize self. See help(type(self)) for accurate signature.

classmethod deserialize(serialised)[source]

Deserialize a serialized instance of this component.

Will get the output of serialize as an argument.

Override this in all your Component classes to make use of snecs’ full-World serialization feature.

serialize()[source]

Serialize an instance of this component into a simpler type.

Override this in all your Component classes to make use of snecs’ full-World serialization feature.

class WinCondition[source]

Bases: scripts.engine.core.component.NQPComponent

A flag to show that an entity is a win objective

classmethod deserialize(serialised)[source]

Deserialize a serialized instance of this component.

Will get the output of serialize as an argument.

Override this in all your Component classes to make use of snecs’ full-World serialization feature.

serialize()[source]

Serialize an instance of this component into a simpler type.

Override this in all your Component classes to make use of snecs’ full-World serialization feature.

scripts.engine.core.dungen module

class DungeonGenerator(rng: 'random.Random', map_data: 'MapData', rooms_data: 'Dict[str, RoomConceptData]' = <factory>, actors_data: 'Dict[str, ActorData]' = <factory>, placed_rooms: 'List[RoomConcept]' = <factory>, map_of_categories: 'List[List[TileCategoryType]]' = <factory>, positions_in_rooms: 'List[Tuple[int, int]]' = <factory>, _passable_map: 'List[List[Literal[True]]]' = <factory>, _bools_map: 'List[List[bool]]' = <factory>, _tiles_map: 'List[List[Tile]]' = <factory>, is_dirty: 'bool' = False)[source]

Bases: object

__init__(rng: random.Random, map_data: MapData, rooms_data: Dict[str, RoomConceptData] = <factory>, actors_data: Dict[str, ActorData] = <factory>, placed_rooms: List[RoomConcept] = <factory>, map_of_categories: List[List[TileCategoryType]] = <factory>, positions_in_rooms: List[Tuple[int, int]] = <factory>, _passable_map: List[List[Literal[True]]] = <factory>, _bools_map: List[List[bool]] = <factory>, _tiles_map: List[List[Tile]] = <factory>, is_dirty: bool = False)None

Initialize self. See help(type(self)) for accurate signature.

actors_data: Dict[str, ActorData]
property bools_map

Returns an array of bools by converting values from map_of_categories to bool. Floor == True, Wall == False.

border_size = 4
count_adjacent_walls(x: int, y: int)int[source]

Get the number of walls in 4 directions.

count_neighbouring_walls(x: int, y: int)int[source]

Get the number of walls in 8 directions.

create_entities()[source]

Create all entities listed in rooms

property generation_string
get_actor_data(key: str)scripts.engine.internal.definition.ActorData[source]

Get the data for an actor based on key.

get_room(x: int, y: int)Optional[RoomConcept][source]

Returns the room at xy.

get_room_data(key: str)scripts.engine.internal.definition.RoomConceptData[source]

Get the data for a room based on key.

is_dirty: bool = False
is_in_border(x: int, y: int)[source]

Check if a position is in the border of the map

is_in_bounds(x: int, y: int)[source]

Check if a position is in the bounds of the map

is_in_room(x: int, y: int)bool[source]

Check if a position is in a placed room.

is_only_accessible_diagonally(x: int, y: int)bool[source]

Checks if a tile is only accessible via a diagonal move.

map_data: MapData
map_of_categories: List[List[TileCategoryType]]
max_generate_room_attempts = 100
max_make_room_accessible_attempts = 100
max_place_entity_attempts = 50
max_place_entrance_attempts = 50
max_place_room_attempts = 1000
property passable_map

2d array of True, matching map size

placed_rooms: List[RoomConcept]
positions_in_rooms: List[Tuple[int, int]]
rng: random.Random
rooms_data: Dict[str, RoomConceptData]
set_tile_category(x: int, y: int, category: TileCategoryType)[source]

Set the tile category at xy in map_of_categories. Marks map as dirty

property tiles_map

Returns an array of Tiles by converting values from map_of_categories to tiles.

class RoomConcept(tile_categories: List[List[TileCategoryType]], design: str, key: str, start_x: int = -1, start_y: int = -1, actors: Dict[str, Tuple[int, int]] = <factory>)[source]

Bases: object

Details of a room. Used for world generation.

__init__(tile_categories: List[List[TileCategoryType]], design: str, key: str, start_x: int = -1, start_y: int = -1, actors: Dict[str, Tuple[int, int]] = <factory>)None

Initialize self. See help(type(self)) for accurate signature.

actors: Dict[str, Tuple[int, int]]
property available_area

Number of unblocked tiles.

property centre_x
property centre_y
design: str
property end_x
property end_y
property generation_info

Return the generation information about the room

property height

Tallest height

property id

Return the id. Uses xy.

intersects(room: scripts.engine.core.dungen.RoomConcept)bool[source]

Check if this room intersects with another.

key: str
start_x: int = -1
start_y: int = -1
tile_categories: List[List[TileCategoryType]]
property total_area

Number of tiles in room.

property width

Widest width.

generate(map_name: str, rng: random.Random, player_data: Optional[ActorData] = None)Tuple[List[List[Tile]], str][source]

Generate the map using the specified details.

generate_steps(map_name: str)Iterator[source]

Generates a map, returning each step of the generation. Used for dev view.

scripts.engine.core.effect module

class AffectCooldownEffect(origin: EntityID, target: EntityID, success_effects: List[Effect], failure_effects: List[Effect], skill_name: str, affect_amount: int)[source]

Bases: scripts.engine.core.effect.Effect

__init__(origin: EntityID, target: EntityID, success_effects: List[Effect], failure_effects: List[Effect], skill_name: str, affect_amount: int)[source]

Initialize self. See help(type(self)) for accurate signature.

evaluate()Tuple[bool, List[Effect]][source]

Reduces the cooldown of a skill of an entity

class AffectStatEffect(origin: EntityID, target: EntityID, success_effects: List[Effect], failure_effects: List[Effect], cause_name: str, stat_to_target: PrimaryStatType, affect_amount: int)[source]

Bases: scripts.engine.core.effect.Effect

__init__(origin: EntityID, target: EntityID, success_effects: List[Effect], failure_effects: List[Effect], cause_name: str, stat_to_target: PrimaryStatType, affect_amount: int)[source]

Initialize self. See help(type(self)) for accurate signature.

evaluate()Tuple[bool, List[Effect]][source]

Log the affliction and the stat modification in the Affliction component.

class AftershockEffect(origin: EntityID, target: EntityID, success_effects: List[Effect], failure_effects: List[Effect])[source]

Bases: scripts.engine.core.effect.Effect

__init__(origin: EntityID, target: EntityID, success_effects: List[Effect], failure_effects: List[Effect])[source]

Initialize self. See help(type(self)) for accurate signature.

evaluate()Tuple[bool, List[Effect]][source]

Evaluate the effect, triggering more if needed. Must be overridden by subclass

class AlterTerrainEffect(origin: EntityID, target: EntityID, success_effects: List[Effect], failure_effects: List[Effect], terrain_name: str, affect_amount: int)[source]

Bases: scripts.engine.core.effect.Effect

__init__(origin: EntityID, target: EntityID, success_effects: List[Effect], failure_effects: List[Effect], terrain_name: str, affect_amount: int)[source]

Initialize self. See help(type(self)) for accurate signature.

evaluate()Tuple[bool, List[Effect]][source]

Create or reduce the duration of temporary terrain.

class ApplyAfflictionEffect(origin: EntityID, target: EntityID, success_effects: List[Effect], failure_effects: List[Effect], affliction_name: str, duration: int)[source]

Bases: scripts.engine.core.effect.Effect

__init__(origin: EntityID, target: EntityID, success_effects: List[Effect], failure_effects: List[Effect], affliction_name: str, duration: int)[source]

Initialize self. See help(type(self)) for accurate signature.

evaluate()Tuple[bool, List[Effect]][source]

Applies an affliction to an entity

class DamageEffect(origin: EntityID, target: EntityID, success_effects: List[Effect], failure_effects: List[Effect], stat_to_target: PrimaryStatType, accuracy: int, damage: int, damage_type: DamageTypeType, mod_stat: PrimaryStatType, mod_amount: float, potency: float = 1.0)[source]

Bases: scripts.engine.core.effect.Effect

__init__(origin: EntityID, target: EntityID, success_effects: List[Effect], failure_effects: List[Effect], stat_to_target: PrimaryStatType, accuracy: int, damage: int, damage_type: DamageTypeType, mod_stat: PrimaryStatType, mod_amount: float, potency: float = 1.0)[source]

Initialize self. See help(type(self)) for accurate signature.

evaluate()Tuple[bool, List[Effect]][source]

Resolve the damage effect and return the conditional effects based on if the damage is greater than 0.

class Effect(origin: EntityID, target: EntityID, success_effects: List[Effect], failure_effects: List[Effect], potency: float = 1.0)[source]

Bases: abc.ABC

A collection of parameters and instructions to apply a change to an entity’s or tile’s state.

__init__(origin: EntityID, target: EntityID, success_effects: List[Effect], failure_effects: List[Effect], potency: float = 1.0)[source]

Initialize self. See help(type(self)) for accurate signature.

abstract evaluate()[source]

Evaluate the effect, triggering more if needed. Must be overridden by subclass

class MoveOtherEffect(origin: EntityID, target: EntityID, success_effects: List[Effect], failure_effects: List[Effect], direction: DirectionType, move_amount: int)[source]

Bases: scripts.engine.core.effect.Effect

__init__(origin: EntityID, target: EntityID, success_effects: List[Effect], failure_effects: List[Effect], direction: DirectionType, move_amount: int)[source]

Initialize self. See help(type(self)) for accurate signature.

evaluate()Tuple[bool, List[Effect]][source]

Resolve the move effect and return the conditional effects based on if the target moved the full amount.

class MoveSelfEffect(origin: EntityID, target: EntityID, success_effects: List[Effect], failure_effects: List[Effect], direction: DirectionType, move_amount: int)[source]

Bases: scripts.engine.core.effect.Effect

__init__(origin: EntityID, target: EntityID, success_effects: List[Effect], failure_effects: List[Effect], direction: DirectionType, move_amount: int)[source]

Initialize self. See help(type(self)) for accurate signature.

evaluate()Tuple[bool, List[Effect]][source]

Resolve the move effect and return the conditional effects based on if the target moved the full amount.

scripts.engine.core.hourglass module

end_round()[source]

Posts END_ROUND event.

end_turn(entity: int, time_spent: int)[source]

Spend an entities time, progress time, move to next acting entity in queue. Posts END_TURN event.

N.B. If entity given is NOT the turn holder then nothing happens.

get_previous_turn_holder()int[source]

Get the entity who had the last turn

get_round()int[source]

Get the current round

get_time()int[source]

Get the current time

get_time_in_round()int[source]

Get current time in the current round

get_time_left_in_round()int[source]

Get the amount of time left in the current round

get_time_of_last_turn()int[source]

Get the time of the last turn

get_turn_holder()int[source]

Get the entity who has the current turn

get_turn_queue()Dict[EntityID, int][source]

Get the turn queue

next_round()[source]

Move to the next round. Posts NEW_ROUND event.

next_turn(entity_to_exclude: Optional[EntityID] = None)[source]

Proceed to the next turn, setting the next entity to act as the turn holder and updating the passage of time. Posts NEW_TURN event.

rebuild_turn_queue(entity_to_exclude: Optional[EntityID] = None)[source]

Build a new turn queue that includes all timed entities. entity_to_exclude is one that should not be added to the queue. Usually used in relation to deletion.

set_previous_turn_holder(entity: int)[source]

Set the entity who had the last turn

set_time_in_round(time: int)[source]

Set current time in the current round

set_time_of_last_turn(time: int)[source]

Set the time of the last turn

set_turn_holder(active_entity: int)[source]

Set the entity who has the current turn

set_turn_queue(queue: Dict[EntityID, int])[source]

Set the turn queue

scripts.engine.core.key module

convert_to_intent(event: pygame.event)Optional[InputIntentType][source]

Convert input to an intent.

convert_vector_to_intent(direction: Tuple[int, int])Optional[InputIntentType][source]

scripts.engine.core.matter module

add_component(entity: int, component: snecs.component.Component)[source]

Add a component to the entity

add_immunity(entity: int, immunity_name: str, duration: int)[source]

Add an immunity to an Entity’s Immunities Component. If entity has no Immunities Component one will be added.

apply_affliction(affliction: scripts.engine.internal.action.Affliction)bool[source]

Apply the affliction’s effects. Returns True is successful if criteria to trigger the affliction was met, False if not.

apply_damage(entity: int, damage: int)bool[source]

Remove damage from entity’s health. Return True is damage was applied.

apply_skill(skill: scripts.engine.internal.action.Skill)bool[source]

Resolve the skill’s effects. Returns True is successful if criteria to apply skill was met, False if not.

calculate_damage(base_damage: int, damage_mod_amount: int, resist_value: int, hit_type: HitTypeType)int[source]

Work out the damage to be dealt.

calculate_to_hit_score(attacker_accuracy: int, skill_accuracy: int, stat_to_target_value: int)int[source]

Get the to hit score based on the stats of both entities and a random roll.

can_use_skill(entity: int, skill_name: str)bool[source]

Check if entity can use skill. Checks cooldown and resource affordability.

choose_target(entity: int)Optional[int][source]

Choose an appropriate target for the entity. N.B. CURRENTLY JUST RETURNS PLAYER

create_actor(actor_data: scripts.engine.internal.definition.ActorData, spawn_pos: Tuple[int, int], is_player: bool = False)int[source]

Create an entity with all of the components to be an actor. Returns entity ID.

create_affliction(name: str, creator: int, target: int, duration: int)scripts.engine.internal.action.Affliction[source]

Creates an instance of an Affliction provided the name

create_compatible_blessings(amount: int)List[scripts.engine.internal.action.SkillModifier][source]
create_delayed_skill(creating_entity: int, tile_pos: Tuple[int, int], data: scripts.engine.internal.definition.DelayedSkillData)int[source]

Create an entity with all of the components to be a delayed skill. Returns Entity ID.

create_effect(origin: int, target: int, data: scripts.engine.internal.definition.EffectData)scripts.engine.core.effect.Effect[source]

Create an effect from effect data.

create_entity(components: Optional[List[snecs.component.Component]] = None)int[source]

Use each component in a list of components to create an entity

create_god(god_data: scripts.engine.internal.definition.GodData)int[source]

Create an entity with all of the components to be a god. god_name must be in the gods json file.

create_light(pos: Tuple[int, int], radius: int, colour: Tuple[int, int, int], alpha: int)str[source]

Create a Light and add it to the current GameMap’s Lightbox. Pos is the world position - the light will handle scaling to screen. Returns the light_id of the Light.

create_pathfinder()tcod.path.Pathfinder[source]

Create an empty pathfinder using the current game map

create_projectile(creating_entity: int, tile_pos: Tuple[int, int], data: scripts.engine.internal.definition.ProjectileData)int[source]

Create an entity with all of the components to be a projectile. Returns entity ID.

create_terrain(terrain_data: scripts.engine.internal.definition.TerrainData, spawn_pos: Tuple[int, int], lifespan: int = 999)int[source]

Create terrain

delete_entity(entity: int)[source]

Queues entity for removal from the world_objects. Happens at the next run of process.

entity_has_immunity(entity: int, name: str)bool[source]

Check if an entity has immunity to the named Action.

get_affected_entities(target_pos: Tuple[int, int], shape: ShapeType, shape_size: int, shape_direction: Optional[Tuple[int, int]] = None)[source]

Return a list of entities that are within the shape given, using target position as a centre point. Entity must have Position, Resources to be eligible.

get_entities_on_tile(tile: scripts.engine.world_objects.tile.Tile)List[int][source]

Return a list of all the entities in that tile

get_entitys_component(entity: int, component: Type[_C])_C[source]

Get an entity’s component. Will raise exception if entity does not have the component. Use entity_has_component to check.

get_hit_type(to_hit_score: int)HitTypeType[source]

Get the hit type from the to hit score

get_known_skill(entity: int, skill_name: str)Type[scripts.engine.internal.action.Skill][source]

Get an entity’s known skill from their Knowledge component.

get_name(entity: int)str[source]

Get an entity’s Identity component’s name.

get_player()int[source]

Get the player.

kill_entity(entity: int)[source]

Add entity to the deletion stack and removes them from the turn queue.

learn_skill(entity: int, skill_name: str)[source]

Add the skill name to the entity’s knowledge component.

pay_resource_cost(entity: int, resource: ResourceType, cost: int)bool[source]

Remove the resource cost from the using entity

remove_affliction(entity: int, affliction: scripts.engine.internal.action.Affliction)[source]

Remove affliction from active list and undo any stat modification.

remove_component(entity: int, component: Type[snecs.component.Component])[source]

Remove a component from the entity

set_skill_on_cooldown(entity: int, skill_name: str, cooldown_duration: int)[source]

Sets an entity’s skill on cooldown.

spend_time(entity: int, time_spent: int)bool[source]

Add time_spent to the entity’s total time spent.

take_turn(entity: int)bool[source]

Process the entity’s Thought component. If no component found then EndTurn event is fired.

trigger_affliction(affliction: scripts.engine.internal.action.Affliction)[source]

Trigger the affliction on the affected entity.

use_skill(user: int, skill: Type[scripts.engine.internal.action.Skill], target_tile: scripts.engine.world_objects.tile.Tile, direction: DirectionType)bool[source]

Use the specified skill on the target tile, usually creating a projectile. Returns True is successful if criteria to use skill was met, False if not.

scripts.engine.core.query module

scripts.engine.core.state module

dump_save_game()[source]

Export the save game data, if it exists, to an external json file

get_active_skill()str[source]

Get the active skill. Used for targeting mode.

get_active_skill_target()Tuple[int, int][source]

Get the active skill target. Used for targeting mode.

get_current()scripts.engine.internal.constant.GameState[source]

Get the current game state

get_internal_clock()[source]

Get the internal clock

get_previous()scripts.engine.internal.constant.GameState[source]

Get the previous game state

get_skill_target_valid()bool[source]

Get the validity of the current target. Used for targeting mode.

initialise_engine()[source]

Initialise engine resources.

N.B. Must be called before using the rest of the engine.

load_game(filename: str)[source]

Deserialise the game data from a file. Filename does not include path to save folder.

save_game()[source]

Serialise the game data to an internal container

set_active_skill(skill_name: str)[source]

Set the active skill. Used for targeting mode.

set_active_skill_target(skill_target: Tuple[int, int])[source]

Set the active skill target. Used for targeting mode.

set_new(new_game_state: scripts.engine.internal.constant.GameState)[source]

Set the current game state

set_skill_target_valid(skill_target_valid: bool)[source]

Set the validity of the current target. Used for targeting mode.

update_clock()float[source]

Tick the internal clock. Manages the frame rate. Returns delta time.

scripts.engine.core.system module

process_activations()[source]

Allocate active component to appropriate NPCs. Entity with no position or with position and close to player.

process_fov()[source]

Update FOV for all active entities

process_light_map()[source]

Update light map and light box using light sources of all entities

process_tile_visibility()[source]

Update tile visibility based on player fov

reduce_affliction_durations()[source]

Reduce all affliction durations

reduce_immunity_durations()[source]

Reduce all immunity durations

reduce_lifespan_durations()[source]

Reduce all lifespan durations

reduce_skill_cooldowns()[source]

Reduce skill cool down for all entities.

scripts.engine.core.ui module

class UI[source]

Bases: object

Manage the UI, such as windows, resource bars etc

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

create_screen_message(message: str, colour: str = '#531B75', size: int = 4)[source]

Create a message on the screen.

draw()[source]

Draw the UI.

element_is_active(element_type: scripts.engine.internal.constant.UIElement)bool[source]

Check if an element has been created and is visible

element_is_visible(element_type: scripts.engine.internal.constant.UIElement)bool[source]

Check if an element is visible.

get_element(element_type: UIElement)Union[Panel, Window][source]

Get UI element.

get_gui_manager()pygame_gui.ui_manager.UIManager[source]

Return the pygame_gui UI Manager

has_element(element_type: scripts.engine.internal.constant.UIElement)bool[source]

Check if an element exists

kill_all_elements()[source]

Close and kill the game’s UI elements. Helper function to run kill_element on all elements.

kill_element(element_type: scripts.engine.internal.constant.UIElement)[source]

Remove any reference to the element.

process_ui_events(event)[source]

Pass event to the gui manager.

register_element(element_type: UIElement, element: Union[Panel, Window])[source]

Register the specified UI element. Can be returned with get_element at a later date. If it already exists current instance will be overwritten.

set_element_visibility(element_type: scripts.engine.internal.constant.UIElement, visible: bool)bool[source]

Set whether the element is visible or not. Returns true if successful, false if element not found.

update(time_delta: float)[source]

Update all ui_manager elements

scripts.engine.core.utility module

build_sprites_from_paths(sprite_paths: List[TraitSpritePathsData], desired_size: Tuple[int, int] = (32, 32))TraitSpritesData[source]

Build a TraitSpritesData class from a list of TraitSpritePathsData. For each member in TraitSpritePathsData, combines the sprites from each TraitSpritePathsData in the list and flattens to a single surface.

clamp(value: _V, min_value: _V, max_value: _V)_V[source]

Return the value, clamped between min and max.

convert_direction_to_name(direction: DirectionType)str[source]

Get the direction name from the direction. e.g. (0,1) = ‘up’ etc.

convert_tile_string_to_xy(tile_pos_string: str)Tuple[int, int][source]

Convert a tile position string to (x, y)

flatten_images(images: List[pygame.Surface])pygame.Surface[source]

Flatten a list of images into a single image. All images must be the same size. Images are blitted in order.

get_class_members(cls: Type[Any])List[str][source]

Get a class’ members, excluding special methods e.g. anything prefixed with ‘__’. Useful for use with dataclasses.

get_coords_from_shape(shape: ShapeType, size: int, direction: Optional[Tuple[int, int]])List[Tuple[int, int]][source]

Get a list of coordinates from a shape, size and direction.

get_image(img_path: str, desired_dimensions: Tuple[int, int] = (32, 32), copy: bool = False)pygame.Surface[source]

Get the specified image and resize if dimensions provided. Dimensions are in (width, height) format. If img path is “none” then a blank surface is created to the size of the desired dimensions, or TILE_SIZE if no dimensions provided.

get_images(img_paths: List[str], desired_dimensions: Tuple[int, int] = (32, 32), copy: bool = False)List[pygame.Surface][source]

Get a collection of images.

is_close(current_pos: Tuple[float, float], target_pos: Tuple[float, float], delta: float = 0.05)bool[source]

True if the absolute distance between both coordinates is less than delta.

lerp(initial_value: float, target_value: float, lerp_fraction: float)float[source]

Linear interpolation between initial and target by amount. Fraction clamped between 0 and 1. >=0.99 is treated as 1 to handle float imprecision.

roll(min_value: int = 0, max_value: int = 99)int[source]

Roll for a number between min and max

value_to_member(value: Any, cls: Type[Any])str[source]

Get a member of a class that matches the value given

scripts.engine.core.world module

get_a_star_direction(start_pos: Tuple[int, int], target_pos: Tuple[int, int])Optional[DirectionType][source]

Use a* pathfinding to get a direction from one entity to another. Does not allow diagonals.

get_a_star_path(start_pos: Tuple[int, int], target_pos: Tuple[int, int])List[List[int]][source]

Get a list of coords that dictates the path between 2 entities.

get_cast_positions(entity: EntityID, target_pos: Position, skills: List[Type[Skill]])Dict[Type[Skill], List[Tuple[int, int]]][source]

Check through list of skills to find unblocked cast positions to target

get_chebyshev_distance(start_pos: Tuple[int, int], target_pos: Tuple[int, int])[source]

Get distance from an xy position towards another location. Expected tuple in the form of (x, y). This returns an int indicating the number of tile moves between the two points.

get_direction(start_pos: Tuple[int, int], target_pos: Tuple[int, int])DirectionType[source]

Get the direction between two locations.

get_entity_blocking_movement_map()numpy.ndarray[source]

Return a Numpy array of bools, True for blocking and False for open

get_euclidean_distance(start_pos: Tuple[int, int], target_pos: Tuple[int, int])float[source]

Get distance from an xy position towards another location. Expected tuple in the form of (x, y). This returns a float indicating the straight line distance between the two points.

get_game_map()scripts.engine.world_objects.game_map.GameMap[source]

Get current game_map. Raises AttributeError if game_map doesnt exist.

get_reflected_direction(active_entity: int, current_pos: Tuple[int, int], target_direction: Tuple[int, int])DirectionType[source]

Use surrounding walls to understand how the object should be reflected.

get_tile(tile_pos: Tuple[int, int])scripts.engine.world_objects.tile.Tile[source]

Get the tile at the specified location. Raises exception if out of bounds or doesnt exist.

get_tiles(start_pos: Tuple[int, int], coords: List[Tuple[int, int]])List[scripts.engine.world_objects.tile.Tile][source]

Get multiple tiles based on starting position and coordinates given. Coords are relative to start position given.

is_direction_blocked(entity: int, dir_x: int, dir_y: int)bool[source]

Checks if the entity will collide with something when trying to move in the provided direction. Returns True if blocked.

tile_has_tag(active_entity: int, tile: scripts.engine.world_objects.tile.Tile, tag: TileTagType)bool[source]

Check if a given tag applies to the tile. True if tag applies.

tile_has_tags(active_entity: int, tile: scripts.engine.world_objects.tile.Tile, tags: List[TileTagType])bool[source]

Check a tile has all required tags

Module contents