Source code for yracing.car.fsm

from yyagl.gameobject import FsmColleague
from yracing.car.ai import CarResultsAi
from .event import InputBuilder


[docs]class CarFsm(FsmColleague): def __init__(self, mediator, car_props, players): FsmColleague.__init__(self, mediator) self.defaultTransitions = {'Loading': ['Countdown'], 'Countdown': ['Play'], 'Play': ['Waiting', 'Results'], 'Waiting': ['Results']} self.cprops = car_props self.__players = players
[docs] def enterPlay(self): self.mediator.audio.on_play()
[docs] def enterWaiting(self): state = self.getCurrentOrNextState() #self.mediator.event.input_bld = InputBuilder.create(state, has_j) self.mediator.ai.destroy() self.mediator.ai = CarResultsAi(self.mediator, self.cprops, self.__players) self.mediator.gui.hide()
#self.mediator.gui.panel.enter_waiting()
[docs]class CarPlayerFsm(CarFsm):
[docs] def enterWaiting(self): CarFsm.enterWaiting(self) self.mediator.gui.panel.enter_waiting()
[docs] def enterResults(self): self.mediator.gui.panel.exit_waiting()