예제 #1
0
    def __init__(self, controller, view, map_id, shop_id):
        super().__init__(
            controller,
            view,
            map_id,
            logger=getLogger(
                f'root.app.game.map.{map_id}.shop.{shop_id}.constructor.model')
        )
        self.shop_id = shop_id
        self.shop_stages_state_matrix = {}
        USER_DB_CURSOR.execute(
            '''SELECT stage_number, locked, under_construction, construction_time,
            unlock_condition_from_level, unlock_condition_from_previous_stage, unlock_available 
            FROM shop_stages WHERE map_id = ? AND shop_id = ?''',
            (self.map_id, self.shop_id))
        for stage_info in USER_DB_CURSOR.fetchall():
            self.shop_stages_state_matrix[stage_info[0]] = [
                *stage_info[1:6], 1, stage_info[6]
            ]
            CONFIG_DB_CURSOR.execute(
                '''SELECT price, max_construction_time, level_required, hourly_profit,
                storage_capacity, exp_bonus FROM shop_progress_config WHERE map_id = ? AND stage_number = ?''',
                (self.map_id, stage_info[0]))
            stage_progress_config = CONFIG_DB_CURSOR.fetchone()
            self.shop_stages_state_matrix[stage_info[0]].extend(
                [*stage_progress_config[:3], 0, *stage_progress_config[3:]])

        USER_DB_CURSOR.execute(
            '''SELECT current_stage, shop_storage_money, internal_shop_time FROM shops 
            WHERE map_id = ? AND shop_id = ?''', (self.map_id, self.shop_id))
        self.current_stage, self.shop_storage_money, self.internal_shop_time = USER_DB_CURSOR.fetchone(
        )
