Fixed last hand rendering
This commit is contained in:
@@ -44,6 +44,7 @@ function idToCard(cardId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function cardToElement(card, forDeck = false, drawn = false) {
|
function cardToElement(card, forDeck = false, drawn = false) {
|
||||||
|
if (card) {
|
||||||
var element = document.createElement("okey-card");
|
var element = document.createElement("okey-card");
|
||||||
element.innerHTML = card.number.toString();
|
element.innerHTML = card.number.toString();
|
||||||
|
|
||||||
@@ -81,6 +82,9 @@ function cardToElement(card, forDeck = false, drawn = false) {
|
|||||||
return element.outerHTML;
|
return element.outerHTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
function isHandFull(thisHand = null) {
|
function isHandFull(thisHand = null) {
|
||||||
if (thisHand == null) {
|
if (thisHand == null) {
|
||||||
thisHand = hand;
|
thisHand = hand;
|
||||||
@@ -139,7 +143,7 @@ function discard(cardId, thisHand = null, update = true) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function cashOut(thisHand = null) {
|
function cashOut(thisHand = null, forceRefresh = true) {
|
||||||
if (recommendations.length > 0) {
|
if (recommendations.length > 0) {
|
||||||
let handGiven = true;
|
let handGiven = true;
|
||||||
if (thisHand == null) {
|
if (thisHand == null) {
|
||||||
@@ -147,11 +151,7 @@ function cashOut(thisHand = null) {
|
|||||||
handGiven = false;
|
handGiven = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// console.log("Recommendation: ");
|
|
||||||
// console.log(recommendations[0]);
|
|
||||||
|
|
||||||
if (recommendations[0].burnedCard) {
|
if (recommendations[0].burnedCard) {
|
||||||
// console.log("Discarding: " + recommendations[0].burnedCard);
|
|
||||||
discard(recommendations[0].burnedCard, thisHand, false);
|
discard(recommendations[0].burnedCard, thisHand, false);
|
||||||
}
|
}
|
||||||
else if (recommendations[0].pattern && recommendations[0].cards) {
|
else if (recommendations[0].pattern && recommendations[0].cards) {
|
||||||
@@ -163,22 +163,17 @@ function cashOut(thisHand = null) {
|
|||||||
recommendations = [];
|
recommendations = [];
|
||||||
|
|
||||||
for (let cardId of localCards) {
|
for (let cardId of localCards) {
|
||||||
// console.log("Redeeming: " + cardId);
|
|
||||||
discard(cardId, thisHand, false);
|
discard(cardId, thisHand, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
globalPoints += localPoints;
|
globalPoints += localPoints;
|
||||||
// console.log("Cashed out: " + (localPoints * pointsMultiplier) + " points");
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!handGiven) {
|
if (forceRefresh) {
|
||||||
updateUI();
|
updateUI();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
// console.log("Nothing to do.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function drawCard(cardId, thisHand = null, thisDeck = null) {
|
function drawCard(cardId, thisHand = null, thisDeck = null) {
|
||||||
let handGiven = true;
|
let handGiven = true;
|
||||||
@@ -239,9 +234,11 @@ function getPatterns(thisHand = null) {
|
|||||||
// fill them with the current hand's cards
|
// fill them with the current hand's cards
|
||||||
for (let cardId of thisHand) {
|
for (let cardId of thisHand) {
|
||||||
let card = idToCard(cardId);
|
let card = idToCard(cardId);
|
||||||
|
if (card) {
|
||||||
cardColorsByNumbers[card.number - 1].push(card.color);
|
cardColorsByNumbers[card.number - 1].push(card.color);
|
||||||
cardsByNumbers[card.number - 1].push(card);
|
cardsByNumbers[card.number - 1].push(card);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// check if there are "color" amount of any
|
// check if there are "color" amount of any
|
||||||
for (let i = 0; i < maxNumber; i++) {
|
for (let i = 0; i < maxNumber; i++) {
|
||||||
@@ -458,10 +455,6 @@ function recommendThrowaway(depth = 0, thisHand = null, thisDeck = null, chance
|
|||||||
}
|
}
|
||||||
return place;
|
return place;
|
||||||
});
|
});
|
||||||
// let fewer = recommendations.filter(choice => choice.chance >= 0.01);
|
|
||||||
// if (fewer.length > 0) {
|
|
||||||
// recommendations = fewer;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -486,7 +479,7 @@ function updateUI(skipAuto = false) {
|
|||||||
recommend();
|
recommend();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// recommendations = [];
|
recommendations = [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
recommendationArray = [];
|
recommendationArray = [];
|
||||||
|
|||||||
Reference in New Issue
Block a user