Skip to content

Commit

Permalink
Add shop free conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
narumi147 committed Jul 6, 2024
1 parent f312985 commit d25abde
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/core/nice/bgm.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def get_nice_bgm_entity_from_raw(
)
}
nice_bgm.shop = get_nice_shop(
region, bgm_entity.mstShop, [], {}, item_map, GiftData([], {}), [], []
region, bgm_entity.mstShop, [], {}, item_map, GiftData([], {}), [], [], []
)

return nice_bgm
Expand Down
1 change: 1 addition & 0 deletions app/core/nice/event/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ async def get_nice_event(
item_map,
gift_data,
raw_event.mstCommonConsume,
raw_event.mstCommonRelease,
raw_event.mstShopRelease,
)
for shop in raw_event.mstShop
Expand Down
7 changes: 7 additions & 0 deletions app/core/nice/event/shop.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from sqlalchemy.ext.asyncio import AsyncConnection

from ....config import Settings
from ....core.nice.common_release import get_nice_common_releases
from ....core.nice.gift import GiftData, get_nice_common_consume, get_nice_gifts
from ....core.nice.item import get_nice_item_from_raw
from ....core.raw import get_raw_mstShop, get_shop_entities
Expand All @@ -29,6 +30,7 @@
)
from ....schemas.raw import (
MstCommonConsume,
MstCommonRelease,
MstGift,
MstSetItem,
MstShop,
Expand Down Expand Up @@ -79,6 +81,7 @@ def get_nice_shop(
item_map: dict[int, NiceItem],
gift_data: GiftData,
raw_consumes: list[MstCommonConsume],
raw_releases: list[MstCommonRelease],
shop_releases: list[MstShopRelease],
) -> NiceShop:
shop_item_id = get_shop_cost_item_id(shop)
Expand Down Expand Up @@ -154,6 +157,9 @@ def get_nice_shop(
payType=PAY_TYPE_NAME[shop.payType],
cost=cost,
consumes=common_consumes,
freeShopConds=get_nice_common_releases(raw_releases, shop.freeShopCondId),
freeShopReleaseDate=shop.freeShopReleaseDate,
freeShopCondMessage=shop.freeShopCondMessage,
purchaseType=PURCHASE_TYPE_NAME[shop.purchaseType],
targetIds=shop.targetIds,
itemSet=shop_set_items,
Expand Down Expand Up @@ -217,6 +223,7 @@ async def get_nice_shops_from_raw(
shop_scripts=script_map,
item_map=item_map,
raw_consumes=shop.mstCommonConsume,
raw_releases=shop.mstCommonRelease,
gift_data=gift_data,
shop_releases=shop.mstShopRelease,
)
Expand Down
12 changes: 12 additions & 0 deletions app/core/raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -1081,6 +1081,7 @@ async def get_event_entity(conn: AsyncConnection, event_id: int) -> EventEntity:
shop_ids = [shop.id for shop in shops]
shop_scripts = await fetch.get_all_multiple(conn, MstShopScript, shop_ids)
shop_releases = await fetch.get_all_multiple(conn, MstShopRelease, shop_ids)
shop_release_ids = {shop.freeShopCondId for shop in shops if shop.freeShopCondId}

rewards = await fetch.get_all(conn, MstEventReward, event_id)

Expand Down Expand Up @@ -1162,6 +1163,7 @@ async def get_event_entity(conn: AsyncConnection, event_id: int) -> EventEntity:
| fortification_release_ids
| command_assist_release_ids
| event_svt_release_ids
| shop_release_ids
)
common_releases = await fetch.get_all_multiple(
conn, MstCommonRelease, common_release_ids
Expand Down Expand Up @@ -1474,6 +1476,11 @@ async def get_shop_entities(
conn, MstCommonConsume, common_consume_ids
)

common_release_ids = {shop.freeShopCondId for shop in shops if shop.freeShopCondId}
common_releases = await fetch.get_all_multiple(
conn, MstCommonRelease, common_release_ids
)

set_item_ids = {
set_id
for shop in shops
Expand Down Expand Up @@ -1538,6 +1545,11 @@ async def get_shop_entities(
if shop.payType == PayType.COMMON_CONSUME
else []
),
mstCommonRelease=[
release
for release in common_releases
if release.id == shop.freeShopCondId
],
mstGift=gifts,
mstGiftAdd=gift_adds,
)
Expand Down
3 changes: 3 additions & 0 deletions app/schemas/nice.py
Original file line number Diff line number Diff line change
Expand Up @@ -1695,6 +1695,9 @@ class NiceShop(BaseModelORJson):
consumes: list[NiceCommonConsume] = Field(
..., title="Common Consume", description="If payType is commonConsume"
)
freeShopConds: list[NiceCommonRelease] = Field(..., title="Free Shop Conditions")
freeShopReleaseDate: int | None = None
freeShopCondMessage: str | None = None
purchaseType: NicePurchaseType = Field(
..., title="Reward Type", description="Type of items to be received."
)
Expand Down
1 change: 1 addition & 0 deletions app/schemas/raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -2348,6 +2348,7 @@ class ShopEntity(BaseModelORJson):
mstGift: list[MstGift]
mstGiftAdd: list[MstGiftAdd]
mstCommonConsume: list[MstCommonConsume]
mstCommonRelease: list[MstCommonRelease]


class EventMissionEntity(BaseModelORJson):
Expand Down

0 comments on commit d25abde

Please sign in to comment.