cast

Defines the Cast class.

class pyskool.cast.Cast(config, screen, gallery)

The control centre from which the entire cast of characters is monitored.

Parameters:
  • config (dict) – Configuration parameters from the ini file.
  • screen (Screen) – The screen to draw on.
  • gallery (Gallery) – The gallery of images to use for drawing.
add_bike(bike_id, sprite_group_id, initial_as, location, command_list_id, move_delay, pedal_momentum, max_momentum)

Add the bike to the cast.

Parameters:
  • bike_id – The ID of the bike.
  • sprite_group_id – The ID of the bike’s sprite group.
  • initial_as – The bike’s initial animatory state.
  • location – The bike’s initial location (after being unchained).
  • command_list_id – The ID of the command list the bike will use.
  • move_delay – The delay between consecutive movements of the bike when wheeling along or being pedalled.
  • pedal_momentum – The momentum increment when the bike is pedalled.
  • max_momentum – The maximum momentum the bike can have.
add_blackboard_message(character_id, message)

Add a blackboard message to a character’s collection.

Parameters:
  • character_id – The ID of the character.
  • message – The blackboard message.
add_character(character_id, name, title, sprite_group_id, initial_as, direction, head_xy, flags)

Add a character (other than Eric) to the cast.

Parameters:
  • character_id – The character’s unique ID.
  • name – The character’s name.
  • title – The character’s title (how he is addressed by the swot).
  • sprite_group_id – The ID of the character’s sprite group.
  • initial_as – The character’s initial animatory state.
  • direction – The character’s initial direction.
  • head_xy – The coordinates of the character’s head within his sprite when he’s standing upright (used for collision detection).
  • flags – The character’s flags.
add_command(command_list_id, command_name, *params)

Add a command to a command list.

Parameters:
  • command_list_id – The ID of the command list.
  • command_name – The name of the command.
  • params – The command’s parameters.
add_command_list(character_id, lesson_id, command_list_id)

Add a command list to a character’s personal timetable.

Parameters:
  • character_id – The ID of the character.
  • lesson_id – The ID of the lesson to place the command list against.
  • command_list_id – The ID of the command list.
add_conker(object_id, sprite_group_id, command_list_id, min_x, max_x, min_y, max_y, hit_xy)

Add the conker to the cast.

Parameters:
  • object_id – The ID of the conker.
  • sprite_group_id – The ID of the conker’s sprite group.
  • command_list_id – The ID of the command list the conker will use.
  • min_x – The minimum x-coordinate a pellet must reach to knock the conker out of the tree.
  • max_x – The maximum x-coordinate a pellet must reach to knock the conker out of the tree.
  • min_y – The minimum y-coordinate a pellet must fly at to knock the conker out of the tree.
  • max_y – The maximum y-coordinate a pellet must fly at to knock the conker out of the tree.
  • hit_xy – The coordinates of the conker within its sprite (used for collision detection).
add_desk_lid(desk_lid_id, sprite_group_id, command_list_id, x_offset)

Add the desk lid to the cast.

Parameters:
  • desk_lid_id – The ID of the desk lid.
  • sprite_group_id – The ID of the desk lid’s sprite group.
  • command_list_id – The ID of the command list the desk lid will use.
  • x_offset – The offset (relative to the desk being opened) at which the desk lid should be displayed.
add_eric(character_id, name, sprite_group_id, initial_as, direction, head_xy, flags, bend_over_hand_xy)

Add Eric to the cast.

Parameters:
  • character_id – Eric’s unique ID.
  • name – Eric’s name.
  • sprite_group_id – The ID of Eric’s sprite group.
  • initial_as – Eric’s initial animatory state.
  • direction – Eric’s initial direction.
  • head_xy – The coordinates of Eric’s head within his sprite when he’s standing upright (used for collision detection).
  • flags – Eric’s character flags.
  • bend_over_hand_xy – The coordinates of Eric’s hand within his left-facing BENDING_OVER sprite (used to determine where a mouse or frog should be when caught or released).
add_frog(frog_id, sprite_group_id, initial_as, location, command_list_id, turn_round, short_hop, long_hop, sit_xy, eric_proximity)

Add a frog to the cast.

Parameters:
  • frog_id – The ID of the frog.
  • sprite_group_id – The ID of the frog’s sprite group.
  • initial_as – The frog’s initial animatory state.
  • location – The frog’s initial location.
  • command_list_id – The ID of the command list the frog will use.
  • turn_round – The animation phases to use when the frog turns round.
  • short_hop – The animation phases to use when the frog makes a short hop.
  • long_hop – The animation phases to use when the frog makes a long hop.
  • sit_xy – The coordinates of the frog within its sprite when it’s sitting (used for collision detection and placement in cups).
  • eric_proximity – The minimum distance from the frog that Eric can be before it will try to hop away.
