Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed May 10, 2024
1 parent 803587d commit 2e39736
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 18 deletions.
8 changes: 4 additions & 4 deletions src/Disp/HelperFunctions/CalculateLuckyLevels.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default function CalculateLuckyLevels(currentLevel) {
// Consider only top 15 digits if it is big number
let localLevel;
if (numberOfDigits >= 16) {
localLevel = Math.ceil(currentLevel / (10 ** (numberOfDigits - 15)));
localLevel = Math.ceil(currentLevel / 10 ** (numberOfDigits - 15));
} else {
localLevel = currentLevel;
}
Expand All @@ -65,7 +65,7 @@ export default function CalculateLuckyLevels(currentLevel) {

result.luckyDigit = localLevel;
if (numberOfDigits >= 16) {
result.luckyDigit *= 10 ** Number((numberOfDigits - 15));
result.luckyDigit *= 10 ** Number(numberOfDigits - 15);
}
}

Expand All @@ -80,7 +80,7 @@ export default function CalculateLuckyLevels(currentLevel) {

result.luckyNumber = localLevel;
if (numberOfDigits >= 16) {
result.luckyNumber *= 10 ** Number((numberOfDigits - 15));
result.luckyNumber *= 10 ** Number(numberOfDigits - 15);
}
}

Expand All @@ -97,7 +97,7 @@ export default function CalculateLuckyLevels(currentLevel) {

result.luckyPayout = localLevel;
if (numberOfDigits >= 16) {
result.luckyPayout *= 10 ** Number((numberOfDigits - 15));
result.luckyPayout *= 10 ** Number(numberOfDigits - 15);
}

return result;
Expand Down
18 changes: 10 additions & 8 deletions src/Disp/MenuSections/Statistics/CreateStatsSections.js
Original file line number Diff line number Diff line change
Expand Up @@ -607,11 +607,7 @@ export function PrestigeSection() {
const currentPrestige = Math.floor(Game.HowMuchPrestige(Game.cookiesReset));
const willHave = Math.floor(Game.HowMuchPrestige(Game.cookiesReset + Game.cookiesEarned));
const willGet = willHave - currentPrestige;
const {
luckyDigit,
luckyNumber,
luckyPayout
} = CalculateLuckyLevels(willHave);
const { luckyDigit, luckyNumber, luckyPayout } = CalculateLuckyLevels(willHave);
if (!Game.Has('Lucky digit')) {
const luckyDigitDelta = luckyDigit - willHave;
const luckyDigitReset = willGet + luckyDigitDelta;
Expand All @@ -621,7 +617,9 @@ export function PrestigeSection() {
`${luckyDigit.toLocaleString()} / ${luckyDigitReset.toLocaleString()} (+${luckyDigitDelta})`,
),
);
section.appendChild(StatsListing('basic', 'Next "Lucky Digit" (total / reset)', fragLuckyDigit));
section.appendChild(
StatsListing('basic', 'Next "Lucky Digit" (total / reset)', fragLuckyDigit),
);
}

if (!Game.Has('Lucky number')) {
Expand All @@ -633,7 +631,9 @@ export function PrestigeSection() {
`${luckyNumber.toLocaleString()} / ${luckyNumberReset.toLocaleString()} (+${luckyNumberDelta})`,
),
);
section.appendChild(StatsListing('basic', 'Next "Lucky Number" (total / reset)', fragLuckyNumber));
section.appendChild(
StatsListing('basic', 'Next "Lucky Number" (total / reset)', fragLuckyNumber),
);
}

if (!Game.Has('Lucky payout')) {
Expand All @@ -645,7 +645,9 @@ export function PrestigeSection() {
`${luckyPayout.toLocaleString()} / ${luckyPayoutReset.toLocaleString()} (+${luckyPayoutDelta})`,
),
);
section.appendChild(StatsListing('basic', 'Next "Lucky Payout" (total / reset)', fragLuckyPayout));
section.appendChild(
StatsListing('basic', 'Next "Lucky Payout" (total / reset)', fragLuckyPayout),
);
}

return section;
Expand Down
25 changes: 19 additions & 6 deletions test/t_Disp/t_CalculateLuckyLevels.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
import { describe, it } from 'mocha';
import { expect } from 'chai';

import CalculateLuckyLevels, { CalculateSevenDelta, CountSevens } from '../../src/Disp/HelperFunctions/CalculateLuckyLevels';
import CalculateLuckyLevels, {
CalculateSevenDelta,
CountSevens,
} from '../../src/Disp/HelperFunctions/CalculateLuckyLevels';

describe('CountSevens', () => {
const examples = [
{ input: 1234567890, output: 1 },
{ input: 7777777777, output: 10 },
{ input: 1111111111, output: 0 },
{ input: 7897897897, output: 4 }
{ input: 7897897897, output: 4 },
];

examples.forEach((example) => {
it(`Counts sevens in ${example.input}`, () => {
expect(CountSevens(example.input)).to.equal(example.output);
})
});
});
});

Expand Down Expand Up @@ -48,16 +51,26 @@ describe('CalculateLuckyLevels', () => {
{ input: 77777, luckyDigit: 77777, luckyNumber: 77777, luckyPayout: 77777 },
{ input: 799999, luckyDigit: 799999, luckyNumber: 800077, luckyPayout: 807777 },
{ input: 999999, luckyDigit: 1000007, luckyNumber: 1000077, luckyPayout: 1007777 },
{ input: 123456789123456789, luckyDigit: 123456789123456789, luckyNumber: 123456789123456789, luckyPayout: 123456789123777000 },
{ input: 8888888888888888888, luckyDigit: 8888888888888970000, luckyNumber: 8888888888889770000, luckyPayout: 8888888888977770000 },
{
input: 123456789123456789,
luckyDigit: 123456789123456789,
luckyNumber: 123456789123456789,
luckyPayout: 123456789123777000,
},
{
input: 8888888888888888888,
luckyDigit: 8888888888888970000,
luckyNumber: 8888888888889770000,
luckyPayout: 8888888888977770000,
},
];

examples.forEach((example) => {
it(`Calculates the next lucky levels for the starting level ${example.input}`, () => {
expect(CalculateLuckyLevels(example.input)).to.deep.equal({
luckyDigit: example.luckyDigit,
luckyNumber: example.luckyNumber,
luckyPayout: example.luckyPayout
luckyPayout: example.luckyPayout,
});
});
});
Expand Down

0 comments on commit 2e39736

Please sign in to comment.