Skip to content

Commit

Permalink
Release Candidate v0.9.0 (#61)
Browse files Browse the repository at this point in the history
- Use `team_winner` and `opponent_winner` attributes to determine winner instead of using score

NOTE: Not backward compatible with v0.8.x of TeamTracker sensor.  Must upgrade to v0.9.0 of TeamTracker sensor to work
  • Loading branch information
vasqued2 committed Jul 16, 2023
1 parent 5bafba1 commit 813139a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 62 deletions.
2 changes: 1 addition & 1 deletion dist/const.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export let VERSION = "v0.8.1"
export let VERSION = "v0.9.0"
15 changes: 9 additions & 6 deletions dist/set_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export function initCardData(c) {
c.color = [];
c.timeouts = [];
c.possessionOp = [];
c.winner = [];
}

//
Expand Down Expand Up @@ -66,11 +67,13 @@ export function setDefaults(t, lang, stateObj, c, o, sport, team, oppo) {
c.name[team] = stateObj.attributes.team_name;
c.rank[team] = stateObj.attributes.team_rank;
c.record[team] = stateObj.attributes.team_record;
c.winner[team] = stateObj.attributes.team_winner || false;
c.logo[oppo] = stateObj.attributes.opponent_logo;
c.logoBG[oppo] = stateObj.attributes.opponent_logo;
c.name[oppo] = stateObj.attributes.opponent_name;
c.rank[oppo] = stateObj.attributes.opponent_rank;
c.record[oppo] = stateObj.attributes.opponent_record;
c.winner[oppo] = stateObj.attributes.opponent_winner || false;
c.playClock = stateObj.attributes.clock;
if (o.showLeague) {
c.logoBG[team] = stateObj.attributes.league_logo
Expand All @@ -80,13 +83,13 @@ export function setDefaults(t, lang, stateObj, c, o, sport, team, oppo) {
c.score[team] = stateObj.attributes.team_score;
c.score[oppo] = stateObj.attributes.opponent_score;

c.scoreOp[1] = 1;
c.scoreOp[2] = 1;
if (Number(c.score[1]) < Number(c.score[2])) {
c.scoreOp[1] = 0.6;
c.scoreOp[1] = .6;
c.scoreOp[2] = .6;
if (c.winner[team]) {
c.scoreOp[team] = 1;
}
if (Number(c.score[2]) < Number(c.score[1])) {
c.scoreOp[2] = 0.6;
if (c.winner[oppo]) {
c.scoreOp[oppo] = 1;
}

if (stateObj.attributes.team_homeaway == 'home') {
Expand Down
55 changes: 0 additions & 55 deletions dist/set_sports.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,9 @@ export function setBasketball(t, stateObj, c, team, oppo) {
// in2 = quarter;
// score = split score into 2 parts
// record = set to second part of split score
// scoreOP = adjust opacity based on total runs

export function setCricket(t, stateObj, c, team, oppo) {
var runs_substring = [];
var runs = [];
var total_runs = [];
var subscores = [];
var i = 0;

c.timeoutsDisplay = 'none';
c.barDisplay = "none";
Expand All @@ -100,37 +95,6 @@ export function setCricket(t, stateObj, c, team, oppo) {
if (subscores[2].length > 1) {
c.record[2] = "(" + subscores[2][1];
}

if (stateObj.state == 'POST') {
runs_substring[1] = c.score[1].split("/");
runs_substring[2] = c.score[2].split("/");

runs[1] = runs_substring[1][0].split("&");
runs[2] = runs_substring[2][0].split("&");

total_runs[1] = 0;
total_runs[2] = 0;

i = 0;
while (i < runs[1].length) {
total_runs[1] = total_runs[1] + Number(runs[1][i]);
i = i + 1;
}
i = 0;
while (i < runs[2].length) {
total_runs[2] = total_runs[2] + Number(runs[2][i]);
i = i + 1;
}

if (total_runs[1] > total_runs[2]) {
c.scoreOp[1] = 1.0;
c.scoreOp[2] = 0.6;
}
if (total_runs[1] < total_runs[2]) {
c.scoreOp[1] = 0.6;
c.scoreOp[2] = 1.0;
}
}
}
}
}
Expand All @@ -144,7 +108,6 @@ export function setCricket(t, stateObj, c, team, oppo) {
// barLabel = team_total_shots, opponent_total_shots
// finalTerm = clock
// timeoutsDisplay = 'none';
// scoreOp = adjust opacity to show lowest score as winner
//
export function setGolf(t, stateObj, c, team, oppo) {
c.title = c.title || stateObj.attributes.event_name;
Expand All @@ -156,14 +119,6 @@ export function setGolf(t, stateObj, c, team, oppo) {
c.finalTerm = stateObj.attributes.clock;
c.timeoutsDisplay = 'none';

if (Number(c.score[1]) < Number(c.score[2])) {
c.scoreOp[1] = 1.0;
c.scoreOp[2] = 0.6;
}
if (Number(c.score[2]) < Number(c.score[1])) {
c.scoreOp[1] = 0.6;
c.scoreOp[2] = 1.0;
}
}

//
Expand Down Expand Up @@ -206,7 +161,6 @@ export function setMMA(t, stateObj, c, team, oppo) {
// timeoutsDisplay = 'none';
// barLength = team_total_shots, opponent_total_shots (laps)
// barLabel = (laps)
// scoreOp = adjust opacity to show lowest score as winner
// If NASCAR, remove logos and use initials
//
export function setRacing(t, stateObj, c, team, oppo) {
Expand All @@ -223,15 +177,6 @@ export function setRacing(t, stateObj, c, team, oppo) {
c.barLabel[team] = t.translate("racing.teamBarLabel", "%s", String(stateObj.attributes.team_total_shots));
c.barLabel[oppo] = t.translate("racing.teamBarLabel", "%s", String(stateObj.attributes.team_total_shots));

if (Number(c.score[1]) < Number(c.score[2])) {
c.scoreOp[1] = 1.0;
c.scoreOp[2] = 0.6;
}
if (Number(c.score[2]) < Number(c.score[1])) {
c.scoreOp[1] = 0.6;
c.scoreOp[2] = 1.0;
}

if (stateObj.attributes.league.includes("NASCAR")) {
c.logo[team] = null;
c.logo[oppo] = null;
Expand Down

0 comments on commit 813139a

Please sign in to comment.