Skip to content

bug: sideEffect race condition with selectFollowup #2

Description

@calummackervoy

Context

  • The sideEffect of a message represents the game state changes caused when a message is rendered. It's stored on the message object and called by the Dialogue component
  • selectFollowup is also included on a message, in particular when this message is an optional choice to be made by the player (returned by the getResponses method). It is provided by the DialogueContext and executed in getResponse - ultimately called when the response choice is clicked by the player

Current Behaviour

Reproducible 1: When a dialogue response choice has a method selectFollowup containing logic which checks game state before choosing which message to display (such as hasRelationshipPair), and it also has a sideEffect method which changes the same game state properties, the selectFollowup code will run before sideEffect and the messages will have been queued with an out-of-date game state

Reproducible 2: Writing a selectFollowup method which queues many messages, when one of those messages includes a sideEffect, the later messages in the queue will have been

Expected Behaviour

The selectFollowup code should not be running until the game state is up-to-date with previous messages

Fixing it now

Moving game state changing code into selectFollowup to maintain the correct order

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions