Skip to content

diepAPI.player.level has a bug #36

@gurumnyang

Description

@gurumnyang

diepAPI.player.level cannot detect level if tank type name contains a blank character.

[ /diepAPI/src/player.ts ]

        CanvasKit.hook('fillText', (target, thisArg, args) => {
            const text = args[0];
            const match = text.match(/^Lvl (\d+) (\w*)$/);   // problem!
            if (match == null) {
                return;
            }

            const newLevel = Number(match[1]);
            const newTank = match[2];

            // make sure to trigger events for all levels in between.
            while (newLevel > this.#level + 1) {
                super.emit('level', ++this.#level);
            }

            if (newLevel !== this.#level) super.emit('level', newLevel);
            if (newTank !== this.#tank) super.emit('tank', newTank);

            this.#level = newLevel;
            this.#tank = match[2];
        });

the way to fix the bug.

const match = text.match(/^Lvl (\d+) (\w*)$/); ( x )
const match = text.match(/^Lvl (\d+) (\w*\s?\w*)$/); ( o )

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions