File tree 7 files changed +53
-54
lines changed
7 files changed +53
-54
lines changed Original file line number Diff line number Diff line change
1
+ // needs to be a `function` so `this` is the Vue component
2
+ export function seriesMapNumbers ( ) {
3
+ const mapNumbers = new Set ( )
4
+
5
+ for ( const key of Object . keys ( this . $opts ) ) {
6
+ if ( key . startsWith ( 'series.maps.' ) ) {
7
+ const mapNumber = Number ( key . substring ( 12 ) . split ( '.' , 2 ) [ 0 ] )
8
+ mapNumbers . add ( mapNumber )
9
+ }
10
+ }
11
+
12
+ return [ ...mapNumbers ] . sort ( ( a , b ) => a - b )
13
+ }
Original file line number Diff line number Diff line change 1
1
import { formatMapName } from '/hud/helpers/format-map-name.js'
2
+ import { seriesMapNumbers } from '/hud/helpers/series-map-numbers.js'
2
3
import Match from '/hud/series-graph/match/match.vue'
3
4
4
5
export default {
@@ -7,21 +8,17 @@ export default {
7
8
} ,
8
9
9
10
computed : {
10
- matches ( ) {
11
- const mapNumbers = new Set ( )
12
-
13
- for ( const key of Object . keys ( this . $opts ) ) {
14
- if ( key . startsWith ( 'series.maps.' ) ) mapNumbers . add ( key . substring ( 12 ) . split ( '.' , 2 ) [ 0 ] )
15
- }
11
+ seriesMapNumbers,
16
12
13
+ matches ( ) {
17
14
const maps = [ ]
18
15
19
- for ( const mapNumber of [ ... mapNumbers ] . sort ( ( a , b ) => Number ( a ) - Number ( b ) ) ) {
16
+ for ( const mapNumber of this . seriesMapNumbers ) {
20
17
const mapName = this . $opts [ `series.maps.${ mapNumber } .name` ]
21
18
const scoreA = this . $opts [ `series.maps.${ mapNumber } .pickTeamScore` ]
22
19
const scoreB = this . $opts [ `series.maps.${ mapNumber } .enemyTeamScore` ]
23
20
24
- const isOnlyMatch = mapNumbers . size === 1
21
+ const isOnlyMatch = this . seriesMapNumbers . length === 1
25
22
const isFirstMapWithoutScores = ! scoreA && ! scoreB && ( mapNumber === 1 || maps [ maps . length - 1 ] ?. scores )
26
23
27
24
maps . push ( {
Original file line number Diff line number Diff line change
1
+ import { seriesMapNumbers } from '/hud/helpers/series-map-numbers.js'
1
2
import Player from '/hud/sidebars/sidebar/player/player.vue'
2
3
import TeamEquipment from '/hud/sidebars/sidebar/team-equipment/team-equipment.vue'
3
4
import TeamGrenades from '/hud/sidebars/sidebar/team-grenades/team-grenades.vue'
@@ -21,14 +22,11 @@ export default {
21
22
22
23
hasSeriesGraph ( ) {
23
24
if ( this . $opts [ 'preferences.seriesGraph.showMapForOnlyMatch' ] ) return true
24
-
25
- const mapNumbers = new Set ( )
26
-
27
- for ( const key of Object . keys ( this . $opts ) ) {
28
- if ( key . startsWith ( 'series.maps.' ) ) mapNumbers . add ( key . substring ( 12 ) . split ( '.' , 2 ) [ 0 ] )
29
- }
30
-
31
- return mapNumbers . size > 1
25
+ return this . seriesMapNumbers ( ) . length > 1
32
26
} ,
33
- }
27
+ } ,
28
+
29
+ methods : {
30
+ seriesMapNumbers,
31
+ } ,
34
32
}
Original file line number Diff line number Diff line change
1
+ import { seriesMapNumbers } from '/hud/helpers/series-map-numbers.js'
1
2
import CurrentMap from '/hud/top-bar/center/current-map/current-map.vue'
2
3
import CurrentRound from '/hud/top-bar/center/current-round/current-round.vue'
3
4
import Digits from '/hud/digits/digits.vue'
@@ -17,13 +18,11 @@ export default {
17
18
18
19
computed : {
19
20
isMultipleMapSeries ( ) {
20
- const mapNumbers = new Set ( )
21
-
22
- for ( const key of Object . keys ( this . $opts ) ) {
23
- if ( key . startsWith ( 'series.maps.' ) ) mapNumbers . add ( key . substring ( 12 ) . split ( '.' , 2 ) [ 0 ] )
24
- }
25
-
26
- return mapNumbers . size > 1
21
+ return this . seriesMapNumbers ( ) . length > 1
27
22
} ,
28
23
} ,
24
+
25
+ methods : {
26
+ seriesMapNumbers,
27
+ } ,
29
28
}
Original file line number Diff line number Diff line change
1
+ import { seriesMapNumbers } from '/hud/helpers/series-map-numbers.js'
2
+
1
3
export default {
2
4
computed : {
3
- currentMapNumber ( ) {
4
- const mapNumbers = new Set ( )
5
-
6
- for ( const key of Object . keys ( this . $opts ) ) {
7
- if ( key . startsWith ( 'series.maps.' ) ) mapNumbers . add ( key . substring ( 12 ) . split ( '.' , 2 ) [ 0 ] )
8
- }
5
+ seriesMapNumbers,
9
6
10
- if ( mapNumbers . size === 1 ) return 1
7
+ currentMapNumber ( ) {
8
+ if ( this . seriesMapNumbers . length < 2 ) return 1
11
9
12
- for ( const mapNumber of [ ... mapNumbers ] . sort ( ( a , b ) => Number ( a ) - Number ( b ) ) ) {
10
+ for ( const mapNumber of this . seriesMapNumbers ) {
13
11
const scoreA = this . $opts [ `series.maps.${ mapNumber } .pickTeamScore` ]
14
12
const scoreB = this . $opts [ `series.maps.${ mapNumber } .enemyTeamScore` ]
15
13
16
- const isFirstMapWithoutScores = ! scoreA && ! scoreB
14
+ const isFirstMapWithoutScores = ! scoreA && ! scoreB
17
15
if ( isFirstMapWithoutScores ) return mapNumber
18
16
}
19
17
20
18
return 1
21
19
} ,
22
20
23
21
seriesLength ( ) {
24
- const mapNumbers = new Set ( )
25
-
26
- for ( const key of Object . keys ( this . $opts ) ) {
27
- if ( key . startsWith ( 'series.maps.' ) ) mapNumbers . add ( key . substring ( 12 ) . split ( '.' , 2 ) [ 0 ] )
28
- }
29
-
30
- return mapNumbers . size
22
+ return this . seriesMapNumbers . length
31
23
} ,
32
24
} ,
33
25
}
Original file line number Diff line number Diff line change
1
+ import { seriesMapNumbers } from '/hud/helpers/series-map-numbers.js'
1
2
import { teamColorClass } from '/hud/helpers/team-color-class.js'
2
3
3
4
export default {
@@ -16,12 +17,7 @@ export default {
16
17
} ,
17
18
18
19
pips ( ) {
19
- const mapNumbers = new Set ( )
20
-
21
- for ( const key of Object . keys ( this . $opts ) ) {
22
- if ( key . startsWith ( 'series.maps.' ) ) mapNumbers . add ( key . substring ( 12 ) . split ( '.' , 2 ) [ 0 ] )
23
- }
24
-
20
+ const mapNumbers = this . seriesMapNumbers ( )
25
21
const pips = [ ]
26
22
27
23
for ( const mapNumber of mapNumbers ) {
@@ -34,8 +30,12 @@ export default {
34
30
} else if ( scoreB > scoreA ) pips . push ( true )
35
31
}
36
32
37
- const maxMapWins = Math . floor ( mapNumbers . size / 2 ) + 1
33
+ const maxMapWins = Math . floor ( mapNumbers . length / 2 ) + 1
38
34
return [ ...pips , ...new Array ( maxMapWins - pips . length ) . fill ( false ) ]
39
35
} ,
40
36
} ,
37
+
38
+ methods : {
39
+ seriesMapNumbers,
40
+ } ,
41
41
}
Original file line number Diff line number Diff line change
1
+ import { seriesMapNumbers } from '/hud/helpers/series-map-numbers.js'
2
+
1
3
export default {
2
4
computed : {
3
5
isMatchPointRoundsActive ( ) {
@@ -6,13 +8,11 @@ export default {
6
8
} ,
7
9
8
10
isMultipleMapSeries ( ) {
9
- const mapNumbers = new Set ( )
10
-
11
- for ( const key of Object . keys ( this . $opts ) ) {
12
- if ( key . startsWith ( 'series.maps.' ) ) mapNumbers . add ( key . substring ( 12 ) . split ( '.' , 2 ) [ 0 ] )
13
- }
14
-
15
- return mapNumbers . size > 1
11
+ return this . seriesMapNumbers ( ) . length > 1
16
12
} ,
17
13
} ,
14
+
15
+ methods : {
16
+ seriesMapNumbers,
17
+ } ,
18
18
}
You can’t perform that action at this time.
0 commit comments