new feature: hide own cards when showing remaining cards

This commit is contained in:
Maximilian Keßler 2023-01-09 18:58:29 +01:00
parent 23bf7d7cec
commit fbf28302b2
Signed by: max
GPG key ID: BCC5A619923C0BA5

View file

@ -1,6 +1,6 @@
// ==UserScript==
// @name onlinetichu.com card counter
// @version 1.3.6
// @version 1.4.0
// @description automatically count cards at onlinetichu.com
// @match *://*.onlinetichu.com/Site/Game/Table/*
// @author Maximilian Keßler
@ -119,12 +119,19 @@ function injectCounter() {
showRemainingButton.type = "button";
showRemainingButton.innerHTML = 'Show: <span id="showRemainingValue" data-on="Remaining" data-off="Played">Remaining</span>';
var showOwnCardsButton = document.createElement('button');
showOwnCardsButton.className = "btn btn-primary btn-xs";
showOwnCardsButton.id = "showOwnCards";
showOwnCardsButton.type = "button";
showOwnCardsButton.innerHTML = 'OwnCards: <span id="showOwnCardsValue" data-on="Shown" data-off="Hidden">Shown</span>';
var showCountedCardsButton = document.createElement('button');
showCountedCardsButton.className = "btn btn-success btn-xs";
showCountedCardsButton.id = "showCountedCards";
showCountedCardsButton.type = "button";
showCountedCardsButton.innerHTML = 'Show cards: <span id="showCountedCardsValue" data-on="Yes" data-off="No">No</span>';
controlButtonsRight.appendChild(showOwnCardsButton);
controlButtonsRight.appendChild(showRemainingButton);
controlButtonsRight.appendChild(showCountedCardsButton);
controlButtonsLeft.appendChild(davidProtectionButton);
@ -237,6 +244,8 @@ function injectCounter() {
$showCardCounterValue: $('#showCardCounterValue'),
$showRemaining: $('#showRemaining'),
$showRemainingValue: $('#showRemainingValue'),
$showOwnCards: $('#showOwnCards'),
$showOwnCardsValue: $('#showOwnCardsValue'),
$showCountedCards: $('#showCountedCards'),
$showCountedCardsValue: $('#showCountedCardsValue'),
$davidProtection: $('#davidProtection'),
@ -267,10 +276,12 @@ function injectCounter() {
exchangedFrom: {},
handCardShuffle: [],
playerNames: {},
ownCards: [],
// config values, triggered with buttons
smartFold: false,
showCardCounter: false,
showOwnCards: true,
showRemaining: true,
showCountedCards: false,
davidProtection: false,
@ -476,7 +487,7 @@ function injectCounter() {
if (otc.showRemaining) {
cards = [];
for(let j=0; j < otc.allCards[i].length; j ++) {
if(!otc.util.cardInArray(otc.allCards[i][j], otc.playedCards[i])) {
if(!otc.util.cardInArray(otc.allCards[i][j], otc.playedCards[i]) && (otc.showOwnCards || !otc.util.cardInArray(otc.allCards[i][j], otc.ownCards))) {
cards.push(otc.allCards[i][j]);
}
otc.$playedCards[i].html(otc.util.displayCardsHtmlString(cards));
@ -578,6 +589,16 @@ function injectCounter() {
otc.action.drawPlayedCards();
});
otc.$showOwnCards.click(function () {
otc.showOwnCards = !otc.showOwnCards;
if (otc.showOwnCards) {
otc.$showOwnCardsValue.text(otc.$showOwnCardsValue.data('on'));
} else {
otc.$showOwnCardsValue.text(otc.$showOwnCardsValue.data('off'));
}
otc.action.drawPlayedCards();
});
for(let i = 1; i < 15; i++) {
otc.$playedCards[i] = $('#playedCards' + i);
}
@ -635,6 +656,7 @@ function injectCounter() {
southPosition = 1;
$(message.Table.Players).each(function () {
if (this.Username == ot.$Username.val()) {
otc.ownCards = this.Cards;
spectator = false;
southPosition = this.Position;
// console.log('found player');