def check_game_stage(screen):
    auspiciousness_condition = variables.TestCondition().test_auspiciousness_condition()

    if variables.game_stage == 'beginning of the game':
        gui.game_beginning(screen)
        gui.load_sprites()

    elif variables.game_stage == 'information':
        gui.show_back_button(screen)
        gui.show_information(screen)

    elif variables.game_stage == 'achievements':
        gui.show_back_button(screen)
        gui.load_achievements(screen)

    elif 'show video about' in variables.game_stage:
        gui.ask_about_video(screen, variables.video_name)

    elif variables.game_stage == 'choose planet':
        gui.show_back_button(screen)
        gui.show_continue_button(screen)
        gui.choose_planet(screen, variables.planet_sprite)

    elif variables.game_stage == 'change planet':
        if check_achievements('достижение_первая_планета'):
            gui.show_new_achievement(screen, 'достижение_первая_планета')

        gui.change_planet(screen)
        gui.load_pictures_for_widgets(screen)
        gui.show_change_planet_widgets(screen)

        gui.draw_temperature_condition_widgets(screen)
        gui.draw_oxygen_condition_widgets(screen)
        change_auspiciousness()
        gui.draw_auspiciousness_condition_widgets(screen)

        WeatherParameter(screen).check_water_level_parameter()
        WeatherParameter(screen).check_temperature()

        if variables.TestCondition().test_weak_magnetic_field():
            WeatherParameter(screen).change_temperature_parameter(10)  # 10 degrees

        if variables.planets_parameters[variables.planet_name]['wind_speed'] >= 5:  # 5 km/h
            WeatherParameter(screen).change_wind_speed_parameter(-1)

        if auspiciousness_condition:
            LifeParameters(screen).change_life_parameter(5, auspiciousness_condition)

            if variables.planets_parameters[variables.planet_name]['people']:
                LifeParameters(screen).change_people_parameter(5, auspiciousness_condition)

        check_game_event(screen)
        gui.mountains_rise(screen)
        WeatherParameter(screen).check_magnetic_field_parameter()

        if variables.planets_parameters[variables.planet_name]['UFO'] and auspiciousness_condition:
            gui.aliens_fly_to_the_planet(screen, variables.aliens_coordinates)
        elif variables.planets_parameters[variables.planet_name]['UFO']:
            gui.show_new_planets_parameter(screen, 'aliens', 'Goodbye')
            variables.planets_parameters[variables.planet_name]['UFO'] = False

        if variables.TestCondition().test_game_end():
            if check_achievements('конец_игры'):
                gui.show_new_achievement(screen, 'конец_игры')

            if variables.planets_parameters[variables.planet_name]['game_over_question'] is False:
                variables.game_stage = 'game_over'

    elif variables.game_stage == 'game_over':
        gui.is_game_over(screen)
 def __init__(self, screen):
     self.screen = screen
     self.condition = variables.TestCondition()
def change_auspiciousness():
    auspiciousness = variables.planets_parameters[variables.planet_name]['auspiciousness']
    if variables.TestCondition().test_planet_condition() and auspiciousness < 100:  # 100 %
        variables.planets_parameters[variables.planet_name]['auspiciousness'] += 5
    elif auspiciousness > 0 and variables.TestCondition().test_planet_condition() is False:
        variables.planets_parameters[variables.planet_name]['auspiciousness'] -= 5
def control_change_planet_widgets(screen, change_planet_widgets, event):
    weather = WeatherParameter(screen)
    auspiciousness_condition = variables.TestCondition().test_auspiciousness_condition()

    if change_planet_widgets['rain_widget'].collidepoint(event.pos):
        weather.change_water_level_parameter(5, True)  # increase water_level on 5%
        weather.change_temperature_parameter(-5)  # low temperature on 5 degree

    elif change_planet_widgets['sun_widget'].collidepoint(event.pos):
        weather.change_temperature_parameter(5, True)  # increase temperature on 5 degree
        variables.game_event = ''

    elif change_planet_widgets['lightnings_widget'].collidepoint(event.pos):
        variables.game_event = 'lightnings'
        gui.load_sprites()

        AirAndSoilComposition(screen).change_oxygen_parameter(-2, True)

        variables.game_stage = 'show video about lightnings'
        variables.video_name = 'Влияние молнии на атмосферу'

    elif change_planet_widgets['wind_widget'].collidepoint(event.pos):
        weather.change_wind_speed_parameter(1, True)  # the wind gets up on 1 km/h
        weather.change_water_level_parameter(-5)  # decrease water_level on 5 %
        variables.game_event = ''

    elif change_planet_widgets['meteorite_widget'].collidepoint(event.pos):
        variables.game_event = 'meteorite'
        weather.check_meteorite_parameter()

        variables.game_stage = 'show video about destraction'
        variables.video_name = 'Уничтожение планеты.(Способ 3)'

    elif change_planet_widgets['hurricane_widget'].collidepoint(event.pos):
        gui.load_sprites()

        weather.change_wind_speed_parameter(40, True)  # the wind gets up on 40 km/h
        variables.game_event = 'hurricane'

        if variables.planets_parameters[variables.planet_name]['hurricane'] is False:
            variables.planets_parameters[variables.planet_name]['hurricane'] = True
            variables.game_stage = 'show video about hurricane'
            variables.video_name = 'Торнадо'

    elif change_planet_widgets['earthquake_widget'].collidepoint(event.pos):
        weather.change_earthquake_parameter()

    elif change_planet_widgets['tsunami_widget'].collidepoint(event.pos):
        weather.change_water_level_parameter(30, True)  # increase water_level on 30 %
        variables.game_event = ''

    elif change_planet_widgets['mountains_widget'].collidepoint(event.pos):
        magnetic_field = variables.magnetic_fields[
            variables.planets_parameters[variables.planet_name]['magnetic_field']]
        if magnetic_field in ['strong', 'the strongest']:
            if variables.planets_parameters[variables.planet_name]['wind_speed'] <= variables.optimal_wind_speed[1]:
                variables.game_event = 'mountains'

    elif change_planet_widgets['people_widget'].collidepoint(event.pos):
        LifeParameters(screen).change_people_parameter(10, auspiciousness_condition, True)
        # increase number of people

    elif change_planet_widgets['low_temperature_widget'].collidepoint(event.pos):
        weather.change_temperature_parameter(-5, True)  # low temperature on 10 degree

    elif change_planet_widgets['increase_magnetic_field_widget'].collidepoint(event.pos):
        weather.change_magnetic_field_parameter(True)

    elif change_planet_widgets['increase_oxygen_widget'].collidepoint(event.pos):
        AirAndSoilComposition(screen).change_oxygen_parameter(5, True)

    elif change_planet_widgets['alien_invasion_widget'].collidepoint(event.pos):
        LifeParameters(screen).change_ufo_parameter(auspiciousness_condition)