Skip to content

Commit

Permalink
chore: 瞬間タイピング速度機能削除
Browse files Browse the repository at this point in the history
  • Loading branch information
h-takeyeah committed Apr 16, 2024
1 parent 65c5061 commit d4a7383
Showing 1 changed file with 0 additions and 21 deletions.
21 changes: 0 additions & 21 deletions typing-app/src/components/templates/GameTyping.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ const GameTyping: React.FC<GameTypingProps> = ({ nextPage, subjectText, setResul
// タイピング速度計算用
const typingQueueListSize = 5; // ここで瞬間タイピング速度計算の粒度を決める 増やすほど変化が穏やかになる
const [typingQueueList] = useState<number[]>([]);
const [currentTypeSpeed, setCurrentTypeSpeed] = useState(0);
const [averageTypeSpeed, setAverageTypeSpeed] = useState(0);

const typeIndexRef = useRef(typeIndex);
Expand All @@ -105,15 +104,6 @@ const GameTyping: React.FC<GameTypingProps> = ({ nextPage, subjectText, setResul
}, [typeIndex]);

useEffect(() => {
const calcCurrentTypingSpeed = (): number => {
if (typingQueueList.length <= 1) {
return 0;
}
const typeTime = getTypingQueueListIndex(typingQueueList.length - 1) - getTypingQueueListIndex(0);
const currentWpm = (typingQueueList.length / typeTime) * 60000;
return currentWpm;
};

const calcAverageTypingSpeed = (): number => {
const timeFromStart: number = new Date().valueOf() - startedAt.valueOf();
const averageTypingSpeed: number = (correctType / timeFromStart) * 60000;
Expand All @@ -128,16 +118,6 @@ const GameTyping: React.FC<GameTypingProps> = ({ nextPage, subjectText, setResul
}
};

const getTypingQueueListIndex = (index: number): number => {
if (index < 0) {
return 0;
}
if (index >= typingQueueList.length) {
return typingQueueList.length - 1;
}
return 0;
};

const handleOnKeyDown = (e: KeyboardEvent) => {
const key = e.key;
if (key.length !== 1) {
Expand All @@ -148,7 +128,6 @@ const GameTyping: React.FC<GameTypingProps> = ({ nextPage, subjectText, setResul
setTypeIndex((prev) => prev + 1);
setCorrectType((prev) => prev + 1);
addTypingQueueList();
setCurrentTypeSpeed(calcCurrentTypingSpeed());
setAverageTypeSpeed(calcAverageTypingSpeed());
} else {
setIncorrectType((prev) => prev + 1);
Expand Down

0 comments on commit d4a7383

Please sign in to comment.