#268_achievements #325
@ -1 +1 @@
|
||||
Subproject commit 0179ab1ed725c233c5844ee94ed51cad176d9c7e
|
||||
Subproject commit 440fb3bd353dce31a2408c977a3168e3cfc32f9a
|
@ -8,11 +8,13 @@ from cpl_translation import TranslatePipe
|
||||
from bot_core.configuration.server_settings import ServerSettings
|
||||
from bot_core.service.message_service import MessageService
|
||||
from bot_data.abc.achievement_repository_abc import AchievementRepositoryABC
|
||||
from bot_data.abc.user_repository_abc import UserRepositoryABC
|
||||
from bot_data.model.achievement import Achievement
|
||||
from bot_data.model.user import User
|
||||
from bot_data.model.user_got_achievement import UserGotAchievement
|
||||
from modules.achievements.achievement_attribute_resolver import AchievementAttributeResolver
|
||||
from modules.achievements.model.achievement_attribute import AchievementAttribute
|
||||
from modules.base.configuration.base_server_settings import BaseServerSettings
|
||||
|
||||
|
||||
class AchievementService:
|
||||
@ -22,6 +24,7 @@ class AchievementService:
|
||||
logger: LoggerABC,
|
||||
bot: DiscordBotServiceABC,
|
||||
achievements: AchievementRepositoryABC,
|
||||
users: UserRepositoryABC,
|
||||
db: DatabaseContextABC,
|
||||
message_service: MessageService,
|
||||
resolver: AchievementAttributeResolver,
|
||||
@ -31,6 +34,7 @@ class AchievementService:
|
||||
self._logger = logger
|
||||
self._bot = bot
|
||||
self._achievements = achievements
|
||||
self._users = users
|
||||
self._db = db
|
||||
self._message_service = message_service
|
||||
self._t = t
|
||||
@ -92,8 +96,15 @@ class AchievementService:
|
||||
|
||||
self._achievements.add_user_got_achievement(UserGotAchievement(user, achievement, user.server))
|
||||
self._db.save_changes()
|
||||
await self._give_user_xp(user)
|
||||
await self._send_achievement_notification(user.server.discord_id, user.discord_id, achievement.name)
|
||||
|
||||
async def _give_user_xp(self, user: User):
|
||||
settings: BaseServerSettings = self._config.get_configuration(f"BaseServerSettings_{user.server.discord_id}")
|
||||
user.xp += settings.xp_per_achievement
|
||||
self._users.update_user(user)
|
||||
self._db.save_changes()
|
||||
|
||||
async def _send_achievement_notification(self, guild_id: int, member_id: int, achievement_name: str):
|
||||
member = self._bot.get_guild(guild_id).get_member(member_id)
|
||||
|
||||
|
@ -16,6 +16,7 @@ class BaseServerSettings(ConfigurationModelABC):
|
||||
self._max_message_xp_per_hour: int = 0
|
||||
self._xp_per_ontime_hour: int = 0
|
||||
self._xp_per_event_participation: int = 0
|
||||
self._xp_per_achievement: int = 0
|
||||
self._afk_channel_ids: List[int] = List(int)
|
||||
self._afk_command_channel_id: int = 0
|
||||
self._help_command_reference_url: str = ""
|
||||
@ -51,6 +52,10 @@ class BaseServerSettings(ConfigurationModelABC):
|
||||
def xp_per_event_participation(self) -> int:
|
||||
return self._xp_per_event_participation
|
||||
|
||||
@property
|
||||
def xp_per_achievement(self) -> int:
|
||||
return self._xp_per_achievement
|
||||
|
||||
@property
|
||||
def afk_channel_ids(self) -> List[int]:
|
||||
return self._afk_channel_ids
|
||||
|
Loading…
Reference in New Issue
Block a user