export class Player { constructor(id, name, level, status) { this.id = id; this.name = name; this.level = typeof level !== 'undefined' ? level : 1; this.status = typeof status !== 'undefined' ? status : false; } toggle() { this.status = !this.status; this.print(); } print() { let status = this.status ? "active" : "inactive"; console.log(this.name + " has a level of " + this.level + " and is currently " + status); } render() { let type = this.status ? `class="button is-success"` : 'class="button is-danger"'; return ``; } } function randomLevel() { const max_level = 10; return Math.floor(Math.random() * max_level + 1); } function randomStatus() { return Math.random() < 0.5; } export function generatePlayers() { let players = []; for (let i = 0; i < 71; i++) { players.push(new Player(i, "Player " + i, randomLevel(), randomStatus())); } return players; } function parseLineToPlayer(data) { var info = data.split(","); var id = Number(info[0].trim()); var name = info[1].trim() + " " + info[2].trim(); var level = Number(info[3].trim()); return new Player(id, name, level, false); } export function csvToPlayers(csv) { var lines = csv.split("\n"); var players = []; for (var i = 1; i < lines.length; i++) { if(lines[i] == undefined || lines[i].trim() == "") {continue;} players.push(parseLineToPlayer(lines[i])); } console.log("Loaded " + players.length + " Players"); for (var i=0; i