Fixed achievement_service #1.1.0.rc2

This commit is contained in:
Sven Heidemann 2023-08-16 16:47:48 +02:00
parent 4e32414f48
commit 44f6b36347

View File

@ -60,13 +60,20 @@ class AchievementService:
self._operators = { 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: self._num(value) <= self._num(expected_value),
">=": lambda value, expected_value: value >= expected_value, ">=": lambda value, expected_value: self._num(value) >= self._num(expected_value),
"<": lambda value, expected_value: value < expected_value, "<": lambda value, expected_value: self._num(value) < self._num(expected_value),
">": lambda value, expected_value: value > expected_value, ">": lambda value, expected_value: self._num(value) > self._num(expected_value),
"contains": lambda value, expected_value: expected_value in 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): def add_achievement_attribute(self, atr: AchievementAttribute):
self._attributes.add(atr) self._attributes.add(atr)