Skip to content

development responses

nhmkdev edited this page Mar 19, 2018 · 3 revisions

SAMQ Development: Responses

Responses represent the actions that the player can perform to transition from one InputRequest to another (or the same in certain circumstances).

Standard Usage

Sample

Response::with('Choice 1', 'sample_02a')

This is a very basic response with text to display the choice and a destination InputRequest. Responses are always used as part of an InputRequest.

Extra Functionality

Adjustments

Adjusments performed when the response is selected (and before transitioning to the next InputRequest).

Conditions and State

Responses support a number of different configurations for Conditions and the resulting state (ResponseState) of the Response. The state of the Response determines how and if it is displayed.

Response States

Enabled

This response will be displayed and may be selected.

Disabled

This response will be displayed and cannot be selected.

Hidden

This response will not be displayed.

Condition Checks

There are six methods that allow conditions to be specified. They are divided into two groups.

Any

If any of the specified conditions pass the resulting state will be returned.

setHiddenOnAnyConditions
setDisabledOnAnyConditions
setEnabledOnAnyConditions
All

If all of the specified conditions pass the resulting state will be returned.

setHiddenOnAllConditions
setDisabledOnAllConditions
setEnabledOnAllConditions
Order of Checks

If a state check fails it will fall through in this order. If a check passes the resulting state is returned immediately.

HiddenOnAllConditions
HiddenOnAnyConditions
DisabledOnAllConditions
DisabledOnAnyConditions
EnabledOnAllConditions
EnabledOnAnyConditions

Default State

To allow for extensive control over the condition logic each response can have its own custom default state (if all condition checks fail). By default the returned state is Enabled. Sample

$response->setDefaultState(ResponseState::Disabled);
Clone this wiki locally