| 5 | import {champDict} from "@/resources/champList"; |
| 6 | |
| 7 | export default class BaseMatch { |
| 8 | |
| 9 | public gerSummonerInfo = async (summonerId?: number) => { |
| 10 | const summonerInfo = await querySummonerInfo(summonerId) |
| 11 | if (summonerInfo !== null) { |
| 12 | const rankList = await queryRankPoint(summonerInfo.puuid) |
| 13 | return {summonerInfo,rankList} |
| 14 | } |
| 15 | return null |
| 16 | } |
| 17 | |
| 18 | public dealMatchHistory = async (puuid: string, begIndex: number, endIndex: number): Promise<SimpleMatchDetailsTypes[]|null> => { |
| 19 | const matchList = await queryMatchHistory(puuid, begIndex, endIndex) |
| 20 | if (matchList === null) { |
| 21 | return null |
| 22 | } |
| 23 | |
| 24 | return matchList.map((matchListElement) => { |
| 25 | return this.getSimpleMatch(matchListElement) |
| 26 | }) |
| 27 | } |
| 28 | |
| 29 | public getSimpleMatch = (match: Games): SimpleMatchDetailsTypes => { |
| 30 | const times = this.timestampToDate(match.gameCreation) |
| 31 | const kills = match.participants[0].stats.kills |
| 32 | const deaths = match.participants[0].stats.deaths |
| 33 | const assists = match.participants[0].stats.assists |
| 34 | const kda = deaths===0? kills+assists : Math.round((kills+assists)/deaths*3) |
| 35 | |
| 36 | return { |
| 37 | gameId:match.gameId, |
| 38 | champImgUrl: `${champDict[String(match.participants[0].championId)].alias}.png`, |
| 39 | // 是否取得胜利 |
| 40 | isWin: match.participants[0].stats.win === true ? true : false, |
| 41 | // 击杀数目 |
| 42 | kills: kills, |
| 43 | // 死亡数目 |
| 44 | deaths: deaths, |
| 45 | // 助攻数目 |
| 46 | assists: assists, |
| 47 | //kda |
| 48 | kda: kda, |
| 49 | // 游戏时间 |
| 50 | matchTime: times[1], |
| 51 | // 开始时间 22:00 |
| 52 | startTime:times[0], |
| 53 | // 游戏模式 |
| 54 | gameModel:queryGameType(match.queueId), |
| 55 | //游戏对局ID |
| 56 | queueId:match.queueId, |
| 57 | champId: match.participants[0].championId |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | public querySpecialMatch = async (puuid: string,queueId:number) => { |
| 62 | const matchList = await queryMatchHistory(puuid, 0, 99) |
| 63 | if (matchList === null){ |
| 64 | return [] |
nothing calls this directly
no test coverage detected