The status exposes "locked" which has four fields that I've seen as far.
In a way this already exists in mafia, via "currentRound" and "handlingChoice", but it is a series of checks and it doesn't actually tell you if the choice being handled can be walked away from.
The main concern I have about this would be that mafia might not update the locked state if kol doesn't tell us to. Namely, if there's a http error when refreshing api status or when a fight win page would've been displayed but wasn't and thus we didn't get informed to refresh the status.
It might be an idea to update the state ourselves if the state mismatched a page we received from the server. Such as we're told we're locked in a fight, but we can load the main page.
As for the actual exposure, a proxy class perhaps?
So
Although, with walkaway choices. Feels a bit like that should be a one-line piece of code. Like "is_stuck_in_state" instead of "state != LockState.none && state != LockState.walkway_choice"
Regardless, this is more of an idea and it could be that we instead expose this as a function that will make a http request to fetch our state. Perhaps do both, with a "getLockState(boolean ignoreCache)" where "ignoreCache" is false by default.
Code:
"choice"
false
"fight"
"cancelable-choice"
In a way this already exists in mafia, via "currentRound" and "handlingChoice", but it is a series of checks and it doesn't actually tell you if the choice being handled can be walked away from.
The main concern I have about this would be that mafia might not update the locked state if kol doesn't tell us to. Namely, if there's a http error when refreshing api status or when a fight win page would've been displayed but wasn't and thus we didn't get informed to refresh the status.
It might be an idea to update the state ourselves if the state mismatched a page we received from the server. Such as we're told we're locked in a fight, but we can load the main page.
As for the actual exposure, a proxy class perhaps?
Code:
get_lock_state()
none
fight
choice
walkaway_choice
So
Code:
function taskFinished() {
return getLockState() == LockState.choice || getLockState() == LockState.none;
}
if (!taskFinished()) {
throw "Unexpectably still handling a " + getLockState() + "!";
}
Although, with walkaway choices. Feels a bit like that should be a one-line piece of code. Like "is_stuck_in_state" instead of "state != LockState.none && state != LockState.walkway_choice"
Regardless, this is more of an idea and it could be that we instead expose this as a function that will make a http request to fetch our state. Perhaps do both, with a "getLockState(boolean ignoreCache)" where "ignoreCache" is false by default.