makefuture / games / accept-the-cookie / game / scenes / Zone3Scene.js
235 words
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import { BaseZoneScene } from './BaseZoneScene.js?v=20260427c';
import { ZONE_DEFINITIONS } from '../systems/session.js?v=20260427c';

export class Zone3Scene extends BaseZoneScene {
    constructor() {
        super('Zone3Scene', ZONE_DEFINITIONS[2]);
    }

    buildHorizontalLevel() {
        super.buildHorizontalLevel();
        for (let x = 520; x < this.levelWidth - 360; x += 620) {
            this.addShopItem(x, this.scale.height - 185, 'Shield', 45);
            this.addShopItem(x + 190, this.scale.height - 245, 'Double Jump', 65);
        }
    }

    addShopItem(x, y, label, price) {
        const card = this.add.rectangle(x, y, 150, 74, 0xffffff, 0.96).setStrokeStyle(2, 0xff3d00, 0.8);
        this.add.text(x, y - 12, `${label}\n${price}+ cookies`, {
            fontFamily: 'system-ui',
            fontSize: '12px',
            color: '#111',
            fontStyle: '700',
            align: 'center',
        }).setOrigin(0.5);
        this.physics.add.existing(card, true);
        this.time.delayedCall(50, () => {
            if (!this.player) return;
            this.physics.add.overlap(this.player.sprite, card, () => {
                if (card.used) return;
                card.used = true;
                this.marketplacePurchase(label, price);
                card.setFillStyle(0xdddddd, 0.6);
            });
        });
    }

    spawnZoneThreats(time) {
        if (!this.nextAdAt) this.nextAdAt = time + 1200;
        if (time < this.nextAdAt) return;
        const fewerAds = this.session.adblock.detected === true;
        this.nextAdAt = time + (fewerAds ? 2500 : 1050);
        const place = this.session.geo.city && this.session.geo.city !== 'Unknown' ? this.session.geo.city : this.session.device.timezone || 'your area';
        const label = this.session.consent.marketing
            ? Phaser.Utils.Array.GetRandom([`HOT DEALS\n${place}`, `${this.session.device.os || 'DEVICE'} SALE`, 'ONLY 03:14 LEFT'])
            : 'GENERIC AD';
        this.spawnAd(label, 0xff004d);
    }

    zonePrompts() {
        return [
            {
                at: 10,
                key: 'Share location',
                title: 'Share your location?',
                copy: 'Optimize local offers, smoother routes, and suspiciously relevant billboards.',
                accept: 'Share',
                decline: 'No thanks',
                onAccept: () => {
                    this.session.flags.sharedLocation = true;
                    this.session.currencies.cookies += 40;
                    this.algorithm.say(`Great. ${this.session.geo.city || 'Your area'} is full of opportunities.`);
                },
            },
        ];
    }
}

static mirror of HEAD · about · clone: git clone https://git.makefuture.ro/makefuture.git