Skip to content

Commit

Permalink
Merge pull request #56 from 2skydev/dev
Browse files Browse the repository at this point in the history
v0.0.11
  • Loading branch information
2skydev authored Jul 3, 2023
2 parents a4f27f2 + 4a256dd commit d9c6444
Show file tree
Hide file tree
Showing 32 changed files with 497 additions and 272 deletions.
2 changes: 2 additions & 0 deletions src/main/modules/config/stores/config.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface ConfigStoreValues {
game: {
autoAccept: boolean
autoAcceptDelaySeconds: number
useCurrentPositionChampionData: boolean
}
}

Expand All @@ -29,6 +30,7 @@ export const configStore = new Store<ConfigStoreValues>({
game: {
autoAccept: false,
autoAcceptDelaySeconds: 0,
useCurrentPositionChampionData: true,
},
},
})
Expand Down
9 changes: 9 additions & 0 deletions src/main/modules/league/constants/lane.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export const LANE_IDS = [0, 1, 2, 3, 4] as const

export const LANE_ID_TO_LABEL_MAP = {
0: '탑',
1: '정글',
2: '미드',
3: '원딜',
4: '서폿',
} as const
11 changes: 11 additions & 0 deletions src/main/modules/league/types/lane.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { LANE_IDS } from '@main/modules/league/constants/lane'

export type LaneId = (typeof LANE_IDS)[number]

export enum LANE_ID_ENUM {
top = 0,
jg = 1,
mid = 2,
adc = 3,
sup = 4,
}
15 changes: 15 additions & 0 deletions src/main/modules/league/utils/lane.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { LaneId } from '@main/modules/league/types/lane'

export const leagueChampSelectLaneStringToLaneId = (
value: 'top' | 'jungle' | 'middle' | 'bottom' | 'utility' | '',
): LaneId | null => {
return (
{
top: 0,
jungle: 1,
middle: 2,
bottom: 3,
utility: 4,
}[value] || null
)
}
4 changes: 4 additions & 0 deletions src/main/modules/migration/migration.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,8 @@ export class MigrationModule {
await ladaAutoLauncher.enable()
}
}

async 'v0.0.11'() {
configStore.set('game.useCurrentPositionChampionData', true)
}
}
8 changes: 8 additions & 0 deletions src/main/modules/ps/constants/rank.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export const RANK_RANGE_IDS = [2, 13, 3, 1] as const

export const RANK_RANGE_ID_TO_LABEL_MAP = {
2: '플레티넘+',
13: '다이아+',
3: '마스터+',
1: '브실골',
} as const
139 changes: 74 additions & 65 deletions src/main/modules/ps/ps.module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { initializer, singleton } from '@launchtray/tsyringe-async'
import axios from 'axios'
import axios, { AxiosResponse } from 'axios'
import * as cheerio from 'cheerio'

