seerapi-models 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,448 @@
1
+ from typing import TYPE_CHECKING, Optional, cast
2
+
3
+ from pydantic import BaseModel
4
+ from sqlmodel import Field, Relationship, SQLModel
5
+
6
+ from seerapi_models.build_model import (
7
+ BaseCategoryModel,
8
+ BaseResModel,
9
+ BaseResModelWithOptionalId,
10
+ ConvertToORM,
11
+ )
12
+ from seerapi_models.common import ResourceRef, SixAttributes, SixAttributesORM
13
+
14
+ if TYPE_CHECKING:
15
+ from .pet import Pet, PetORM
16
+ from .skill import Skill, SkillORM
17
+
18
+
19
+ class SkillMintmarkLink(SQLModel, table=True):
20
+ skill_id: int | None = Field(default=None, foreign_key='skill.id', primary_key=True)
21
+ mintmark_id: int | None = Field(
22
+ default=None, foreign_key='mintmark.id', primary_key=True
23
+ )
24
+
25
+
26
+ class MintmarkMaxAttrORM(SixAttributesORM, table=True):
27
+ ability_mintmark: list['AbilityPartORM'] = Relationship(
28
+ back_populates='max_attr_value',
29
+ )
30
+ universal_mintmark: list['UniversalPartORM'] = Relationship(
31
+ back_populates='max_attr_value',
32
+ )
33
+
34
+ @classmethod
35
+ def resource_name(cls) -> str:
36
+ return 'mintmark_max_attr'
37
+
38
+
39
+ class MintmarkBaseAttrORM(SixAttributesORM, table=True):
40
+ universal_mintmark: list['UniversalPartORM'] = Relationship(
41
+ back_populates='base_attr_value',
42
+ )
43
+
44
+ @classmethod
45
+ def resource_name(cls) -> str:
46
+ return 'mintmark_base_attr'
47
+
48
+
49
+ class MintmarkExtraAttrORM(SixAttributesORM, table=True):
50
+ universal_mintmark: list['UniversalPartORM'] = Relationship(
51
+ back_populates='extra_attr_value',
52
+ )
53
+
54
+ @classmethod
55
+ def resource_name(cls) -> str:
56
+ return 'mintmark_extra_attr'
57
+
58
+
59
+ class PetMintmarkLink(SQLModel, table=True):
60
+ pet_id: int | None = Field(default=None, foreign_key='pet.id', primary_key=True)
61
+ mintmark_id: int | None = Field(
62
+ default=None, foreign_key='mintmark.id', primary_key=True
63
+ )
64
+
65
+
66
+ class SkillMintmarkEffect(BaseModel):
67
+ effect: int = Field(description='增幅效果ID')
68
+ arg: int | None = Field(description='增幅效果参数')
69
+
70
+
71
+ class MintmarkBase(BaseResModel):
72
+ name: str = Field(description='名称')
73
+ desc: str = Field(description='刻印描述')
74
+ rarity_id: int = Field(
75
+ foreign_key='mintmark_rarity.id',
76
+ exclude=True,
77
+ )
78
+
79
+
80
+ class MintmarkResRefs(SQLModel):
81
+ type: ResourceRef['MintmarkTypeCategory'] = Field(description='刻印类型')
82
+ rarity: ResourceRef['MintmarkRarityCategory'] = Field(description='刻印稀有度')
83
+ pet: list[ResourceRef['Pet']] | None = Field(
84
+ default=None, description='表示该刻印仅能安装在这些精灵上,null表示无精灵限制'
85
+ )
86
+
87
+
88
+ class AbilityMintmark(MintmarkBase, MintmarkResRefs):
89
+ max_attr_value: SixAttributes = Field(
90
+ description='刻印满级属性值,仅当该刻印为能力刻印或全能刻印时有效'
91
+ )
92
+
93
+ @classmethod
94
+ def resource_name(cls) -> str:
95
+ return 'ability_mintmark'
96
+
97
+
98
+ class SkillMintmark(MintmarkBase, MintmarkResRefs):
99
+ effect: SkillMintmarkEffect = Field(
100
+ description='技能刻印效果,仅当刻印类型为技能刻印时有效'
101
+ )
102
+ skill: list[ResourceRef['Skill']] = Field(
103
+ default_factory=list, description='该刻印所绑定的技能列表'
104
+ )
105
+
106
+ @classmethod
107
+ def resource_name(cls) -> str:
108
+ return 'skill_mintmark'
109
+
110
+
111
+ class UniversalMintmark(MintmarkBase, MintmarkResRefs):
112
+ mintmark_class: ResourceRef['MintmarkClassCategory'] | None = Field(
113
+ default=None, description='刻印所属系列,当该刻印是精灵专属刻印时可能为null'
114
+ )
115
+ base_attr_value: SixAttributes = Field(
116
+ description='刻印基础属性值,仅当该刻印为全能刻印时有效'
117
+ )
118
+ max_attr_value: SixAttributes = Field(
119
+ description='刻印满级属性值,仅当该刻印为能力刻印或全能刻印时有效'
120
+ )
121
+ extra_attr_value: SixAttributes | None = Field(
122
+ default=None,
123
+ description='刻印隐藏属性值,仅当该刻印为全能刻印并具有隐藏属性时有效',
124
+ )
125
+
126
+ @classmethod
127
+ def resource_name(cls) -> str:
128
+ return 'universal_mintmark'
129
+
130
+
131
+ class AbilityPartORM(BaseResModelWithOptionalId, table=True):
132
+ mintmark_id: int = Field(foreign_key='mintmark.id')
133
+ mintmark: 'MintmarkORM' = Relationship(
134
+ back_populates='ability_part',
135
+ sa_relationship_kwargs={
136
+ 'primaryjoin': 'MintmarkORM.id == AbilityPartORM.mintmark_id',
137
+ },
138
+ )
139
+ max_attr_value: 'MintmarkMaxAttrORM' = Relationship(
140
+ back_populates='ability_mintmark',
141
+ )
142
+ max_attr_value_id: int | None = Field(
143
+ default=None, foreign_key='mintmark_max_attr.id'
144
+ )
145
+
146
+ @classmethod
147
+ def resource_name(cls) -> str:
148
+ return 'ability_mintmark_part'
149
+
150
+
151
+ class SkillPartORM(BaseResModelWithOptionalId, table=True):
152
+ mintmark_id: int = Field(foreign_key='mintmark.id')
153
+ mintmark: 'MintmarkORM' = Relationship(
154
+ back_populates='skill_part',
155
+ sa_relationship_kwargs={
156
+ 'primaryjoin': 'MintmarkORM.id == SkillPartORM.mintmark_id',
157
+ },
158
+ )
159
+ effect: int = Field(description='增幅效果ID')
160
+ arg: int | None = Field(default=None, description='增幅效果参数')
161
+
162
+ @classmethod
163
+ def resource_name(cls) -> str:
164
+ return 'skill_mintmark_part'
165
+
166
+
167
+ class UniversalPartORM(BaseResModelWithOptionalId, table=True):
168
+ mintmark_id: int = Field(foreign_key='mintmark.id')
169
+ mintmark: 'MintmarkORM' = Relationship(
170
+ back_populates='universal_part',
171
+ sa_relationship_kwargs={
172
+ 'primaryjoin': 'MintmarkORM.id == UniversalPartORM.mintmark_id',
173
+ },
174
+ )
175
+ mintmark_class_id: int | None = Field(default=None, foreign_key='mintmark_class.id')
176
+ mintmark_class: Optional['MintmarkClassCategoryORM'] = Relationship(
177
+ back_populates='mintmark',
178
+ )
179
+ base_attr_value: 'MintmarkBaseAttrORM' = Relationship(
180
+ back_populates='universal_mintmark',
181
+ )
182
+ base_attr_value_id: int | None = Field(
183
+ default=None, foreign_key='mintmark_base_attr.id'
184
+ )
185
+ max_attr_value: 'MintmarkMaxAttrORM' = Relationship(
186
+ back_populates='universal_mintmark',
187
+ )
188
+ max_attr_value_id: int | None = Field(
189
+ default=None, foreign_key='mintmark_max_attr.id'
190
+ )
191
+ extra_attr_value: Optional['MintmarkExtraAttrORM'] = Relationship(
192
+ back_populates='universal_mintmark',
193
+ )
194
+ extra_attr_value_id: int | None = Field(
195
+ default=None, foreign_key='mintmark_extra_attr.id'
196
+ )
197
+
198
+ @classmethod
199
+ def resource_name(cls) -> str:
200
+ return 'universal_mintmark_part'
201
+
202
+
203
+ class Mintmark(MintmarkBase, MintmarkResRefs, ConvertToORM['MintmarkORM']):
204
+ effect: SkillMintmarkEffect | None = Field(
205
+ default=None, description='技能刻印效果,仅当刻印类型为技能刻印时有效'
206
+ )
207
+ mintmark_class: ResourceRef['MintmarkClassCategory'] | None = Field(
208
+ default=None, description='刻印所属系列,仅当该刻印为全能刻印时有效'
209
+ )
210
+ base_attr_value: SixAttributes | None = Field(
211
+ default=None, description='刻印基础属性值,仅当该刻印为全能刻印时有效'
212
+ )
213
+ max_attr_value: SixAttributes | None = Field(
214
+ default=None, description='刻印满级属性值,仅当该刻印为能力刻印或全能刻印时有效'
215
+ )
216
+ extra_attr_value: SixAttributes | None = Field(
217
+ default=None,
218
+ description='刻印隐藏属性值,仅当该刻印为全能刻印并具有隐藏属性时有效',
219
+ )
220
+ skill: list[ResourceRef['Skill']] | None = Field(
221
+ default=None, description='该刻印所绑定的技能列表,仅当该刻印为技能刻印时有效'
222
+ )
223
+
224
+ @classmethod
225
+ def resource_name(cls) -> str:
226
+ return 'mintmark'
227
+
228
+ @classmethod
229
+ def get_orm_model(cls) -> type['MintmarkORM']:
230
+ return MintmarkORM
231
+
232
+ def to_orm(self) -> 'MintmarkORM':
233
+ part_kwargs: dict = {
234
+ 'ability_part': None,
235
+ 'skill_part': None,
236
+ 'universal_part': None,
237
+ }
238
+ type_id = self.type.id
239
+ if type_id == 0:
240
+ self = cast(AbilityMintmark, self)
241
+ part_kwargs['ability_part'] = AbilityPartORM(
242
+ mintmark_id=self.id,
243
+ max_attr_value=MintmarkMaxAttrORM(
244
+ **self.max_attr_value.model_dump(),
245
+ ),
246
+ )
247
+ elif type_id == 1:
248
+ self = cast(SkillMintmark, self)
249
+ part_kwargs['skill_part'] = SkillPartORM(
250
+ mintmark_id=self.id,
251
+ effect=self.effect.effect,
252
+ arg=self.effect.arg,
253
+ )
254
+ elif type_id == 3:
255
+ self = cast(UniversalMintmark, self)
256
+ part_kwargs['universal_part'] = UniversalPartORM(
257
+ mintmark_id=self.id,
258
+ mintmark_class_id=self.mintmark_class.id
259
+ if self.mintmark_class
260
+ else None,
261
+ base_attr_value=MintmarkBaseAttrORM(
262
+ **self.base_attr_value.model_dump(),
263
+ ),
264
+ max_attr_value=MintmarkMaxAttrORM(
265
+ **self.max_attr_value.model_dump(),
266
+ ),
267
+ extra_attr_value=MintmarkExtraAttrORM(
268
+ **self.extra_attr_value.model_dump(),
269
+ )
270
+ if self.extra_attr_value
271
+ else None,
272
+ )
273
+
274
+ return MintmarkORM(
275
+ id=self.id,
276
+ name=self.name,
277
+ desc=self.desc,
278
+ type_id=type_id,
279
+ rarity_id=self.rarity_id,
280
+ **part_kwargs,
281
+ )
282
+
283
+ def to_detailed(self) -> 'AbilityMintmark | SkillMintmark | UniversalMintmark':
284
+ general_args = {
285
+ 'id': self.id,
286
+ 'name': self.name,
287
+ 'desc': self.desc,
288
+ 'pet': self.pet,
289
+ 'rarity': self.rarity,
290
+ 'rarity_id': self.rarity_id,
291
+ 'type': self.type,
292
+ }
293
+ if self.type.id == 0:
294
+ self = cast(AbilityMintmark, self)
295
+ return AbilityMintmark(
296
+ **general_args,
297
+ max_attr_value=self.max_attr_value,
298
+ )
299
+ elif self.type.id == 1:
300
+ self = cast(SkillMintmark, self)
301
+ return SkillMintmark(
302
+ **general_args,
303
+ effect=self.effect,
304
+ skill=self.skill or [],
305
+ )
306
+ elif self.type.id == 3:
307
+ self = cast(UniversalMintmark, self)
308
+ return UniversalMintmark(
309
+ **general_args,
310
+ mintmark_class=self.mintmark_class,
311
+ base_attr_value=self.base_attr_value,
312
+ max_attr_value=self.max_attr_value,
313
+ extra_attr_value=self.extra_attr_value,
314
+ )
315
+
316
+ raise ValueError(f'Invalid mintmark type: {self.type.id}')
317
+
318
+
319
+ class MintmarkORM(MintmarkBase, table=True):
320
+ type_id: int = Field(foreign_key='mintmark_type.id')
321
+ type: 'MintmarkTypeCategoryORM' = Relationship(
322
+ back_populates='mintmark',
323
+ )
324
+ rarity_id: int = Field(foreign_key='mintmark_rarity.id')
325
+ rarity: 'MintmarkRarityCategoryORM' = Relationship(
326
+ back_populates='mintmark',
327
+ )
328
+ ability_part: Optional['AbilityPartORM'] = Relationship(
329
+ back_populates='mintmark',
330
+ sa_relationship_kwargs={
331
+ 'primaryjoin': 'MintmarkORM.id == AbilityPartORM.mintmark_id',
332
+ },
333
+ )
334
+ skill_part: Optional['SkillPartORM'] = Relationship(
335
+ back_populates='mintmark',
336
+ sa_relationship_kwargs={
337
+ 'primaryjoin': 'MintmarkORM.id == SkillPartORM.mintmark_id',
338
+ },
339
+ )
340
+ universal_part: Optional['UniversalPartORM'] = Relationship(
341
+ back_populates='mintmark',
342
+ sa_relationship_kwargs={
343
+ 'primaryjoin': 'MintmarkORM.id == UniversalPartORM.mintmark_id',
344
+ },
345
+ )
346
+ pet: list['PetORM'] = Relationship(
347
+ back_populates='exclusive_mintmark',
348
+ link_model=PetMintmarkLink,
349
+ )
350
+ skill: list['SkillORM'] = Relationship(
351
+ back_populates='mintmark',
352
+ link_model=SkillMintmarkLink,
353
+ )
354
+
355
+ @classmethod
356
+ def resource_name(cls) -> str:
357
+ return 'mintmark'
358
+
359
+
360
+ class MintmarkRarityBase(BaseCategoryModel):
361
+ @classmethod
362
+ def resource_name(cls) -> str:
363
+ return 'mintmark_rarity'
364
+
365
+
366
+ class MintmarkRarityCategory(
367
+ MintmarkRarityBase, ConvertToORM['MintmarkRarityCategoryORM']
368
+ ):
369
+ mintmark: list[ResourceRef['Mintmark']] = Field(
370
+ default_factory=list, description='刻印列表'
371
+ )
372
+
373
+ @classmethod
374
+ def get_orm_model(cls) -> type['MintmarkRarityCategoryORM']:
375
+ return MintmarkRarityCategoryORM
376
+
377
+ def to_orm(self) -> 'MintmarkRarityCategoryORM':
378
+ return MintmarkRarityCategoryORM(
379
+ id=self.id,
380
+ )
381
+
382
+
383
+ class MintmarkRarityCategoryORM(MintmarkRarityBase, table=True):
384
+ mintmark: list['MintmarkORM'] = Relationship(
385
+ back_populates='rarity',
386
+ )
387
+
388
+
389
+ class MintmarkTypeBase(BaseCategoryModel):
390
+ name: str = Field(description='名称')
391
+
392
+ @classmethod
393
+ def resource_name(cls) -> str:
394
+ return 'mintmark_type'
395
+
396
+
397
+ class MintmarkTypeCategory(MintmarkTypeBase, ConvertToORM['MintmarkTypeCategoryORM']):
398
+ mintmark: list[ResourceRef['Mintmark']] = Field(
399
+ default_factory=list, description='刻印列表'
400
+ )
401
+
402
+ @classmethod
403
+ def get_orm_model(cls) -> type['MintmarkTypeCategoryORM']:
404
+ return MintmarkTypeCategoryORM
405
+
406
+ def to_orm(self) -> 'MintmarkTypeCategoryORM':
407
+ return MintmarkTypeCategoryORM(
408
+ id=self.id,
409
+ name=self.name,
410
+ )
411
+
412
+
413
+ class MintmarkTypeCategoryORM(MintmarkTypeBase, table=True):
414
+ mintmark: list['MintmarkORM'] = Relationship(
415
+ back_populates='type',
416
+ )
417
+
418
+
419
+ class MintmarkClassBase(BaseCategoryModel):
420
+ name: str = Field(description='名称')
421
+
422
+ @classmethod
423
+ def resource_name(cls) -> str:
424
+ return 'mintmark_class'
425
+
426
+
427
+ class MintmarkClassCategory(
428
+ MintmarkClassBase, ConvertToORM['MintmarkClassCategoryORM']
429
+ ):
430
+ mintmark: list[ResourceRef['UniversalMintmark']] = Field(
431
+ default_factory=list, description='刻印列表'
432
+ )
433
+
434
+ @classmethod
435
+ def get_orm_model(cls) -> type['MintmarkClassCategoryORM']:
436
+ return MintmarkClassCategoryORM
437
+
438
+ def to_orm(self) -> 'MintmarkClassCategoryORM':
439
+ return MintmarkClassCategoryORM(
440
+ id=self.id,
441
+ name=self.name,
442
+ )
443
+
444
+
445
+ class MintmarkClassCategoryORM(MintmarkClassBase, table=True):
446
+ mintmark: list['UniversalPartORM'] = Relationship(
447
+ back_populates='mintmark_class',
448
+ )
@@ -0,0 +1,59 @@
1
+ from .pet import (
2
+ BaseStatORM,
3
+ DiyStatsRangeORM,
4
+ Pet,
5
+ PetClass,
6
+ PetClassORM,
7
+ PetGenderCategory,
8
+ PetGenderORM,
9
+ PetMountTypeCategory,
10
+ PetMountTypeORM,
11
+ PetORM,
12
+ PetVipBuffCategory,
13
+ PetVipBuffORM,
14
+ SkillInPet,
15
+ SkillInPetORM,
16
+ YieldingEvORM,
17
+ )
18
+ from .pet_skin import PetSkin, PetSkinCategory, PetSkinCategoryORM, PetSkinORM
19
+ from .petbook import (
20
+ PetArchiveStoryBook,
21
+ PetArchiveStoryBookORM,
22
+ PetArchiveStoryEntry,
23
+ PetArchiveStoryEntryORM,
24
+ PetEncyclopediaEntry,
25
+ PetEncyclopediaEntryORM,
26
+ )
27
+ from .soulmark import Soulmark, SoulmarkORM, SoulmarkTagCategory, SoulmarkTagORM
28
+
29
+ __all__ = [
30
+ 'BaseStatORM',
31
+ 'DiyStatsRangeORM',
32
+ 'Pet',
33
+ 'PetArchiveStoryBook',
34
+ 'PetArchiveStoryBookORM',
35
+ 'PetArchiveStoryEntry',
36
+ 'PetArchiveStoryEntryORM',
37
+ 'PetClass',
38
+ 'PetClassORM',
39
+ 'PetEncyclopediaEntry',
40
+ 'PetEncyclopediaEntryORM',
41
+ 'PetGenderCategory',
42
+ 'PetGenderORM',
43
+ 'PetMountTypeCategory',
44
+ 'PetMountTypeORM',
45
+ 'PetORM',
46
+ 'PetSkin',
47
+ 'PetSkinCategory',
48
+ 'PetSkinCategoryORM',
49
+ 'PetSkinORM',
50
+ 'PetVipBuffCategory',
51
+ 'PetVipBuffORM',
52
+ 'SkillInPet',
53
+ 'SkillInPetORM',
54
+ 'Soulmark',
55
+ 'SoulmarkORM',
56
+ 'SoulmarkTagCategory',
57
+ 'SoulmarkTagORM',
58
+ 'YieldingEvORM',
59
+ ]