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

Replace FrameContext with Context #784

Merged
merged 13 commits into from
Nov 12, 2024
Merged

Conversation

davesmith00000
Copy link
Member

Goals:

  1. Introduce the idea of services, which should be stub-able to replace the parts of FrameContext that were stateful or side effecting.
  2. Rework FrameContext into Context, something better organised / designed.
  3. Also split random number generation into Dice (pseudo random and imperfect, but stateless) and Random (stateful).

Related issues: #783, #742, and to some extent #750

@davesmith00000 davesmith00000 self-assigned this Nov 9, 2024
@davesmith00000 davesmith00000 marked this pull request as ready for review November 12, 2024 00:58
@davesmith00000
Copy link
Member Author

davesmith00000 commented Nov 12, 2024

Brief summary:

FrameContext replaced with Context. Context is split into frame and services, which are frame values and long running processes respectively, accessible something like this:

// `StartUpData` is accessible at the top level
ctx.startUpData

// Example 'frame' values / facilities
ctx.frame.time.delta
ctx.frame.dice.rollDouble // PRNG seeded on the game running time at the point of frame entry

// Example 'services'
ctx.services.screen.capture(..)
ctx.services.random.nextInt // Long running scala.util.Random instance.

Also, everything has an interface, meaning that it is much easier to include in unit tests.

@davesmith00000 davesmith00000 merged commit 23c892f into main Nov 12, 2024
2 checks passed
@davesmith00000 davesmith00000 deleted the issue/783/introduce-services branch November 12, 2024 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant