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.
Title: Re: TypeError: e.name is undefined after reconnecting to game
Post by: Dwedit on 26 July 2025, 12:32:09 AM
Can also confirm that if you manage to rejoin the game (using the javascript console), you can make the opponent resign.  Game won't proceed, but reloading the page will take you back to the main screen.
Title: Re: TypeError: e.name is undefined after reconnecting to game
Post by: Dwedit on 17 October 2025, 12:50:09 AM
It just keeps happening.