Open vetom opened 6 years ago
Following is the structure for the party object:
const party = {
id: 'A234AF',
createdAt: 'July 24, 2018 at 8:31:19 PM UTC-4'
moderator: '34bs486nkr84',
name: 'Werewolf village'
players: {
'34bs486nkr84': {
timestamp: '20180621T041748Z',
card: {},
},
'9m7uf46nkr84': {
timestamp: '20180621T041749Z',
card: {},
},
},
};
I suggest adding the player's name to the players' object and prepare to the keep alive structure for #15 and #16.
const party = {
id: 'A234AF',
createdAt: 'July 24, 2018 at 8:31:19 PM UTC-4',
moderatorId: '34bs486nkr84',
moderator: 'Jim',
name: 'Werewolf village',
players: {
'34bs486nkr84': {
joinedAt: '20180621T041749Z',
name: 'Bill',
card: {},
},
'9m7uf46nkr84': {
joinedAt: '20180621T041749Z',
name: 'Sam',
card: {},
},
},
keepAlive: {
'34bs486nkr84': '20180621T041749Z',
'9m7uf46nkr84': '20180621T041749Z',
},
};
After a meeting with @wistcc and @mamodom, the following is the suggested structure:
const party = {
id: 'A234AF',
createdAt: 'July 24, 2018 at 8:31:19 PM UTC-4',
name: 'Werewolf village',
players: {
'34bs486nkr84': {
joinedAt: '20180621T041749Z',
name: 'Jim',
moderator: true,
},
'34bs486nkr84': {
joinedAt: '20180621T041749Z',
name: 'Bill',
},
'9m7uf46nkr84': {
joinedAt: '20180621T041749Z',
name: 'Sam',
},
},
keepAlive: {
'34bs486nkr84': '20180621T041749Z',
'9m7uf46nkr84': '20180621T041749Z',
},
game: {
'34bs486nkr84': {
name: 'Bill',
card: { key: 'villager', role:'Villager', description:'Find the werewolves and lynch them.' },
alive: true,
},
'9m7uf46nkr84': {
name: 'Sam',
card: { key: 'werewolf', role:'Werewolf', description:'Eat a villager each night.' },
alive: true,
},
}
};
Due to the high resource usage of firebase when sending the snapshots to the subscribed users, we have to update the structure to the following.
const party = {
id: 'A234AF',
createdAt: 'July 24, 2018 at 8:31:19 PM UTC-4',
name: "Jim's party",
gameInProgress: false,
players: {
'34bs486nkr84': {
joinedAt: '20180621T041749Z',
name: 'Jim',
moderator: true,
},
'34bs486nkr84': {
joinedAt: '20180621T041749Z',
name: 'Bill',
},
'9m7uf46nkr84': {
joinedAt: '20180621T041749Z',
name: 'Sam',
},
},
};
const keepAlive = {
'34bs486nkr84': '20180621T041749Z',
'9m7uf46nkr84': '20180621T041749Z',
};
const game = {
'34bs486nkr84': {
name: 'Bill',
card: { key: 'villager', role:'Villager', description:'Find the werewolves and lynch them.' },
alive: true,
},
'9m7uf46nkr84': {
name: 'Sam',
card: { key: 'werewolf', role:'Werewolf', description:'Eat a villager each night.' },
alive: true,
},
}
We need to inform to players when the game is over so here is the last structure to meet the necessity.
const party = {
id: 'A234AF',
createdAt: 'July 24, 2018 at 8:31:19 PM UTC-4',
name: "Jim's party",
gameInProgress: false,
players: {
'34bs486nkr84': {
joinedAt: '20180621T041749Z',
name: 'Jim',
moderator: true,
},
'34bs486nkr84': {
joinedAt: '20180621T041749Z',
name: 'Bill',
},
'9m7uf46nkr84': {
joinedAt: '20180621T041749Z',
name: 'Sam',
},
},
};
const keepAlive = {
'34bs486nkr84': '20180621T041749Z',
'9m7uf46nkr84': '20180621T041749Z',
};
const game = {
gameOver: false,
players: {
'34bs486nkr84': {
name: 'Bill',
card: { key: 'villager', role:'Villager', description:'Find the werewolves and lynch them.' },
alive: true,
},
'9m7uf46nkr84': {
name: 'Sam',
card: { key: 'werewolf', role:'Werewolf', description:'Eat a villager each night.' },
alive: true,
},
}
}
We should take a look at the database guides firebase gives us here and set here any feedbacks for future enhancements.