# Complex Interactions

Let's take a look at how simple modules can come together to create complex structures and user experiences.

In this RPG scenario, the player's character encounters a formidable "Legendary Beast" controlled by the game's "Main" entity. To defeat the creature, the player needs a special item called the "Key to Release Beast."

The player interacts with the "ShopModule" to purchase the key. Upon successful authentication using a Time-Based One-Time Password (TOTP)/2FA code provided by the module, the player obtains authorization to make the purchase.

{% @mermaid/diagram content="sequenceDiagram
Main->>Player: Encounter "Legendary Beast"
Player->>ShopModule: Buy "Key to Release Beast"
ShopModule-->>Player: Confirm purchase and display TOTP/2FA code
Note over Player: Initiates TOTP/2FA authentication process
Player->>AuthModule: Provide TOTP/2FA code for purchase confirmation
AuthModule-->>Player: Authorization granted
" %}

With the key acquired, the player informs the "Main" entity and gains the ability to release the "Legendary Beast."

{% @mermaid/diagram content="sequenceDiagram
Player->>DBModule: Record purchase of "Key to Release Beast"
DBModule-->>Player: Confirmation of successful record
Player-->>Main: Key to Release Beast acquired
" %}

However, releasing the creature is an irreversible action with significant consequences for gameplay. The player must seek special authorization from the AuthModule based on their level and quest completion. After being granted authorization, the player records the release of the beast in the DBModule which persists the irreversible action.

{% @mermaid/diagram content="sequenceDiagram
Main->>Player: Perform irreversible action "Release Legendary Beast"
Player->>AuthModule: Request special authorization for releasing the beast
Note over AuthModule: Verifies player's level and quest completion
AuthModule-->>Player: Authorization granted
Player->>DBModule: Record release of Legendary Beast
DBModule-->>Player: Confirmation of successful record
Note over DBModule: Persists irreversible action
" %}

The consequences of this action shape the gameplay experience, adding depth and complexity to the RPG. Motion Modules work together seamlessly, facilitating interactions, authentication, authorization, and secure data recording.

With Motion developers can create intricate and immersive experiences, allowing players to engage with a diverse range of functionalities while ensuring security and integrity throughout the gameplay.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://motionzk.gitbook.io/docs/motion-modules/module-composition-walkthrough/complex-interactions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
