cast

Defines the Cast class.

class cast.Cast(sprites)

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

Parameter:sprites (pygame.Surface) – An image of the sprite matrix (sprites.png).
add_bike(bike_id, sprite_group_id, initial_as, location, command_list_id)

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.
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, 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.
  • 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)

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.
add_desk_lid(desk_lid_id, sprite_group_id, command_list_id)

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.
add_eric(character_id, name, sprite_group_id, initial_as, flags)

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.
  • flags – Eric’s character flags.
add_frog(frog_id, sprite_group_id, initial_as, location, command_list_id)

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.
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, 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.
  • immortal – Whether the mouse is immortal (will not disappear until Eric catches it).
add_pellet(character_id, pellet_id, sprite_group_id, command_list_id, pellet_range, hit_zone)

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.
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)

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.
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)

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.
add_water(character_id, water_id, sprite_group_id, command_list_id)

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.
add_water_drop(object_id, sprite_group_id, command_list_id)

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.
can_get_lines(message_id)

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

Parameter: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.

Parameter:mouse – The captured mouse.
change_command_list(character, command_list_id)

Switch a character to a new command list.

Parameters:
  • character (Character) – The character.
  • command_list_id – The ID of the command list.
check_heads(frog)

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

Parameter:frog – The frog to check.
Returns:True if Eric got the safe key, False otherwise.
conker_falling()
Return whether a conker is currently falling.
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’.

Parameter: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(command_list_id)

Set someone with the appropriate authority on their way to expel Eric.

Parameter:command_list_id – The ID of the command list the expeller should use.
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.

Parameter: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.

Parameter:teacher – The teacher.
get_animal(character)

Return any mouse or frog that is on the floor immediately in front of a character, or None if there is none.

Parameter:character (Character) – The character.
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.

Parameter: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 enough to a target character (and are facing the right way) to be able to see him.

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

Return a list of lines-givers who are close enough to a target character (and are facing the right way) to be able to see him.

Parameter: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.

Parameter: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 for every member of 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.

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

Initialise every member of the cast.

Parameters:
  • skool (Skool) – The skool.
  • screen (Screen) – The screen.
  • 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.

Parameter:cup – The cup.
is_beside_bike(character)

Return whether a character is next to the bike.

Parameter: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).

Parameter: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.

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

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

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

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

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

Remove a mouse from the game.

Parameter: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.

Parameter: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).

Parameter: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.

Parameter: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.
scare_musophobes(mouse)

Make any characters near a mouse respond appropriately.

Parameter: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.

Parameter: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.
set_sit_down_message(character_id, message)

Set the sit-down message for a character.

Parameters:
  • character_id – The ID of the character
  • message – The sit-down message.
shadow_eric(command_list_id)

Set someone with the appropriate authority on their way to shadow Eric for this period.

Parameter:command_list_id – The ID of the command list the shadower should use.
smeller(stinkbomb)

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

Parameter:stinkbomb – The stinkbomb.
somebody_near_door(door)

Return whether somebody is standing near a door.

Parameter: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.
cast.BESIDE_ERIC_X_RANGE
Maximum distance from Eric at which a character is considered beside him.
cast.GRASSEE_MARKER
Marker replaced by the grassee’s name in EINSTEIN’s speech.
cast.KISS_DISTANCE
Distance in front of Eric a character must be in order to be kissable.
cast.LINES_MESSAGE_NEWLINE
Character that will be replaced by a newline in lines messages.
cast.MOUSE_COMMAND_LIST
ID of the command list used by mortal mice.
cast.MOUSE_LOCATIONS
Locations at which a new immortal mouse may be released (after Eric catches one).
cast.MOUSE_SPRITE_GROUP
ID of the sprite group used by mortal mice.
cast.NEARBY_X_RANGE
Maximum horizontal distance at which a character is considered nearby (for lines-giving purposes).
cast.NEARBY_Y_RANGE
Maximum vertical distance at which a character is considered nearby (for lines-giving purposes).
cast.SPRITE_COLORKEY
The transparent colour in sprites.png.
cast.SPRITE_COLUMNS
Number of columns in the sprite matrix in sprites.png.
cast.SPRITE_ROWS
Number of rows in the sprite matrix in sprites.png.
cast.TITLE_MARKER
Marker replaced by a teacher’s title in EINSTEIN’s speech.

Previous topic

bike

Next topic

character