fix bug in fold button click function

This commit is contained in:
Maximilian Keßler 2022-09-17 22:30:53 +02:00
parent 2e3c9eb117
commit dfcf6af304
Signed by: max
GPG Key ID: BCC5A619923C0BA5

View File

@ -1,6 +1,6 @@
// ==UserScript== // ==UserScript==
// @name onlinetichu.com card counter // @name onlinetichu.com card counter
// @version 1.1.0 // @version 1.1.1
// @description automatically count cards at onlinetichu.com // @description automatically count cards at onlinetichu.com
// @author kesslermaximilian // @author kesslermaximilian
// @match *://*.onlinetichu.com/Site/Game/Table/* // @match *://*.onlinetichu.com/Site/Game/Table/*
@ -396,7 +396,7 @@ function injectCounter() {
// overwrite functionality of fold button // overwrite functionality of fold button
ot.$fold.unbind(); ot.$fold.unbind();
ot.$fold.click()(function () { ot.$fold.hide().click(function () {
if (otc.davidProtection) { if (otc.davidProtection) {
if(ot.$passCards.length != 0 && !otc.davidProtectionTriggered) { if(ot.$passCards.length != 0 && !otc.davidProtectionTriggered) {
ot.$gameMessage.text("You have selected cards to play but folded. Are you sure? Press fold again to fold"); ot.$gameMessage.text("You have selected cards to play but folded. Are you sure? Press fold again to fold");
@ -404,7 +404,7 @@ function injectCounter() {
return; return;
} }
} }
ot.action.fold(); ot.action.Fold();
otc.davidProtectionTriggered = false; otc.davidProtectionTriggered = false;
$(this).hide(); $(this).hide();
}); });
@ -436,15 +436,15 @@ function injectCounter() {
otc.action.drawPlayedCards(); otc.action.drawPlayedCards();
console.log('reached smartFold point'); // console.log('reached smartFold point');
$(message.Table.Players).each(function () { $(message.Table.Players).each(function () {
if (this.Username == ot.$Username.val()) { if (this.Username == ot.$Username.val()) {
console.log('found player'); // console.log('found player');
if (message.Table.Turn == this.Position) { if (message.Table.Turn == this.Position) {
console.log('my turn!'); // console.log('my turn!');
if (this.Cards.length < 4 && this.Cards.length < message.Table.TableCards.length) { if (this.Cards.length < 4 && this.Cards.length < message.Table.TableCards.length) {
console.log('obvious that have to fold now');
if (otc.smartFold) { if (otc.smartFold) {
console.log('smart fold triggered');
ot.action.Fold(); ot.action.Fold();
} }
} }