Skip to content
Permalink
Browse files

odds sample size

  • Loading branch information...
Manuel-777 committed Feb 4, 2019
1 parent dd43ab6 commit d76ee052cb3f7a33cf68a182d276ff6a55d0e879
Showing with 68 additions and 11 deletions.
  1. +17 −8 window_background/background.js
  2. +23 −3 window_overlay/index.css
  3. +28 −0 window_overlay/overlay.js
@@ -551,6 +551,15 @@ ipc.on('set_deck_mode', function (event, state) {
update_deck(true);
});

let odds_sample_size = 1;
ipc.on('set_odds_samplesize', function (event, state) {
odds_sample_size = state;
forceDeckUpdate();
update_deck(true);
});



ipc.on('get_deck_changes', function (event, arg) {
get_deck_changes(arg);
});
@@ -1448,16 +1457,16 @@ function forceDeckUpdate() {
else if (c.type.includes("Sorcery", 0)) typeSor += card.quantity;
else if (c.type.includes("Planeswalker", 0)) typePla += card.quantity;
}
card.chance = Math.round(hypergeometric(1, cardsleft, 1, card.quantity)*100);
card.chance = Math.round(hypergeometric(1, cardsleft, odds_sample_size, card.quantity)*100);
});

currentDeckUpdated.chanceCre = Math.round(hypergeometric(1, cardsleft, 1, typeCre) * 1000)/10;
currentDeckUpdated.chanceIns = Math.round(hypergeometric(1, cardsleft, 1, typeIns) * 1000)/10;
currentDeckUpdated.chanceSor = Math.round(hypergeometric(1, cardsleft, 1, typeSor) * 1000)/10;
currentDeckUpdated.chancePla = Math.round(hypergeometric(1, cardsleft, 1, typePla) * 1000)/10;
currentDeckUpdated.chanceArt = Math.round(hypergeometric(1, cardsleft, 1, typeArt) * 1000)/10;
currentDeckUpdated.chanceEnc = Math.round(hypergeometric(1, cardsleft, 1, typeEnc) * 1000)/10;
currentDeckUpdated.chanceLan = Math.round(hypergeometric(1, cardsleft, 1, typeLan) * 1000)/10;
currentDeckUpdated.chanceCre = Math.round(hypergeometric(1, cardsleft, odds_sample_size, typeCre) * 1000)/10;
currentDeckUpdated.chanceIns = Math.round(hypergeometric(1, cardsleft, odds_sample_size, typeIns) * 1000)/10;
currentDeckUpdated.chanceSor = Math.round(hypergeometric(1, cardsleft, odds_sample_size, typeSor) * 1000)/10;
currentDeckUpdated.chancePla = Math.round(hypergeometric(1, cardsleft, odds_sample_size, typePla) * 1000)/10;
currentDeckUpdated.chanceArt = Math.round(hypergeometric(1, cardsleft, odds_sample_size, typeArt) * 1000)/10;
currentDeckUpdated.chanceEnc = Math.round(hypergeometric(1, cardsleft, odds_sample_size, typeEnc) * 1000)/10;
currentDeckUpdated.chanceLan = Math.round(hypergeometric(1, cardsleft, odds_sample_size, typeLan) * 1000)/10;
currentDeckUpdated.deckSize = decksize;
currentDeckUpdated.cardsLeft = cardsleft;
}
@@ -156,7 +156,7 @@ body {pointer-events: none}
color: #bdd6ff;
}

.clock_prev, .draft_prev, .deck_prev {
.clock_prev, .draft_prev, .deck_prev, .odds_prev {
-webkit-app-region:no-drag;
position: absolute;
cursor: pointer;
@@ -170,7 +170,7 @@ body {pointer-events: none}
-webkit-transition: all .2s ease-in;
}

.clock_next, .draft_next, .deck_next {
.clock_next, .draft_next, .deck_next, .odds_next {
-webkit-app-region:no-drag;
cursor: pointer;
position: absolute;
@@ -184,10 +184,30 @@ body {pointer-events: none}
-webkit-transition: all .2s ease-in;
}

.clock_prev:hover, .clock_next:hover, .draft_prev:hover, .draft_next:hover, .deck_prev:hover, .deck_next:hover {
.clock_prev:hover, .clock_next:hover, .draft_prev:hover, .draft_next:hover, .deck_prev:hover, .deck_next:hover, .odds_prev:hover, .odds_next:hover {
opacity: 1;
}

.overlay_samplesize_container {
margin-top: 16px;
position: relative;
height: 32px;
flex-direction: column;
display: flex;
width: 100%;
}

.odds_number {
width: 100%;
margin-top: auto;
text-align: center;
color: rgba(255, 255, 255, 0.85);
}

.odds_prev, .odds_next {
height: 44px;
}

.overlay_card_quantity {
width: 100%;
display: flex;
@@ -38,6 +38,8 @@ let turnPriority = 0;
let soundPriority = false;
let overlayAlpha = 1;
let overlayAlphaBack = 1;
let oddsSampleSize = 1;
let cardsLeft = 60;

let showSideboard = false;
let actionLog = [];
@@ -366,6 +368,7 @@ ipc.on('set_deck', function (event, arg) {
var prevIndex = 0;

if (arg.cardsLeft && (deckMode == 0 || deckMode == 2)) {
cardsLeft = arg.cardsLeft;
deckListDiv.append('<div class="chance_title">'+arg.cardsLeft+' cards left</div>');
}
else {
@@ -404,6 +407,14 @@ ipc.on('set_deck', function (event, arg) {
}

if (deckMode == 2) {
deckListDiv.append(`
<div class="overlay_samplesize_container">
<div class="odds_prev click-on"></div>
<div class="odds_number">Sample size: ${oddsSampleSize}</div>
<div class="odds_next click-on"></div>
</div>
`);

deckListDiv.append('<div class="chance_title"></div>');// Add some space
deckListDiv.append('<div class="chance_title">Creature: ' + (arg.chanceCre != undefined ? arg.chanceCre : '0')+'%</div>');
deckListDiv.append('<div class="chance_title">Instant: ' + (arg.chanceIns != undefined ? arg.chanceIns : '0')+'%</div>');
@@ -412,6 +423,23 @@ ipc.on('set_deck', function (event, arg) {
deckListDiv.append('<div class="chance_title">Enchantment: ' + (arg.chanceEnc != undefined ? arg.chanceEnc : '0')+'%</div>');
deckListDiv.append('<div class="chance_title">Planeswalker: ' + (arg.chancePla != undefined ? arg.chancePla : '0')+'%</div>');
deckListDiv.append('<div class="chance_title">Land: ' + (arg.chanceLan != undefined ? arg.chanceLan : '0')+'%</div>');

//
$(".odds_prev").click(function () {
oddsSampleSize -= 1;
if (oddsSampleSize < 1) {
oddsSampleSize = cardsLeft-1;
}
ipc_send('set_odds_samplesize', oddsSampleSize);
});
//
$(".odds_next").click(function () {
oddsSampleSize += 1;
if (oddsSampleSize > cardsLeft-1) {
oddsSampleSize = 1;
}
ipc_send('set_odds_samplesize', oddsSampleSize);
});
}
}
});

0 comments on commit d76ee05

Please sign in to comment.
You can’t perform that action at this time.