import { getAvgTier } from '@main/modules/league/utils/rank'
Expand Down Expand Up @@ -121,75 +121,86 @@ export class PSModule {
laneId = Number(laneId)
rankRangeId = Number(rankRangeId)

const {
data: { data: summary },
} = await axios.get(`https://lol.ps/api/champ/${id}/summary.json`, {
params: {
region: 0,
version: this.version,
tier: rankRangeId,
lane: laneId,
},
})
let promises: Promise<AxiosResponse<any>>[] = [
axios.get(`https://lol.ps/api/champ/${id}/summary.json`, {
params: {
region: 0,
version: this.version,
tier: rankRangeId,
lane: laneId,
},
}),

axios.get(`https://lol.ps/api/champ/${id}/spellitem.json`, {
params: {
region: 0,
version: this.version,
tier: rankRangeId,
lane: laneId,
},
}),

axios.get(`https://lol.ps/api/champ/${id}/skill.json`, {
params: {
region: 0,
version: this.version,
tier: rankRangeId,
lane: laneId,
},
}),

axios.get(`https://lol.ps/api/champ/${id}/runestatperk.json`, {
params: {
region: 0,
version: this.version,
tier: rankRangeId,
lane: laneId,
},
}),

axios.get(`https://lol.ps/api/champ/${id}/graphs.json`, {
params: {
region: 0,
version: this.version,
tier: rankRangeId,
lane: laneId,
},
}),

axios.get(`https://lol.ps/api/champ/${id}/versus.json`, {
params: {
region: 0,
version: this.version,
tier: rankRangeId,
lane: laneId,
},
}),
]

const {
data: {
data: { itemWinrates: item, spellWinrates: spell },
},
} = await axios.get(`https://lol.ps/api/champ/${id}/spellitem.json`, {
params: {
region: 0,
version: this.version,
tier: rankRangeId,
lane: laneId,
const [
{
data: { data: summary },
},
})

const {
data: { data: skill },
} = await axios.get(`https://lol.ps/api/champ/${id}/skill.json`, {
params: {
region: 0,
version: this.version,
tier: rankRangeId,
lane: laneId,
{
data: {
data: { itemWinrates: item, spellWinrates: spell },
},
},
})

const {
data: { data: runestatperk },
} = await axios.get(`https://lol.ps/api/champ/${id}/runestatperk.json`, {
params: {
region: 0,
version: this.version,
tier: rankRangeId,
lane: laneId,
{
data: { data: skill },
},
})

const {
data: {
data: { timelineWinrates },
{
data: { data: runestatperk },
},
} = await axios.get(`https://lol.ps/api/champ/${id}/graphs.json`, {
params: {
region: 0,
version: this.version,
tier: rankRangeId,
lane: laneId,
{
data: {
data: { timelineWinrates },
},
},
})

const {
data: { data: versus },
} = await axios.get(`https://lol.ps/api/champ/${id}/versus.json`, {
params: {
region: 0,
version: this.version,
tier: rankRangeId,
lane: laneId,
{
data: { data: versus },
},
})
] = await Promise.all(promises)

const counterChampionIdList = JSON.parse(versus.counterChampionIdList)
const counterWinrateList = JSON.parse(versus.counterWinrateList)
Expand Down Expand Up @@ -260,8 +271,6 @@ export class PSModule {

async getInGame(summonerPsId: string): Promise<PSInGame | null> {
try {
// return inGameTempData as PSInGame

const {
data: { data },
} = await axios.get(`https://lol.ps/api/summoner/${summonerPsId}/spectator.json`, {
Expand Down
3 changes: 3 additions & 0 deletions src/main/modules/ps/types/rank.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { RANK_RANGE_IDS } from '@main/modules/ps/constants/rank'

export type RankRangeId = (typeof RANK_RANGE_IDS)[number]
5 changes: 3 additions & 2 deletions src/renderer/src/components/Sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import clsx from 'clsx'
import { motion, LayoutGroup, AnimatePresence } from 'framer-motion'
import { useRecoilValue } from 'recoil'

import { LANE_ID_ENUM } from '@main/modules/league/types/lane'

import logoImage from '@renderer/assets/images/logo@256.png'
import LaneIcon from '@renderer/features/asset/LaneIcon'
import { configStore } from '@renderer/stores/config'
import { LANE_ID } from '@renderer/types/league'

import { SidebarStyled } from './styled'

Expand Down Expand Up @@ -38,7 +39,7 @@ const Sidebar = ({ className }: SidebarProps) => {
title: '통계',
items: [
{
icon: <LaneIcon laneId={LANE_ID.top} />,
icon: <LaneIcon laneId={LANE_ID_ENUM.top} />,
link: '/',
text: '챔피언 티어',
isActiveFn: (pathname: string) => pathname === '/' || pathname.includes('/champ/'),
Expand Down
12 changes: 5 additions & 7 deletions src/renderer/src/features/champ/ChampDetail/ChampDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ import { useLocation } from 'react-router-dom'
import clsx from 'clsx'
import { motion } from 'framer-motion'
import QueryString from 'qs'
import { useRecoilValue } from 'recoil'

import LoadingIcon from '@renderer/components/LoadingIcon'
import DataDragonImage from '@renderer/features/asset/DataDragonImage'
import TierIcon, { HoneyIcon, OpIcon } from '@renderer/features/asset/TierIcon'
import ItemBuilds from '@renderer/features/item/ItemBuilds'
import LaneSelect from '@renderer/features/lane/LaneSelect'
import RankRangeSelect from '@renderer/features/rank/RankRangeSelect'
import { rankRangeIdAtom } from '@renderer/features/rank/RankRangeSelect/rankRangeId.atom'
import RunePage from '@renderer/features/rune/RunePage'
import RuneStyleButtonRadioList from '@renderer/features/rune/RuneStyleButtonRadioList'
import useAPI from '@renderer/hooks/useAPI'
Expand Down Expand Up @@ -41,20 +43,20 @@ const ChampDetail = ({ className, champId }: ChampDetailProps) => {
const form = useCustomForm({
defaultValues: {
laneId: defaultLaneId ? Number(defaultLaneId) : null,
rankRangeId: 2,
runeStyleId: 0,
},
onSubmit: () => {},
})

const laneId = form.watch('laneId')
const rankRangeId = form.watch('rankRangeId')
const selectedRuneStyleId = form.watch('runeStyleId')
const rankRangeId = useRecoilValue(rankRangeIdAtom)

const champNames = useDataDragonChampNames()
const summonerSpells = useDataDragonSummonerSpells()

const { data, isValidating } = useAPI('ps', `/champ/${champId}`, {
dedupingInterval: 1000 * 60 * 5,
payload: {
laneId,
rankRangeId,
Expand Down Expand Up @@ -113,11 +115,7 @@ const ChampDetail = ({ className, champId }: ChampDetailProps) => {
)}
/>

<Controller
control={form.control}
name="rankRangeId"
render={({ field }) => <RankRangeSelect {...field} />}
/>
<RankRangeSelect />
</div>

<section className="summary">
Expand Down
15 changes: 9 additions & 6 deletions src/renderer/src/features/duo/DuoLaneSelect/DuoLaneSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,23 @@ import { forwardRef } from 'react'
import { Radio, RadioGroupProps } from 'antd'
import clsx from 'clsx'

import { LANE_ID_ENUM } from '@main/modules/league/types/lane'

import LaneIcon from '@renderer/features/asset/LaneIcon'
import { LANE_ID } from '@renderer/types/league'

import { DuoLaneSelectStyled } from './styled'

export interface DuoLaneSelectProps extends RadioGroupProps {
className?: string
}

export const DUO_OPTIONS: [LANE_ID, LANE_ID, string][] = [
[LANE_ID.adc, LANE_ID.sup, '바텀'],
[LANE_ID.mid, LANE_ID.jg, '미드 & 정글'],
[LANE_ID.top, LANE_ID.jg, '탑 & 정글'],
[LANE_ID.jg, LANE_ID.sup, '정글 & 서폿'],
export type DuoId = 0 | 1 | 2 | 3

export const DUO_OPTIONS: [LANE_ID_ENUM, LANE_ID_ENUM, string][] = [
[LANE_ID_ENUM.adc, LANE_ID_ENUM.sup, '바텀'],
[LANE_ID_ENUM.mid, LANE_ID_ENUM.jg, '미드 & 정글'],
[LANE_ID_ENUM.top, LANE_ID_ENUM.jg, '탑 & 정글'],
[LANE_ID_ENUM.jg, LANE_ID_ENUM.sup, '정글 & 서폿'],
]

const DuoLaneSelect = forwardRef<HTMLDivElement, DuoLaneSelectProps>(
Expand Down
Loading

0 comments on commit d9c6444

Please sign in to comment.