我很难收集一个班级
匹配示例
和比赛
匹配是匹配的集合
我的班级比赛:
const uuid = require("uuid");
// Match class is a single game Match structure
class Match {
constructor(players) {
this.id = uuid.v4().toString();
this.players = players;
}
// Match rest methods...
// I.E: isMatchEnded, isMatchStarted ...
}
module.exports = Match;
我的班级比赛
class Matches {
constructor() {
this.matches = {};
}
addMatch(match) {
this.matches.push(match);
}
// Matches rest methods... }
module.exports = Matches;
我的主要:
const matches = new Matches();
const queue = new Queue();
queue.addPlayer(new Player(1,'spt',970));
queue.addPlayer(new Player(2,'test2',1000));
queue.addPlayer(new Player(3,'test3',1050));
queue.addPlayer(new Player(4,'test4',70));
const playerOne = queue.players.find((playerOne) => playerOne.mmr === 970);
const players = queue.searching(playerOne);
if(players){
const match = new Match(players);
matches.addMatch(match);
}
console.log(matches);
但我收到此错误:
Matches.js:7
this.matches.push(match);
^
TypeError: this.matches.push is not a function
开心每一天1111
摇曳的蔷薇
相关分类