예제 #2
0
    def on_check_for_updates():
        # create logs directory if it does not exist
        if not path.exists('logs'):
            mkdir('logs')

        logger = getLogger('update_log')
        # create .update_log file
        current_datetime = datetime.now()
        logs_handler = FileHandler(
            'logs/logs_{0}_{1:0>2}-{2:0>2}-{3:0>2}-{4:0>6}.update_log'.format(
                str(current_datetime.date()), current_datetime.time().hour, current_datetime.time().minute,
                current_datetime.time().second, current_datetime.time().microsecond
            )
        )
        logs_handler.setFormatter(Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s'))
        logger.addHandler(logs_handler)
        # for now log level is set to DEBUG, but can also be set to LOG_LEVEL_INFO
        logger.setLevel(LOG_LEVEL_DEBUG)
        logger.info('START CHECK_FOR_UPDATES')
        # If version exists, read it from user DB.
        # If current game version is higher, use migration scripts one by one.
        # Migration script file is named "<version>.sql"
        try:
            USER_DB_CURSOR.execute('SELECT * FROM version')
        except OperationalError:
            raise UpdateIncompatibleError

        user_db_version = USER_DB_CURSOR.fetchone()
        logger.debug(f'user DB version: {user_db_version}')
        logger.debug(f'current game version: {CURRENT_VERSION}')
        if user_db_version == CURRENT_VERSION:
            logger.debug('user DB version is up to date')
        # update from versions < MIN_UPDATE_COMPATIBLE_VERSION is not supported
        elif user_db_version < MIN_UPDATE_COMPATIBLE_VERSION:
            raise UpdateIncompatibleError
        else:
            logger.debug('upgrading database...')
            next_app_version = [*user_db_version[MAJOR:PATCH], user_db_version[PATCH] + 1]
            while next_app_version <= list(CURRENT_VERSION):
                if path.exists('db/patch/{}{}{}.sql'.format(*next_app_version)):
                    logger.debug('start {}.{}.{} migration'.format(*next_app_version))
                    with open('db/patch/{}{}{}.sql'.format(*next_app_version), 'r') as migration:
                        # simply execute each line in the migration script
                        for line in migration.readlines():
                            USER_DB_CURSOR.execute(line)
                            logger.debug(f'executed request: {line}')

                    on_commit()
                    logger.debug('{}.{}.{} migration complete'.format(*next_app_version))
                    next_app_version[PATCH] += 1
                else:
                    next_app_version[MINOR] += 1
                    next_app_version[PATCH] = 0
                    if not path.exists('db/patch/{}{}{}.sql'.format(*next_app_version)):
                        next_app_version[MAJOR] += 1
                        next_app_version[MINOR], next_app_version[PATCH] = 0, 0

            logger.debug('user DB version is up to date')

        logger.info('END CHECK_FOR_UPDATES')
예제 #3
0
 def on_save_state(self):
     USER_DB_CURSOR.execute(
         '''UPDATE switches SET busy = ?, force_busy = ?, last_entered_by = ?, current_position = ?, locked = ? 
         WHERE track_param_1 = ? AND track_param_2 = ? AND switch_type = ? AND map_id = ?''',
         (self.busy, self.force_busy, self.last_entered_by,
          self.current_position, self.locked, self.track_param_1,
          self.track_param_2, self.switch_type, self.map_id))
예제 #4
0
    def __init__(self, column, row, on_update_state_action, parent_viewport,
                 logger):
        def on_check(button):
            self.on_change_state(TRUE)
            self.on_update_state_action(TRUE)

        def on_uncheck(button):
            self.on_change_state(FALSE)
            self.on_update_state_action(FALSE)

        self.logger = logger
        self.column, self.row = column, row
        self.parent_viewport = parent_viewport
        self.viewport = Viewport()
        USER_DB_CURSOR.execute('SELECT current_locale FROM i18n')
        self.current_locale = USER_DB_CURSOR.fetchone()[0]
        self.on_update_state_action = on_update_state_action
        self.checked_checkbox_button, self.unchecked_checkbox_button = create_two_state_button(
            CheckedCheckboxButton(on_click_action=on_uncheck,
                                  parent_viewport=self.viewport),
            UncheckedCheckboxButton(on_click_action=on_check,
                                    parent_viewport=self.viewport))
        self.buttons = [
            self.checked_checkbox_button, self.unchecked_checkbox_button
        ]
        self.screen_resolution = (0, 0)
        self.description_label = None
        self.is_activated = False
        self.opacity = 0
        self.on_window_resize_handlers = [
            self.on_window_resize,
        ]
예제 #5
0
 def on_save_and_commit_last_known_base_offset(self):
     self.last_known_base_offset = self.view.base_offset
     USER_DB_CURSOR.execute(
         '''UPDATE map_position_settings SET last_known_base_offset = ? WHERE map_id = ?''',
         (','.join(str(p) for p in self.last_known_base_offset), self.map_id)
     )
     on_commit()
예제 #6
0
 def on_save_and_commit_last_known_zoom(self):
     self.last_known_zoom = self.view.zoom
     USER_DB_CURSOR.execute(
         '''UPDATE map_position_settings SET last_known_zoom = ? WHERE map_id = ?''',
         (self.last_known_zoom, self.map_id)
     )
     on_commit()
예제 #7
0
 def __init__(self, controller, view, map_id, track, train_route):
     super().__init__(
         controller,
         view,
         map_id,
         logger=getLogger(
             f'root.app.game.map.{map_id}.train_route.{track}.{train_route}.model'
         ))
     self.track = track
     self.train_route = train_route
     USER_DB_CURSOR.execute(
         '''SELECT opened, last_opened_by, current_checkpoint, priority, cars FROM train_routes 
         WHERE track = ? AND train_route = ? AND map_id = ?''',
         (self.track, self.train_route, self.map_id))
     self.opened, self.last_opened_by, self.current_checkpoint, self.priority, self.cars = USER_DB_CURSOR.fetchone(
     )
     USER_DB_CURSOR.execute(
         '''SELECT train_route_section_busy_state FROM train_routes 
         WHERE track = ? AND train_route = ? AND map_id = ?''',
         (self.track, self.train_route, self.map_id))
     self.train_route_section_busy_state = [
         int(s) for s in USER_DB_CURSOR.fetchone()[0].split(',')
     ]
     CONFIG_DB_CURSOR.execute(
         '''SELECT start_point_v2, stop_point_v2, destination_point_v2, checkpoints_v2 FROM train_route_config 
         WHERE track = ? AND train_route = ? AND map_id = ?''',
         (self.track, self.train_route, self.map_id))
     for i in range(len(fetched_data := list(CONFIG_DB_CURSOR.fetchone()))):
예제 #8
0
 def __init__(self, logger, parent_viewport, map_id, track_param_1,
              track_param_2, crossover_type):
     super().__init__(logger, parent_viewport, map_id)
     CONFIG_DB_CURSOR.execute(
         '''SELECT offset_x, offset_y FROM crossovers_config
         WHERE track_param_1 = ? AND track_param_2 = ? AND crossover_type = ? AND map_id = ?''',
         (track_param_1, track_param_2, crossover_type, self.map_id))
     self.x, self.y = CONFIG_DB_CURSOR.fetchone()
     self.batch = BATCHES['main_batch']
     self.group = GROUPS['main_map']
     CONFIG_DB_CURSOR.execute(
         '''SELECT region_x, region_y, region_w, region_h FROM crossovers_config
         WHERE track_param_1 = ? AND track_param_2 = ? AND crossover_type = ? AND map_id = ?''',
         (track_param_1, track_param_2, crossover_type, self.map_id))
     self.crossover_region = CONFIG_DB_CURSOR.fetchone()
     self.textures = [
         SWITCHES_STRAIGHT.get_region(*self.crossover_region),
         SWITCHES_DIVERGING.get_region(*self.crossover_region)
     ]
     USER_DB_CURSOR.execute(
         '''SELECT current_position_1, current_position_2 FROM crossovers 
         WHERE track_param_1 = ? AND track_param_2 = ? AND crossover_type = ? AND map_id = ?''',
         (track_param_1, track_param_2, crossover_type, self.map_id))
     current_position_1, current_position_2 = USER_DB_CURSOR.fetchone()
     self.texture = self.textures[int(
         current_position_1 == current_position_2)]
예제 #9
0
        def _make_an_instance_localizable(*args, **kwargs):
            def on_update_current_locale(new_locale):
                args[0].current_locale = new_locale
                if args[0].text_label:
                    args[0].text_label.text = args[0].get_formatted_text()

            def get_formatted_text():
                return I18N_RESOURCES[args[0].i18n_key][
                    args[0].current_locale].format(*args[0].arguments)

            def get_complicated_formatted_text():
                base_resource = I18N_RESOURCES[args[0].i18n_key][
                    args[0].current_locale]
                for k in args[0].resource_list_keys:
                    base_resource = base_resource[k]

                return base_resource.format(*args[0].arguments)

            f(*args, **kwargs)
            USER_DB_CURSOR.execute('SELECT current_locale FROM i18n')
            args[0].current_locale = USER_DB_CURSOR.fetchone()[0]
            args[0].on_update_current_locale = on_update_current_locale
            args[0].i18n_key = i18n_key
            if hasattr(args[0], 'resource_list_keys') and len(
                    args[0].resource_list_keys) > 0:
                args[0].get_formatted_text = get_complicated_formatted_text
            else:
                args[0].get_formatted_text = get_formatted_text
예제 #10
0
def _create_window():
    CONFIG_DB_CURSOR.execute(
        'SELECT app_width, app_height FROM screen_resolution_config')
    screen_resolution_config = CONFIG_DB_CURSOR.fetchall()
    monitor_resolution_config = (windll.user32.GetSystemMetrics(0),
                                 windll.user32.GetSystemMetrics(1))
    USER_DB_CURSOR.execute('SELECT fullscreen FROM graphics')
    if USER_DB_CURSOR.fetchone(
    )[0] and monitor_resolution_config in screen_resolution_config:
        window = Window(width=monitor_resolution_config[0],
                        height=monitor_resolution_config[1],
                        caption='Railway Station Simulator',
                        style='borderless',
                        fullscreen=False,
                        vsync=False)
        window.set_fullscreen(True)
        return window

    USER_DB_CURSOR.execute('SELECT app_width, app_height FROM graphics')
    screen_resolution = USER_DB_CURSOR.fetchone()
    return Window(width=screen_resolution[0],
                  height=screen_resolution[1],
                  caption='Railway Station Simulator',
                  style='borderless',
                  fullscreen=False,
                  vsync=False)
예제 #11
0
 def __init__(self):
     self.music_track = None
     self.narrator_intro = None
     USER_DB_CURSOR.execute('''SELECT master_volume FROM sound''')
     self.master_volume = USER_DB_CURSOR.fetchone()[0]
     self.narrator_intro_opacity = 255
     self.music_track_opacity = 0
     self.is_muted = False
예제 #12
0
 def on_save_state(self):
     USER_DB_CURSOR.execute(
         '''UPDATE train_routes SET opened = ?, last_opened_by = ?, current_checkpoint = ?, priority = ?, cars = ?, 
         train_route_section_busy_state = ? WHERE track = ? AND train_route = ? AND map_id = ?''',
         (self.opened, self.last_opened_by, self.current_checkpoint,
          self.priority, self.cars, ','.join(
              str(t) for t in self.train_route_section_busy_state),
          self.track, self.train_route, self.map_id))
 def __init__(self, controller, view):
     super().__init__(
         controller,
         view,
         logger=getLogger('root.app.bonus_code_activation.model'))
     USER_DB_CURSOR.execute(
         '''SELECT bonus_codes_abuse_counter FROM game_progress''')
     self.bonus_code_abuse_counter = USER_DB_CURSOR.fetchone()[0]
 def __init__(self, logger, parent_viewport, map_id):
     super().__init__(logger, parent_viewport)
     self.map_id = map_id
     USER_DB_CURSOR.execute('''SELECT unlocked_environment FROM map_progress WHERE map_id = ?''', (self.map_id, ))
     self.unlocked_environment = USER_DB_CURSOR.fetchone()[0]
     self.texture = get_map_environment_primary(map_id=self.map_id, tiers=self.unlocked_environment)
     self.batch = BATCHES['mini_map_batch']
     self.group = GROUPS['mini_environment']
     self.usage = 'static'
예제 #15
0
 def on_save_state(self):
     USER_DB_CURSOR.execute(
         '''UPDATE map_progress SET locked = ?, unlocked_tracks = ?, unlocked_environment = ?, 
         unlocked_car_collections = ? WHERE map_id = ?''',
         (
             self.locked, self.unlocked_tracks, self.unlocked_environment,
             ','.join(str(c) for c in self.unlocked_car_collections), self.map_id
         )
     )
예제 #16
0
    def __init__(self, controller, map_id, shop_id):
        def on_clear_storage(button):
            self.controller.on_clear_storage()

        def on_buy_stage_action(stage_number):
            self.controller.on_put_stage_under_construction(stage_number)

        super().__init__(
            controller,
            map_id,
            logger=getLogger(
                f'root.app.game.map.{map_id}.shop.{shop_id}.constructor.view'),
            child_window=True)
        self.shop_id = shop_id
        self.shop_stages_state_matrix = {}
        USER_DB_CURSOR.execute(
            '''SELECT current_stage, shop_storage_money
            FROM shops WHERE map_id = ? AND shop_id = ?''',
            (self.map_id, self.shop_id))
        self.current_stage, self.shop_storage_money = USER_DB_CURSOR.fetchone()
        self.shop_stages_cells_position = (0, 0)
        self.shop_stages_cells_size = (0, 0)
        self.shader_sprite = ShopConstructorViewShaderSprite(view=self)
        self.current_hourly_profit_label = CurrentHourlyProfitDescriptionLabel(
            parent_viewport=self.viewport)
        self.current_exp_bonus_label = CurrentExpBonusDescriptionLabel(
            parent_viewport=self.viewport)
        self.hourly_profit_value_label = CurrentHourlyProfitValueLabel(
            parent_viewport=self.viewport)
        self.exp_bonus_value_label = CurrentExpBonusValueLabel(
            parent_viewport=self.viewport)
        self.shop_storage_progress_bar = ShopStorageProgressBar(
            parent_viewport=self.viewport)
        self.clear_shop_storage_button = ClearShopStorageButton(
            on_click_action=on_clear_storage, parent_viewport=self.viewport)
        self.buttons = [
            self.clear_shop_storage_button,
        ]
        self.shop_stage_cells = {}
        for i in range(1, 5):
            self.shop_stage_cells[i] = ShopStageCell(
                stage_number=i,
                on_buy_stage_action=on_buy_stage_action,
                parent_viewport=self.viewport)
            self.buttons.append(self.shop_stage_cells[i].build_button)
            self.on_window_resize_handlers.extend(
                self.shop_stage_cells[i].on_window_resize_handlers)

        self.on_window_resize_handlers.extend([
            self.shader_sprite.on_window_resize,
            self.current_hourly_profit_label.on_window_resize,
            self.current_exp_bonus_label.on_window_resize,
            self.hourly_profit_value_label.on_window_resize,
            self.exp_bonus_value_label.on_window_resize,
            *self.shop_storage_progress_bar.on_window_resize_handlers
        ])
        self.on_append_window_handlers()
예제 #17
0
    def __init__(self, stage_number, on_buy_stage_action, parent_viewport):
        def on_buy_shop_stage(button):
            button.on_deactivate(instant=True)
            self.on_buy_stage_action(self.stage_number)

        self.logger = getLogger(
            f'root.app.game.map.shop.view.cell.{stage_number}')
        self.is_activated = False
        self.stage_number = stage_number
        USER_DB_CURSOR.execute('SELECT current_locale FROM i18n')
        self.current_locale = USER_DB_CURSOR.fetchone()[0]
        self.on_buy_stage_action = on_buy_stage_action
        self.data = []
        self.screen_resolution = (0, 0)
        self.parent_viewport = parent_viewport
        self.viewport = Viewport()
        self.locked_label = ShopStageLockedLabel(parent_viewport=self.viewport)
        self.level_placeholder_label = ShopStageLevelPlaceholderLabel(
            parent_viewport=self.viewport)
        self.previous_stage_placeholder_label = ShopStagePreviousStagePlaceholderLabel(
            parent_viewport=self.viewport)
        self.hourly_profit_description_label = ShopStageHourlyProfitDescriptionLabel(
            parent_viewport=self.viewport)
        self.hourly_profit_value_label = ShopStageHourlyProfitValueLabel(
            parent_viewport=self.viewport)
        self.storage_capacity_description_label = ShopStageStorageCapacityDescriptionLabel(
            parent_viewport=self.viewport)
        self.storage_capacity_value_label = ShopStageStorageCapacityValueLabel(
            parent_viewport=self.viewport)
        self.exp_bonus_description_label = ShopStageExpBonusDescriptionLabel(
            parent_viewport=self.viewport)
        self.exp_bonus_value_label = ShopStageExpBonusValueLabel(
            parent_viewport=self.viewport)
        self.price_label = ShopStagePriceLabel(parent_viewport=self.viewport)
        self.under_construction_label = ShopStageUnderConstructionLabel(
            parent_viewport=self.viewport)
        self.build_button = BuildShopStageButton(
            on_click_action=on_buy_shop_stage, parent_viewport=self.viewport)
        self.buttons = [
            self.build_button,
        ]
        USER_DB_CURSOR.execute('''SELECT money FROM game_progress''')
        self.money = USER_DB_CURSOR.fetchone()[0]
        self.opacity = 0
        self.on_window_resize_handlers = [
            self.on_window_resize, self.locked_label.on_window_resize,
            self.level_placeholder_label.on_window_resize,
            self.previous_stage_placeholder_label.on_window_resize,
            self.hourly_profit_description_label.on_window_resize,
            self.hourly_profit_value_label.on_window_resize,
            self.storage_capacity_description_label.on_window_resize,
            self.storage_capacity_value_label.on_window_resize,
            self.exp_bonus_description_label.on_window_resize,
            self.exp_bonus_value_label.on_window_resize,
            self.price_label.on_window_resize,
            self.under_construction_label.on_window_resize
        ]
 def on_save_state(self):
     for code in BONUS_CODE_MATRIX:
         USER_DB_CURSOR.execute(
             '''UPDATE bonus_codes SET activation_available = ?, activations_left = ?, is_activated = ?, 
             bonus_time = ? WHERE sha512_hash = ?''',
             (BONUS_CODE_MATRIX[code][ACTIVATION_AVAILABLE],
              BONUS_CODE_MATRIX[code][ACTIVATIONS_LEFT],
              BONUS_CODE_MATRIX[code][IS_ACTIVATED],
              BONUS_CODE_MATRIX[code][BONUS_TIME], code))
예제 #19
0
 def __init__(self, controller, view):
     super().__init__(controller, view, logger=getLogger('root.app.game.model'))
     self.game_paused = True
     USER_DB_CURSOR.execute('''SELECT exp, money_target, exp_multiplier FROM game_progress''')
     self.exp, self.money_target, self.exp_multiplier = USER_DB_CURSOR.fetchone()
     CONFIG_DB_CURSOR.execute(
         '''SELECT player_progress FROM player_progress_config WHERE level = ?''', (self.level, )
     )
     self.player_progress = CONFIG_DB_CURSOR.fetchone()[0]
예제 #20
0
    def on_save_state(self):
        USER_DB_CURSOR.execute(
            '''UPDATE constructor SET money_target_activated = ?, money_target_cell_position = ? WHERE map_id = ?''',
            (self.money_target_activated, ','.join(
                str(p) for p in self.money_target_cell_position), self.map_id))
        # if some tracks were unlocked since last time the game progress was saved,
        # they are not listed in track state matrix anymore, so their state is updated separately
        for track in self.cached_unlocked_tracks:
            USER_DB_CURSOR.execute(
                '''UPDATE tracks SET locked = 0, under_construction = 0, construction_time = 0, 
                unlock_condition_from_level = 0, unlock_condition_from_previous_track = 0, 
                unlock_condition_from_environment = 0, unlock_available = 0 WHERE track_number = ? AND map_id = ?''',
                (track, self.map_id))

        self.cached_unlocked_tracks = []
        # locked tracks state is saved from track_state_matrix the same way it was read
        for track in CONSTRUCTION_STATE_MATRIX[self.map_id][TRACKS]:
            USER_DB_CURSOR.execute(
                '''UPDATE tracks SET locked = ?, under_construction = ?, construction_time = ?, 
                unlock_condition_from_level = ?, unlock_condition_from_previous_track = ?, 
                unlock_condition_from_environment = ?, unlock_available = ? WHERE track_number = ? AND map_id = ?''',
                (CONSTRUCTION_STATE_MATRIX[self.map_id][TRACKS][track][LOCKED],
                 CONSTRUCTION_STATE_MATRIX[self.map_id][TRACKS][track]
                 [UNDER_CONSTRUCTION], CONSTRUCTION_STATE_MATRIX[self.map_id]
                 [TRACKS][track][CONSTRUCTION_TIME], CONSTRUCTION_STATE_MATRIX[
                     self.map_id][TRACKS][track][UNLOCK_CONDITION_FROM_LEVEL],
                 CONSTRUCTION_STATE_MATRIX[self.map_id][TRACKS][track]
                 [UNLOCK_CONDITION_FROM_PREVIOUS_TRACK],
                 CONSTRUCTION_STATE_MATRIX[self.map_id][TRACKS][track]
                 [UNLOCK_CONDITION_FROM_ENVIRONMENT],
                 CONSTRUCTION_STATE_MATRIX[self.map_id][TRACKS][track]
                 [UNLOCK_AVAILABLE], track, self.map_id))

        # same for environment
        for tier in self.cached_unlocked_tiers:
            USER_DB_CURSOR.execute(
                '''UPDATE environment SET locked = 0, under_construction = 0, construction_time = 0, 
                unlock_condition_from_level = 0, unlock_condition_from_previous_environment = 0, unlock_available = 0 
                WHERE tier = ? AND map_id = ?''', (tier, self.map_id))

        self.cached_unlocked_tiers = []
        for tier in CONSTRUCTION_STATE_MATRIX[self.map_id][ENVIRONMENT]:
            USER_DB_CURSOR.execute(
                '''UPDATE environment SET locked = ?, under_construction = ?, construction_time = ?, 
                unlock_condition_from_level = ?, unlock_condition_from_previous_environment = ?, unlock_available = ? 
                WHERE tier = ? AND map_id = ?''',
                (CONSTRUCTION_STATE_MATRIX[self.map_id][ENVIRONMENT][tier]
                 [LOCKED], CONSTRUCTION_STATE_MATRIX[self.map_id][ENVIRONMENT]
                 [tier][UNDER_CONSTRUCTION], CONSTRUCTION_STATE_MATRIX[
                     self.map_id][ENVIRONMENT][tier][CONSTRUCTION_TIME],
                 CONSTRUCTION_STATE_MATRIX[self.map_id][ENVIRONMENT][tier]
                 [UNLOCK_CONDITION_FROM_LEVEL],
                 CONSTRUCTION_STATE_MATRIX[self.map_id][ENVIRONMENT][tier]
                 [UNLOCK_CONDITION_FROM_PREVIOUS_ENVIRONMENT],
                 CONSTRUCTION_STATE_MATRIX[self.map_id][ENVIRONMENT][tier]
                 [UNLOCK_AVAILABLE], tier, self.map_id))
예제 #21
0
 def __init__(self, end_opacity, animation_object, logger):
     self.animation_object = animation_object
     self.logger = logger
     self.end_opacity = end_opacity
     self.current_fade_animation_time = 0.0
     self.is_activated = False
     self.on_deactivate_listener = None
     USER_DB_CURSOR.execute('SELECT fade_animations_enabled FROM graphics')
     self.fade_animations_enabled = USER_DB_CURSOR.fetchone()[0]
     self.child_animations = []
예제 #22
0
 def __init__(self, controller, logger, child_window=False):
     super().__init__(controller, logger, child_window)
     USER_DB_CURSOR.execute('SELECT * FROM epoch_timestamp')
     self.game_time, self.game_time_fraction, self.dt_multiplier = USER_DB_CURSOR.fetchone(
     )
     USER_DB_CURSOR.execute(
         '''SELECT level, money, exp_bonus_multiplier, money_bonus_multiplier,  
         construction_speed_bonus_multiplier FROM game_progress''')
     self.level, self.money, self.exp_bonus_multiplier, self.money_bonus_multiplier, \
         self.construction_speed_bonus_multiplier = USER_DB_CURSOR.fetchone()
예제 #23
0
 def __init__(self, controller, view):
     super().__init__(controller, view, logger=getLogger('root.app.model'))
     USER_DB_CURSOR.execute('SELECT fullscreen FROM graphics')
     self.fullscreen_mode = USER_DB_CURSOR.fetchone()[0]
     CONFIG_DB_CURSOR.execute('SELECT app_width, app_height FROM screen_resolution_config')
     self.screen_resolution_config = CONFIG_DB_CURSOR.fetchall()
     if (monitor_resolution_config := (windll.user32.GetSystemMetrics(0), windll.user32.GetSystemMetrics(1))) \
             in self.screen_resolution_config:
         self.fullscreen_mode_available = True
         self.fullscreen_resolution = monitor_resolution_config
예제 #24
0
 def __init__(self, controller, map_id):
     super().__init__(
         controller,
         map_id,
         logger=getLogger(f'root.app.game.map.{map_id}.narrator.view'))
     self.is_speaking = False
     self.is_playing_announcement = False
     self.playback_start_time = 0
     USER_DB_CURSOR.execute('SELECT announcements_enabled FROM sound')
     self.announcements_enabled = USER_DB_CURSOR.fetchone()[0]
     self.on_append_window_handlers()
예제 #25
0
 def __init__(self):
     super().__init__(min_zoom=0.5, max_zoom=1.0)
     USER_DB_CURSOR.execute(
         '''SELECT last_known_base_offset FROM map_position_settings 
         WHERE map_id IN (SELECT last_known_map_id FROM graphics)''')
     self.offset_x, self.offset_y = (
         int(p) for p in USER_DB_CURSOR.fetchone()[0].split(','))
     USER_DB_CURSOR.execute(
         '''SELECT last_known_zoom FROM map_position_settings 
         WHERE map_id IN (SELECT last_known_map_id FROM graphics)''')
     self.zoom = USER_DB_CURSOR.fetchone()[0]
예제 #26
0
 def __init__(self, controller, view, map_id):
     super().__init__(controller, view, map_id, logger=getLogger(f'root.app.game.map.{map_id}.dispatcher.model'))
     self.trains = []
     USER_DB_CURSOR.execute('''SELECT unlocked_tracks FROM map_progress WHERE map_id = ?''', (self.map_id, ))
     self.unlocked_tracks = USER_DB_CURSOR.fetchone()[0]
     USER_DB_CURSOR.execute('SELECT busy FROM tracks WHERE map_id = ?', (self.map_id, ))
     self.track_busy_status = [TRUE, *[t[0] for t in USER_DB_CURSOR.fetchall()]]
     CONFIG_DB_CURSOR.execute(
         '''SELECT supported_cars_min, supported_cars_max FROM track_config WHERE map_id = ?''', (self.map_id, )
     )
     self.supported_cars_by_track = ((0, 20), *CONFIG_DB_CURSOR.fetchall())
예제 #27
0
    def create_trains(self):
        trains = {}
        trains_list = []
        USER_DB_CURSOR.execute('''SELECT train_id FROM trains WHERE map_id = ?''', (PASSENGER_MAP,))
        try:
            for i in USER_DB_CURSOR.fetchall():
                trains[i[0]] = PassengerTrainController(self, i[0])
                trains_list.append(trains[i[0]])
        except TypeError:
            pass

        return trains, trains_list
예제 #28
0
 def on_save_state(self):
     USER_DB_CURSOR.execute(
         '''UPDATE epoch_timestamp SET game_time = ?, game_time_fraction = ?''',
         (self.game_time, self.game_time_fraction)
     )
     USER_DB_CURSOR.execute(
         '''UPDATE game_progress SET level = ?, exp = ?, money = ?, money_target = ?, exp_multiplier = ?, 
         exp_bonus_multiplier = ?, money_bonus_multiplier = ?, construction_speed_bonus_multiplier = ?''',
         (
             self.level, self.exp, self.money, self.money_target, self.exp_multiplier, self.exp_bonus_multiplier,
             self.money_bonus_multiplier, self.construction_speed_bonus_multiplier
         )
     )
예제 #29
0
 def __init__(self, logger, parent_viewport, map_id, track, base_route):
     super().__init__(logger, parent_viewport, map_id)
     CONFIG_DB_CURSOR.execute(
         '''SELECT x, y, rotation FROM signal_config WHERE track = ? AND base_route = ? AND map_id = ?''',
         (track, base_route, self.map_id))
     self.x, self.y, self.rotation = CONFIG_DB_CURSOR.fetchone()
     self.batch = BATCHES['main_batch']
     self.group = GROUPS['signal']
     USER_DB_CURSOR.execute(
         '''SELECT state FROM signals WHERE track = ? AND base_route = ? AND map_id = ?''',
         (track, base_route, self.map_id))
     self.texture = RED_SIGNAL_IMAGE
     if (state := USER_DB_CURSOR.fetchone()[0]) == GREEN_SIGNAL:
         self.texture = GREEN_SIGNAL_IMAGE
예제 #30
0
 def __init__(self):
     self.speaker = win32com.client.Dispatch('SAPI.SpVoice')
     USER_DB_CURSOR.execute('''SELECT master_volume FROM sound''')
     self.master_volume = USER_DB_CURSOR.fetchone()[0]
     self.speaker.Volume = 100
     self.speaker.Priority = 2
     self.opacity = 0
     # SpVoice hangs during the first speech, so we fake the first one to avoid hanging at the real one
     self.speaker.Speak('<silence msec="10"/>', 9)
     self.track_number_converters = {
         ENGLISH: numbers_to_speech_en.to_cardinal,
         RUSSIAN: numbers_to_speech_ru.to_ordinal
     }
     self.is_muted = False