Skip to content

Commit

Permalink
fix: 通关成功状态判断,完成游戏后无法点击问题
Browse files Browse the repository at this point in the history
  • Loading branch information
StreakingMan committed Oct 19, 2022
1 parent c667103 commit 331b96c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
24 changes: 15 additions & 9 deletions src/components/Game.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ const Game: FC<{
Record<MySymbol['id'], number>
>({});
const [finished, setFinished] = useState<boolean>(false);
const [success, setSuccess] = useState<boolean>(false);
const [animating, setAnimating] = useState<boolean>(false);

// 音效
Expand Down Expand Up @@ -326,6 +327,7 @@ const Game: FC<{
// 重开
const restart = () => {
setFinished(false);
setSuccess(false);
setScore(0);
setLevel(1);
setQueue([]);
Expand Down Expand Up @@ -395,21 +397,25 @@ const Game: FC<{
// 输了
if (updateQueue.length === 7) {
setFinished(true);
setSuccess(false);
}

if (!updateScene.find((s) => s.status !== 2)) {
// 胜利
// 队列清空了
if (level === maxLevel) {
// 胜利
setFinished(true);
return;
setSuccess(true);
} else {
// 升级
// 通关奖励关卡对应数值分数
setScore(score + level);
setLevel(level + 1);
setQueue([]);
checkCover(makeScene(level + 1, theme.icons));
}
// 升级
// 通关奖励关卡对应数值分数
setScore(score + level);
setLevel(level + 1);
setQueue([]);
checkCover(makeScene(level + 1, theme.icons));
} else {
// 更新队列
setQueue(updateQueue);
checkCover(updateScene);
}
Expand Down Expand Up @@ -496,7 +502,7 @@ const Game: FC<{
level={level}
time={usedTime}
score={score}
success={level === maxLevel}
success={success}
pure={theme.pure}
restartMethod={restart}
/>
Expand Down
2 changes: 1 addition & 1 deletion src/components/WxQrCode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { FC, MouseEventHandler, useState } from 'react';
import style from './WxQrCode.module.scss';
import classNames from 'classnames';
const WxQrCode: FC<{ title?: string; onClick?: MouseEventHandler }> = ({
title = '【广告位招租中】同时如果您喜欢这个项目的话,可以点击扫描下方收款码分摊后台相关费用,感谢~😘',
title = '如果您喜欢这个项目的话,可以点击扫描下方收款码分担后台相关费用(或请我喝杯咖啡),感谢~😘',
onClick,
}) => {
const [fullScreen, setFullScreen] = useState<Record<number, boolean>>({
Expand Down
2 changes: 1 addition & 1 deletion src/themes/default/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const getDefaultTheme: () => Theme<DefaultSoundNames> = () => {
title: '有解的羊了个羊',
desc: '真的可以通关~',
dark: true,
maxLevel: 20,
maxLevel: 5,
backgroundColor: '#8dac85',
icons: icons.map((icon) => ({
name: icon,
Expand Down

0 comments on commit 331b96c

Please sign in to comment.