Commit f5b40cfd authored by hewenhao's avatar hewenhao

feat: 增加特别关卡

parent cf408658
......@@ -69,6 +69,8 @@ export interface Stage {
type?: StageType;
upGear: boolean;
part?: number;
/** 星星限制数量 */
limitStar: number;
/** pk负 */
pkLoseNum: number | null;
......
......@@ -151,6 +151,17 @@
flex-direction: column;
align-items: center;
}
.special_name {
display: flex;
align-items: center;
}
.special_star {
width: 40px;
height: 40px;
display: block;
margin-right: 6px;
}
.score {
position: absolute;
......
......@@ -4,12 +4,13 @@ import assetsRoundNext from '@/assets/oss/assets-round-next'
import { useMemo } from 'react'
import classNames from 'classnames'
import { cs } from '@/styles'
import { navigateTo } from '@tarojs/taro'
import { navigateTo, showToast } from '@tarojs/taro'
import type { ImageSource } from '@/types'
import { useStoreActions, useStoreState } from '@/store/hooks'
import { UserGuideView } from '@/components'
import tutorial from '@/assets/oss/assets-tutorial'
import assetsGuide from '@/assets/oss/assets-guide'
import assetsMainNext from '@/assets/oss/assets-main-next'
import { type Stage, StageType, StageStatus, StageLevel, CurrentRoundId } from './constants'
import StageTag from './stage-tag'
......@@ -152,6 +153,7 @@ const StageComp = (props: StageProps) => {
const nextPkGuide = useStoreActions(state => state.guideModel.nextPkGuide)
const showPkGuideFromHis = useStoreState(state => state.guideModel.showPkGuideFromHis)
const updateGuideState = useStoreActions(state => state.guideModel.updateState)
const pkDetails = useStoreState(state => state.userModel.pkDetails)
const isPkGuideShow = useMemo(() => {
const force = pkGuideStep === 2 && pkGuideActive && stage.$stageIndex === 1
......@@ -164,8 +166,18 @@ const StageComp = (props: StageProps) => {
}
}, [pkGuideActive, pkGuideStep, stage, showPkGuideFromHis])
const isSpecialRound = useMemo(() => {
return stage.type === StageType.Special
}, [stage])
const handleClick = () => {
if (stage.status !== StageStatus.DISABLED || !isProduction) {
if (isSpecialRound) {
if ((pkDetails?.stars ?? 0) < stage.limitStar) {
showToast({ title: '星星数量不够,快去收集吧~', icon: 'none' })
return
}
}
/** 从首页进入更新状态 */
updateState({ isSubmit: false })
navigateTo({ url: `/pages/prepare/index?id=${stage.id}` })
......@@ -174,6 +186,7 @@ const StageComp = (props: StageProps) => {
}
const handleLongPress = () => {
if (isSpecialRound) return
if (stage.status === StageStatus.PASSED) {
updateMainModelState({ isCreatePkShow: true, currentPkStage: stage })
}
......@@ -202,6 +215,12 @@ const StageComp = (props: StageProps) => {
}
case StageStatus.CURRENT: {
if (isSpecialRound && (pkDetails?.stars ?? 0) < stage.limitStar) {
return (
<Image src={getLockedIcon(stage.type).u} className={getIconClassNames(stage.type)} />
)
}
return (
<UserGuideView
src={getUnlockedIcon(stage.type).u}
......@@ -249,10 +268,12 @@ const StageComp = (props: StageProps) => {
<Image src={getStarSrc(1, starNum)} className={styles.star_1}></Image>
<Image src={getStarSrc(2, starNum)} className={styles.star_2}></Image>
<Image src={getStarSrc(3, starNum)} className={styles.star_3}></Image>
<View className={styles.pk}>
<View className={styles.pk_item}>{stage.pkWinNum ?? 0}</View>
<View className={classNames(styles.pk_item, styles.is_right)}>{stage.pkLoseNum ?? 0}</View>
</View>
{!isSpecialRound && (
<View className={styles.pk}>
<View className={styles.pk_item}>{stage.pkWinNum ?? 0}</View>
<View className={classNames(styles.pk_item, styles.is_right)}>{stage.pkLoseNum ?? 0}</View>
</View>
)}
</UserGuideView>
)
}
......@@ -274,7 +295,14 @@ const StageComp = (props: StageProps) => {
>
{renderRound(isReady)}
<View className={styles.roundName}>
<View>{!isProduction ? `${stage.id}.` : ''}{stage.name}</View>
{isSpecialRound ? (
<View className={styles.special_name}>
<Image src={assetsMainNext['star.png'].u} className={styles.special_star} />
星星 {pkDetails?.stars ?? 0}/{stage.limitStar}
</View>
) : (
<View>{!isProduction ? `${stage.id}.` : ''}{stage.name}</View>
)}
</View>
</View>
)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment