mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-12-23 03:11:55 +00:00
Fix LinearFSM not being compatible with controller stuff
This commit is contained in:
parent
96b4e314a9
commit
cb4ba563e9
@ -1,6 +1,8 @@
|
||||
# Copyright (C) 2018 Avatao.com Innovative Learning Kft.
|
||||
# All Rights Reserved. See LICENSE file for details.
|
||||
|
||||
from transitions import State
|
||||
|
||||
from .fsm_base import FSMBase
|
||||
|
||||
|
||||
@ -13,17 +15,17 @@ class LinearFSM(FSMBase):
|
||||
(0) -- step_1 --> (1) -- step_2 --> (2) -- step_3 --> (3) ... and so on
|
||||
"""
|
||||
def __init__(self, number_of_steps):
|
||||
self.states = list(map(str, range(number_of_steps)))
|
||||
self.states = [State(name=str(index)) for index in range(number_of_steps)]
|
||||
self.transitions = []
|
||||
for index in self.states[:-1]:
|
||||
for state in self.states[:-1]:
|
||||
self.transitions.append({
|
||||
'trigger': f'step_{int(index)+1}',
|
||||
'source': index,
|
||||
'dest': str(int(index)+1)
|
||||
'trigger': f'step_{int(state.name)+1}',
|
||||
'source': state.name,
|
||||
'dest': str(int(state.name)+1)
|
||||
})
|
||||
self.transitions.append({
|
||||
'trigger': 'step_next',
|
||||
'source': index,
|
||||
'dest': str(int(index)+1)
|
||||
'source': state.name,
|
||||
'dest': str(int(state.name)+1)
|
||||
})
|
||||
super(LinearFSM, self).__init__()
|
||||
|
Loading…
Reference in New Issue
Block a user