Enum initiative_core::app::command::tutorial::TutorialCommand
source · pub enum TutorialCommand {
Show 19 variants
Introduction,
GeneratingLocations,
SavingLocations,
GeneratingCharacters {
inn: ThingRef,
},
GeneratingAlternatives {
inn: ThingRef,
},
ViewingAlternatives {
inn: ThingRef,
npc_name: String,
},
EditingCharacters {
inn: ThingRef,
npc: ThingRef,
},
TheJournal {
inn: ThingRef,
npc: ThingRef,
},
LoadingFromJournal {
inn: ThingRef,
npc: ThingRef,
},
SrdReference {
inn: ThingRef,
npc: ThingRef,
},
SrdReferenceLists {
inn: ThingRef,
npc: ThingRef,
},
RollingDice {
inn: ThingRef,
npc: ThingRef,
},
DeletingThings {
inn: ThingRef,
npc: ThingRef,
},
AdvancingTime {
inn: ThingRef,
npc: ThingRef,
},
CheckingTheTime {
inn: ThingRef,
npc: ThingRef,
},
Conclusion {
inn: ThingRef,
npc: ThingRef,
},
Cancel {
inn: Option<ThingRef>,
npc: Option<ThingRef>,
},
Resume,
Restart {
inn: Option<ThingRef>,
npc: Option<ThingRef>,
},
}
Expand description
An enum representing each possible state of the tutorial. The Introduction variant is mapped to
the tutorial
command, while each other variant is registered as a CommandAlias
upon
completion of the previous step.
What’s up with the data fields? There is some dynamically generated content that gets carried along from one tutorial step to the next. In order for the “Deleting Things” step to drop the name of the randomly generated inn, it needs to be persisted through the entire process.
While the tutorial is active, every user input is interpreted as a TutorialCommand
by
registering a CommandAlias::StrictWildcard
. TutorialCommand::run
then re-parses the user
input, displaying the result in all cases. If the input parsed to the correct command, it
advances the tutorial to the next step and appends its own output to the end of the command
output. If the user did something different, the command takes effect anyway, and a brief note
about the tutorial still being active is appended to the output.
Variants§
Introduction
GeneratingLocations
SavingLocations
GeneratingCharacters
GeneratingAlternatives
ViewingAlternatives
EditingCharacters
TheJournal
LoadingFromJournal
SrdReference
SrdReferenceLists
RollingDice
DeletingThings
AdvancingTime
CheckingTheTime
Conclusion
Cancel
Resume
Restart
Implementations§
source§impl TutorialCommand
impl TutorialCommand
sourcefn output(
&self,
command_output: Option<Result<String, String>>,
app_meta: &mut AppMeta,
) -> Result<String, String>
fn output( &self, command_output: Option<Result<String, String>>, app_meta: &mut AppMeta, ) -> Result<String, String>
Generate the output to be displayed to the user when invoking TutorialCommand::run
. This
is done in a separate method because it can be invoked in two ways: by satisfying a
tutorial step and advancing to the next step, and by running the resume
command to get a
reminder prompt indicating what the user is supposed to do.
Very counterintuitively, there is an off-by-one state going on here. The resume
command doesn’t have access to the current step, only the next step, which is
registered as an alias and monitoring the app state until its prompt is satisfied.
Self::Resume
, then, runs on that registered alias, while the various registered
variants work around this limitation by running the output
method of the alias after
registration.
That was the reasoning, anyhow. Whether or not it was a good decision is left to the judgement of the reader.
sourcefn is_correct_command(&self, command: Option<&CommandType>) -> bool
fn is_correct_command(&self, command: Option<&CommandType>) -> bool
Is this the command that is required to advance to the next step of the tutorial? This is
determined not by a string match but by validating the parsed result, eg. time
and now
are equally recognized for the CheckingTheTime step because they both parse to
CommandType::Time(TimeCommand::Now)
.
Trait Implementations§
source§impl Autocomplete for TutorialCommand
impl Autocomplete for TutorialCommand
fn autocomplete<'life0, 'life1, 'async_trait>(
input: &'life0 str,
_app_meta: &'life1 AppMeta,
) -> Pin<Box<dyn Future<Output = Vec<AutocompleteSuggestion>> + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
source§impl Clone for TutorialCommand
impl Clone for TutorialCommand
source§fn clone(&self) -> TutorialCommand
fn clone(&self) -> TutorialCommand
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl ContextAwareParse for TutorialCommand
impl ContextAwareParse for TutorialCommand
fn parse_input<'life0, 'life1, 'async_trait>(
input: &'life0 str,
_app_meta: &'life1 AppMeta,
) -> Pin<Box<dyn Future<Output = CommandMatches<Self>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
source§impl Debug for TutorialCommand
impl Debug for TutorialCommand
source§impl Display for TutorialCommand
impl Display for TutorialCommand
source§impl From<TutorialCommand> for CommandType
impl From<TutorialCommand> for CommandType
source§fn from(c: TutorialCommand) -> CommandType
fn from(c: TutorialCommand) -> CommandType
source§impl PartialEq for TutorialCommand
impl PartialEq for TutorialCommand
source§fn eq(&self, other: &TutorialCommand) -> bool
fn eq(&self, other: &TutorialCommand) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl Runnable for TutorialCommand
impl Runnable for TutorialCommand
impl Eq for TutorialCommand
impl StructuralPartialEq for TutorialCommand
Auto Trait Implementations§
impl Freeze for TutorialCommand
impl RefUnwindSafe for TutorialCommand
impl Send for TutorialCommand
impl Sync for TutorialCommand
impl Unpin for TutorialCommand
impl UnwindSafe for TutorialCommand
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)