From b9b39fb0f394cc94dc0c5348bcbbfe934845302b Mon Sep 17 00:00:00 2001 From: Miku AuahDark Date: Sun, 24 Nov 2024 10:12:25 +0800 Subject: [PATCH] Always give background and titles when completing goals. Fixes #32. --- npps4/system/achievement.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/npps4/system/achievement.py b/npps4/system/achievement.py index 7af278d..edef01a 100644 --- a/npps4/system/achievement.py +++ b/npps4/system/achievement.py @@ -10,6 +10,7 @@ from . import item_model from . import unit from . import reward +from .. import const from .. import data from .. import db from .. import idol @@ -792,6 +793,9 @@ async def give_achievement_reward( ) +BACKGROUND_TITLE_ADD_TYPE = (const.ADD_TYPE.BACKGROUND, const.ADD_TYPE.AWARD) + + async def process_achievement_reward( context: idol.BasicSchoolIdolContext, user: main.User, @@ -800,7 +804,13 @@ async def process_achievement_reward( ): for ach, reward_list in zip(achievements, rewardss): ach_info = await get_achievement_info(context, ach.achievement_id) - if ach_info is not None and ach_info.auto_reward_flag: - await give_achievement_reward(context, user, ach_info, reward_list) - await mark_achievement_reward_claimed(context, ach) + if ach_info is not None: + if ach_info.auto_reward_flag: + await give_achievement_reward(context, user, ach_info, reward_list) + await mark_achievement_reward_claimed(context, ach) + else: + # Backgrounds and titles are always gained, regardless of the auto_reward_flag + for r in reward_list: + if r.add_type in BACKGROUND_TITLE_ADD_TYPE: + await advanced.add_item(context, user, r) await context.db.main.flush()