From f681a8b59683dc9d2aa56e61c917ca97bf9e3c50 Mon Sep 17 00:00:00 2001 From: Joel Wetzell Date: Sat, 25 Nov 2023 10:01:38 -0600 Subject: [PATCH] add wrestling support --- packages/lib/index.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/packages/lib/index.js b/packages/lib/index.js index 6b41c58..87788c8 100644 --- a/packages/lib/index.js +++ b/packages/lib/index.js @@ -15,7 +15,6 @@ class Console { delete this.sport; this.state = { time: {}, - auxTime: {}, home: {}, guest: {}, }; @@ -54,7 +53,8 @@ class Console { throw new Error('Soccer is not implemented'); case 0x60: this.sport = 'wrestling'; - throw new Error('Wrestling is not implemented'); + this.parseWrestling(); + break; case 0x40: this.sport = 'hockey'; throw new Error('Hockey is not implemented'); @@ -315,6 +315,21 @@ class Console { // TODO(jwetzell): decode player stats in seqNum >= 22 } + + parseWrestling() { + if (!this.sportInitialized) { + this.sportInitialized = true; + } + + const seqNum = this.currentBuffer.buffer.at(10); + if (seqNum === 0x11) { + this.state.home.boutScore = this.getInt(this.currentBuffer.buffer.at(16)); + this.state.guest.boutScore = this.getInt(this.currentBuffer.buffer.at(17)); + this.state.weight = + this.getInt(this.currentBuffer.buffer.at(18)) + this.getInt(this.currentBuffer.buffer.at(19)) * 100; + } + } + /** * * @param {number} packedNumber