Ejemplo n.º 1
0
    def map2text(map, unknown='?', languages=None):
        map_id = IkaUtils.map2id(map, unknown=None)

        if map_id is None:
            return unknown

        if stages.get(map_id, None) is None:
            return unknown

        if languages is None:
            languages = Localization.get_languages()

        if not isinstance(languages, list):
            languages = [languages]

        # fallback list
        languages.extend(['en', 'ja'])

        for lang in languages:
            map_text = stages[map_id].get(lang, None)
            if map_text is not None:
                return map_text

        # Should not reach here
        return map_id
Ejemplo n.º 2
0
def find_image_file(img_file=None, languages=None):
    if languages is None:
        languages = Localization.get_game_languages()

    if languages is not None:
        if not isinstance(languages, list):
            languages = [lang]

        for lang in languages:
            f = IkaUtils.get_path('masks', lang, img_file)
            if os.path.exists(f):
                return f

    f = IkaUtils.get_path('masks', img_file)
    if os.path.exists(f):
        return f

    f = IkaUtils.get_path(img_file)
    if os.path.exists(f):
        return f

    f = IkaUtils.get_path('masks', 'ja', img_file)
    if os.path.exists(f):
        IkaUtils.dprint('%s: mask %s: using ja version' %
            (self, img_file))
        return f

    raise Exception('Could not find image file %s (lang %s)' % (img_file, lang))
Ejemplo n.º 3
0
    def rule2text(rule, unknown='?', languages=None):
        rule_id = IkaUtils.rule2id(rule, unknown=None)

        if rule_id is None:
            return unknown

        if rules.get(rule_id, None) is None:
            return unknown

        if languages is None:
            languages = Localization.get_languages()

        if not isinstance(languages, list):
            languages = [languages]

        # fallback list
        languages.extend(['en', 'ja'])

        for lang in languages:
            rule_text = rules[rule_id].get(lang, None)
            if rule_text is not None:
                return rule_text

        # Should not reach here
        return rule_id
Ejemplo n.º 4
0
    def gear_ability2text(gear_ability, unknown='?', languages=None):
        gear_ability_id = IkaUtils.gear_ability2id(gear_ability, unknown=None)

        if gear_ability_id is None:
            return unknown

        if gear_abilities.get(gear_ability_id, None) is None:
            return unknown

        if languages is None:
            languages = Localization.get_languages()

        if not isinstance(languages, list):
            languages = [languages]

        # fallback list
        languages.extend(['en', 'ja'])

        for lang in languages:
            gear_ability_text = gear_abilities[gear_ability_id].get(lang, None)
            if gear_ability_text is not None:
                return gear_ability_text

        # Should not reach here
        return gear_ability_id
Ejemplo n.º 5
0
    def map2text(map, unknown='?', languages=None):
        map_id = IkaUtils.map2id(map, unknown=None)

        if map_id is None:
            return unknown

        if stages.get(map_id, None) is None:
            return unknown

        if languages is None:
            languages = Localization.get_languages()

        if not isinstance(languages, list):
            languages = [languages]

        # fallback list
        languages.extend(['en', 'ja'])

        for lang in languages:
            map_text = stages[map_id].get(lang, None)
            if map_text is not None:
                return map_text

        # Should not reach here
        return map_id
Ejemplo n.º 6
0
    def gear_ability2text(gear_ability, unknown='?', languages=None):
        gear_ability_id = IkaUtils.gear_ability2id(gear_ability, unknown=None)

        if gear_ability_id is None:
            return unknown

        if gear_abilities.get(gear_ability_id, None) is None:
            return unknown

        if languages is None:
            languages = Localization.get_languages()

        if not isinstance(languages, list):
            languages = [languages]

        # fallback list
        languages.extend(['en', 'ja'])

        for lang in languages:
            gear_ability_text = gear_abilities[gear_ability_id].get(lang, None)
            if gear_ability_text is not None:
                return gear_ability_text

        # Should not reach here
        return gear_ability_id
Ejemplo n.º 7
0
    def rule2text(rule, unknown='?', languages=None):
        rule_id = IkaUtils.rule2id(rule, unknown=None)

        if rule_id is None:
            return unknown

        if rules.get(rule_id, None) is None:
            return unknown

        if languages is None:
            languages = Localization.get_languages()

        if not isinstance(languages, list):
            languages = [languages]

        # fallback list
        languages.extend(['en', 'ja'])

        for lang in languages:
            rule_text = rules[rule_id].get(lang, None)
            if rule_text is not None:
                return rule_text

        # Should not reach here
        return rule_id
Ejemplo n.º 8
0
    def extend_languages(languages=None):
        if languages is None:
            languages = Localization.get_languages()

        if not isinstance(languages, list):
            languages = [languages]

        # fallback list
        languages.extend(['en', 'ja'])
        return languages
Ejemplo n.º 9
0
    def extend_languages(languages=None):
        if languages is None:
            languages = Localization.get_languages()

        if not isinstance(languages, list):
            languages = [languages]

        # fallback list
        languages.extend(['en', 'ja'])
        return languages