GameLog: dependency injection #2348
Replies: 1 comment 2 replies
-
Sounds good! 👍🏻
Makes sense, ideally |
Beta Was this translation helpful? Give feedback.
-
Sounds good! 👍🏻
Makes sense, ideally |
Beta Was this translation helpful? Give feedback.
-
I wonder if it'd be worthwhile to remove
GameLog
's reference togame
and replace it with dependency injection.GameLog
currently has a reference to agame
or amatch
.GameLog
modifiesgame
with aconfig
object and "replays" actions ongame
. Unfortunately,game
is a large class with lots of dependencies, making it very difficult to mock and test.Instead,
GameLog
could be rewritten with dependency injection, instead of requiring agame
reference. This will allow it to be more easily tested in isolation and simpler. And it'll move the modifications togame
togame
, where one would normally look for it.While we're at it, would it be acceptable to modify the serialized format? It's currently more fidgety than necessary.
The current log prefix format is:
return 'AB-' + version + '@' + this.today + ':';
It's harder than necessary to pull apart.
Incorporating the prefix fields - date and game version - into the log object and using
JSON.stringify
would be much simpler.We could start the serialized log with 'AB-'.
Thoughts on this?
Beta Was this translation helpful? Give feedback.
All reactions