Beispiel #1
0
class Role(Translatable):
    _trans_table: 'TranslateTable' = \
            load_translate_table(_where / 'res/translate/terms.csv')

    @property
    def translate_table(self) -> 'TranslateTable':
        cls = type(self)
        return cls._trans_table
class CardName(Translatable):
    _trans_table: 'TranslateTable' = {
        k: v
        for p in (_where / 'res/translate/cards').glob('*.csv')
        for k, v in load_translate_table(p).items()
    }

    @property
    def translate_table(self) -> 'TranslateTable':
        cls = type(self)
        return cls._trans_table
class CardType(Translatable):
    _trans_table: 'TranslateTable' = \
            load_translate_table(_where / 'res/translate/types.csv')

    def __init__(self, raw_name: str):
        super().__init__(raw_name.capitalize())

    @property
    def translate_table(self) -> 'TranslateTable':
        cls = type(self)
        return cls._trans_table
class EffectType(Translatable):
    _trans_table: 'TranslateTable' = \
            load_translate_table(_where / 'res/translate/types.csv')

    def __init__(self, raw_name: str):
        assert raw_name in {
            'Event',
            'Landmark',
            'Project',
        }
        super().__init__(raw_name)

    @property
    def translate_table(self) -> 'TranslateTable':
        cls = type(self)
        return cls._trans_table
class Expansion(Translatable):
    _trans_table: 'TranslateTable' = \
            load_translate_table(_where / 'res/translate/expansions.csv')

    def __init__(self, raw_name: str):
        assert raw_name in {
            'Dominion',
            'Intrigue',
            'Seaside',
            'Alchemy',
            'Prosperity',
            'Cornucopia',
            'Hinterlands',
            'DarkAges',
            'Guilds',
            'Adventures',
        }, f'Unknown expansion; "{raw_name}".'

        super().__init__(raw_name)

    @property
    def translate_table(self) -> 'TranslateTable':
        cls = type(self)
        return cls._trans_table