Example #1
0
def transition(state):
    if state['current_state'] == WORK_BEGINNING:
        io.print_large(WORK_MESSAGE)
        io.say_with_beeps(WORK_MESSAGE)
        new_state = { 'time_remaining': WORK_TIMEDELTA,
                      'current_state' : WORKING }
    else:
        io.print_large(BREAK_MESSAGE)
        io.say_with_beeps(BREAK_MESSAGE)
        new_state = { 'time_remaining': BREAK_TIMEDELTA,
                      'current_state' : BREAKING }
    return new_state
Example #2
0
def countdown(state):
    time_remaining = state['time_remaining']
    io.print_large(time_remaining)

    new_state = state.copy();
    new_state['time_remaining'] = state['time_remaining'] - SLEEP_TIMEDELTA
    if time_remaining <= ZERO_TIMEDELTA:
        if state['current_state'] == WORKING:
            new_state['current_state'] = BREAK_BEGINNING
        else:
            new_state['current_state'] = WORK_BEGINNING

    return new_state