-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#52 Cleanup: series map numbers helper
- Loading branch information
1 parent
c926b56
commit 16ae047
Showing
7 changed files
with
53 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// needs to be a `function` so `this` is the Vue component | ||
export function seriesMapNumbers() { | ||
const mapNumbers = new Set() | ||
|
||
for (const key of Object.keys(this.$opts)) { | ||
if (key.startsWith('series.maps.')) { | ||
const mapNumber = Number(key.substring(12).split('.', 2)[0]) | ||
mapNumbers.add(mapNumber) | ||
} | ||
} | ||
|
||
return [...mapNumbers].sort((a, b) => a - b) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 8 additions & 16 deletions
24
src/themes/fennec/top-bar/center/current-map/current-map.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,25 @@ | ||
import { seriesMapNumbers } from '/hud/helpers/series-map-numbers.js' | ||
|
||
export default { | ||
computed: { | ||
currentMapNumber() { | ||
const mapNumbers = new Set() | ||
|
||
for (const key of Object.keys(this.$opts)) { | ||
if (key.startsWith('series.maps.')) mapNumbers.add(key.substring(12).split('.', 2)[0]) | ||
} | ||
seriesMapNumbers, | ||
|
||
if (mapNumbers.size === 1) return 1 | ||
currentMapNumber() { | ||
if (this.seriesMapNumbers.length < 2) return 1 | ||
|
||
for (const mapNumber of [...mapNumbers].sort((a, b) => Number(a) - Number(b))) { | ||
for (const mapNumber of this.seriesMapNumbers) { | ||
const scoreA = this.$opts[`series.maps.${mapNumber}.pickTeamScore`] | ||
const scoreB = this.$opts[`series.maps.${mapNumber}.enemyTeamScore`] | ||
|
||
const isFirstMapWithoutScores = !scoreA && !scoreB | ||
const isFirstMapWithoutScores = ! scoreA && ! scoreB | ||
if (isFirstMapWithoutScores) return mapNumber | ||
} | ||
|
||
return 1 | ||
}, | ||
|
||
seriesLength() { | ||
const mapNumbers = new Set() | ||
|
||
for (const key of Object.keys(this.$opts)) { | ||
if (key.startsWith('series.maps.')) mapNumbers.add(key.substring(12).split('.', 2)[0]) | ||
} | ||
|
||
return mapNumbers.size | ||
return this.seriesMapNumbers.length | ||
}, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters