def from_data(cls, file: File, data: Dict[str, Any], translations: Dict[str, Dict[str, Any]], game_contents: GameContents) -> 'Deck': d = game_contents.get_deck(data['id']) d.file = file d._cards = [ DeckCard(element=game_contents.get_element(c)) for c in get(data, 'spec', []) ] d.default_card = game_contents.get_element( get(data, 'defaultcard', None)) d.reset_on_exhaustion = get(data, 'resetonexhaustion', False, to_bool) d.label = get(data, 'label', None, translations=translations) d.description = get(data, 'description', None, translations=translations) d.all_draw_messages = [ DeckDrawMessage(element=game_contents.get_element(element_id), message=message + cls._get_draw_message_loc( translations, element_id)) for element_id, message in get(data, 'drawmessages', {}).items() ] + [ DeckDrawMessage(element=game_contents.get_element(element_id), message=message + cls._get_draw_message_loc( translations, element_id), default=True) for element_id, message in get( data, 'defaultdrawmessages', {}).items() ] d.comments = get(data, 'comments', None) return d
def from_data(cls, val: Dict[str, str], game_contents: GameContents): return [ cls( deck=game_contents.get_deck(deck_id), quantity=int(quantity) ) for deck_id, quantity in val.items() ]