Skip to content

Commit a80eff4

Browse files
Port to Cookie Connoisseur the test for the GFD delay patch.
1 parent e7dc1d3 commit a80eff4

File tree

2 files changed

+56
-31
lines changed

2 files changed

+56
-31
lines changed

old-test.js

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,6 @@ function testImplicitAssumptions() {
66
}
77
testImplicitAssumptions();
88

9-
async function testGFDDelayPatch() {
10-
Util.wipeSave('with minigames');
11-
Game.seed = 'aaaaa';
12-
13-
await Util.waitMinigame('Wizard tower');
14-
15-
Game.Objects['Wizard tower'].minigame.magic = 50;
16-
let save = Game.WriteSave(1);
17-
18-
document.getElementById('grimoireSpell6').click(); // cast GFD, get FtHoF
19-
console.assert(Game.Objects['Wizard tower'].minigame.magic == 45);
20-
await Util.waitPredicate(() => Math.floor(Game.Objects['Wizard tower'].minigame.magic) != 45);
21-
console.assert(Math.floor(Game.Objects['Wizard tower'].minigame.magic) == 25);
22-
console.assert(Game.shimmers.length == 1);
23-
console.assert(Game.shimmers[0].force == 'clot');
24-
// This is the same as backfiring FtHoF with one spell cast
25-
26-
// Patch, and check the patch works:
27-
Game.LoadSave(save);
28-
document.getElementById('prefsButton').click();
29-
document.getElementById('SpiceButtonpatchGFDDelay').click();
30-
document.getElementById('prefsButton').click();
31-
document.getElementById('grimoireSpell6').click(); // cast GFD, get FtHoF
32-
console.assert(Game.Objects['Wizard tower'].minigame.magic == 25); // Instantaneous
33-
console.assert(Game.shimmers.length == 1);
34-
console.assert(Game.shimmers[0].force == 'cookie storm drop');
35-
// This is the same as succeeding FtHoF with zero spells cast
36-
37-
console.log("Finished testGFDDelayPatch()");
38-
}
39-
409
async function testSeasonsAffectingFtHoFPatch() {
4110
Util.wipeSave('with minigames');
4211
Game.seed = 'aaaaa';

test/gfd-delay-patch.test.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/* Test the patch for the GFD delay.
2+
*/
3+
4+
import { test, expect } from '@playwright/test';
5+
import { setupCookieClickerPage } from 'cookie-connoisseur';
6+
7+
let saveGame = {
8+
seed: 'aaaaa',
9+
buildings: {
10+
'Wizard tower': {
11+
amount: 100,
12+
level: 1,
13+
minigame: {
14+
magic: 50,
15+
onMinigame: true,
16+
},
17+
},
18+
},
19+
};
20+
21+
test.describe('GFD delay patch', () => {
22+
test('is not present in the vanilla game', async ({ page }) => {
23+
await setupCookieClickerPage(page, {saveGame});
24+
await page.click('#grimoireSpell6'); // cast GFD, get FtHoF
25+
/* GFD cast costs only 5 magic, it takes another 1.5 seconds to deduct the FtHoF cost.
26+
* We still need to use Math.floor because math keeps regenerating.
27+
*/
28+
expect(await page.evaluate(() => Math.floor(Game.Objects['Wizard tower'].minigame.magic))).toEqual(45);
29+
await page.waitForFunction(() => Game.Objects['Wizard tower'].minigame.magic < 45);
30+
31+
expect(await page.evaluate(() => Math.floor(Game.Objects['Wizard tower'].minigame.magic))).toEqual(25);
32+
33+
expect(await page.evaluate(() => Game.shimmers.length)).toEqual(1);
34+
expect(await page.evaluate(() => Game.shimmers[0]['force'])).toEqual('clot');
35+
// This is the same as backfiring FtHoF with one spell cast
36+
});
37+
38+
test('works', async ({ page }) => {
39+
await setupCookieClickerPage(page, {saveGame});
40+
await page.evaluate(() => Game.LoadMod('https://staticvariablejames.github.io/SpicedCookies/Spice.js'));
41+
await page.waitForFunction(() => 'Spiced cookies' in Game.mods);
42+
43+
await page.evaluate(() => Game.CloseNotes());
44+
await page.click('text=Options');
45+
await page.click('#SpiceButtonpatchGFDDelay');
46+
await page.click('text=Options');
47+
48+
await page.click('#grimoireSpell6'); // cast GFD, get FtHoF
49+
// Now the results are essentially instantaneous
50+
expect(await page.evaluate(() => Math.floor(Game.Objects['Wizard tower'].minigame.magic))).toEqual(25);
51+
52+
expect(await page.evaluate(() => Game.shimmers.length)).toEqual(1);
53+
expect(await page.evaluate(() => Game.shimmers[0]['force'])).toEqual('cookie storm drop');
54+
// This is the same as succeeding FtHoF with zero spells cast
55+
});
56+
});

0 commit comments

Comments
 (0)