In my two-player game, both players start with similar data that evolves as the game progresses.
I believe I need to create a constructor object that can be duplicated and modified, while also being in JSON format for easy ajax sending.
Is there a design pattern that could assist me? I would rather avoid using a database since I only require the data for a single instance of the game.
Currently, this is the structure I am using for one player:
player = {
"active" : true,
"room" : openRoom,
"id" : playerID,
"name": username,
"hp" : 5,
"units" : {
1 : {
"id" : 1,
"hp" : 3,
"row" : 1,
"square" : 1
},
2 : {
"id" : 2,
"hp" : 4,
"row" : 2,
"square" : 1
},
3 : {
"id" : 3,
"hp" : 5,
"row" : 3,
"square" : 1
}
}
};