|  | (() => {
    let digestRate = 0.5;
    function devour(state, count) {
        state.player.stats.stomach.value += count;
        state.player.stats.eaten.value += count;
        playRandomSfx("swallow");
    }
    function digest(state, count) {
        if (count === undefined) {
            count = digestRate * (state.player.stats.stomach.value / 100 + 2);
        }
        count = Math.min(state.player.stats.stomach.value, count);
        count = Math.floor(count);
        state.player.stats.stomach.value -= count;
        state.player.stats.digested.value += count;
        state.player.stats.gas.value += count * 3;
    }
    sfxGroups = {
        "swallow": [
            "sfx/swallows/swallow-1.ogg",
            "sfx/swallows/swallow-2.ogg",
            "sfx/swallows/swallow-3.ogg",
            "sfx/swallows/swallow-4.ogg",
            "sfx/swallows/swallow-5.ogg",
            "sfx/swallows/swallow-6.ogg",
            "sfx/swallows/swallow-7.ogg",
        ]
    }
    function playRandomSfx(category) {
        const choice = Math.floor(Math.random() * sfxGroups[category].length);
        playSfx(sfxGroups[category][choice]);
    }
    stories.push({
        id: "mass-vore",
        name: "Mass Vore",
        tags: [
        "Player Predator",
        "Macro/Micro",
        "Digestion"
        ],
        sounds: [
            "sfx/belches/belch.ogg",
            "loop/stomach/stomach.ogg"
        ].concat(sfxGroups["swallow"]),
        preload: [
            "loop/stomach/stomach.ogg"
        ],
        intro: {
            start: "city",
            setup: state => {
                state.player.stats.fullness = {
                    name: "Fullness",
                    type: "meter",
                    get value() {
                        return state.player.stats.gas.value + state.player.stats.stomach.value;
                    },
                    min: 0,
                    max: 10000,
                    color: "rgb(200,20,100)"
                };
                state.player.stats.gas = {
                    name: "Gas",
                    type: "meter",
                    value: 0,
                    min: 0,
                    get max() {
                        return 10000 - state.player.stats.stomach.value;
                    },
                    color: "rgb(10,200,100)"
                }
                state.player.stats.stomach = {
                    name: "Stomach",
                    type: "meter",
                    value: 0,
                    min: 0,
                    max: 10000,
                    color: "rgb(255,10,150)"
                }
                state.player.stats.eaten = {
                    name: "Eaten",
                    type: "counter",
                    value: 0
                }
                state.player.stats.digested = {
                    name: "Digested",
                    type: "counter",
                    value: 0
                }
                startTimer({
                    id: "belch",
                    func: state => {
                        if (state.player.stats.gas.value > state.player.stats.gas.max) {
                            print(["BUURRRRRP!"]);
                            playSfx("sfx/belches/belch.ogg");
                            state.player.stats.gas.value /= 3;
                        }
                        return true;
                    },
                    delay: 100,
                    loop: true,
                    classes: [
                        
                    ]
                }, state);
                startTimer({
                    id: "digestion",
                    func: state => {
                        digest(state);
                        const rateChange = (digestRate - 0.5) / 1000
                        digestRate -= rateChange;
                        let vol = state.player.stats.fullness.value / state.player.stats.fullness.max
                        vol = Math.sqrt(vol);
                        playLoop("loop/stomach/stomach.ogg", vol);
                        return true;
                    },
                    delay: 1000/60,
                    loop: true,
                    classes: [
                        
                    ]
                }, state);
            },
            intro: state => {
                print(["Munch time"]);
            }
        },
        world: {
            "city": {
                id: "",
                name: "",
                desc: "",
                move: (room, state) => {
                    
                },
                enter: (room, state) => {
                },
                exit: (room, state) => {
                    
                },
                hooks: [
                ],
                actions: [
                    {
                        name: "Eat",
                        desc: "Munch!",
                        execute: (room, state) => {
                            const victims = Math.floor((0.5 + Math.random()) * 500);
                            print(["You scoop up " + victims + " people and swallow them down."]);
                            devour(state, victims);
                        }
                    },
                    {
                        name: "Rub",
                        desc: "Rub your belly",
                        execute: (room, state) => {
                            print(["You rub over the " + state.player.stats.stomach.value + " prey in your guts, hastening their digestion."]);
                            digestRate += 0.25;
                        }
                    }
                ],
                exits: {
                }
            }
        }
    });
})();
 |