なんかもうめっちゃ変えた

This commit is contained in:
syuilo
2018-03-09 18:11:10 +09:00
parent caea9c91b9
commit 910ccf1804
7 changed files with 425 additions and 307 deletions

View File

@@ -28,7 +28,7 @@ export interface IGame {
winner_id: mongo.ObjectID;
logs: any[];
settings: {
map: Map;
map: string[];
bw: string | number;
is_llotheo: boolean;
};
@@ -39,8 +39,15 @@ export interface IGame {
*/
export const pack = (
game: any,
me?: string | mongo.ObjectID | IUser
me?: string | mongo.ObjectID | IUser,
options?: {
detail?: boolean
}
) => new Promise<any>(async (resolve, reject) => {
const opts = Object.assign({
detail: true
}, options);
let _game: any;
// Populate the game if 'game' is ID
@@ -69,6 +76,11 @@ export const pack = (
_game.id = _game._id;
delete _game._id;
if (opts.detail === false) {
delete _game.logs;
delete _game.settings.map;
}
// Populate user
_game.user1 = await packUser(_game.user1_id, meId);
_game.user2 = await packUser(_game.user2_id, meId);