Skip to content

Commit

Permalink
fix(base): 重置 ElectronFlowGoal 中的 failed 状态
Browse files Browse the repository at this point in the history
  • Loading branch information
13m0n4de committed Oct 31, 2024
1 parent 4337fb1 commit 41bd6e4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions base/wireworld/app/models/goal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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]
2 changes: 1 addition & 1 deletion base/wireworld/app/services/challenge.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 41bd6e4

Please sign in to comment.