From 19fa4454a1351df2a17a01a6d2b957fddf7dfe58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Fri, 21 Oct 2022 17:37:45 +0200 Subject: [PATCH] fix displaying of stats in non-full tables --- onlinetichu-counter.js | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/onlinetichu-counter.js b/onlinetichu-counter.js index ef81919..593381d 100644 --- a/onlinetichu-counter.js +++ b/onlinetichu-counter.js @@ -1,6 +1,6 @@ // ==UserScript== // @name onlinetichu.com card counter -// @version 1.3.0 +// @version 1.3.1 // @description automatically count cards at onlinetichu.com // @match *://*.onlinetichu.com/Site/Game/Table/* // @author Maximilian Keßler @@ -631,10 +631,12 @@ function injectCounter() { // reset player names as they might have changed otc.playerNames = {}; - + + southPosition = 1; $(message.Table.Players).each(function () { if (this.Username == ot.$Username.val()) { spectator = false; + southPosition = this.Position; // console.log('found player'); if (message.Table.Turn == this.Position) { // console.log('my turn!'); @@ -651,30 +653,17 @@ function injectCounter() { } } - console.log('position of iterated player is: ' + this.Position) - if (ot.eastPlayer != null && ot.eastPlayer == this.Position) { - otc.playerNames['east'] = this.Username; - console.log('found east player'); - } - if (ot.southPlayer != null && ot.southPlayer == this.Position) { - otc.playerNames['south'] = this.Username; - } - if (ot.westPlayer != null && ot.westPlayer == this.Position) { - otc.playerNames['west'] = this.Username; - } - // get stats of player if we don't have them yet) if (otc.stats[this.Username] === undefined) { otc.util.getStats(this.Username); } }); - // store usernames of players for display of stats - if (spectator) { - otc.playerNames['south'] = message.Table.Players[0].Username; - } else { - otc.playerNames['south'] = ot.$Username.val(); - } + $(message.Table.Players).each(function () { + dirs = ['south', 'east', 'north', 'west']; + index = (this.Position - southPosition + 4) % 4; + otc.playerNames[dirs[index]] = this.Username; + }); otc.action.updateDisplayStats();