Fix duplicate cards bug

This commit is contained in:
Dragon Fire
2020-11-22 11:31:48 -05:00
parent 63192b4960
commit 26af8afbd4
3 changed files with 10 additions and 9 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "xiao", "name": "xiao",
"version": "120.0.3", "version": "120.0.4",
"description": "Your personal server companion.", "description": "Your personal server companion.",
"main": "Xiao.js", "main": "Xiao.js",
"scripts": { "scripts": {
+1 -1
View File
@@ -29,7 +29,7 @@ module.exports = class Card {
} }
get pokersolverKey() { get pokersolverKey() {
if (this.value === 'Joker') return null; if (this.value === 'Joker') return 'Or';
let suitLetter; let suitLetter;
switch (this.suit) { switch (this.suit) {
case 'clubs': suitLetter = 'c'; break; case 'clubs': suitLetter = 'c'; break;
+8 -7
View File
@@ -12,18 +12,19 @@ module.exports = class Deck {
} }
makeCards(deckCount) { makeCards(deckCount) {
const newDeck = [];
for (let i = 0; i < deckCount; i++) { for (let i = 0; i < deckCount; i++) {
for (const suit of suits) { for (const suit of suits) {
this.deck.push(new Card('Ace', suit)); newDeck.push(new Card('Ace', suit));
for (let j = 2; j <= 10; j++) this.deck.push(new Card(j, suit)); for (let j = 2; j <= 10; j++) newDeck.push(new Card(j, suit));
for (const face of faces) this.deck.push(new Card(face, suit)); for (const face of faces) newDeck.push(new Card(face, suit));
} }
if (this.includeJokers) { if (this.includeJokers) {
this.deck.push(new Card('Joker', 'joker')); newDeck.push(new Card('Joker', 'joker'));
this.deck.push(new Card('Joker', 'joker')); newDeck.push(new Card('Joker', 'joker'));
} }
} }
this.deck = shuffle(this.deck); this.deck = shuffle(newDeck);
return this.deck; return this.deck;
} }
@@ -38,7 +39,7 @@ module.exports = class Deck {
} }
reset() { reset() {
this.deck = this.makeCards(this.deckCount); this.makeCards(this.deckCount);
return this; return this;
} }
}; };