Skip to content

Commit

Permalink
mime and steel breakdown
Browse files Browse the repository at this point in the history
  • Loading branch information
EFHIII committed Mar 14, 2024
1 parent c86d270 commit 62baf3a
Show file tree
Hide file tree
Showing 4 changed files with 164 additions and 11 deletions.
16 changes: 14 additions & 2 deletions balatro-sim.js
Original file line number Diff line number Diff line change
Expand Up @@ -901,8 +901,20 @@ class Hand {
}

// retriggers
if(!retrigger && card[SEAL] === RED_SEAL) {
this.triggerCardInHand(card, true);
if(!retrigger) {
if(card[SEAL] === RED_SEAL) {
this.triggerCardInHand(card, true);
}

for(let j = 0; j < this.jokers.length; j++) {
const joker = this.jokers[j];
if(joker[JOKER_DISABLED]) continue;
switch(joker[JOKER]) {
case 14:
this.triggerCardInHand(card, true);
break;
}
}
}
}

Expand Down
141 changes: 139 additions & 2 deletions breakdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -1032,6 +1032,16 @@ class Hand {
if(!retrigger) {
if(card[SEAL] === RED_SEAL) {
this.triggerCard(card, true);

if(this.bd) {
this.breakdown.push({
cards: [card],
description: 'Retrigger',
chips: this.compiledChips,
mult: this.compiledMult,
retrigger: true
});
}
}

for(let j = 0; j < this.jokers.length; j++) {
Expand All @@ -1041,30 +1051,80 @@ class Hand {
case 13:
// Sock and Buskin
if(isFace) {
if(this.bd) {
this.breakdown.push({
cards: [card, joker],
description: 'Retrigger',
chips: this.compiledChips,
mult: this.compiledMult,
retrigger: true
});
}

this.triggerCard(card, true);
}
break;
case 25:
// Hack
if(card[RANK] <= _5) {
if(this.bd) {
this.breakdown.push({
cards: [card, joker],
description: 'Retrigger',
chips: this.compiledChips,
mult: this.compiledMult,
retrigger: true
});
}

this.triggerCard(card, true);
}
break;
case 69:
// Hanging Chad
if(this.jokersExtraValue[j] === 0) {
if(this.bd) {
this.breakdown.push({
cards: [card, joker],
description: 'Retrigger',
chips: this.compiledChips,
mult: this.compiledMult,
retrigger: true
});
}

this.jokersExtraValue[j]++;
this.triggerCard(card, true);
}
break;
case 74:
// Dusk
if(joker[VALUE] !== 0) {
if(this.bd) {
this.breakdown.push({
cards: [card, joker],
description: 'Retrigger',
chips: this.compiledChips,
mult: this.compiledMult,
retrigger: true
});
}

this.triggerCard(card, true);
}
break;
case 153:
// Seltzer
if(this.bd) {
this.breakdown.push({
cards: [card, joker],
description: 'Retrigger',
chips: this.compiledChips,
mult: this.compiledMult,
retrigger: true
});
}

this.triggerCard(card, true);
break;
}
Expand All @@ -1077,6 +1137,15 @@ class Hand {
if(card[ENHANCEMENT] === STEEL && !card[CARD_DISABLED]) {
this.compiledInHandPlusMult = bigTimes(1.5, this.compiledInHandPlusMult);
this.compiledInHandTimesMult = bigTimes(1.5, this.compiledInHandTimesMult);

if(this.bd) {
this.inHandBreakdown.push({
cards: [card],
description: `${prodc}1.5${endc} Mult`,
chips: this.compiledInHandTimesMult,
mult: this.compiledInHandPlusMult
});
}
}

for(let j = 0; j < this.jokers.length; j++) {
Expand All @@ -1087,27 +1156,86 @@ class Hand {
// Raised Fist
if(card === this.compiledValues[j] && card[ENHANCEMENT] !== STONE) {
this.compiledInHandPlusMult = bigAdd(2 * (card[RANK] === ACE ? 11 : Math.max(10, card[RANK] + 2)), this.compiledInHandPlusMult);

if(this.bd) {
this.inHandBreakdown.push({
cards: [card, joker],
description: `${multc}+${2 * (card[RANK] === ACE ? 11 : Math.max(10, card[RANK] + 2))}${endc} Mult`,
chips: this.compiledInHandTimesMult,
mult: this.compiledInHandPlusMult
});
}
}
break;
case 62:
// Shoot the Moon
if(card[RANK] === QUEEN && card[ENHANCEMENT] !== STONE) {
this.compiledInHandPlusMult = bigAdd(13, this.compiledInHandPlusMult);

if(this.bd) {
this.inHandBreakdown.push({
cards: [card, joker],
description: `${multc}+13${endc} Mult`,
chips: this.compiledInHandTimesMult,
mult: this.compiledInHandPlusMult
});
}
}
break;
case 126:
// Baron
if(card[RANK] === KING && card[ENHANCEMENT] !== STONE) {
this.compiledInHandPlusMult = bigTimes(1.5, this.compiledInHandPlusMult);
this.compiledInHandTimesMult = bigTimes(1.5, this.compiledInHandTimesMult);

if(this.bd) {
this.inHandBreakdown.push({
cards: [card, joker],
description: `${prodc}1.5${endc} Mult`,
chips: this.compiledInHandTimesMult,
mult: this.compiledInHandPlusMult
});
}
}
break;
}
}

// retriggers
if(!retrigger && card[SEAL] === RED_SEAL) {
this.triggerCardInHand(card, true);
if(!retrigger) {
if(card[SEAL] === RED_SEAL) {
if(this.bd) {
this.inHandBreakdown.push({
cards: [card],
description: 'Retrigger',
chips: this.compiledInHandTimesMult,
mult: this.compiledInHandPlusMult,
retrigger: true
});
}

this.triggerCardInHand(card, true);
}

for(let j = 0; j < this.jokers.length; j++) {
const joker = this.jokers[j];
if(joker[JOKER_DISABLED]) continue;
switch(joker[JOKER]) {
case 14:
if(this.bd) {
this.inHandBreakdown.push({
cards: [card, joker],
description: 'Retrigger',
chips: this.compiledInHandTimesMult,
mult: this.compiledInHandPlusMult,
retrigger: true
});
}

this.triggerCardInHand(card, true);
break;
}
}
}
}

Expand Down Expand Up @@ -1362,6 +1490,7 @@ class Hand {
this.lowestCard = false;

this.breakdown = [];
this.inHandBreakdown = [];

for(let c = 0; c < this.cards.length; c++) {
if(this.cards[c][ENHANCEMENT] === WILD) {
Expand Down Expand Up @@ -1801,6 +1930,14 @@ class Hand {
}

// score cards-in-hand
if(this.bd) {
for(let l = 0; l < this.inHandBreakdown.length; l++) {
this.inHandBreakdown[l].mult = bigBigAdd(bigBigTimes(this.inHandBreakdown[l].chips, this.mult), this.inHandBreakdown[l].mult);
this.inHandBreakdown[l].chips = this.chips;
}
this.breakdown.push(...this.inHandBreakdown);
}

this.mult = bigBigTimes(this.compiledInHandTimesMult, this.mult);
this.mult = bigBigAdd(this.compiledInHandPlusMult, this.mult);

Expand Down
16 changes: 10 additions & 6 deletions manageWorkers.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ function terminateThreads() {

let tmpBestJokers;
let tmpBestCards;
let tmpBestCardsInHand;
let tmpBestHighHand;
let tmpBestLowHand;
let tmpTypeOfHand;
Expand All @@ -219,17 +220,19 @@ function workerMessage(msg) {
bestScore = msg.data[1];
tmpBestJokers = msg.data[2];
tmpBestCards = msg.data[3];
tmpBestHighHand = msg.data[4];
tmpBestLowHand = msg.data[5];
tmpTypeOfHand = msg.data[6];
tmpBestCardsInHand = msg.data[4];
tmpBestHighHand = msg.data[5];
tmpBestLowHand = msg.data[6];
tmpTypeOfHand = msg.data[7];
}
if(msg.data[1][1] > bestScore[1] || (msg.data[1][1] === bestScore[1] && msg.data[1][0] > bestScore[0])) {
bestScore = msg.data[1];
tmpBestJokers = msg.data[2];
tmpBestCards = msg.data[3];
tmpBestHighHand = msg.data[4];
tmpBestLowHand = msg.data[5];
tmpTypeOfHand = msg.data[6];
tmpBestCardsInHand = msg.data[4];
tmpBestHighHand = msg.data[5];
tmpBestLowHand = msg.data[6];
tmpTypeOfHand = msg.data[7];
}
if(tasks === 0) {
bestJokers = tmpBestJokers.map(a => {
Expand Down Expand Up @@ -258,6 +261,7 @@ function workerMessage(msg) {

breakdownHand.jokers = tmpBestJokers;
breakdownHand.cards = tmpBestCards;
breakdownHand.cardsInHand = tmpBestCardsInHand;
breakdownHand.compileAll();
breakdownHand.simulateWorstHand();
updateBreakdown(breakdownHand.breakdown.map(a => {
Expand Down
2 changes: 1 addition & 1 deletion worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ function run(jokers = [[]]) {

thisHand.compileAll();

postMessage([taskID, bestScore, bestJokers, bestCards, thisHand.simulateBestHand(), thisHand.simulateWorstHand(), thisHand.typeOfHand]);
postMessage([taskID, bestScore, bestJokers, bestCards, bestCardsInHand, thisHand.simulateBestHand(), thisHand.simulateWorstHand(), thisHand.typeOfHand]);
}

self.onmessage = async function(msg) {
Expand Down

0 comments on commit 62baf3a

Please sign in to comment.