From 41bd6e45e7e0b0009e278972667239501fa7d778 Mon Sep 17 00:00:00 2001 From: Yeol <136407746+13m0n4de@users.noreply.github.com> Date: Fri, 1 Nov 2024 03:39:13 +0800 Subject: [PATCH] =?UTF-8?q?fix(base):=20=E9=87=8D=E7=BD=AE=20`ElectronFlow?= =?UTF-8?q?Goal`=20=E4=B8=AD=E7=9A=84=20`failed`=20=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- base/wireworld/app/models/goal.py | 7 +++++++ base/wireworld/app/services/challenge.py | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/base/wireworld/app/models/goal.py b/base/wireworld/app/models/goal.py index 6d4a9ce..bd79b35 100644 --- a/base/wireworld/app/models/goal.py +++ b/base/wireworld/app/models/goal.py @@ -23,6 +23,9 @@ def update(self, world: Wireworld) -> bool: def is_achieved(self) -> bool: return self.current_matches >= self.required_matches + def reset(self): + self.current_matches = 0 + class SpecificPeriodGoal(Goal): type: Literal["SpecificPeriodGoal"] @@ -65,5 +68,9 @@ def update(self, world: Wireworld) -> bool: def is_achieved(self) -> bool: return not self.failed and self.current_matches >= self.required_matches + def reset(self): + self.current_matches = 0 + self.failed = False + GoalUnion = Union[SpecificPeriodGoal, ElectronFlowGoal] diff --git a/base/wireworld/app/services/challenge.py b/base/wireworld/app/services/challenge.py index 838eb7a..2e151a4 100644 --- a/base/wireworld/app/services/challenge.py +++ b/base/wireworld/app/services/challenge.py @@ -134,7 +134,7 @@ def reset(cls): ) cls._setup_initial_state() for goal in cls.config.goals: - goal.current_matches = 0 + goal.reset() cls.completed = False @classmethod