JSFiddle - React, Tailwind, and code Playground
by amarcrypto
HTML
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
Balance :
<input type="text" id="tx_saldo" value="0.00001000" />
<p>Base Bet :
<input type="text" id="tx_amount" value="0.00000001" />
</p>
<p>Chance :
<input type="text" id="tx_chance" value="49.50" style="width:40px;" />%</p>
<p>Payout : <span id="tx_payout"> 2 </span></p>
<p>Multiply After Every <input type="text" id="tx_multiply" value="1" /> Streak of Loss.</p>
<p>Loss :
<input type="text" id="tx_loss" value="100" style="width:90px;" />% (Minimum Recommended : <span id="tx_minLoss">100</span> % )</p>
<p>
<input type="submit" id="bt_submit" value="Calculate" />
</p>
<div id="Table">
CSS
table {
border-collapse: collapse;
}
table,
th,
td {
border: 1px solid black;
padding: 3px;
text-align: center;
}
destaque {
color: red;
font-weight: 800;
}
JavaScript
var pout = 2;
var minloss = 100;
function roundUp(num, precision) {
return Math.ceil(num * precision) / precision
}
$("#tx_chance").change(function() {
pout = (99 / $("#tx_chance").val());
$("#tx_payout").html(pout.toFixed(4));
minloss = 100 / (pout - 1);
$("#tx_minLoss").html(minloss);
$("#tx_loss").val(roundUp(minloss, 10000));
});
$("#bt_submit").click(function() {
var curSaldo = $("#tx_saldo").val();
var curBet = $("#tx_amount").val();
var multiply = $("#tx_multiply").val();
var curLoss = 1 + $("#tx_loss").val() / 100;
var nBet = 1;
var prof = 0;
if ($("#tabela").length) $("#tabela").remove();
$("<div id='tabela'><p><div id='result'></div></p><table id='tabela_rows'><tbody><tr style='font-weight: 600;'><td>#</td><td>Bet Amount</td><td>Balance after loss</td><td>Profit if win</td></tr></tbody></table></div>").insertAfter("#bt_submit");
while (curSaldo > curBet) {
curSaldo = curSaldo - curBet;
prof = ((parseFloat(curBet) * parseFloat($("#tx_payout").html())) - ($("#tx_saldo").val() - curSaldo)).toFixed(8);
$('#tabela_rows > tbody:last').append('<tr><td>' + nBet + '</td><td>' + parseFloat(curBet).toFixed(8) + '</td><td>' + curSaldo.toFixed(8) + '</td><td>' + prof + '</td></tr>');
if(nBet%multiply == 0)
curBet = curBet * curLoss;
nBet += 1;
}
curSaldo = curSaldo - curBet;
$('#tabela_rows > tbody:last').append('<tr style="color: red;font-weight: 600;"><td>' + nBet + '</td><td>' + parseFloat(curBet).toFixed(8) + '</td><td colspan="2">Bet greater than balance</td></tr>');
$("#result").html("Your strategy supports <destaque>" + (nBet - 1).toString() + "</destaque> losses<p>The persistence of this strategy is <destaque>" + ((nBet - 1) / parseFloat($("#tx_payout").html())).toFixed(1) + " (Minimum 8 Recommended)</destaque>");
});