### Navigation

- index
- modules |
- next |
- previous |
- Pyskool 1.1.1 documentation »

# skool

Defines the `Skool` class.

class `skool.``Skool`(config, screen, beeper, cast, gallery)

  Represents the play area and its features and fixtures.

  Parameters: | config (dict) – Configuration parameters from the ini file. screen (`Screen`) – The screen to draw on. beeper (`Beeper`) – The beeper to use. cast (`Cast`) – The cast of characters. gallery (`Gallery`) – The gallery to obtain skool images from.

  `add_bike`(bike_id, sprite_group_id, initial_as, location, command_list_id, top_left, size, coords, move_delay, pedal_momentum, max_momentum)

    Add a bike to the skool and the cast.

    Parameters: | bike_id – The bike’s unique ID. 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. command_list_id – The ID of the command list the bike will use. top_left – The coordinates of the top left of the image of the base of the tree without the bike. size – The size of the image. coords – The coordinates of the image in the skool. 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`(room_id, top_left, size, chalk)

    Add a blackboard to a room in the skool.

    Parameters: | room_id – The ID of the room. top_left – The coordinates of the top-left of the blackboard. size – The size (width, height) of the blackboard. chalk – The chalk colour to use when writing on the blackboard.

  `add_chair`(room_id, x)

    Add a chair to a classroom in the skool.

    Parameters: | room_id – The ID of the classroom. x – The x-coordinate of the chair.

  `add_cup`(cup_id, empty_top_left, size, coords)

    Add a cup to the skool.

    Parameters: | cup_id – The cup’s unique ID. empty_top_left – The coordinates of the top left of the image of the cup when empty. size – The size of the image. coords – The coordinates of the cup in the skool.

  `add_desk`(room_id, x)

    Add a desk to a classroom in the skool.

    Parameters: | room_id – The ID of the classroom. x – The x-coordinate of the desk.

  `add_door`(door_id, x, bottom_y, top_y, initially_shut, auto_shut_delay, shut_top_left, size, coords, climb_phases, fly_phases)

    Add a door to the skool.

    Parameters: | door_id – The door’s unique ID. x – The door’s x-coordinate. bottom_y – The y-coordinate of the bottom of the door. top_y – The y-coordinate of the top of the door. initially_shut – Whether the door is shut at the start of a game. auto_shut_delay – The delay before the door shuts automatically; if zero or negative, the door will not shut automatically. shut_top_left – The coordinates of the top left of the image of the door when shut. size – The size of the image. coords – The coordinates of the door in the skool. climb_phases – The sequence of animation phases to use for Eric if he climbs over the door when it’s shut; if empty, Eric will not be able to climb over the door. fly_phases – The sequence of animation phases to use for Eric if he flies over the door after hitting it while standing on the saddle of the bike; if empty, Eric will not be able to fly over the door.

  `add_floor`(floor_id, min_x, max_x, y)

    Add a floor to the skool.

    Parameters: | floor_id – The floor’s unique ID. min_x – The x-coordinate of the left edge of the floor. max_x – The x-coordinate of the right edge of the floor. y – The y-coordinate of the floor.

  `add_font_character`(char, offset, width)

    Define the location and width of a font character bitmap in the font image.

    Parameters: | char – The font character. offset – The offset (in pixels) of the font character bitmap from the left edge of the font image. width – The width of the font character bitmap.

  `add_inventory_item`(item_id, top_left, size)

    Add an inventory item.

    Parameters: | item_id – The item’s unique ID. top_left – The coordinates of the top left of the image of the inventory item. size – The size of the image.

  `add_lines`(addend)

    Add some lines to Eric’s total. If, as a result, Eric has exceeded the lines limit, appropriate action is taken.

    Parameters: | addend – The number of lines to add.

  `add_location`(location_id, coords)

    Add a named location. Named locations can be used by the `GoTo` command.

    Parameters: | location_id – The name of the location. coords – The coordinates of the location (as a 2-tuple).

  `add_no_go_zone`(zone_id, min_x, max_x, bottom_y, top_y)

    Add a no-go zone to the skool.

    Parameters: | zone_id – The zone’s unique ID. min_x – The x-coordinate of the left edge of the zone. max_x – The x-coordinate of the right edge of the zone. bottom_y – The y-coordinate of the bottom edge of the zone. top_y – The y-coordinate of the top edge of the zone.

  `add_plant`(plant_id, sprite_group_id, x, y, command_list_id)

    Add a plant pot to the skool, and a plant to the cast.

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

  `add_room`(room_id, name, top_left, bottom_right, get_along)

    Add a room to the skool.

    Parameters: | room_id – The room’s unique ID. name – The room’s name (as it will appear in the lesson box). top_left – The coordinates of the top-left corner of the room. bottom_right – The coordinates of the bottom-right corner of the room. get_along – Whether Eric should be told to get a move on if he’s spotted in this room when the timetable says he should be somewhere else.

  `add_routes`(home_floor_id, dest_floor_ids, staircase_id)

    Add routes from one floor (the home floor) to other floors.

    Parameters: | home_floor_id – The ID of the home floor. dest_floor_ids – The IDs of the destination floors. staircase_id – The ID of the first staircase to use when moving from the home floor to any of the destination floors.

  `add_safe`(top_left, size, coords)

    Add a safe to the skool.

    Parameters: | top_left – The coordinates of the top left of the image of the safe. size – The size of the image. coords – The coordinates of the safe in the skool.

  `add_shield`(score, top_left, size, coords)

    Add a shield to the skool.

    Parameters: | top_left – The coordinates of the top left of the image of the shield. size – The size of the image. coords – The coordinates of the shield in the skool. score – The score for hitting the shield.

  `add_staircase`(staircase_id, bottom, top, force, alias)

    Add a staircase to the skool.

    Parameters: | staircase_id – The unique ID of the staircase. bottom – The coordinates of the bottom of the staircase. top – The coordinates of the top of the staircase. force – If True, the staircase must be ascended or descended when approached. alias – An alias for the staircase (may be blank).

  `add_to_score`(addend)

    Award some points.

    Parameters: | addend – The number of points to add to the score.

  `add_wall`(wall_id, x, bottom_y, top_y)

    Add a wall to the skool.

    Parameters: | wall_id – The wall’s unique ID. x – The wall’s x-coordinate. bottom_y – The y-coordinate of the bottom of the wall. top_y – The y-coordinate of the top of the wall.

  `add_window`(window_id, x, bottom_y, top_y, initially_shut, opener_coords, shut_top_left, size, coords, descent_phases, not_a_bird)

    Add a window to the skool.

    Parameters: | window_id – The window’s unique ID. x – The window’s x-coordinate. bottom_y – The y-coordinate of the bottom of the window. top_y – The y-coordinate of the top of the window. initially_shut – Whether the window is shut at the start of a game. opener_coords – The coordinates at which a character should stand to open or close the window. shut_top_left – The coordinates of the top left of the image of the window when shut. size – The size of the image. coords – The coordinates of the window in the skool. descent_phases – The animation phases to use for Eric if he jumps out of the window. not_a_bird – The ID of the command list Mr Wacker should switch to when Eric hits the ground after jumping out of the window; if not blank, Eric will be paralysed when he hits the ground.

  `auto_shut_doors`()

    Shut any automatically shutting doors that are due to be and can be shut.

  `barrier`(character, distance=0)

    Return the barrier (wall, window or door) that is in front of a character.

    Parameters: | character (`Character`) – The character. distance – The maximum distance to check in front of the character.
    Returns: | The wall, window or door in front of the character, or None if there is none.

  `beside_blackboard`(character)

    Return whether a character is beside a blackboard.

    Parameters: | character (`Character`) – The character to check.

  `can_reveal_safe_secret`(flashing)

    Return whether safe combination letters can be revealed now. This will be True only if the following conditions are met:

    - the safe has not been opened yet
    - all the shields are flashing, or flashing is False
  `chain_bike`()

    Chain the bike to the tree.

  `chair`(character, check_dir=True)

    Return the chair that is beside a character.

    Parameters: | character (`Character`) – The character to check. check_dir – If True, return the chair only if the character is facing the correct way to sit in it; otherwise, return the chair whichever way the character is facing.
    Returns: | The chair, or None if there is none.

  `check_drinks_cabinet`(x, y)

    Return whether the drinks cabinet is at a given location and is open.

    Parameters: | x – The x-coordinate of the location to check. y – The y-coordinate of the location to check.

  `check_safe`(x, y, got_key)

    Check whether there is a safe that can be opened at a given location. The safe will be opened if Eric either has the safe key, or has written the safe combination on a blackboard while all the shields are flashing.

    Parameters: | x – The x-coordinate of the location to check. y – The y-coordinate of the location to check. got_key – Whether Eric has the safe key.

  `cup`(x, y)

    Return the cup at a given location.

    Parameters: | x – The x-coordinate of the location. y – The y-coordinate of the location.
    Returns: | The cup, or None if there is no cup at the given location.

  `desk`(character)

    Return the desk that a character is sitting at.

    Parameters: | character (`Character`) – The character.
    Returns: | The desk, or None if the character is not sitting at a desk.

  `draw`(update=True)

    Draw the skool.

    Parameters: | update – Whether to update the screen after drawing.

  `draw_mutable`(images, coords)

    Draw a mutable object (a door, window, cup, or bike-on-a-tree).

    Parameters: | images – The images of the mutable object. coords – The coordinates at which to draw the object.

  `end_game`(up_a_year=False)

    Indicate that the game should restart. The score will be cleared if Eric was expelled, or retained if he went up a year.

    Parameters: | up_a_year – Whether Eric has gone up a year.

  `expand_message`(message)

    Return a message with character name and newline macros expanded. A character name macro takes the form $WACKER (for example), which expands to the name of the character whose ID is WACKER.

    Parameters: | message – The message that may contain unexpanded name macros.
    Returns: | A list of the lines in the expanded message.

  `expel_eric`(command_list_id)

    Set whoever is responsible for expelling Eric on his way.

    Parameters: | command_list_id – The ID of the command list the expeller should switch to.

  `fill_cup`(cup_id, contents)

    Fill a cup with water, sherry, or nothing.

    Parameters: | cup_id – The ID of the cup. contents – The stuff to fill the cup with.

  `fill_desks`()

    Hide the water pistol and stinkbombs in randomly chosen desks.

  `floor`(thing)

    Return the floor that a character or thing is in direct contact with.

    Parameters: | thing – The character or thing.
    Returns: | The floor, or None is the character is not on a floor.

  `floor_at`(x, y)

    Return the floor at a given location.

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

  `floor_below`(character)

    Return the highest floor that is below a character.

    Parameters: | character (`Character`) – The character.

  `get_assembly_message`()

    Return a message to deliver during assembly (with verb and noun randomly chosen).

  `get_door`(door_id)

    Return the door or window with a given ID.

    Parameters: | door_id – The ID of the door or window.

  `get_height`()

    Return the height of the play area (in pixels).

  `get_home_room`()

    Return the room Eric’s supposed to be in at the moment.

    Returns: | The room, or None if it’s an unsupervised period or Eric still has time to reach the room in which the class will be taking place.

  `get_inventory_images`(item_ids)

    Return a list of images of inventory items.

    Parameters: | item_ids – The IDs of the inventory items.

  `get_lesson_desc`()

    Return the name of the teacher and the room for this period (for display in the lesson box). The name of the teacher will be blank if it’s Playtime or Revision Library.

  `get_lines_message`(num_lines, name)

    Return a lines message containing the number of lines being given and the recipient’s name.

    Parameters: | num_lines – The number of lines being given. name – The recipient’s name.

  `get_mouse_image`()

    Return an image of a captured mouse (as it appears in the mouse inventory).

  `get_room`(room_id)

    Return the room with a given ID.

    Parameters: | room_id – The ID of the room.

  `get_teacher`()

    Return Eric’s teacher for this period.

    Returns: | Eric’s teacher, or None if it’s an unsupervised period.

  `get_width`()

    Return the width of the play area (in pixels).

  `got_bike_combination`(blackboard)

    Return whether the bike combination is written on a blackboard.

    Parameters: | blackboard (`Blackboard`) – The blackboard to check.

  `got_safe_combination`()

    Return whether the safe combination is written on any of the blackboards in the skool.

  `got_signal`(signal)

    Return whether a signal has been raised.

    Parameters: | signal – The signal to check.

  `got_storeroom_combination`(blackboard)

    Return whether the storeroom combination is written on a blackboard.

    Parameters: | blackboard (`Blackboard`) – The blackboard to check.

  `hide_in_desk`(item)

    Hide an item (stinkbombs or a water pistol) in a desk.

    Parameters: | item – The item to hide.

  `hit_shield`(x, y)

    Check whether there is a shield that can be hit at a given location, and make it flash or unflash if required. If the last shield was made to flash or unflash, appropriate sound effects are played, points are awarded, and other required actions are taken.

    Parameters: | x – The x-coordinate of the location to check. y – The y-coordinate of the location to check.
    Returns: | True if a shield was hit, False otherwise.

  `in_no_go_zone`(x, y)

    Return whether a given location is in a no-go zone.

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

  `in_playground`(character)

    Return whether a character is in the playground.

    Parameters: | character (`Character`) – The character to check.

  `initialise_bike_combo`()

    Initialise the bike combination.

  `initialise_cast`(keyboard)

    Initialise the cast and the safe, bike and storeroom combinations.

    Parameters: | keyboard (`Keyboard`) – The keyboard for Eric to use.

  `initialise_safe_combo`()

    Initialise the safe combination.

  `initialise_storeroom_combo`()

    Initialise the storeroom combination.

  `is_assembly`()

    Return whether it’s Assembly.

  `is_door_shut`(barrier_id)

    Return whether a door or window is shut.

    Parameters: | barrier_id – The ID of the door or window.

  `is_playtime`()

    Return whether it’s Playtime.

  `is_teaching_eric`(character)

    Return whether a character is teaching Eric’s class this period.

    Parameters: | character (`Character`) – The character to check.

  `is_time_remaining`(ticks)

    Return whether there is no more than a certain number of skool clock ticks remaining before the bell rings.

    Parameters: | ticks – The number of ticks.

  `is_time_to_start_lesson`()

    Return whether enough time has passed to start the lesson. This is used, for example, to check whether a teacher should tell the kids to sit down, or continue pacing up and down outside the classroom doorway.

  `line_of_sight_between`(a, b)

    Return whether there is a clear line of sight between two points (that is, there are no walls between them).

  `make_sitting_sound`()

    Play a sitting sound effect. This will be a walking sound effect, chosen at random from those available.

  `make_walking_sound`(index)

    Play a walking sound effect.

    Parameters: | index – The index of the walking sound effect.

  `move_bike_away`(barrier_id)

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

    Parameters: | barrier_id – The ID of the door.

  `move_characters`()

    Move the characters.

    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_door`(barrier_id, shut)

    Open or close a door or window.

    Parameters: | barrier_id – The ID of the door or window. shut – True if the door or window should be closed, False if it should be opened.

  `nearby_window`(character)

    Return a window that is close to a character.

    Parameters: | character (`Character`) – The character.
    Returns: | The window, or None if there is no window nearby.

  `next_lesson`(ring_bell)

    Proceed to the next lesson in the timetable.

    Parameters: | ring_bell – Whether to ring the bell.

  `next_staircase`(home_floor, dest_floor)

    Return the next staircase that any character on one floor (the home floor) should ascend or descend next to reach another floor (the destination floor).

    Parameters: | home_floor – The home floor. dest_floor – The destination floor.

  `on_floor`(character)

    Return whether a character is in direct contact with a floor.

    Parameters: | character (`Character`) – The character.

  `on_staircase`(character)

    Return whether a character is on a step of any of the staircases in the skool.

    Parameters: | character (`Character`) – The character.

  `plant_pot`(x, y)

    Return the plant pot at a given location.

    Parameters: | x – The x-coordinate of the location. y – The y-coordinate of the location.
    Returns: | The plant pot, or None if there is no plant pot at the given location.

  `play_sound`(sound_id, mode=1, pre_resume=None, pre_resume_args=())

    Play a sound effect.

    Parameters: | sound_id – The ID of the sound effect. mode – See `sound.Beeper.play()`. pre_resume – A method to execute after a sound effect played in `SUSPEND` mode has finished. pre_resume_args – The arguments for the pre_resume method.

  `print_lesson`()

    Print the lesson description in the lesson box.

  `reinitialise`()

    Reinitialise the skool in preparation for a new game.

  `resolve_location_id`(location_id)

    Resolve a location ID into a pair of coordinates.

    Parameters: | location_id – The ID of the location.
    Returns: | The coordinates of the location.

  `restore`()

    Perform tasks required immediately after rescaling or loading a saved game. The tasks are:

    - set the screen size and background colour
    - set the window icon and title
    - print the logo, score box, lesson box and inventories
    - restore the blackboard images
    - redraw the bike, cups, doors, and windows
  `resume`()

    Run any method that was queued up before playing a sound effect in `SUSPEND` mode.

  `rewind_clock`(ticks)

    Rewind the skool clock by a number of ticks.

    Parameters: | ticks – The number of ticks.

  `room`(character)

    Return the room a character is in (or None if he is not in a room).

    Parameters: | character (`Character`) – The character to check.

  `scroll`(inc, clock)

    Scroll the skool left or right across the screen.

    Parameters: | inc – The scroll increment; should be -1 (scroll right), 0 (don’t scroll), or 1 (scroll left). clock – The clock to use to time the scrolling.

  `scroll_on`(clock)

    Scroll the skool into view across the screen.

    Parameters: | clock – The clock to use to time the scrolling.

  `set_home_room`()

    Set Eric’s home room for the current period. The home room is the place Eric should be in by now; if he’s not, and he’s spotted by a teacher, he will be given lines.

  `should_get_along`(eric)

    Return whether Eric is somewhere other than he should be.

  `signal`(signal)

    Raise a signal.

    Parameters: | signal – The signal to raise.

  `staircase`(character, distance=0)

    Return the staircase that a character is on or close to.

    Parameters: | character (`Character`) – The character to check. distance – The maximum distance in front of the character to check for a staircase.
    Returns: | The staircase, or None if there is none.

  `start_clock`(ticks)

    Start the skool clock with a certain number of ticks remaining till the bell rings.

    Parameters: | ticks – The number of ticks.

  `stop_clock`()

    Stop the skool clock.

  `tick`()

    Advance the skool clock by one tick.

  `unchain_bike`()

    Unchain the bike from the tree.

  `unflash`(flashable)

    Make a flashing object stop flashing.

    Parameters: | flashable – The flashing object.

  `unset_home_room`()

    Unset Eric’s home room for the current period. This is used when assembly is finished (so that Eric is not told off for being outside the assembly hall after Mr Wacker has finished speaking).

  `unsignal`(signal)

    Lower a signal.

    Parameters: | signal – The signal to lower.

  `update_score_box`()

    Print the score, lines total and hi-score.

  `visible_blackboard`(character)

    Return the blackboard that is in a character’s line of sight, or None if there is none.

    Parameters: | character (`Character`) – The character to check.

  `window`(character)

    Return the window that is in front of a character.

    Parameters: | character (`Character`) – The character.
    Returns: | The window, or None if there is no window.

  `wipe_board`(blackboard, column)

    Wipe a bit of a blackboard clean.

    Parameters: | blackboard – The blackboard. column – The column of the blackboard to wipe.

  `write_on_board`(character, blackboard, message, index=1)

    Write the next character of a message on a blackboard.

    Parameters: | character (`Character`) – The character writing on the blackboard. blackboard – The blackboard. message – The message being written. index – The index of the next character in the message to write.
    Returns: | True if the entire message has been written, False otherwise.

### Navigation

- index
- modules |
- next |
- previous |
- Pyskool 1.1.1 documentation »