new Game(engine:Engine, channels:Channels)
?
#2360
Closed
andretchen0
started this conversation in
Ideas
Replies: 1 comment
-
Sounds good to me. Things are always best kept decoupled and modular, just in case. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'd like to refactor
Game
; the details can be subject to further discussion. Generally speaking, as a first step, the bits that could be refactored should be covered by tests, if possible, in order to make sure that changes don't break existing functionality.Currently however, jest can't load PIXI and Phaser. There are workarounds, but they add complexity.
Instead, I wonder about passing a Phaser instance to
Game
as an argument. Using dependency injection for the Phaser instance would give the codebase a nudge in the direction of #2021. In the future, another engine - e.g., a homebrew text-based engine - that implements the same interface could be passed instead.But the short term goal is to make the code more easily testable.
We'd need to:
Engine
, though maybeIO
works as well.Signals
, so would mirror those calls for now. I propose calling thisChannels
.Game
's constructor.Beta Was this translation helpful? Give feedback.
All reactions