lesson

Classes concerned with controlling what goes on during a lesson.

class pyskool.lesson.AssemblyMessageGenerator

Generates messages to be delivered by whoever is conducting assembly. There is only one assembly message generator, shared by the whole skool.

add_message_template(template)

Add template to the generator’s collection of message templates.

add_word(group_id, word)

Add a word to the generator’s collection.

Parameters:
  • group_id – The name of the group to add the word to.
  • word – The word.
generate_message()

Return a message based on a randomly chosen template and containing randomly chosen phrases.

class pyskool.lesson.Lesson(cast, swot, room, config)

Controls the interaction between the teacher, the swot and Eric during a lesson. The various actions required by the teacher and the swot during a lesson - such as grassing on Eric for being absent, writing on the board, and asking and answering questions - are defined by individual methods on this class.

A new lesson is created by the swot when he sits down after being told to by the teacher at the classroom doorway.

Parameters:
  • cast (Cast) – The cast.
  • swot (Character) – The swot.
  • room (Room) – The classroom in which the lesson is taking place.
  • config (dict) – Configuration parameters from the ini file.
answer_question()

Make the swot answer the teacher’s question. The swot’s next action will be check_eric().

ask_question()

Make the teacher ask a question. The swot’s next action is set to answer_question().

Returns:A Say command.
check_eric()

Make the swot tell the teacher that Eric is absent (if he is). If Eric is absent, the teacher’s next action will be fetch_eric().

Returns:A Say command if Eric is absent, otherwise None.
check_eric_initial()

Make the swot tell the teacher that Eric is absent (if he is). This method defines the swot’s first action during a lesson. If Eric is absent, the teacher’s next action will be fetch_eric(). The swot’s next action is set to grass_for_hitting().

Returns:A Say command if Eric is absent, otherwise None.
fetch_eric()

Make the teacher track down Eric if he is absent. The teacher may first give lines to the swot for telling tales. If Eric is present by the time this method is called (after the swot has finished telling the teacher that Eric is not in class), the teacher will give lines to Eric for being late (or for leaving early).

Returns:A FetchEric command if Eric is still absent after the swot has finished speaking, otherwise None.
finished_speaking()

Indicate that the current actor (teacher or swot) has finished speaking.

get_question()

Return the next question for the teacher to ask in a question-and-answer session with the swot.

give_lines(victim_id, message_id)

Make the teacher give lines to the swot for telling a tale, or give lines to the subject of the swot’s tale.

Parameters:
  • victim_id – The ID of the subject (may be None, in which case no lines will be given).
  • message_id – The ID of the lines message.
give_lines_for_hitting()

Make the teacher give lines to the swot for telling a tale about being hit, or give lines to the subject of the tale. If the swot has not told such a tale, nothing happens.

give_lines_for_writing()

Make the teacher give lines to the swot for telling a tale about the blackboard being written on, or give lines to the subject of the tale. If the swot has not told such a tale, nothing happens. The teacher’s next action is set to wipe_board().

grass_for_hitting()

Make the swot tell a tale about someone hitting him (possibly). This method defines the swot’s second action during a lesson. The teacher’s next action is set to give_lines_for_hitting(). The swot’s next action is set to grass_for_writing().

Returns:A Say command, or None if the swot decides not to tell a tale.
grass_for_writing()

Make the swot tell a tale about someone writing on the blackboard (if it was written on by Eric or the tearaway). This method defines the swot’s third action during a lesson. The teacher’s next action is set to give_lines_for_writing().

Returns:A Say command, or None if the swot decides not to tell a tale.
is_eric_absent()

Return whether Eric is absent from the classroom in which this lesson is taking place.

join(teacher, qa_generator, qa_group)

Make a teacher join the lesson. This method is called by the teacher when he notices that the swot has sat down.

Parameters:
  • teacher (Character) – The teacher.
  • qa_generator (QAGenerator) – The question-and-answer generator to use.
  • qa_group – The Q&A group from which to choose questions and answers for the teacher and the swot; if None, the Q&A group will be chosen at random from those available each time a question and answer is generated.
next_swot_action()

Complete any actions required of the swot, and return the next command to be executed by him, or None if it’s not his turn to act.

next_teacher_action()

Complete any actions required of the teacher, and return the next command to be executed by him, or None if it’s not his turn to act.

return_to_base()

Make the teacher return to the classroom after fetching Eric. The teacher’s next action will be ask_question() (if a question-and-answer session was interrupted) or walk_up_or_down().

Returns:A GoToXY command.
switch(action=None)

Switch turns between the actors in this lesson (the teacher and the swot).

Parameters:action – The next action (method to execute) for the next actor; if None, the next action (which may have already been set) is unchanged.
tell_class_what_to_do()

Make the teacher tell the class what to do (as opposed to starting a question-and-answer session with the swot). The teacher’s next action (and base action for the remainder of the lesson) will be walk_up_or_down().

Returns:A TellClassWhatToDo command.
walk_to_board()

Make the teacher walk to the middle of the blackboard (after having wiped it). The teacher’s next action will be write_on_board().

Returns:A GoToXY command.
walk_up_or_down()

Make the teacher walk up or down in front of the blackboard. This action is used during a lesson with no question-and-answer session. The swot’s next action is set to check_eric().

Returns:A WalkUpOrDown command.
wipe_board()

Make the teacher wipe the board (if there is one). The teacher’s next action will be walk_to_board().

Returns:A WipeBoard command if there is a blackboard, None otherwise.
write_on_board()

Make the teacher write on the blackboard (possibly). The teacher’s next action will be the base action for this lesson (either tell_class_what_to_do() or ask_question()).

Returns:A WriteOnBoard command if the teacher chooses to write, otherwise None.
class pyskool.lesson.QAGenerator

Generates questions and answers for the teacher and swot to use during a lesson. Every teacher gets his own generator to keep; it is built before the game starts.

add_answer(question_id, text)

Add an answer to a question.

Parameters:
  • question_id – The ID of the question.
  • text – The text of the answer.
add_qa_pair(qa_group, word1, word2)

Add a Q&A pair to a Q&A group.

Parameters:
  • qa_group – The name of the Q&A group.
  • word1 – The first word of the pair.
  • word2 – The second word of the pair.
add_question(question_id, qa_group, text)

Add a question to a Q&A group.

Parameters:
  • question_id – The ID of the question.
  • qa_group – The name of the Q&A group to add the question to.
  • text – The text of the question.
has_special_question()

Return whether the teacher has a special question. A special question is one to which the answer must be seen written on a blackboard by the teacher to make him reveal his safe combination letter.

initialise_special_answer()

Initialise the answer to the teacher’s special question (if there is one). The special answer is chosen at random from the Q&A pairs in the Q&A group of the special question.

prepare_qa(qa_group=None)

Prepare a randomly chosen question and answer.

Parameters:qa_group – The Q&A group from which to choose the question and answer; if None, the Q&A group will be chosen at random from those available.
Returns:A 2-tuple containing the question and the answer.
prepare_special_qa()

Prepare the teacher’s special question and answer (if any).

Returns:A 2-tuple containing the question and the answer.
set_special_group(qa_group, index)

Set the Q&A group to use for the teacher’s special question (if there is one).

Parameters:
  • qa_group – The name of the Q&A group.
  • index – The index (0 or 1) of the special answer in the Q&A pair.