add soccer parsing

This commit is contained in:
2023-11-25 10:55:26 -06:00
parent aa25dc5918
commit 402b4cfaf4
2 changed files with 19 additions and 3 deletions
+2 -1
View File
@@ -6,4 +6,5 @@
- football
- baseball
- wrestling
- auto racing
- auto racing
- soccer
+17 -2
View File
@@ -50,7 +50,8 @@ class Console {
break;
case 0x16:
this.sport = 'soccer';
throw new Error('Soccer is not implemented');
this.parseSoccer();
break;
case 0x60:
this.sport = 'wrestling';
this.parseWrestling();
@@ -333,13 +334,13 @@ class Console {
parseAutoRacing() {
if (!this.sportInitialized) {
this.state.positions = [];
this.sportInitialized = true;
}
const seqNum = this.latestPacket.buffer.at(10);
if (seqNum === 0x11) {
this.state.lap =
this.getInt(this.latestPacket.buffer.at(19)) * 100 + this.getInt(this.latestPacket.buffer.at(20));
this.state.positions = [];
for (let i = 0; i < 10; i += 1) {
const positionByte = this.latestPacket.buffer.at(21 + i);
if (positionByte !== 0xaa) {
@@ -349,6 +350,20 @@ class Console {
}
}
parseSoccer() {
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.cornerKicks = this.getInt(this.latestPacket.buffer.at(21));
this.state.guest.cornerKicks = this.getInt(this.latestPacket.buffer.at(22));
}
}
/**
*
* @param {number} packedNumber