mirror of
https://github.com/jwetzell/aas-js.git
synced 2026-09-12 07:29:31 +00:00
add hockey parsing
This commit is contained in:
@@ -8,3 +8,4 @@
|
|||||||
- wrestling
|
- wrestling
|
||||||
- auto racing
|
- auto racing
|
||||||
- soccer
|
- soccer
|
||||||
|
- hockey
|
||||||
+53
-1
@@ -58,7 +58,8 @@ class Console {
|
|||||||
break;
|
break;
|
||||||
case 0x40:
|
case 0x40:
|
||||||
this.sport = 'hockey';
|
this.sport = 'hockey';
|
||||||
throw new Error('Hockey is not implemented');
|
this.parseHockey();
|
||||||
|
break;
|
||||||
case 0x85:
|
case 0x85:
|
||||||
this.sport = 'auto_racing';
|
this.sport = 'auto_racing';
|
||||||
this.parseAutoRacing();
|
this.parseAutoRacing();
|
||||||
@@ -364,6 +365,57 @@ class Console {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parseHockey() {
|
||||||
|
if (!this.sportInitialized) {
|
||||||
|
this.sportInitialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const seqNum = this.latestPacket.buffer.at(10);
|
||||||
|
if (seqNum === 0x11) {
|
||||||
|
this.state.home.shotsOnGoal = this.getInt(this.latestPacket.buffer.at(16));
|
||||||
|
this.state.guest.shotsOnGoal = this.getInt(this.latestPacket.buffer.at(17));
|
||||||
|
this.state.home.saves = this.getInt(this.latestPacket.buffer.at(21));
|
||||||
|
this.state.guest.saves = this.getInt(this.latestPacket.buffer.at(22));
|
||||||
|
}
|
||||||
|
if (seqNum === 0x22) {
|
||||||
|
this.state.home.penalties = [];
|
||||||
|
this.state.guest.penalties = [];
|
||||||
|
for (let i = 0; i < 2; i += 1) {
|
||||||
|
const startIndex = 11 + i * 3;
|
||||||
|
if (this.latestPacket.buffer.at(startIndex) !== 0xaa) {
|
||||||
|
const penaltyClock = {
|
||||||
|
minutes: this.latestPacket.buffer.subarray(startIndex, startIndex + 1).toString('hex'),
|
||||||
|
seconds: this.latestPacket.buffer.subarray(startIndex + 1, startIndex + 2).toString('hex'),
|
||||||
|
};
|
||||||
|
|
||||||
|
penaltyClock.display = `${penaltyClock.minutes}:${penaltyClock.seconds}`;
|
||||||
|
|
||||||
|
this.state.home.penalties.push({
|
||||||
|
clock: penaltyClock,
|
||||||
|
playerNum: this.getInt(this.latestPacket.buffer.at(startIndex + 2)),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let i = 0; i < 2; i += 1) {
|
||||||
|
const startIndex = 17 + i * 3;
|
||||||
|
if (this.latestPacket.buffer.at(startIndex) !== 0xaa) {
|
||||||
|
const penaltyClock = {
|
||||||
|
minutes: this.latestPacket.buffer.subarray(startIndex, startIndex + 1).toString('hex'),
|
||||||
|
seconds: this.latestPacket.buffer.subarray(startIndex + 1, startIndex + 2).toString('hex'),
|
||||||
|
};
|
||||||
|
|
||||||
|
penaltyClock.display = `${penaltyClock.minutes}:${penaltyClock.seconds}`;
|
||||||
|
|
||||||
|
this.state.guest.penalties.push({
|
||||||
|
clock: penaltyClock,
|
||||||
|
playerNum: this.getInt(this.latestPacket.buffer.at(startIndex + 2)),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param {number} packedNumber
|
* @param {number} packedNumber
|
||||||
|
|||||||
Reference in New Issue
Block a user