Skip to content

SagaLayout

src.layouts.SagaLayout

Bases: NormalLayout

Saga card layout, introduced in Dominaria.

Source code in src\layouts.py
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
class SagaLayout(NormalLayout):
    """Saga card layout, introduced in Dominaria."""
    card_class: str = LayoutType.Saga

    """
    * Bool Properties
    """

    @auto_prop_cached
    def is_transform(self) -> bool:
        """Sage supports both single and double faced cards."""
        return bool('card_faces' in self.scryfall)

    """
    * Saga Properties
    """

    @auto_prop_cached
    def saga_text(self) -> str:
        """Text comprised of saga ability lines."""
        return strip_lines(self.oracle_text, 1)

    @auto_prop_cached
    def saga_description(self) -> str:
        """Description at the top of the Saga card"""
        return get_line(self.oracle_text, 0)

    @auto_prop_cached
    def saga_lines(self) -> list[dict]:
        """Unpack saga text into list of dictionaries containing ability text and icons."""
        abilities: list[dict] = []
        for i, line in enumerate(self.saga_text.split("\n")):
            # Full ability line
            if "—" in line:
                icons, text = line.split("—", 1)
                abilities.append({
                    "text": text.strip(),
                    "icons": icons.strip().split(", ")
                })
                continue
            # Static text line, "Greatest Show in the Multiverse"
            if i == 0:
                abilities.append({
                    'text': line,
                    'icons': []
                })
                continue
            # Part of a previous ability line
            abilities[-1]['text'] += f"\n{line}"
        return abilities

Attributes

card_class: str = LayoutType.Saga

  • Bool Properties

Functions

is_transform() -> bool

Sage supports both single and double faced cards.

Source code in src\layouts.py
1110
1111
1112
1113
@auto_prop_cached
def is_transform(self) -> bool:
    """Sage supports both single and double faced cards."""
    return bool('card_faces' in self.scryfall)

saga_description() -> str

Description at the top of the Saga card

Source code in src\layouts.py
1124
1125
1126
1127
@auto_prop_cached
def saga_description(self) -> str:
    """Description at the top of the Saga card"""
    return get_line(self.oracle_text, 0)

saga_lines() -> list[dict]

Unpack saga text into list of dictionaries containing ability text and icons.

Source code in src\layouts.py
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
@auto_prop_cached
def saga_lines(self) -> list[dict]:
    """Unpack saga text into list of dictionaries containing ability text and icons."""
    abilities: list[dict] = []
    for i, line in enumerate(self.saga_text.split("\n")):
        # Full ability line
        if "—" in line:
            icons, text = line.split("—", 1)
            abilities.append({
                "text": text.strip(),
                "icons": icons.strip().split(", ")
            })
            continue
        # Static text line, "Greatest Show in the Multiverse"
        if i == 0:
            abilities.append({
                'text': line,
                'icons': []
            })
            continue
        # Part of a previous ability line
        abilities[-1]['text'] += f"\n{line}"
    return abilities

saga_text() -> str

Text comprised of saga ability lines.

Source code in src\layouts.py
1119
1120
1121
1122
@auto_prop_cached
def saga_text(self) -> str:
    """Text comprised of saga ability lines."""
    return strip_lines(self.oracle_text, 1)