Open lhaze opened 7 years ago
Example serialization result:
{
'types': {
'colorResourceStack': {
'factory': 'createResourceStack',
'resourceNames': ['red', 'green', 'blue'],
},
},
'assets': {
'pawn_1': {
'type': 'Token',
'color': 'black',
},
'board': {
'end_turn': {}
}
},
'state': {
'board': {
'slot_red': {
'value': {'ref': 'pawn_1'},
'color': 'red',
},
'slot_blue': {
'value': {
'type': 'colorResourceStack',
'value': { // sic!
'red': 3,
'blue': 2,
'green': 1,
}
},
'color': 'blue',
},
'slot_green': {
'color': 'green',
}
},
'victory_points_counter': {
'value': '5',
},
},
'ruleset': {},
}
The alternative is to use Dependency Injection 4 Javascript and build something like:
di
.register('ColorStack')
.setFactory(createResourceStack)
.param().val(['red', 'green', 'blue'])
.register('pawn_1')
.as(Token)
.withConstructor()
.param('color').val('black')
etc.
Here's the repo.
I think doing both ways seems a nice exercise.
The whole of game (state, ruleset & settings) should be serializable. Map out its design and schema.