File size: 4,666 Bytes
bb3fbf9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
from enum import IntEnum
from typing import Any, List


class CardType(IntEnum):
    """Card types in the game"""

    MEMBER = 0
    LIVE = 1
    ENERGY = 2


class HeartColor(IntEnum):
    """Heart/color types (6 colors + any + rainbow)"""

    PINK = 0
    RED = 1
    YELLOW = 2
    GREEN = 3
    BLUE = 4
    PURPLE = 5
    ANY = 6  # Colorless requirement
    RAINBOW = 7  # Can be any color


class Area(IntEnum):
    """Member areas on stage"""

    LEFT = 0
    CENTER = 1
    RIGHT = 2


class Group(IntEnum):
    """Card Groups (Series/Schools)"""

    MUSE = 0
    AQOURS = 1
    NIJIGASAKI = 2
    LIELLA = 3
    HASUNOSORA = 4
    LIVE = 98
    OTHER = 99

    @classmethod
    def from_japanese_name(cls, name: str) -> "Group":
        name = name.strip()
        name_lower = name.lower()
        if "ラブライブ!" == name or "μ's" in name or "muse" in name_lower:
            return cls.MUSE
        if "サンシャイン" in name or "aqours" in name_lower:
            return cls.AQOURS
        if "虹ヶ咲" in name or "nijigasaki" in name_lower:
            return cls.NIJIGASAKI
        if "スーパースター" in name or "liella" in name_lower:
            return cls.LIELLA
        if "蓮ノ空" in name or "hasunosora" in name_lower:
            return cls.HASUNOSORA
        return cls.OTHER


class Unit(IntEnum):
    """Card Units"""

    PRINTEMPS = 0
    LILY_WHITE = 1
    BIBI = 2
    CYARON = 3
    AZALEA = 4
    GUILTY_KISS = 5
    DIVER_DIVA = 6
    A_ZU_NA = 7
    QU4RTZ = 8
    R3BIRTH = 9
    CATCHU = 10
    KALEIDOSCORE = 11
    SYNCRISE = 12
    CERISE_BOUQUET = 13
    DOLLCHESTRA = 14
    MIRA_CRA_PARK = 15
    EDEL_NOTE = 16
    OTHER = 99

    @classmethod
    def from_japanese_name(cls, name: str) -> "Unit":
        name = name.strip()
        name_lower = name.lower()
        if "printemps" in name_lower:
            return cls.PRINTEMPS
        if "lily white" in name_lower or "lilywhite" in name_lower:
            return cls.LILY_WHITE
        if "bibi" in name_lower:
            return cls.BIBI
        if "cyaron" in name_lower or "cyaron!" in name_lower:
            return cls.CYARON
        if "azalea" in name_lower:
            return cls.AZALEA
        if "guilty kiss" in name_lower or "guiltykiss" in name_lower:
            return cls.GUILTY_KISS
        if "diverdiva" in name_lower:
            return cls.DIVER_DIVA
        if "azuna" in name_lower or "a・zu・na" in name_lower:
            return cls.A_ZU_NA
        if "qu4rtz" in name_lower:
            return cls.QU4RTZ
        if "r3birth" in name_lower:
            return cls.R3BIRTH
        if "catchu" in name_lower:
            return cls.CATCHU
        if "kaleidoscore" in name_lower:
            return cls.KALEIDOSCORE
        if "5yncri5e" in name_lower:
            return cls.SYNCRISE
        if "スリーズブーケ" in name or "cerise" in name_lower:
            return cls.CERISE_BOUQUET
        if "dollchestra" in name_lower:
            return cls.DOLLCHESTRA
        if "みらくらぱーく" in name or "mira-cra" in name_lower or "mirakura" in name_lower:
            return cls.MIRA_CRA_PARK
        if "edelnote" in name_lower:
            return cls.EDEL_NOTE
        if not name:
            return cls.OTHER
        return cls.OTHER


def ensure_group_list(v: Any) -> List[Group]:
    """Validator to convert string/single Group to List[Group]"""
    if isinstance(v, list):
        return [
            g if isinstance(g, Group) else Group(g) if isinstance(g, int) else Group.from_japanese_name(str(g))
            for g in v
        ]
    if isinstance(v, Group):
        return [v]
    if isinstance(v, int):
        return [Group(v)]
    if isinstance(v, str):
        if not v:
            return []
        parts = [p.strip() for p in v.split("\n") if p.strip()]
        return [Group.from_japanese_name(p) for p in parts]
    return []


def ensure_unit_list(v: Any) -> List[Unit]:
    """Validator to convert string/single Unit to List[Unit]"""
    if isinstance(v, list):
        return [
            u if isinstance(u, Unit) else Unit(u) if isinstance(u, int) else Unit.from_japanese_name(str(u)) for u in v
        ]
    if isinstance(v, Unit):
        return [v]
    if isinstance(v, int):
        return [Unit(v)]
    if isinstance(v, str):
        if not v:
            return []
        parts = [p.strip() for p in v.split("\n") if p.strip()]
        return [Unit.from_japanese_name(p) for p in parts]
    return []