Added last_single_ontime_hours achievement logic #268_achievements
This commit is contained in:
parent
189128f0d3
commit
a71e3e4720
@ -44,3 +44,7 @@ class AchievementAttributeResolver:
|
||||
def get_played_on_game_server(self, user: User) -> List[str]:
|
||||
joins = self._user_joined_game_server.get_user_joined_game_servers_by_user_id(user.id)
|
||||
return joins.select(lambda x: x.game_server.name)
|
||||
|
||||
def get_last_ontime_hours(self, user: User) -> int:
|
||||
ujvs = self._user_joined_voice_channels.get_user_joined_voice_channels_by_user_id(user.id)
|
||||
return int(str(ujvs.max(lambda join: (join.leaved_on - join.joined_on).total_seconds() / 3600)))
|
||||
|
@ -48,7 +48,9 @@ class AchievementService:
|
||||
AchievementAttribute(
|
||||
"played_on_game_server", lambda user: resolver.get_played_on_game_server(user), "GameServer"
|
||||
),
|
||||
AchievementAttribute("last_single_ontime_hours", lambda user: user.level, "GameServer"),
|
||||
AchievementAttribute(
|
||||
"last_single_ontime_hours", lambda user: resolver.get_last_ontime_hours(user), "number"
|
||||
),
|
||||
]
|
||||
)
|
||||
|
||||
@ -62,6 +64,9 @@ class AchievementService:
|
||||
"contains": lambda value, expected_value: expected_value in value,
|
||||
}
|
||||
|
||||
def add_achievement_attribute(self, atr: AchievementAttribute):
|
||||
self._attributes.add(atr)
|
||||
|
||||
def get_operators(self) -> list[str]:
|
||||
return [x for x in self._operators.keys()]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user