2020-01-14 21:04:45 +00:00
|
|
|
import { gameModes } from '@/data/data.js'
|
|
|
|
|
import { mapState } from 'vuex'
|
|
|
|
|
|
|
|
|
|
export const liveGame = {
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
gameLength: 0
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
computed: {
|
|
|
|
|
allyTeam() {
|
2020-01-19 15:18:35 +00:00
|
|
|
return this.current && this.current.participants ? this.current.participants.filter(p => p.teamId === this.teamColor) : []
|
|
|
|
|
},
|
|
|
|
|
displayStartTime() {
|
|
|
|
|
if (this.current.gameStartTime === 0) {
|
|
|
|
|
return 'Not started yet'
|
|
|
|
|
}
|
|
|
|
|
return this.$options.filters.secToTime(this.gameLength, true)
|
2020-01-14 21:04:45 +00:00
|
|
|
},
|
|
|
|
|
enemyTeam() {
|
2020-01-19 15:18:35 +00:00
|
|
|
return this.current && this.current.participants ? this.current.participants.filter(p => p.teamId !== this.teamColor) : []
|
2020-01-14 21:04:45 +00:00
|
|
|
},
|
|
|
|
|
gamemode() {
|
|
|
|
|
return gameModes[this.current.gameQueueConfigId]
|
|
|
|
|
},
|
2020-01-15 20:55:22 +00:00
|
|
|
gameStartTime() {
|
2020-01-19 16:03:40 +00:00
|
|
|
return this.current ? this.current.gameStartTime : 0
|
2020-01-15 20:55:22 +00:00
|
|
|
},
|
2020-01-14 21:04:45 +00:00
|
|
|
teamColor() {
|
|
|
|
|
return this.current.participants.find(p => p.summonerId === this.account.id).teamId
|
|
|
|
|
},
|
|
|
|
|
...mapState({
|
|
|
|
|
account: state => state.summoner.basic.account,
|
2020-01-19 15:18:35 +00:00
|
|
|
current: state => state.summoner.live.match,
|
2020-01-14 21:04:45 +00:00
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
created() {
|
2020-01-19 15:48:28 +00:00
|
|
|
this.updateGameLength()
|
2020-01-14 21:04:45 +00:00
|
|
|
|
|
|
|
|
setInterval(() => {
|
|
|
|
|
this.gameLength++
|
|
|
|
|
}, 1000)
|
|
|
|
|
},
|
|
|
|
|
|
2020-01-19 15:48:28 +00:00
|
|
|
watch: {
|
|
|
|
|
gameStartTime() {
|
|
|
|
|
this.updateGameLength()
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2020-01-14 21:04:45 +00:00
|
|
|
methods: {
|
2020-01-19 15:48:28 +00:00
|
|
|
updateGameLength() {
|
|
|
|
|
if (this.gameStartTime === 0) {
|
|
|
|
|
return this.gameLength = 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.gameLength = (new Date() - new Date(this.gameStartTime)) / 1000
|
|
|
|
|
},
|
2020-01-14 21:04:45 +00:00
|
|
|
}
|
|
|
|
|
}
|