mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-05 23:51:21 +00:00
19 lines
769 B
Python
19 lines
769 B
Python
# Copyright (C) 2018 Avatao.com Innovative Learning Kft.
|
|
# All Rights Reserved. See LICENSE file for details.
|
|
|
|
from .fsm_base import FSMBase
|
|
|
|
|
|
class LinearFSM(FSMBase):
|
|
"""
|
|
This is a state machine for challenges with linear progression, consisting of
|
|
a number of steps specified in the constructor. It automatically sets up a single
|
|
action between states as such:
|
|
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.transitions = [{'trigger': 'step_{}'.format(int(index)+1), 'source': index, 'dest': str(int(index)+1)}
|
|
for index in self.states[:-1]]
|
|
super(LinearFSM, self).__init__()
|