Closed JeffML closed 1 year ago
Game metadata such as playerName()
, playerElo()
, etc... are encapsulated so that the Game
class can enforce some constrainted on them: for instance, playerElo()
is guaranteed to be a positive integer, result()
is guaranteed to be an element of [ '1-0', '1/2-1/2', '0-1', '*' ]
... Enforcing these constraints would not be possible by directly exposing metadata as properties.
Just to mention: the lib provides GamePOJO, which is a pure JavaScript object (i.e. not a class, no methods) that conveys the same information as Game
. Conversion back and forth between Game
and GamePOJO
are achieved by Game.pojo()
and Game.fromPOJO()
.
I remember seeing that now that you mention it. That will do nicely. Closing.
I can't decompose Game properties wrapped in functions such as playerName, playerElo, etc. For example, I would like to do the following assignments (if properties were data members instead of functions):