Пример #1
0
 def image_urls(self):
     data = self.get_json()
     layout = data['layout']
     if Layout.simple_faced_layout(layout) or Layout.split_faced_layout(
             layout):
         return [data['card_faces'][0]['image_url']]
     elif Layout.double_sided_layout(layout):
         return [
             x['image_url'] for x in self.card_faces() if 'image_url' in x
         ]
     else:
         raise ValueError(f"Unknown layout type: {layout}")
Пример #2
0
def _image_url(card_data, face_index):
    layout = card_data['layout']

    if Layout.simple_faced_layout(layout) \
       or Layout.split_faced_layout(layout) \
       or Layout.double_sided_layout(layout):

        return card_data['card_faces'][face_index]['image_url']

    else:
        raise NotImplementedError(
            f"Don't have a Cockatrice pattern for image_url of: {layout}")
Пример #3
0
def _mana_cost(card_data, face_index):
    layout = card_data['layout']

    if Layout.simple_faced_layout(layout) or Layout.split_faced_layout(layout):
        mana_costs = [
            _clean_mana_cost(x['mana_cost']) for x in card_data['card_faces']
        ]
        return ' // '.join(mana_costs)
    elif Layout.double_sided_layout(layout):
        return _clean_mana_cost(card_data['card_faces'][face_index].get(
            'mana_cost', ''))
    else:
        raise NotImplementedError(
            f"Don't have a Cockatrice pattern for mana cost of: {layout}")
Пример #4
0
def _card_name(card_data, face_index, scarred):
    layout = card_data['layout']

    if Layout.simple_faced_layout(layout) or Layout.double_sided_layout(
            layout):
        name = card_data['card_faces'][face_index]['name']
    elif Layout.split_faced_layout(layout):
        name = card_data['name']
    else:
        raise NotImplementedError(
            f"Don't have a Cockatrice pattern for card name of: {layout}")

    if scarred:
        return f"{name}++"
    else:
        return f"{name}'"
Пример #5
0
def _oracle_text(card, card_data, face_index):
    layout = card_data['layout']

    if Layout.simple_faced_layout(layout) or Layout.double_sided_layout(
            layout):
        rules_text = card_data['card_faces'][face_index]['oracle_text']
    elif Layout.split_faced_layout(layout):
        rules_text = card_data['oracle_text']
    else:
        raise NotImplementedError(
            f"Don't have a Cockatrice pattern for text of: {layout}")

    achievement_lines = []
    if card.linked_achievements():
        achievement_lines.append("\n\n***")
        for ach in card.linked_achievements():
            achievement_lines.append(ach.conditions)

        rules_text += '\n\n'.join(achievement_lines)

    return rules_text