fix displaying of stats in non-full tables

This commit is contained in:
Maximilian Keßler 2022-10-21 17:37:45 +02:00
parent 23c26422e6
commit 19fa4454a1
Signed by: max
GPG key ID: BCC5A619923C0BA5

View file

@ -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
@ -632,9 +632,11 @@ 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();