Skip to content

Commit e4a102a

Browse files
authored
impr(results): allow PBs with stop on letter if accuracy is 100% (@byseif21) (monkeytypegame#6611)
1 parent 836345c commit e4a102a

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

backend/src/api/controllers/result.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,13 +488,16 @@ export async function addResult(
488488

489489
let dailyLeaderboardRank = -1;
490490

491+
const stopOnLetterTriggered =
492+
completedEvent.stopOnLetter && completedEvent.acc < 100;
493+
491494
const validResultCriteria =
492495
canFunboxGetPb(completedEvent) &&
493496
!completedEvent.bailedOut &&
494497
user.banned !== true &&
495498
user.lbOptOut !== true &&
496499
(isDevEnvironment() || (user.timeTyping ?? 0) > 7200) &&
497-
!completedEvent.stopOnLetter;
500+
!stopOnLetterTriggered;
498501

499502
const selectedBadgeId = user.inventory?.badges?.find((b) => b.selected)?.id;
500503
const isPremium =

backend/src/dal/user.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,12 @@ export async function checkIfPb(
454454
const { mode } = result;
455455

456456
if (!canFunboxGetPb(result)) return false;
457-
if ("stopOnLetter" in result && result.stopOnLetter === true) return false;
457+
if (
458+
"stopOnLetter" in result &&
459+
result.stopOnLetter === true &&
460+
result.acc < 100
461+
)
462+
return false;
458463

459464
if (mode === "quote") {
460465
return false;
@@ -500,7 +505,12 @@ export async function checkIfTagPb(
500505

501506
const { mode, tags: resultTags } = result;
502507
if (!canFunboxGetPb(result)) return [];
503-
if ("stopOnLetter" in result && result.stopOnLetter === true) return [];
508+
if (
509+
"stopOnLetter" in result &&
510+
result.stopOnLetter === true &&
511+
result.acc < 100
512+
)
513+
return [];
504514

505515
if (mode === "quote") {
506516
return [];

frontend/src/ts/test/result.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -483,10 +483,12 @@ async function resultCanGetPb(): Promise<CanGetPbObject> {
483483
const allFunboxesCanGetPb = funboxObjects.every((f) => f?.canGetPb);
484484

485485
const funboxesOk = funboxes.length === 0 || allFunboxesCanGetPb;
486-
const notUsingStopOnLetter = Config.stopOnError !== "letter";
486+
// allow stopOnError:letter to be PB only if 100% accuracy, since it doesn't affect gameplay
487+
const stopOnLetterTriggered =
488+
Config.stopOnError === "letter" && result.acc < 100;
487489
const notBailedOut = !result.bailedOut;
488490

489-
if (funboxesOk && notUsingStopOnLetter && notBailedOut) {
491+
if (funboxesOk && !stopOnLetterTriggered && notBailedOut) {
490492
return {
491493
value: true,
492494
};
@@ -497,7 +499,7 @@ async function resultCanGetPb(): Promise<CanGetPbObject> {
497499
reason: "funbox",
498500
};
499501
}
500-
if (!notUsingStopOnLetter) {
502+
if (stopOnLetterTriggered) {
501503
return {
502504
value: false,
503505
reason: "stop on letter",

0 commit comments

Comments
 (0)