add_lesson_message(character_id, message, condition)

Add a lesson message to a character’s collection. A lesson message is something like ‘START READING AT THE NEXT CHAPTER IN YOUR BOOKS’, which will be used by a teacher during class if he’s not teaching Eric, or he has decided not to have a question-and-answer session with the swot.

Parameters:
  • character_id – The ID of the character.
  • message – The lesson message.
  • condition (string) – The name of the condition that must be met before the lesson message is used.
add_lines_message(character_id, message_id, message)

Add a lines message to a character’s collection.

Parameters:
  • character_id – The ID of the character.
  • message_id – The ID of the lines message.
  • message – The lines message.
add_mouse(mouse_id, sprite_group_id, initial_as, location, command_list_id, sprite_xy, immortal=True)

Add a mouse to the cast.

Parameters:
  • mouse_id – The ID of the mouse.
  • sprite_group_id – The ID of the mouse’s sprite group.
  • initial_as – The mouse’s initial animatory state.
  • location – The mouse’s initial location.
  • command_list_id – The ID of the command list the mouse will use.
  • sprite_xy – The coordinates of the mouse within its sprite (used for detecting whether Eric has caught it).
  • immortal – Whether the mouse is immortal (will not disappear until Eric catches it).
add_mouse_location(x, y)

Add a location at which a new immortal mouse may appear after Eric catches one.

Parameters:
  • x – The x-coordinate of the location.
  • y – The x-coordinate of the location.
add_pellet(character_id, pellet_id, sprite_group_id, command_list_id, pellet_range, hit_zone, hit_xy)

Add a pellet to the cast.

Parameters:
  • character_id – The ID of the pellet’s owner.
  • pellet_id – The ID of the pellet.
  • sprite_group_id – The ID of the pellet’s sprite group.
  • command_list_id – The ID of the command list the pellet will use.
  • pellet_range – The maximum distance the pellet will travel after launch.
  • hit_zone – The size of the portion at the end of the pellet’s journey in which it can hit things.
  • hit_xy – The coordinates of the pellet within its sprite (used for collision detection).
add_plant(plant_id, sprite_group_id, x, y, command_list_id)

Add a plant to the cast.

Parameters:
  • plant_id – The ID of the plant.
  • sprite_group_id – The ID of the plant’s sprite group.
  • x – The plant’s x-coordinate.
  • y – The plant’s y-coordinate.
  • command_list_id – The ID of the command list the bike will use.
Returns:

The plant.

add_sherry_drop(object_id, sprite_group_id, command_list_id, hit_xy)

Add the sherry drop to the cast.

Parameters:
  • object_id – The ID of the sherry drop.
  • sprite_group_id – The ID of the sherry drop’s sprite group.
  • command_list_id – The ID of the command list the sherry drop will use.
  • hit_xy – The coordinates of the sherry drop within its sprite (used for collision detection).
add_sit_down_message(character_id, message)

Add a sit-down message for a character.

Parameters:
  • character_id – The ID of the character
  • message – The sit-down message.
add_sprite(group_id, sprite_id, sprite_index)

Add a sprite (an animatory state image) to the cast.

Parameters:
  • group_id – The sprite group ID.
  • sprite_id – The sprite ID.
  • sprite_index – The index of the sprite in the sprite matrix.
add_stinkbomb(character_id, stinkbomb_id, sprite_group_id, command_list_id, phases, stink_range)

Add a stinkbomb to the cast.

Parameters:
  • character_id – The ID of the stinkbomb’s owner.
  • stinkbomb_id – The ID of the stinkbomb.
  • sprite_group_id – The ID of the stinkbomb’s sprite group.
  • command_list_id – The ID of the command list the stinkbomb will use.
  • phases – The phases of animation the stinkbomb cloud will use.
  • stink_range – The maximum distance from which the stinkbomb can be smelt.
add_water(character_id, water_id, sprite_group_id, command_list_id, phases)

Add a jet of water or sherry to the cast.

Parameters:
  • character_id – The ID of the water/sherry’s owner.
  • water_id – The ID of the water/sherry.
  • sprite_group_id – The ID of the water/sherry’s sprite group.
  • command_list_id – The ID of the command list the water/sherry will use.
  • phases – The phases of animation the water will use after being fired from a water pistol.
add_water_drop(object_id, sprite_group_id, command_list_id, hit_xy)

Add the water drop to the cast.

Parameters:
  • object_id – The ID of the water drop.
  • sprite_group_id – The ID of the water drop’s sprite group.
  • command_list_id – The ID of the command list the water drop will use.
  • hit_xy – The coordinates of the water drop within its sprite (used for collision detection).
can_get_lines(message_id)

Return whether any member of the cast can give a specific lines message.

Parameters:message_id – The ID of the lines message.
caught_mouse(mouse)

