<commit_before>//
//  MusicSelector.swift
//  BreakBaloon
//
//  Created by Emil on 26/06/2016.
//  Copyright © 2016 Snowy_1803. All rights reserved.
//

import Foundation
import MediaPlayer
import SpriteKit

class MusicSelector: Selector {
    init(gvc: GameViewController) {
        super.init(gvc: gvc, title: NSLocalizedString("settings.music", comment: "Music"), value: gvc.currentMusicInt)
    }
    
    @available(*, unavailable)
    required init?(coder _: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func didSetSelectorValue() {
        gvc.currentMusicInt = value
        UserDefaults.standard.set(gvc.currentMusicFileName, forKey: "currentMusic")
        super.didSetSelectorValue()
        gvc.reloadBackgroundMusic()
    }
    
    override var maxValue: Int {
        GameViewController.getMusicURLs().count - 1
    }
    
    override var text: String {
        let cmps = GameViewController.getMusicURLs()[value].absoluteString.components(separatedBy: "/")
        let text = cmps[cmps.count - 1].components(separatedBy: ".")[0].removingPercentEncoding!
        return text == "Race" ? NSLocalizedString("theme.default.name", comment: "Default theme name") : text
    }
}<commit_msg>Fix crash if Race failed downloading<commit_after>//
//  MusicSelector.swift
//  BreakBaloon
//
//  Created by Emil on 26/06/2016.
//  Copyright © 2016 Snowy_1803. All rights reserved.
//

import Foundation
import MediaPlayer
import SpriteKit

class MusicSelector: Selector {
    init(gvc: GameViewController) {
        super.init(gvc: gvc, title: NSLocalizedString("settings.music", comment: "Music"), value: gvc.currentMusicInt)
    }
    
    @available(*, unavailable)
    required init?(coder _: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func didSetSelectorValue() {
        gvc.currentMusicInt = value
        UserDefaults.standard.set(gvc.currentMusicFileName, forKey: "currentMusic")
        super.didSetSelectorValue()
        gvc.reloadBackgroundMusic()
    }
    
    override var maxValue: Int {
        GameViewController.getMusicURLs().count - 1
    }
    
    override var text: String {
        let urls = GameViewController.getMusicURLs()
        guard urls.indices.contains(value) else {
            return NSLocalizedString("error", comment: "Error")
        }
        let cmps = urls[value].absoluteString.components(separatedBy: "/")
        let text = cmps[cmps.count - 1].components(separatedBy: ".")[0].removingPercentEncoding!
        return text == "Race" ? NSLocalizedString("theme.default.name", comment: "Default theme name") : text
    }
}
{'fraction_non_alphanumeric': 0.11485222596333708, 'fraction_numerical': 0.01421623643845866, 'mean_word_length': 3.0576631259484066, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '237448', 'n_tokens_mistral': 826, 'n_tokens_neox': 775, 'n_words': 177}