diff --git a/kdb-bot/src/modules/achievements/achievement_service.py b/kdb-bot/src/modules/achievements/achievement_service.py index 9a5af106..d7b2a455 100644 --- a/kdb-bot/src/modules/achievements/achievement_service.py +++ b/kdb-bot/src/modules/achievements/achievement_service.py @@ -60,13 +60,20 @@ class AchievementService: self._operators = { "==": lambda value, expected_value: value == expected_value, "!=": lambda value, expected_value: value != expected_value, - "<=": lambda value, expected_value: value <= expected_value, - ">=": lambda value, expected_value: value >= expected_value, - "<": lambda value, expected_value: value < expected_value, - ">": lambda value, expected_value: value > expected_value, + "<=": lambda value, expected_value: self._num(value) <= self._num(expected_value), + ">=": lambda value, expected_value: self._num(value) >= self._num(expected_value), + "<": lambda value, expected_value: self._num(value) < self._num(expected_value), + ">": lambda value, expected_value: self._num(value) > self._num(expected_value), "contains": lambda value, expected_value: expected_value in value, } + @staticmethod + def _num(s: str): + try: + return int(s) + except ValueError: + return float(s) + def add_achievement_attribute(self, atr: AchievementAttribute): self._attributes.add(atr)