diff --git a/.config/qutebrowser/greasemonkey/onlinetichu.js b/.config/qutebrowser/greasemonkey/onlinetichu.js
index 98eaf8f..fd093da 100644
--- a/.config/qutebrowser/greasemonkey/onlinetichu.js
+++ b/.config/qutebrowser/greasemonkey/onlinetichu.js
@@ -51,16 +51,21 @@ console.log(styleSheet);
document.head.appendChild(styleSheet);
// add an extra field where we will put down the played cards
+var cardsField = document.createElement('div');
+cardsField.id = 'cardsField';
+cardsField.style.marginLeft = '25px';
var playedHigh = document.createElement('div');
playedHigh.id = 'playedHigh';
-playedHigh.style.marginLEft = '25px';
+playedHigh.style.marginLeft = '25px';
playedHigh.className = 'row';
+playedHigh.hidden = true;
var playedLow = document.createElement('div');
playedLow.id = 'playedLow';
-playedLow.style.marginLEft = '25px';
+playedLow.style.marginLeft = '25px';
playedLow.className = 'row';
+playedLow.hidden = true;
tableIG = document.getElementById('gameField').parentNode;
tableIG.appendChild(playedHigh);
@@ -74,7 +79,7 @@ var createCardPlace = function(value, shift, node) {
playedCards.className = 'playedCardsLayout list-unstyled';
playedCards.style.width = '160px';
playedCards.style.marginLeft = '25px';
- playedCards.style.left = shift*135 + 'px';
+ playedCards.style.left = shift*129 + 'px';
node.appendChild(playedCards);
}
@@ -88,18 +93,44 @@ for(let i = 8; i > 1; i--) {
createCardPlace(i, 8 - i, document.getElementById('playedLow'));
}
+
+var smartFoldButton = document.createElement('button');
+smartFoldButton.className = "btn btn-danger btn-xs";
+smartFoldButton.id = "smartFold";
+smartFoldButton.type = "button";
+smartFoldButton.innerHTML = 'Smart fold: Yes';
+
+var showPlayedButton = document.createElement('button');
+showPlayedButton.className = "btn btn-warning btn-xs";
+showPlayedButton.id = "showPlayed";
+showPlayedButton.type = "button";
+showPlayedButton.innerHTML = 'Show counted cards: No';
+
+buttons = document.getElementById('statusButtons');
+buttons.insertBefore(showPlayedButton, document.getElementById('autoFold'));
+buttons.insertBefore(smartFoldButton, document.getElementById('autoFold'));
+
// playedCards.
// ot.$gameField.insertAfter(playedCards, ot.$gameField.lastChild);
// set up counting of played cards
var OnlineTichuCounter = {
$playedCards: {},
+ $smartFold: $('#smartFold'),
+ $smartFoldValue: $('#smartFoldValue'),
+ $showPlayed: $('#showPlayed'),
+ $showPlayedValue: $('#showPlayedValue'),
+ $playedHigh: $('#playedHigh'),
+ $playedLow: $('#playedLow'),
+
allCards: {},
playedCards: {},
totalPlayed: [],
exchangedTo: {},
exchangedFrom: {},
- smartFold: false,
+ smartFold: true,
+ showPlayed: false,
+ bombAfterFold: null,
util: {
displayCardsHtmlString: function(cards) {
@@ -205,6 +236,30 @@ if (!window.otc) {
window.otc = OnlineTichuCounter;
}
+// add functionality to smartFold button
+otc.$smartFold.click(function () {
+ otc.smartFold = !otc.smartFold;
+ if (otc.smartFold) {
+ otc.$smartFoldValue.text(otc.$smartFoldValue.data('on'));
+ } else {
+ otc.$smartFoldValue.text(otc.$smartFoldValue.data('off'));
+ }
+});
+
+// add functionality to show button
+otc.$showPlayed.click(function () {
+ otc.showPlayed = !otc.showPlayed;
+ if (otc.showPlayed) {
+ otc.$showPlayedValue.text(otc.$showPlayedValue.data('on'));
+ otc.$playedHigh.show();
+ otc.$playedLow.show();
+ } else {
+ otc.$showPlayedValue.text(otc.$showPlayedValue.data('off'));
+ otc.$playedHigh.hide();
+ otc.$playedLow.hide();
+ }
+});
+
for(let i = 1; i < 15; i++) {
otc.$playedCards[i] = $('#playedCards' + i);
}
@@ -221,7 +276,7 @@ MyTableState = (function() {
message = arguments[0];
// console.log('detected table state change event');
- console.log(message.Table.Status);
+// console.log(message.Table.Status);
// reset played cards at start of round
if(message.Table.Status == 'WaitForNextCards') {
@@ -233,14 +288,26 @@ MyTableState = (function() {
}
otc.action.drawPlayedCards();
-
-// otc.$playedCardsQ.html(displayCardsHtmlString);
-// $('.horizontalLayouta .card').css('margin-left', '-64px');
-// $('#playedCards').css('margin-left', '32px');
-// ot.HorizontalAlign(otc.$playedCards);
- }
+
+ console.log('reached smartFold point');
+ $(message.Table.Players).each(function () {
+ if (this.Username == ot.$Username.val()) {
+ console.log('found player');
+ if (message.Table.Turn == this.Position) {
+ console.log('my turn!');
+ if (this.Cards.length < 4 && this.Cards.length < message.Table.TableCards.length) {
+ console.log('obvious that have to fold now');
+ if (otc.smartFold) {
+ ot.action.Fold();
+ }
+ }
+ }
+ }
+ });
return result;
+ }
+
})();