some bugfixes. reverse counting now fully working
This commit is contained in:
parent
7b2022c0a3
commit
b7ac1ddaaa
1 changed files with 20 additions and 31 deletions
|
@ -99,6 +99,7 @@ var OnlineTichuCounter = {
|
|||
totalPlayed: [],
|
||||
exchangedTo: {},
|
||||
exchangedFrom: {},
|
||||
smartFold: false,
|
||||
|
||||
util: {
|
||||
displayCardsHtmlString: function(cards) {
|
||||
|
@ -127,10 +128,10 @@ var OnlineTichuCounter = {
|
|||
}
|
||||
}
|
||||
otc.allCards[1] = [
|
||||
{ Shape: 4, Value: 1 },
|
||||
{ Shape: 5, Value: 0 },
|
||||
{ Shape: 6, Value: 15},
|
||||
{ Shape: 7, Value: 14 }
|
||||
{ Shape: 4, Value: 1 }, // mahjong
|
||||
{ Shape: 5, Value: 0 }, // dog
|
||||
{ Shape: 6, Value: 15}, // dragon
|
||||
{ Shape: 7, Value: 14 } // phoenix
|
||||
];
|
||||
},
|
||||
|
||||
|
@ -140,20 +141,23 @@ var OnlineTichuCounter = {
|
|||
if (array[i].Shape == card.Shape && array[i].Value == card.Value) {
|
||||
contained = true;
|
||||
}
|
||||
return contained;
|
||||
}
|
||||
return contained;
|
||||
}
|
||||
},
|
||||
|
||||
action: {
|
||||
|
||||
handlePlayedCard: function(card) {
|
||||
// console.log('Handling a card:');
|
||||
// console.log(card);
|
||||
// console.log(otc.played);
|
||||
index = 0;
|
||||
// special cards have Shapes 4,5,6,7. We group them at value 1
|
||||
if(card.Shape >= 4) {
|
||||
index = 1;
|
||||
if (card.Shape == 7) {
|
||||
// Treat phoenix as if it had value 14
|
||||
// This is important for comparisons later
|
||||
card.Value = 14;
|
||||
}
|
||||
} else {
|
||||
index = card.Value;
|
||||
}
|
||||
|
@ -166,24 +170,14 @@ var OnlineTichuCounter = {
|
|||
},
|
||||
|
||||
handlePlayedCards: function(cards) {
|
||||
if (cards.length > 0) {
|
||||
contained = false;
|
||||
// console.log(message.Table.TableCards[0].Shape);
|
||||
// console.log(message.Table.TableCards[0].Value);
|
||||
$(otc.totalPlayed).each(function (index, item) {
|
||||
if (item.Shape == cards[0].Shape) {
|
||||
if (item.Value == cards[0].Value) {
|
||||
contained = true;
|
||||
if (cards.length === 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if(!contained) {
|
||||
if (!otc.util.cardInArray(cards[0], otc.totalPlayed)) {
|
||||
$(message.Table.TableCards).each(
|
||||
(index, card) => otc.action.handlePlayedCard(card)
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
resetPlayedCards: function() {
|
||||
|
@ -194,22 +188,17 @@ var OnlineTichuCounter = {
|
|||
},
|
||||
|
||||
drawPlayedCards: function() {
|
||||
console.log('drawing played cards');
|
||||
console.log(otc.playedCards);
|
||||
console.log(otc.allCards);
|
||||
for(let i = 1; i < 15; i++) {
|
||||
cards = [];
|
||||
for(let j=0; j < otc.allCards[i].length; j ++) {
|
||||
if(!otc.util.cardInArray(otc.allCards[i][j], otc.playedCards[i])) {
|
||||
cards.push(otc.allCards[i][j]);
|
||||
}
|
||||
}
|
||||
// cards = otc.allCards[i].filter(x => otc.util.cardInArray(x, otc.playedCards[i]));
|
||||
console.log(cards);
|
||||
otc.$playedCards[i].html(otc.util.displayCardsHtmlString(cards));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!window.otc) {
|
||||
|
|
Loading…
Reference in a new issue