Shuffle iT Forum

Dominion => Bug Reports => Topic started by: Dwedit on 09 October 2024, 02:10:38 AM

Title: TypeError: e.name is undefined after reconnecting to game
Post by: Dwedit on 09 October 2024, 02:10:38 AM
Got exception on the "return a.name.localeCompare(b.name);" line

        key: "createUniqueInitials",
        value: function createUniqueInitials() {
            var players = this.game.state.players;
            players.sort(function (a, b) {
                return a.name.localeCompare(b.name);
            });
            var previousPrefix = 1;
            for (var i = 0; i < players.length - 1; i++) {
                var prefix = 1;
                for (; prefix < players[i].name.length; prefix++) {
                    if (players[i].name[prefix - 1].toLowerCase() !== players[i + 1].name[prefix - 1].toLowerCase()) break;
                }
                players[i].initials = players[i].name.slice(0, Math.max(previousPrefix, prefix));
                previousPrefix = prefix;
            }
            if (players.length > 1 && players[players.length - 2].name.length === previousPrefix) previousPrefix += 1;
            players[players.length - 1].initials = players[players.length - 1].name.slice(0, previousPrefix);
            players.sort(function (a, b) {
                return a.index - b.index;
            });
        }
Title: Re: TypeError: e.name is undefined after reconnecting to game
Post by: Ingix on 09 October 2024, 09:24:24 AM
Thanks for the report. Some info seems to have been lost after the reconnect.
Title: Re: TypeError: e.name is undefined after reconnecting to game
Post by: Dwedit on 25 November 2024, 06:35:54 PM
Seeing this happen again:

        value: function createUniqueInitials() {
            var players = this.game.state.players;
            players.sort(function (a, b) {
                return a.name.localeCompare(b.name);
            });
            var previousPrefix = 1;
            for (var i = 0; i < players.length - 1; i++) {
                var prefix = 1;
                for (; prefix < players[i].name.length; prefix++) {
                    if (players[i].name[prefix - 1].toLowerCase() !== players[i + 1].name[prefix - 1].toLowerCase()) break;
                }
                players[i].initials = players[i].name.slice(0, Math.max(previousPrefix, prefix));
                previousPrefix = prefix;
            }


Upon entering this function, the array `this.game.state.players` contains two elements.

this.game.state.players[0].name = undefined
this.game.state.players[1].name = "Dwedit"

Then it crashes when it attempts to sort the players, and the game never starts.

---

It is actually possible to manually get past this one:

* Set a JavaScript breakpoint at the `var players = this.game.state.players;` line
* Go to Console, and assign `this.game.state.players[0].name = "OPPONENT"` (if players[0] was the one without a name)
* Resume execution

When I finally got past it, I saw a "make opponent resign" prompt.  The opponent was probably was having issues too.
Title: Re: TypeError: e.name is undefined after reconnecting to game
Post by: Dwedit on 23 February 2025, 07:15:51 PM
Can confirm that quitting the game still costs you rating points.