Skip to content

Commit

Permalink
Fix total score
Browse files Browse the repository at this point in the history
  • Loading branch information
EwanLyon committed Feb 16, 2021
1 parent 6992bf1 commit 7e84594
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 26 deletions.
49 changes: 24 additions & 25 deletions src/dashboard/production/currentmatch/currentmatch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ const DashCurrentMatch: React.FC = () => {
}

function UpdateScore() {
const allMaps: Match['maps'] = [];
// Wayyy too much processing here
const allMaps: MapInfo[] = [];
for (let i = 0; i < pickedMaps.length; i++) {
const fakeScores: Score = { teamA: 0, teamB: 0 };
const singleMap: MapInfo = {
Expand All @@ -190,34 +191,32 @@ const DashCurrentMatch: React.FC = () => {

// Get all inputs
const [teamA1, teamB1, teamA2, teamB2, teamAOT, teamBOT] = [
parseInt((document.getElementById(`${i}A1-Score`) as HTMLInputElement).value, 10),
parseInt((document.getElementById(`${i}B1-Score`) as HTMLInputElement).value, 10),
parseInt((document.getElementById(`${i}A2-Score`) as HTMLInputElement).value, 10),
parseInt((document.getElementById(`${i}B2-Score`) as HTMLInputElement).value, 10),
parseInt((document.getElementById(`${i}AOT-Score`) as HTMLInputElement).value, 10),
parseInt((document.getElementById(`${i}BOT-Score`) as HTMLInputElement).value, 10),
parseInt((document.getElementById(`${i}A1-Score`) as HTMLInputElement).value, 10) || 0,
parseInt((document.getElementById(`${i}B1-Score`) as HTMLInputElement).value, 10) || 0,
parseInt((document.getElementById(`${i}A2-Score`) as HTMLInputElement).value, 10) || 0,
parseInt((document.getElementById(`${i}B2-Score`) as HTMLInputElement).value, 10) || 0,
parseInt((document.getElementById(`${i}AOT-Score`) as HTMLInputElement).value, 10) || 0,
parseInt((document.getElementById(`${i}BOT-Score`) as HTMLInputElement).value, 10) || 0,
];

// I think they were being anger at being undefined
if (teamA1 >= 0 && teamB1 >= 0) {
singleMap.firstHalf = {
teamA: teamA1,
teamB: teamB1,
};
}
singleMap.firstHalf = {
teamA: teamA1,
teamB: teamB1,
};

if (teamA2 >= 0 && teamB2 >= 0) {
singleMap.secondHalf = {
teamA: teamA2,
teamB: teamB2,
};
}
singleMap.secondHalf = {
teamA: teamA2,
teamB: teamB2,
};

singleMap.ot = {
teamA: teamAOT,
teamB: teamBOT,
};

if (teamAOT >= 0 && teamBOT >= 0) {
singleMap.ot = {
teamA: teamAOT,
teamB: teamBOT,
};
singleMap.totalScore = {
teamA: teamA1 + teamA2 + teamAOT,
teamB: teamB1 + teamB2 + teamBOT,
}

allMaps.push(singleMap);
Expand Down
2 changes: 1 addition & 1 deletion src/extension/matches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ nodecg.listenFor('createNewMatch', (newMatch: NewMatch) => {
}
});

nodecg.listenFor('updateScore', (data: Match['maps']) => {
nodecg.listenFor('updateScore', (data: MapInfo[]) => {
if (!currentMatchRep.value) return;

const matchIndex = matchesRep.value.findIndex(
Expand Down

0 comments on commit 7e84594

Please sign in to comment.