const Collection = require("../util/Collection");
const Base = require("./Base");
/**
* Represents a clan (squadron) on War Thunder
*/
class Clan extends Base {
constructor(thunderAPI, data) {
super(thunderAPI);
/**
* The squadron name
* @type {string}
* @name Clan#name
*/
this.name = data.name;
/**
* The date this squadron was created
* @type {string}
* @name Clan#created
*/
this.created = data.created;
this._patch(data);
}
_patch(data) {
/**
* The description of the clan
* @type {string}
* @name Clan#description
*/
this.description = data.description;
/**
* The tag of the clan, including tag borders
* @type {string}
* @name Clan#tag
*/
this.tag = data.tag;
/**
* The amount of players in the clan
* @type {number}
* @name Clan#memberCount
*/
this.memberCount = data.players;
/**
* The statistics of the clan for Squadron Events, mapped by mode.
* The modes are:
* * arcade
* * realistic
* * simulator
* @type {Collection<string,SQBStats>}
* @name Clan#stats
*/
this.stats = new Collection(Object.entries(data.stats));
/**
* A collection of squadron members, mapped by name
* @type {Collection<string,ClanMember>}
* @name Clan#members
*/
this.members = new Map();
for (const member of data.members) {
this.members.set(member.name, member);
}
}
}
module.exports = Clan;