Skip to content

Commit 56b2efa

Browse files
committed
Added grand graph
1 parent aa90f05 commit 56b2efa

File tree

11 files changed

+256
-2
lines changed

11 files changed

+256
-2
lines changed

app/core/nice/class_board.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ async def get_nice_class_board(
214214
condType=COND_TYPE_NAME[mstClassBoardBase.condType],
215215
condTargetId=mstClassBoardBase.condTargetId,
216216
condNum=mstClassBoardBase.condNum,
217-
parentClassBoardBaseId=mstClassBoardBase.parentClassBoardBaseId,
217+
parentClassBoardBaseId=mstClassBoardBase.parentClassBoardBaseId or 0,
218218
classes=[
219219
get_nice_class_board_class(class_board_class)
220220
for class_board_class in raw_class_board.mstClassBoardClass

app/core/nice/grand_graph.py

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
from sqlalchemy.ext.asyncio import AsyncConnection
2+
3+
from ...config import Settings
4+
from ...schemas.common import Language, Region
5+
from ...schemas.enums import get_class_name
6+
from ...schemas.gameenums import COND_TYPE_NAME
7+
from ...schemas.nice import NiceGrandGraph, NiceGrandGraphDetail
8+
from ...schemas.raw import MstGrandGraph, MstGrandGraphDetail
9+
from .. import raw
10+
from .item import get_nice_item_amount, get_nice_item_from_raw
11+
12+
13+
settings = Settings()
14+
15+
16+
def get_nice_grand_graph_detail(detail: MstGrandGraphDetail) -> NiceGrandGraphDetail:
17+
return NiceGrandGraphDetail(
18+
baseClassId=detail.baseClassId,
19+
grandClassId=detail.grandClassId,
20+
baseClass=get_class_name(detail.baseClassId),
21+
grandClass=get_class_name(detail.grandClassId),
22+
adjustHp=detail.adjustHp,
23+
adjustAtk=detail.adjustAtk,
24+
condType=COND_TYPE_NAME[detail.condType],
25+
condTargetId=detail.condTargetId,
26+
condNum=detail.condNum,
27+
)
28+
29+
30+
async def get_nice_grand_graph(
31+
conn: AsyncConnection, region: Region, grand_graph_id: int, lang: Language
32+
) -> NiceGrandGraph:
33+
raw_grand_graph = await raw.get_grand_graph_entity(conn, grand_graph_id)
34+
35+
mstGrandGraph = raw_grand_graph.mstGrandGraph
36+
37+
items_map = {item.id: item for item in raw_grand_graph.mstItem}
38+
39+
return NiceGrandGraph(
40+
id=mstGrandGraph.id,
41+
name=mstGrandGraph.name,
42+
nameShort=mstGrandGraph.nameShort,
43+
nameShortEnglish=mstGrandGraph.nameShortEnglish,
44+
classBoardBaseId=mstGrandGraph.classBoardBaseId,
45+
condSvtLv=mstGrandGraph.condSvtLv,
46+
condSkillLv=mstGrandGraph.condSkillLv,
47+
condType=COND_TYPE_NAME[mstGrandGraph.condType],
48+
condTargetId=mstGrandGraph.condTargetId,
49+
condNum=mstGrandGraph.condNum,
50+
removeItems=get_nice_item_amount(
51+
[
52+
get_nice_item_from_raw(region, items_map[itemId], lang)
53+
for itemId in mstGrandGraph.removeItemIds
54+
],
55+
mstGrandGraph.removeItemNums,
56+
),
57+
details=[
58+
get_nice_grand_graph_detail(detail)
59+
for detail in raw_grand_graph.mstGrandGraphDetail
60+
if detail.grandGraphId == mstGrandGraph.id
61+
],
62+
)
63+
64+
65+
async def get_all_nice_grand_graphs(
66+
conn: AsyncConnection,
67+
region: Region,
68+
mstGrandGraphs: list[MstGrandGraph],
69+
lang: Language,
70+
) -> list[NiceGrandGraph]: # pragma: no cover
71+
return [
72+
await get_nice_grand_graph(conn, region, mstGrandGraph.id, lang)
73+
for mstGrandGraph in mstGrandGraphs
74+
]

app/core/raw.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
FunctionEntity,
5353
FunctionEntityNoReverse,
5454
GachaEntity,
55+
GrandGraphEntity,
5556
ItemEntity,
5657
MasterMissionEntity,
5758
MstBattleMasterImage,
@@ -131,6 +132,8 @@
131132
MstFuncGroup,
132133
MstGift,
133134
MstGiftAdd,
135+
MstGrandGraph,
136+
MstGrandGraphDetail,
134137
MstHeelPortrait,
135138
MstIllustrator,
136139
MstImagePartsGroup,
@@ -1703,6 +1706,23 @@ async def get_class_board_entity(
17031706
)
17041707

17051708

1709+
async def get_grand_graph_entity(
1710+
conn: AsyncConnection, grand_graph_id: int
1711+
) -> GrandGraphEntity:
1712+
graph_db = await fetch.get_one(conn, MstGrandGraph, grand_graph_id)
1713+
if not graph_db:
1714+
raise HTTPException(status_code=404, detail="Grand Graph not found")
1715+
1716+
details = await fetch.get_all(conn, MstGrandGraphDetail, grand_graph_id)
1717+
items = await fetch.get_all_multiple(conn, MstItem, graph_db.removeItemIds)
1718+
1719+
return GrandGraphEntity(
1720+
mstGrandGraph=graph_db,
1721+
mstGrandGraphDetail=details,
1722+
mstItem=items,
1723+
)
1724+
1725+
17061726
async def get_gacha_entity(conn: AsyncConnection, gacha_id: int) -> GachaEntity:
17071727
gacha_entity = await gacha.get_gacha_entity(conn, gacha_id)
17081728
if gacha_entity is None:

app/db/helpers/fetch.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@
8686
mstGacha,
8787
mstGift,
8888
mstGiftAdd,
89+
mstGrandGraph,
90+
mstGrandGraphDetail,
8991
mstHeelPortrait,
9092
mstIllustrator,
9193
mstImagePartsGroup,
@@ -221,6 +223,8 @@
221223
MstGacha,
222224
MstGift,
223225
MstGiftAdd,
226+
MstGrandGraph,
227+
MstGrandGraphDetail,
224228
MstHeelPortrait,
225229
MstIllustrator,
226230
MstImagePartsGroup,
@@ -304,6 +308,7 @@
304308
MstSvtAdd: (mstSvtAdd, mstSvtAdd.c.svtId),
305309
MstEventDigging: (mstEventDigging, mstEventDigging.c.eventId),
306310
MstClassBoardBase: (mstClassBoardBase, mstClassBoardBase.c.id),
311+
MstGrandGraph: (mstGrandGraph, mstGrandGraph.c.id),
307312
MstGacha: (mstGacha, mstGacha.c.id),
308313
}
309314

@@ -569,6 +574,11 @@ async def get_one(
569574
mstClassBoardSquare.c.classBoardBaseId,
570575
mstClassBoardSquare.c.id,
571576
),
577+
MstGrandGraphDetail: (
578+
mstGrandGraphDetail,
579+
mstGrandGraphDetail.c.grandGraphId,
580+
mstGrandGraphDetail.c.baseClassId,
581+
),
572582
MstHeelPortrait: (
573583
mstHeelPortrait,
574584
mstHeelPortrait.c.eventId,
@@ -838,6 +848,7 @@ async def get_all_multiple(
838848
AssetStorageLine: (AssetStorage, AssetStorage.c.path),
839849
MstSvt: (mstSvt, mstSvt.c.id),
840850
MstClassBoardBase: (mstClassBoardBase, mstClassBoardBase.c.id),
851+
MstGrandGraph: (mstGrandGraph, mstGrandGraph.c.id),
841852
MstGacha: (mstGacha, mstGacha.c.id),
842853
MstConstant: (mstConstant, mstConstant.c.name),
843854
}

app/models/raw.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2780,6 +2780,38 @@
27802780
)
27812781

27822782

2783+
mstGrandGraph = Table(
2784+
"mstGrandGraph",
2785+
metadata,
2786+
Column("id", Integer, primary_key=True),
2787+
Column("name", String),
2788+
Column("nameShort", String),
2789+
Column("nameShortEnglish", String),
2790+
Column("classBoardBaseId", Integer),
2791+
Column("condSvtLv", Integer),
2792+
Column("condSkillLv", Integer),
2793+
Column("condType", Integer),
2794+
Column("condTargetId", Integer),
2795+
Column("condNum", Integer),
2796+
Column("removeItemIds", ARRAY(Integer)),
2797+
Column("removeItemNums", ARRAY(Integer)),
2798+
)
2799+
2800+
2801+
mstGrandGraphDetail = Table(
2802+
"mstGrandGraphDetail",
2803+
metadata,
2804+
Column("grandGraphId", Integer, index=True),
2805+
Column("baseClassId", Integer),
2806+
Column("grandClassId", Integer),
2807+
Column("adjustHp", Integer),
2808+
Column("adjustAtk", Integer),
2809+
Column("condType", Integer),
2810+
Column("condTargetId", Integer),
2811+
Column("condNum", Integer),
2812+
)
2813+
2814+
27832815
mstFuncDisp = Table(
27842816
"mstFuncDisp",
27852817
metadata,
@@ -2973,6 +3005,7 @@
29733005
[mstEventAlloutBattle],
29743006
[mstClassBoardBase, mstClassBoardClass, mstClassBoardLine, mstFuncDisp],
29753007
[mstClassBoardLock, mstClassBoardSquare],
3008+
[mstGrandGraph, mstGrandGraphDetail],
29763009
[mstFuncTypeDetail, mstBuffTypeDetail],
29773010
[mstGacha, mstGachaStoryAdjust, mstGachaSub, viewGachaFeaturedSvt],
29783011
[mstItemDropEfficiency],

app/routers/nice.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
enemy_master,
1313
gacha,
1414
gift,
15+
grand_graph,
1516
item,
1617
mc,
1718
mm,
@@ -47,6 +48,7 @@
4748
NiceEventMission,
4849
NiceGacha,
4950
NiceGift,
51+
NiceGrandGraph,
5052
NiceItem,
5153
NiceMasterMission,
5254
NiceMysticCode,
@@ -1090,6 +1092,26 @@ async def get_class_board(
10901092
)
10911093

10921094

1095+
@router.get(
1096+
"/{region}/grand-graph/{grand_graph_id}",
1097+
summary="Get Grand Graph data",
1098+
response_description="Nice Grand Graph Entity",
1099+
response_model=NiceGrandGraph,
1100+
response_model_exclude_unset=True,
1101+
responses=get_error_code([404]),
1102+
)
1103+
@cache()
1104+
async def get_grand_graph(
1105+
region: Region,
1106+
grand_graph_id: int,
1107+
lang: Language = Depends(language_parameter),
1108+
) -> Response:
1109+
async with get_db(region) as conn:
1110+
return item_response(
1111+
await grand_graph.get_nice_grand_graph(conn, region, grand_graph_id, lang)
1112+
)
1113+
1114+
10931115
@router.get(
10941116
"/{region}/gift/{gift_id}",
10951117
summary="Get Gift data",

app/routers/raw.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
EventMissionEntity,
2323
FunctionEntity,
2424
GachaEntity,
25+
GrandGraphEntity,
2526
ItemEntity,
2627
MasterMissionEntity,
2728
MstEventAlloutBattle,
@@ -921,6 +922,27 @@ async def get_class_board(
921922
return item_response(class_board_entity)
922923

923924

925+
@router.get(
926+
"/{region}/grand-graph/{grand_graph_id}",
927+
summary="Get Grand Graph data",
928+
response_description="Grand Graph entity",
929+
response_model=GrandGraphEntity,
930+
response_model_exclude_unset=True,
931+
responses=get_error_code([404]),
932+
)
933+
@cache()
934+
async def get_grand_graph(
935+
region: Region,
936+
grand_graph_id: int,
937+
) -> Response:
938+
"""
939+
Get Grand Graph info from ID
940+
"""
941+
async with get_db(region) as conn:
942+
grand_graph_entity = await raw.get_grand_graph_entity(conn, grand_graph_id)
943+
return item_response(grand_graph_entity)
944+
945+
924946
@router.get(
925947
"/{region}/gacha/{gacha_id}",
926948
summary="Get Banner data",

app/schemas/enums.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,6 @@ class SvtClass(StrEnum):
387387
grandBerserker = "grandBerserker"
388388

389389

390-
391390
CLASS_NAME: dict[int, SvtClass] = {
392391
1: SvtClass.saber,
393392
2: SvtClass.archer,

app/schemas/nice.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3207,6 +3207,34 @@ class NiceClassBoard(BaseModelORJson):
32073207
lines: list[NiceClassBoardLine]
32083208

32093209

3210+
class NiceGrandGraphDetail(BaseModelORJson):
3211+
# grandGraphId: int
3212+
baseClassId: int
3213+
grandClassId: int
3214+
baseClass: SvtClass | str
3215+
grandClass: SvtClass | str
3216+
adjustHp: int
3217+
adjustAtk: int
3218+
condType: NiceCondType
3219+
condTargetId: int
3220+
condNum: int
3221+
3222+
3223+
class NiceGrandGraph(BaseModelORJson):
3224+
id: int
3225+
name: str
3226+
nameShort: str
3227+
nameShortEnglish: str
3228+
classBoardBaseId: int
3229+
condSvtLv: int
3230+
condSkillLv: int
3231+
condType: NiceCondType
3232+
condTargetId: int
3233+
condNum: int
3234+
removeItems: list[NiceItemAmount]
3235+
details: list[NiceGrandGraphDetail]
3236+
3237+
32103238
class NiceFuncTypeDetail(BaseModelORJson):
32113239
funcType: NiceFuncType
32123240
ignoreValueUp: bool

app/schemas/raw.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2607,6 +2607,32 @@ class MstClassBoardSquare(BaseModelORJson):
26072607
priority: int
26082608

26092609

2610+
class MstGrandGraph(BaseModelORJson):
2611+
id: int
2612+
name: str
2613+
nameShort: str
2614+
nameShortEnglish: str
2615+
classBoardBaseId: int
2616+
condSvtLv: int
2617+
condSkillLv: int
2618+
condType: int
2619+
condTargetId: int
2620+
condNum: int
2621+
removeItemIds: list[int]
2622+
removeItemNums: list[int]
2623+
2624+
2625+
class MstGrandGraphDetail(BaseModelORJson):
2626+
grandGraphId: int
2627+
baseClassId: int
2628+
grandClassId: int
2629+
adjustHp: int
2630+
adjustAtk: int
2631+
condType: int
2632+
condTargetId: int
2633+
condNum: int
2634+
2635+
26102636
class MstFuncDisp(BaseModelORJson):
26112637
funcIds: list[int]
26122638
id: int
@@ -2637,6 +2663,12 @@ class ClassBoardEntity(BaseModelORJson):
26372663
# mstFuncDisp: list[MstFuncDisp]
26382664

26392665

2666+
class GrandGraphEntity(BaseModelORJson):
2667+
mstGrandGraph: MstGrandGraph
2668+
mstGrandGraphDetail: list[MstGrandGraphDetail]
2669+
mstItem: list[MstItem]
2670+
2671+
26402672
class GachaEntity(BaseModelORJson):
26412673
mstGacha: MstGacha
26422674
mstGachaStoryAdjust: list[MstGachaStoryAdjust]

0 commit comments

Comments
 (0)