implement counting of dog. some minor adjustments

This commit is contained in:
Maximilian Keßler 2022-09-15 08:55:19 +02:00
parent 0c02e83bff
commit 8ce9263b3d

View file

@ -16,14 +16,14 @@ var myStyles = `
position: absolute; position: absolute;
top: 620px; top: 620px;
width: 850px; width: 850px;
height: 580px; height: 120px;
} }
#playedLow { #playedLow {
position: absolute; position: absolute;
top: 750px; top: 750px;
width: 850px; width: 850px;
height: 580px; height: 120px;
} }
.playedCardsLayout { .playedCardsLayout {
@ -70,6 +70,7 @@ var createCardPlace = function(value, shift, node) {
var playedCards = document.createElement('ul'); var playedCards = document.createElement('ul');
playedCards.id = 'playedCards' + value; playedCards.id = 'playedCards' + value;
// playedCards.className = 'layoutPlayedCards list-unstyled col-lg-2'; // playedCards.className = 'layoutPlayedCards list-unstyled col-lg-2';
// playedCards.className = 'playedCardsLayout list-unstyled';
playedCards.className = 'playedCardsLayout list-unstyled'; playedCards.className = 'playedCardsLayout list-unstyled';
playedCards.style.width = '160px'; playedCards.style.width = '160px';
playedCards.style.marginLeft = '25px'; playedCards.style.marginLeft = '25px';
@ -95,6 +96,8 @@ var OnlineTichuCounter = {
$playedCards: {}, $playedCards: {},
played: {}, played: {},
total_played: [], total_played: [],
exchanged_to: {},
exchanged_from: {},
action: { action: {
@ -103,7 +106,7 @@ var OnlineTichuCounter = {
// console.log(card); // console.log(card);
// console.log(otc.played); // console.log(otc.played);
index = 0; index = 0;
if(card.Shape > 4) { if(card.Shape >= 4) {
index = 1; index = 1;
} else { } else {
index = card.Value; index = card.Value;
@ -141,10 +144,11 @@ var OnlineTichuCounter = {
for(let i = 1; i < 15; i++) { for(let i = 1; i < 15; i++) {
otc.played[i] = []; otc.played[i] = [];
} }
otc.total_played = [];
}, },
drawPlayedCards: function() { drawPlayedCards: function() {
console.log('drawing played cards'); // console.log('drawing played cards');
console.log(otc.played); console.log(otc.played);
for(let i = 1; i < 15; i++) { for(let i = 1; i < 15; i++) {
displayCardsHtmlString = ""; displayCardsHtmlString = "";
@ -202,4 +206,64 @@ MyTableState = (function() {
return result; return result;
})(); })();
MyChat = (function() {
var cached_function = ot.reaction.Chat;
return function() {
var result = cached_function.apply(this, arguments);
message = arguments[0];
if (message.User.Username === "System") {
var messageArray = message.Text.replace(/</g, '&lt;').replace(/>/g, '&gt;').split(' ');
message.Text = messageArray.join(' ');
messageArray = message.Text.replace(/</g, '&lt;').replace(/>/g, '&gt;').split(' ');
for(var i in messageArray) {
if(messageArray[i] == "dogs") {
otc.action.handlePlayedCard({
"Shape": 5,
"Value": 0
});
}
}
}
return result;
}
})();
MyExchangeCards = (function() {
var cached_function = ot.action.ExchangeCards;
return function() {
otc.exchanged_to['west'] = {
Shape: ot.$westExchange.children('li:nth-child(1)').data('shape'),
Value: ot.$westExchange.children('li:nth-child(1)').data('value') };
otc.exchanged_to['north'] = {
Shape: ot.$northExchange.children('li:nth-child(1)').data('shape'),
Value: ot.$northExchange.children('li:nth-child(1)').data('value') };
otc.exchanged_to['east'] = {
Shape: ot.$eastExchange.children('li:nth-child(1)').data('shape'),
Value: ot.$eastExchange.children('li:nth-child(1)').data('value') };
console.log(otc.exchanged_to);
var result = cached_function.apply(this, arguments);
return result;
}
})();
MyReviewExchange = (function() {
var cached_function = ot.reaction.ReviewExchange;
return function() {
var result = cached_function.apply(this, arguments);
return result;
}
})();
ot.reaction.TableState = MyTableState; ot.reaction.TableState = MyTableState;
ot.reaction.Chat = MyChat;
ot.action.ExchangeCards = MyExchangeCards;