def recalc_level(level, exp, exp_change):
    """ Recalculate level and EXP after exp_change. """
    exp += exp_change

    if exp >= 0:
        required = 1000 * (level + 1)
        while exp >= required:
            level += 1
            exp -= required
            required += 1000
    else:
        while exp < 0 and level > -1:
            exp += 1000 * level
            level -= 1
    return level, exp