Skip to content

Commit

Permalink
cortex prime: default to "at least" plot
Browse files Browse the repository at this point in the history
  • Loading branch information
HighDiceRoller committed Nov 13, 2023
1 parent 9f64018 commit 3f31816
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions apps/cortex_prime.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ <h2>Total and effect die</h2>
<div style="font-size: 150%;">
Show:
<select id="distSelect">
<option value="pmf">Chance of exactly</option>
<option value="ccdf"><i>Chance of at least</option>
<option value="pmf">Chance of total exactly</option>
<option value="ccdf" selected="selected"><i>Chance of total at least</option>
</select>
</div>
<div class="chart_container"><canvas id="totalChart"></canvas></div>
Expand Down Expand Up @@ -450,6 +450,26 @@ <h2>Hitches</h2>
}

async function updateTotalResults() {
let selected_dist = document.getElementById('distSelect').value;
if (selected_dist === 'pmf') {
for (let i = 0; i < 5; i++) {
totalChart.data.datasets[i].fill = false;
}
totalChart.data.datasets[1].borderColor = 'rgba(220, 200, 0, 0.25)';
totalChart.data.datasets[2].borderColor = 'rgba(0, 200, 0, 0.125)';
totalChart.data.datasets[3].borderColor = 'rgba(0, 0, 240, 0.125)';;
totalChart.data.datasets[4].borderColor = 'rgba(220, 0, 240, 0.125)'
} else {
for (let i = 0; i < 4; i++) {
totalChart.data.datasets[i].fill = '+1';
}
totalChart.data.datasets[4].fill = 'origin';
totalChart.data.datasets[1].borderColor = 'rgba(220, 200, 0, 1.0)';
totalChart.data.datasets[2].borderColor = 'rgba(0, 200, 0, 1.0)';
totalChart.data.datasets[3].borderColor = 'rgba(0, 0, 240, 1.0)';
totalChart.data.datasets[4].borderColor = 'rgba(220, 0, 240, 1.0)';
}

let pyodide = await pyodideReadyPromise;

pyodide.runPython(`
Expand Down Expand Up @@ -481,22 +501,6 @@ <h2>Hitches</h2>
for effect_die in [6, 8, 10, 12]:
data_set_index = effect_die // 2 - 2
js.totalChart.data.datasets[data_set_index].hidden = pyodide.ffi.to_js(effect_die not in player_die_sizes)
if selected_dist == 'pmf':
for i in range(5):
js.totalChart.data.datasets[i].fill = pyodide.ffi.to_js(False)
js.totalChart.data.datasets[1].borderColor = pyodide.ffi.to_js('rgba(220, 200, 0, 0.25)')
js.totalChart.data.datasets[2].borderColor = pyodide.ffi.to_js('rgba(0, 200, 0, 0.125)')
js.totalChart.data.datasets[3].borderColor = pyodide.ffi.to_js('rgba(0, 0, 240, 0.125)')
js.totalChart.data.datasets[4].borderColor = pyodide.ffi.to_js('rgba(220, 0, 240, 0.125)')
else:
for i in range(4):
js.totalChart.data.datasets[i].fill = pyodide.ffi.to_js('+1')
js.totalChart.data.datasets[4].fill = pyodide.ffi.to_js('origin')
js.totalChart.data.datasets[1].borderColor = pyodide.ffi.to_js('rgba(220, 200, 0, 1.0)')
js.totalChart.data.datasets[2].borderColor = pyodide.ffi.to_js('rgba(0, 200, 0, 1.0)')
js.totalChart.data.datasets[3].borderColor = pyodide.ffi.to_js('rgba(0, 0, 240, 1.0)')
js.totalChart.data.datasets[4].borderColor = pyodide.ffi.to_js('rgba(220, 0, 240, 1.0)')
`);

totalChart.update();
Expand Down

0 comments on commit 3f31816

Please sign in to comment.