mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-10-24 14:56:23 +08:00
added more detailed incomplete test tracking
altering incomplete xp gained based on accuracy of those tests
This commit is contained in:
parent
80cc8dde06
commit
ddea63d371
5 changed files with 40 additions and 6 deletions
|
|
@ -445,6 +445,7 @@ async function calculateXp(
|
|||
acc,
|
||||
testDuration,
|
||||
incompleteTestSeconds,
|
||||
incompleteTests,
|
||||
afkDuration,
|
||||
charStats,
|
||||
punctuation,
|
||||
|
|
@ -514,8 +515,18 @@ async function calculateXp(
|
|||
}
|
||||
}
|
||||
|
||||
const incompleteXp = Math.round(incompleteTestSeconds);
|
||||
breakdown["incomplete"] = incompleteXp;
|
||||
let incompleteXp = 0;
|
||||
if (incompleteTests && incompleteTests.length > 0) {
|
||||
incompleteTests.forEach((it: { acc: number; seconds: number }) => {
|
||||
let modifier = (it.acc - 50) / 50;
|
||||
if (modifier < 0) modifier = 0;
|
||||
incompleteXp += Math.round(it.seconds * modifier);
|
||||
});
|
||||
breakdown["incomplete"] = incompleteXp;
|
||||
} else if (incompleteTestSeconds && incompleteTestSeconds > 0) {
|
||||
incompleteXp = Math.round(incompleteTestSeconds);
|
||||
breakdown["incomplete"] = incompleteXp;
|
||||
}
|
||||
|
||||
const accuracyModifier = (acc - 50) / 50;
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,13 @@ const RESULT_SCHEMA = joi
|
|||
funbox: joi.string().required(),
|
||||
hash: joi.string().required(),
|
||||
incompleteTestSeconds: joi.number().required(),
|
||||
incompleteTests: joi.array().items(
|
||||
joi.object({
|
||||
acc: joi.number().min(0).max(100).required(),
|
||||
seconds: joi.number().min(0).required(),
|
||||
})
|
||||
),
|
||||
// .required(), //add required after a few days
|
||||
keyConsistency: joi.number().required(),
|
||||
keyDuration: joi
|
||||
.alternatives()
|
||||
|
|
|
|||
|
|
@ -442,10 +442,12 @@ export function restart(options = {} as RestartOptions): void {
|
|||
TestInput.pushKeypressesToHistory();
|
||||
const testSeconds = TestStats.calculateTestSeconds(performance.now());
|
||||
const afkseconds = TestStats.calculateAfkSeconds(testSeconds);
|
||||
let tt = testSeconds - afkseconds;
|
||||
let tt = Misc.roundTo2(testSeconds - afkseconds);
|
||||
if (tt < 0) tt = 0;
|
||||
TestStats.incrementIncompleteSeconds(tt);
|
||||
TestStats.incrementRestartCount();
|
||||
const acc = Misc.roundTo2(TestStats.calculateAccuracy());
|
||||
TestStats.pushIncompleteTest(acc, tt);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -714,8 +716,6 @@ export function restart(options = {} as RestartOptions): void {
|
|||
}
|
||||
// ChartController.result.update();
|
||||
PageTransition.set(false);
|
||||
// console.log(TestStats.incompleteSeconds);
|
||||
// console.log(TestStats.restartCount);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
@ -1335,6 +1335,7 @@ function buildCompletedEvent(difficultyFailed: boolean): CompletedEvent {
|
|||
timestamp: Date.now(),
|
||||
language: Config.language,
|
||||
restartCount: TestStats.restartCount,
|
||||
incompleteTests: TestStats.incompleteTests,
|
||||
incompleteTestSeconds:
|
||||
TestStats.incompleteSeconds < 0
|
||||
? 0
|
||||
|
|
@ -1794,10 +1795,12 @@ export function fail(reason: string): void {
|
|||
if (!TestState.savingEnabled) return;
|
||||
const testSeconds = TestStats.calculateTestSeconds(performance.now());
|
||||
const afkseconds = TestStats.calculateAfkSeconds(testSeconds);
|
||||
let tt = testSeconds - afkseconds;
|
||||
let tt = Misc.roundTo2(testSeconds - afkseconds);
|
||||
if (tt < 0) tt = 0;
|
||||
TestStats.incrementIncompleteSeconds(tt);
|
||||
TestStats.incrementRestartCount();
|
||||
const acc = Misc.roundTo2(TestStats.calculateAccuracy());
|
||||
TestStats.pushIncompleteTest(acc, tt);
|
||||
}
|
||||
|
||||
$(document).on("click", "#testModesNotice .textButton.restart", () => {
|
||||
|
|
|
|||
|
|
@ -160,6 +160,8 @@ export function restart(): void {
|
|||
export let restartCount = 0;
|
||||
export let incompleteSeconds = 0;
|
||||
|
||||
export let incompleteTests: MonkeyTypes.IncompleteTest[] = [];
|
||||
|
||||
export function incrementRestartCount(): void {
|
||||
restartCount++;
|
||||
}
|
||||
|
|
@ -168,9 +170,14 @@ export function incrementIncompleteSeconds(val: number): void {
|
|||
incompleteSeconds += val;
|
||||
}
|
||||
|
||||
export function pushIncompleteTest(acc: number, seconds: number): void {
|
||||
incompleteTests.push({ acc, seconds });
|
||||
}
|
||||
|
||||
export function resetIncomplete(): void {
|
||||
restartCount = 0;
|
||||
incompleteSeconds = 0;
|
||||
incompleteTests = [];
|
||||
}
|
||||
|
||||
export function setInvalid(): void {
|
||||
|
|
|
|||
6
frontend/src/ts/types/types.d.ts
vendored
6
frontend/src/ts/types/types.d.ts
vendored
|
|
@ -252,6 +252,11 @@ declare namespace MonkeyTypes {
|
|||
sd: number;
|
||||
}
|
||||
|
||||
interface IncompleteTest {
|
||||
acc: number;
|
||||
seconds: number;
|
||||
}
|
||||
|
||||
interface Result<M extends Mode> {
|
||||
_id: string;
|
||||
wpm: number;
|
||||
|
|
@ -266,6 +271,7 @@ declare namespace MonkeyTypes {
|
|||
timestamp: number;
|
||||
restartCount: number;
|
||||
incompleteTestSeconds: number;
|
||||
incompleteTests: IncompleteTest[];
|
||||
testDuration: number;
|
||||
afkDuration: number;
|
||||
tags: string[];
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue