renamed 2 variables

This commit is contained in:
Miodec 2023-07-29 01:52:10 +02:00
parent 73ddb06339
commit f326482af6
3 changed files with 13 additions and 12 deletions

View file

@ -216,8 +216,8 @@ let keyDownData: Record<string, Keydata> = {};
export const input = new Input();
export const corrected = new Corrected();
export let keypressPerSecond: number[] = [];
let currentSecondKeypressData = 0;
export let keypressCountHistory: number[] = [];
let currentKeypressCount = 0;
export let currentBurstStart = 0;
export let missedWords: {
[word: string]: number;
@ -259,7 +259,7 @@ export function enableSpacingDebug(): void {
}
export function incrementKeypressCount(): void {
currentSecondKeypressData++;
currentKeypressCount++;
}
export function setCurrentNotAfk(): void {
@ -279,8 +279,8 @@ export function setBurstStart(time: number): void {
}
export function pushKeypressesToHistory(): void {
keypressPerSecond.push(currentSecondKeypressData);
currentSecondKeypressData = 0;
keypressCountHistory.push(currentKeypressCount);
currentKeypressCount = 0;
}
export function pushAfkToHistory(): void {
@ -482,8 +482,8 @@ export function restart(): void {
wpmHistory = [];
rawHistory = [];
burstHistory = [];
keypressPerSecond = [];
currentSecondKeypressData = 0;
keypressCountHistory = [];
currentKeypressCount = 0;
afkHistory = [];
currentAfk = true;
errorHistory = [];

View file

@ -869,7 +869,7 @@ function buildCompletedEvent(difficultyFailed: boolean): CompletedEvent {
}
//consistency
const rawPerSecond = TestInput.keypressPerSecond.map((count) =>
const rawPerSecond = TestInput.keypressCountHistory.map((count) =>
Math.round((count / 5) * 60)
);

View file

@ -57,7 +57,7 @@ export function getStats(): unknown {
wpmHistory: TestInput.wpmHistory,
rawHistory: TestInput.rawHistory,
burstHistory: TestInput.burstHistory,
keypressPerSecond: TestInput.keypressPerSecond,
keypressPerSecond: TestInput.keypressCountHistory,
currentBurstStart: TestInput.currentBurstStart,
lastSecondNotRound,
missedWords: TestInput.missedWords,
@ -248,9 +248,10 @@ export function calculateAfkSeconds(testSeconds: number): number {
let extraAfk = 0;
if (testSeconds !== undefined) {
if (Config.mode === "time") {
extraAfk = Math.round(testSeconds) - TestInput.keypressPerSecond.length;
extraAfk =
Math.round(testSeconds) - TestInput.keypressCountHistory.length;
} else {
extraAfk = Math.ceil(testSeconds) - TestInput.keypressPerSecond.length;
extraAfk = Math.ceil(testSeconds) - TestInput.keypressCountHistory.length;
}
if (extraAfk < 0) extraAfk = 0;
// console.log("-- extra afk debug");
@ -296,7 +297,7 @@ export function calculateAccuracy(): number {
export function removeAfkData(): void {
const testSeconds = calculateTestSeconds();
TestInput.keypressPerSecond.splice(testSeconds);
TestInput.keypressCountHistory.splice(testSeconds);
TestInput.wpmHistory.splice(testSeconds);
TestInput.burstHistory.splice(testSeconds);
TestInput.rawHistory.splice(testSeconds);