Professional Documents
Culture Documents
Recipe Pseudocode
Recipe Pseudocode
InitRecipeService
Takes a priority number, returns True.
End of InitRecipeService
PostRecipeService
Takes an ES_Event_t, returns boolean outcome of ES_PostToService
End of PostRecipeService
RunRecipeService
The EventType field of ThisEvent will be one of: ES_INIT,
BUTTON2_PRESS, ES_TIMEOUT, RECIPE_TAKE_NEXT_STEP,
RECIPE_STEP_COMPLETE
CurrentState is:
InitP
Set CurrentState to RecipeSelection
RecipeSelection
ThisEvent is BUTTON2_PRESS
Set RecipeIndex to CURRY_RECIPE_INDEX
Set CurrentRecipe to Recipes[RecipeIndex]
Initialize RecipeCommandIndex to 0
TakeRecipeStep
ThisEvent is ES_TIMEOUT
if GAME_TIMER_COUNT <= GameTimerNum
Post GAME_ENDED to MasterSM
Set CurrentState to RecipeSelection
else
Restart GAME_TIMER
ThisEvent is RECIPE_TAKE_NEXT_STEP
Post to MasterSM next recipe step
(CurrentRecipe[RecipeCommandIndex])
Increment RecipeCommandIndex
Set CurrentState to ExecutingRecipeStep
ExecutingRecipeStep
ThisEvent is RECIPE_STEP_COMPLETE
If RecipeCommandIndex is same as max steps in that recipe
Set CurrentState to RecipeSelection
else
Post to self RECIPE_TAKE_NEXT_STEP to start next step
Set CurrentState to TakeRecipeStep
ThisEvent is ES_TIMEOUT
ThisEvent is ES_TIMEOUT
if GAME_TIMER_COUNT <= GameTimerNum
Post GAME_ENDED to MasterSM
Set CurrentState to RecipeSelection
else
Restart GAME_TIMER
Return ES_NO_EVENT
End of RunRecipeService