From 996bda2298783fce32504ca08cf9ad0359c7f5b5 Mon Sep 17 00:00:00 2001 From: break27 Date: Tue, 2 Jun 2026 18:26:13 +0800 Subject: [PATCH] update: added 'force' argument to 'do' in ActionFlow --- src/common/actionflow.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/common/actionflow.py b/src/common/actionflow.py index 9ff4ab2..4814520 100644 --- a/src/common/actionflow.py +++ b/src/common/actionflow.py @@ -21,14 +21,17 @@ class ActionFlow: self.actions: list[type[Action]] = [] self.on: list[bool] = [] - def do(self, action: type[Action]): - name = action.__name__ - index = self.indices.get(name) - assert index is not None, "Action '%s' is not registered" % name - - if self.on[index]: raise Unavailable(name) - if self.on[index] is None: raise NotAllowed(name) - self.on[index] = bool(self.actions[index].prepare()) + def do(self, action: type[Action], force=False): + try: + name = action.__name__ + index = self.indices.get(name) + assert index is not None, "Action '%s' is not registered" % name + + if self.on[index]: raise Unavailable(name) + if self.on[index] is None: raise NotAllowed(name) + self.on[index] = bool(self.actions[index].prepare()) + except Exception as e: + if force: raise e def react(self): while any(self.on):