From 971509b55bd617340c2b611daf960d8b09daa6cc Mon Sep 17 00:00:00 2001 From: Oolonk Date: Wed, 27 Sep 2023 22:58:36 +0200 Subject: [PATCH] add functions, Windows: optimize packaging fix getPride function, add getCommentatorCountry and getCommentatorPride functions Windows: add files to ignore during packaging --- js/class/piio-connector.class.js | 31 ++++++++++++++++++++++++++++--- package.json | 9 ++++++++- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/js/class/piio-connector.class.js b/js/class/piio-connector.class.js index 7b6bcb5..96366f3 100644 --- a/js/class/piio-connector.class.js +++ b/js/class/piio-connector.class.js @@ -221,9 +221,14 @@ class PiioConnector { playerNum = this.getSelectedPlayer(teamNum); } let po = this.getPlayer(teamNum, playerNum); - if (po && this.cache.pride.hasOwnProperty(po.pride)) - return this.cache.pride[po.pride]; - return null; + let po2 = this.cache.pride; + po2 = Object.keys(po2) + .filter(key => po.pride.includes(key)) + .reduce((obj, key) => { + obj[key] = po2[key]; + return obj; + }, {}); + return Object.values(po2); } getPort(teamNum, playerNum) { @@ -280,6 +285,26 @@ class PiioConnector { return null; } + getCasterCountry(casterNum) { + let po = this.getCaster(casterNum); + if (po && this.cache.country.hasOwnProperty(po.country)) + return this.cache.country[po.country]; + return null; + } + + getCasterPride(casterNum) { + let po = this.getCaster(casterNum); + let po2 = this.cache.pride; + po2 = Object.keys(po2) + .filter(key => po.pride.includes(key)) + .reduce((obj, key) => { + obj[key] = po2[key]; + return obj; + }, {}); + return Object.values(po2); + } + + getGame() { if (!this.cache.scoreboard.hasOwnProperty("game")) { return null; diff --git a/package.json b/package.json index 8b7b666..bdd12dc 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,13 @@ ] }, "packagerConfig": { + "ignore": [ + ".gitignore", + "regions.json", + "changelog.txt", + "README.md", + "scoreboard.json" + ], "executableName": "piio", "icon": "./app/logo.ico" }, @@ -94,4 +101,4 @@ "rxjs": "^7.8.0", "ws": "^6.1.0" } -} +} \ No newline at end of file