diff options
| author | Karan Jayachandra <karan.jayachandra@nxp.com> | 2025-11-13 16:57:32 +0100 |
|---|---|---|
| committer | Karan Jayachandra <karan.jayachandra@nxp.com> | 2025-11-13 16:57:32 +0100 |
| commit | 33c3c6d7dc89187c08ec0775bbad8aaccb85d086 (patch) | |
| tree | ab3183c231402b46a91605fb0ee7d3c03d255f8c /player.mjs | |
| parent | 05d2f2f943921d6b5c921686c5edce6eb39d23b8 (diff) | |
Only guests need to be implemented to merge to main
Diffstat (limited to 'player.mjs')
| -rw-r--r-- | player.mjs | 24 |
1 files changed, 9 insertions, 15 deletions
@@ -14,18 +14,11 @@ class Player { } print() { let status = this.status ? "active" : "inactive"; - console.log( - this.name + - " has a level of " + - this.level + - " and is currently " + - status - ); + console.log(this.name + " is currently " + status); } render() { - let type = this.status - ? `class="button is-medium is-success"` - : 'class="button is-medium is-danger"'; + let color = this.status ? "is-success" : "is-danger"; + let type = `class="button is-medium ${color}"`; return `<button id=${"regular_" + this.id} ${type}>${this.name}</button>`; } } @@ -67,7 +60,8 @@ export class PlayerManager extends Manager { } console.log("Loaded " + this.listData.length + " players."); this.render(); - this.addToggleBehaviour(); + this.addBehaviour(); + addLoadBehaviour(this); } generate() { console.log("Generating player data."); @@ -79,7 +73,7 @@ export class PlayerManager extends Manager { console.log("Generated data for " + this.listData.length + " players"); this.store(); this.render(); - this.addToggleBehaviour(); + this.addBehaviour(); } import(data) { var lines = data.split("\n"); @@ -97,7 +91,7 @@ export class PlayerManager extends Manager { this.listData = players; this.store(); this.render(); - this.addToggleBehaviour(); + this.addBehaviour(); } active(factor) { factor = typeof factor !== "undefined" ? factor : 1; @@ -112,7 +106,7 @@ export class PlayerManager extends Manager { propose(count) { console.log("Required players are " + count); let factor = Number(document.getElementById("skill").value); - console.log("Skill normalized by a factor of " + factor + "."); + console.log("Skill normalized by a factor of " + factor + "."); const activePlayers = this.active(factor); console.log("Active players are:"); console.log( @@ -138,7 +132,7 @@ export class PlayerManager extends Manager { } } -// Try to add this functionality inside the class to call after constructor +// TODO Add load behaviour to constructor export function addLoadBehaviour(p) { const f = document.querySelector("#player-load input[type=file]"); f.addEventListener("change", () => { |
