private CharacterCreationSubState RegressState(CharacterCreationSubState current)
        {
            if (current is ConfirmPasswordState)
            {
                // If password confirmation failed, try selecting a new password.
                return(new GetPasswordState(this.Session));
            }

            throw new InvalidOperationException("The character state machine does not know how to calculate the next step after '" + current.GetType().Name + "' fails");
        }
        private CharacterCreationSubState AdvanceState(CharacterCreationSubState current)
        {
            // This character creation state machine can return actual creation state objects - if someone
            // were to expand and add new creation state(s) that are not MUD-agnostic, then they should also
            // add and use their own CreationStateMachine handling those states instead of this default one;
            // they could of course reuse some/all of the states below in addition to their own.
            if (current is ConfirmCreationEntryState)
            {
                return(new GetNameState(this.Session));
            }
            else if (current is GetNameState)
            {
                return(new GetPasswordState(this.Session));
            }
            else if (current is GetPasswordState)
            {
                return(new ConfirmPasswordState(this.Session));
            }
            else if (current is ConfirmPasswordState)
            {
                return(new PickGenderState(this.Session));
            }
            else if (current is PickGenderState)
            {
                return(new GetDescriptionState(this.Session));
            }
            else if (current is GetDescriptionState)
            {
                return(new SetAttributesState(this.Session));
            }
            else if (current is SetAttributesState)
            {
                return(new PickSkillsState(this.Session));
            }
            else if (current is PickSkillsState)
            {
                return(new PickTalentsState(this.Session));
            }
            else if (current is PickTalentsState)
            {
                return(new PickRaceState(this.Session));
            }
            else if (current is PickRaceState)
            {
                // We are done with character creation!
                return(null);
            }

            throw new InvalidOperationException("The character state machine does not know how to calculate the next step after '" + current.GetType().Name + "' succeeds");
        }
        /// <summary>Gets the next step in the creation process.</summary>
        /// <param name="current">The current (just executed step).</param>
        /// <param name="previousStatus">Whether the current step passed or failed.</param>
        /// <returns>The next step in the character creation process, or null if it is finished.</returns>
        public override CharacterCreationSubState GetNextStep(CharacterCreationSubState current, StepStatus previousStatus)
        {
            // entry point of the state machine
            if (current == null)
            {
                return(new ConfirmCreationEntryState(this.Session));
            }

            if (previousStatus == StepStatus.Success)
            {
                return(this.AdvanceState(current));
            }
            else
            {
                return(this.RegressState(current));
            }
        }