Take appropriate action when a mouse is caught. If the mouse is immortal (defined in the [Mice] section of the ini file), it will be relocated (so that Eric can catch it again). If it is not immortal (Eric previously released it), it is removed from the game.

Parameters:mouse – The captured mouse.
change_command_list(character_id, command_list_id)

Switch a character to a new command list.

Parameters:
  • character_id – The ID of the character.
  • command_list_id – The ID of the command list.
check_heads_at(x, y)

Check whether a frog has hit the head of anyone who holds a safe key, and hand the safe key to Eric if so.

Parameters:
  • x – The x-coordinate to check for heads.
  • y – The y-coordinate to check for heads.
Returns:

True if the frog hit someone’s head, False otherwise.

conker_falling()

Return whether a conker is currently falling.

create_lesson(swot, room)

Return a new Lesson instance for the swot.

Parameters:
  • swot (Character) – The swot.
  • room (Room) – The room in which the lesson will take place.
drop_anyone_at(x, y)

Drop any character at a given location. This is used by plants when they die.

Parameters:
  • x – The x-coordinate of the location.
  • y – The y-coordinate of the location.
eric_understood()

Return whether Eric understood the message just delivered to him.

expand_names(message)

Replace occurrences of $BLAH in a message with the name of the character whose unique ID is ‘BLAH’.

Parameters:message – The message.
expand_title(message, character)

Replace any title macros in a message with the title of a character.

Parameters:
  • message – The message that may contain title macros.
  • character (Character) – The character whose title should be substituted.
expel_eric(character_id, command_list_id)

Mark Eric as expelled and set somebody on their way to expel him.

Parameters:
  • character_id – The ID of the character who will expel Eric.
  • command_list_id – The ID of the command list the character should switch to.
freeze_eric()

Attempt to freeze Eric. The attempt will fail if Eric is writing on a blackboard.

Returns:True if Eric was frozen, False otherwise.
get(character_id)

Return a member of the cast.

Parameters:character_id – The ID of the cast member.
get_absent_tale(teacher)

Return a tale about Eric being absent for the swot to tell a teacher.

Parameters:teacher – The teacher.
get_animal(x, y)

Return any animal that is on the floor at a given location.

Parameters:
  • x – The x-coordinate of the location.
  • y – The y-coordinate of the location.
Returns:

The animal, or None if there is none.

get_conkerable(x, y)

Return a suitable character to hit with a conker at a given location, or None if there is none. A character is considered suitable if he can be knocked over by a conker.

Parameters:
  • x – The x-coordinate of the location.
  • y – The x-coordinate of the location.
get_eric_stopper()

Return any character who is currently standing in Eric’s way (as Albert does when trying to prevent him from escaping), or None if there is none.

get_hit_tale(teacher)

Return a tale about hitting for the swot to tell a teacher.

Parameters:teacher – The teacher.
Returns:A 2-tuple containing the ID of the character blamed by the swot, and the tale.
get_images()

Return a list of images for every member of the cast.

get_location_of_eric()

Return the non-staircase location closest to Eric.

get_nearby_adults(character)

Return a list of adults who are close to and facing a target character.

Parameters:character (Character) – The target character.
get_nearby_lines_givers(character)

Return a list of lines-givers who are close to and facing a target character, and are able to give lines now.

Parameters:character (Character) – The target character.
get_nearest_lines_recipient(character)

Return the potential lines recipient who is nearest to a target character, or None if there is none.

Parameters:character (Character) – The target character.
get_pelletable(x, y)

Return the most suitable character to hit with a catapult pellet at a given location, or None if there is none.

Parameters:
  • x – The x-coordinate of the location.
  • y – The x-coordinate of the location.
get_punchee(character, offset)

Return the first punchable character who is facing a target character at a given distance.

Parameters:
  • character (Character) – The target character.
  • offset – The distance in front of the target character to look for facing characters.
Returns:

A punchable character, or None if there is none at the given distance.

get_sherryable(x, y)

Return a suitable character to hit with a drop of sherry at a given location, or None if there is none. A character is considered suitable if he holds a storeroom combination letter.

Parameters:
  • x – The x-coordinate of the location.
  • y – The x-coordinate of the location.
get_speech_bubbles()

Return a list of speech bubbles currently in use by the cast.

get_waterable(x, y)

Return a suitable character to hit with a drop of water at a given location, or None if there is none. A character is considered suitable if he holds a bike combination digit.

Parameters:
  • x – The x-coordinate of the location.
  • y – The x-coordinate of the location.
get_write_tale(writer_id, teacher)

Return a tale about writing on the blackboard for the swot to tell a teacher.

Parameters:
  • writer_id – The ID of the character to who wrote on the blackboard.
  • teacher – The teacher.
Returns:

