Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: sideEffect race condition with selectFollowup #2

Open
calummackervoy opened this issue Apr 17, 2022 · 0 comments
Open

bug: sideEffect race condition with selectFollowup #2

calummackervoy opened this issue Apr 17, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@calummackervoy
Copy link
Member

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

@calummackervoy calummackervoy added the bug Something isn't working label Apr 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant