core: split: game and pong
This commit is contained in:
@ -1,13 +1,15 @@
|
||||
import { AExchangeable } from "./AExchangable.js";
|
||||
import { Client } from "./Client.js";
|
||||
import { Game } from "./game/Game.js";
|
||||
|
||||
class Profile
|
||||
export class Profile extends AExchangeable
|
||||
{
|
||||
/**
|
||||
* @param {Client} client
|
||||
*/
|
||||
constructor (client, username=undefined, id=undefined, avatar_url=undefined)
|
||||
constructor (client, username, id, avatar)
|
||||
{
|
||||
super();
|
||||
|
||||
/**
|
||||
* @type {Client} client
|
||||
*/
|
||||
@ -26,7 +28,7 @@ class Profile
|
||||
/**
|
||||
* @type {String}
|
||||
*/
|
||||
this.avatar_url = avatar_url;
|
||||
this.avatar = avatar;
|
||||
|
||||
/**
|
||||
* @type {Boolean}
|
||||
@ -53,7 +55,7 @@ class Profile
|
||||
let response_data = await response.json();
|
||||
this.id = response_data.user_id;
|
||||
this.username = response_data.username;
|
||||
this.avatar_url = response_data.avatar;
|
||||
this.avatar = response_data.avatar;
|
||||
|
||||
await this.getBlock();
|
||||
await this.getFriend();
|
||||
@ -61,7 +63,7 @@ class Profile
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {[Game]}
|
||||
* @returns {[Object]}
|
||||
*/
|
||||
async getGameHistory()
|
||||
{
|
||||
@ -71,20 +73,7 @@ class Profile
|
||||
let games = [];
|
||||
|
||||
response_data.forEach(game_data => {
|
||||
games.push(new Game(this.client,
|
||||
game_data.id,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
game_data.winner_id,
|
||||
game_data.state,
|
||||
game_data.started,
|
||||
game_data.finished,
|
||||
game_data.players,
|
||||
game_data.start_timestamp,
|
||||
game_data.stop_timestamp
|
||||
)
|
||||
);
|
||||
games.push(game_data);
|
||||
});
|
||||
|
||||
return games;
|
||||
@ -126,6 +115,11 @@ class Profile
|
||||
return this.isFriend;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export {Profile};
|
||||
/**
|
||||
* @param {[String]} additionalFieldList
|
||||
*/
|
||||
export(additionalFieldList = [])
|
||||
{
|
||||
super.export([...["username", "avatar", "id"], ...additionalFieldList])
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user