A 2-tuple containing writer_id and the tale, or (None, None) if the character who wrote on the board is not in the list of scapegoats favoured by the swot.

has_kissees()

Return whether anyone in the cast can kiss Eric.

hit_conker(pellet)

Check whether a catapult pellet has hit a conker. If it has, the conker will start falling.

Parameters:pellet – The catapult pellet.
Returns:True if a conker was hit, False otherwise.
initialise(skool, keyboard)

Initialise every member of the cast.

Parameters:
  • skool (Skool) – The skool.
  • keyboard (Keyboard) – The keyboard for Eric to use.
initialise_bike_combo()

Initialise the bike combination.

Returns:The combination.
initialise_safe_combo()

Initialise the safe combination.

Returns:The combination.
initialise_storeroom_combo()

Initialise the storeroom combination.

Returns:The combination.
insert_frog(cup)

Insert any frogs that have been caught by Eric into a cup.

Parameters:cup – The cup.
is_beside_bike(character)

Return whether a character is next to the bike.

Parameters:character (Character) – The character to check.
is_beside_eric(character)

Return whether a character is beside Eric (and so need go no further to find him).

Parameters:character (Character) – The character to check.
is_bike_visible()

Return whether the bike is in the play area at the moment.

is_eric_absent()

Return whether Eric is playing truant.

is_eric_expelled()

Return whether Eric is due to be or is in the process of being expelled.

is_home(x)

Return whether every character is on the ‘home’ side of a given x-coordinate.

Parameters:x – The x-coordinate.
is_standing_on_kid(character)

Return whether a character is standing on a kid who’s been knocked out.

Parameters:character (Character) – The character to check.
is_touching_eric(character)

Return whether a character is in the same location as Eric.

Parameters:character (Character) – The character to check.
kill_mouse(mouse)

Remove a mouse from the game.

Parameters:mouse – The mouse to remove.
kissee()

Return the first kissable candidate in front of Eric, or None if there is none.

knock_cup(cup)

Make a cup spill its contents (as when hit by a catapult pellet). A cup may contain water, sherry, a frog, or nothing.

Parameters:cup – The cup.
lift_anyone_at(x, y)

Lift any character at a given location. This is used by plants when growing.

Parameters:
  • x – The x-coordinate of the location.
  • y – The y-coordinate of the location.
move()

Move the members of the cast.

Returns:-1 if the screen should scroll right, 1 if it should scroll left, or 0 if it should not scroll (after moving Eric).
move_bike_away(door)

Move the bike away from a door if necessary (so that it may be closed).

Parameters:door – The door.
open_desk(character, desk)

Make a character open a desk. The desk lid will be raised.

Parameters:
  • character (Character) – The character.
  • desk – The desk.
plant(character)

Return the plant that a character is standing on, or None if he’s not standing on one.

Parameters:character (Character) – The character to check.
reinitialise()

Reinitialise every member of the cast.

release_mice(num_mice, x, y)

Release some mice at a given location.

Parameters:
  • num_mice – The number of mice to release.
  • x – The x-coordinate of the location.
  • y – The y-coordinate of the location.
relocate_mouse(mouse)

Relocate a mouse at a randomly chosen location.

restore()

Perform tasks required immediately after restoring a saved game. The tasks are:

  • build the sprite images
  • print the inventory
  • print the mouse inventory
scare_musophobes(mouse)

Make any characters near a mouse respond appropriately.

Parameters:mouse – The mouse.
set_lesson(lesson_id)

Set the lesson (as after the bell rings). Everybody except Eric collects a new command list from their personal timetable.

Parameters:lesson_id – The ID of the lesson.
set_location(character_id, x, y)

Set the location of a character.

Parameters:
  • character_id – The ID of the character.
  • x – The x-coordinate of the location.
  • y – The y-coordinate of the location.
set_random_locations(character_id, locations)

Set the collection of random locations for a character.

Parameters:
  • character_id – The ID of the character.
  • locations – The locations.
smeller(stinkbomb)

Return a character who can smell a stinkbomb, or None if there is none.

Parameters:stinkbomb – The stinkbomb.
somebody_near_door(door)

Return whether somebody is standing near a door.

Parameters:door – The door to check.
trip_people_up_at(character, x, y)

Make a character trip people up at a given location.

Parameters:
  • character (Character) – The character trying to trip people up.
  • x – The x-coordinate of the location.
  • y – The y-coordinate of the location.
unchain_bike()

Bring the bike into the play area (as after being unchained).

unfreeze_eric()

Unfreeze Eric.

water_plant(plant_pot, liquid)

Water (or sherry) a plant. If the liquid is water, the plant will start growing.

Parameters:
  • plant_pot – The plant pot hit by the water or sherry.
  • liquid – The type of liquid.

Previous topic

bike

Next topic

character