FullScreenShenanigans / FullScreenPokemon

A free HTML5 remake of the original Pokemon, expanded for modern browsing.
MIT License
214 stars 88 forks source link

PokeCenter's "NO" test doesn't finish the dialog before asserting no healing has happened #704

Open Machinocheese opened 6 years ago

Machinocheese commented 6 years ago

Bug Summary

PokeCenter.test.ts seems to have some issues with not going through the cutscene properly.

Steps to Reproduce

Try running some console logs on the test. Example shown below on a combined version of a PokeCenter test:

it("PokeCenter test...", (): void => {
        const { fsp, player, ...extras } = stubBlankGame({
            automaticallyAdvanceMenus: true,
        });
        const firstPokemonInParty: IPokemon = fsp.equations.createPokemon({
            level: 77,
            title: "METAPOD".split(""),
        });
        const nurse = fsp.objectMaker.make<ICharacter>("Nurse", {
            id: "Nurse",
        });
        const machine = fsp.objectMaker.make<IThing>("HealingMachine", {
            id: "HealingMachine",
        });

        fsp.things.add(machine, nurse.right, nurse.top);
        fsp.things.add(nurse, player.right, player.top);

        fsp.itemsHolder.setItem(fsp.storage.names.pokemonInParty, [firstPokemonInParty]);

        fsp.cutscenes.pokeCenter.Welcome();
        console.log("-1: " + fsp.menuGrapher.getActiveMenuName());
        fsp.inputs.keyDownA(player);
        console.log("0: " + fsp.menuGrapher.getActiveMenuName());
        fsp.inputs.keyDownA(player);

        firstPokemonInParty.status = "frozen";

        // Act
        console.log("1: " + fsp.menuGrapher.getActiveMenuName());
        fsp.inputs.keyDownDown(player);
        console.log("2: " + fsp.menuGrapher.getActiveMenuName());
        fsp.inputs.keyDownA(player);
        console.log("3: " + fsp.menuGrapher.getActiveMenuName());

        // Assert
        expect(firstPokemonInParty.status).to.be.equal("frozen");
    });

should produce a console log of something like: -1: GeneralText 0: Heal/Cancel 1: GeneralText 2: GeneralText 3: GeneralText

The issue with the above is that fsp.inputs.keyDownDown and fsp.inputs.keyDownA are supposed to be called on the Heal/Cancel menu as a means to select the Cancel option, but they instead seem to be acting on a GeneralText menu, which should not respond to fsp.inputs.keyDownDown.

JoshuaKGoldberg commented 6 years ago

Looks like it's not getting all the way through the cutscene.

Part of the problem is that keyDownDown is an asynchronous call.