Hallo Re:Later ,
vielen Dank für die Anleitung.
Irgendwas mach ich aber scheinbar trotzdem noch falsch.
Die PHP-Datei haben ich unter /templates/rstrone/html/mod_custom/meincode.php angelegt.
In meiner meincode.php steht:
mit" value="Simulate Bets" />
</p>
<div id="Table">1<br><br><br><br><br></div>
<?php
defined('_JEXEC') or die;
use Joomla\CMS\HTML\HTMLHelper;
HTMLHelper::_('jquery.framework');
HTMLHelper::_('script', 'meincode.js', array('version' => 'auto', 'relative' => true));
/*HTMLHelper::_('stylesheet', 'ubc.css', array('version' => 'auto', 'relative' => true));*/
?>
Balance:
<input type="text" id="tx_saldo" value="0.00001000" />
<p>Base Bet:
<input type="text" id="tx_amount" value="0.00000001" />
</p>
<p>Start chance:
<input type="text" id="tx_chance" value="0.1" style="width:40px;" />%
Increment chance by:
<input type="text" id="tx_increment" value="0.1" style="width:40px;" />%
</p>
<p>House edge:
<input type="text" id="tx_houseedge" value="1" style="width:40px;" />%
</p>
<!--<p>Payout: <span id="tx_payout"> 990 </span></p>-->
<!--<p>Multiply After Every <input type="text" id="tx_multiply" value="1" /> Streak of Loss.</p> -->
<!--<p>Raise on loss:
<input type="text" id="tx_loss" value="1" style="width:90px;" />%<!-- (Minimum Recommended : <span id="tx_minLoss">100</span> % )</p>-->
<p>Show only higher strategies:
<input type="checkbox" class="cb_high" title="Best strategy will be at the end of the table" checked><br>
<input type="radio" id="show_by_p" name="show_by" value="P" checked>
<label for="show_by">Persistance</label><br>
<input type="radio" id="show_by_o" name="show_by" value="O">
<label for="show_by">Odds of losing bets in a row</label><br>
</p>
<p>
<input type="submit" id="bt_submit" value="Simulate Bets" />
</p>
Alles anzeigen
Eine css-Datei habe ich nicht angelegt, da ich aktuell das css des Template nutzen will.
Die JS-Datei habe ich unter /templates/rstrone/js angelegt.
In meiner meincode.js Datei steht:
jQuery(function($) {
var payout = 990;
var minloss = 1;
function roundUp(num, precision) {
return Math.ceil(num * precision) / precision
}
function roundDown(num, precision) {
return Math.floor(num * precision) / precision
}
/*$("#tx_chance").change(function() {*/
$("#tx_chance").on("change", function() {
payout = ((100 - $("#tx_houseedge").val()) / $("#tx_chance").val()); //stake 99 //freebitco.in 95
$("#tx_payout").html(payout.toFixed(4));
minloss = 100 / (payout - 1);
$("#tx_minLoss").html(roundUp(minloss, 100));
$("#tx_loss").val(roundUp(minloss, 10000));
});
/*$("#bt_submit").click(function() {*/
$("#bt_submit").on("click", function() {
var Saldo = $("#tx_saldo").val();
var Bet = $("#tx_amount").val();
var multiply = 1 //$("#tx_multiply").val();
var chance = $("#tx_chance").val();
var increment = $("#tx_increment").val();
var cb_high = document.querySelector('.cb_high').checked;//$("#checkbox").is(":checked");
var cb_show_by = document.querySelector('input[name="show_by"]:checked').value;
var run = 1;
var optRun = 1;
var highlight;
var high_persistance = 0;
var high_once_in = 0;
var show_result = 0;
var houseedge = 100 - $("#tx_houseedge").val();
var payout = (houseedge / chance);
var profit = 0;
//var once_in = 0;
if ($("#table").length) $("#table").remove();
$("<div id='table'><p><div id=result></div></p><table id='table_rows'><tbody>" +
"<tr><td>#</td>" +
"<td>Chance</td>" +
"<td>Payout</td>" +
"<td>Base Bet</td>" +
"<td>Profit on win</td>" +
"<td>Raise on loss</td>" +
"<td>Optimized<br/>Raise on loss</td>" +
"<td>Max loss streak</td>" +
"<td>Persistance</td>" +
"<td>Odds of losing bets in a row<br>once every</td>" +
"</tr></tbody></table></div>").insertAfter("#bt_submit");
profit = (parseFloat(Bet) * parseFloat(payout)).toFixed(8);
while (chance <= houseedge && payout >= 1.01 && profit >= 0.00000001) {
var curSaldo = Saldo;
var optSaldo = Saldo;
var curBet = Bet;
var optBet = Bet;
var Bet2 = Bet;
var nBet = 1;
var optnBet = 0;
var profit = 0;
var payout = (houseedge / chance);
var minloss = 100 / (payout - 1);
var curLoss = (1 + roundUp(minloss, 10000) / 100).toFixed(8);
var optLoss = curLoss;
var persistance = 0;
var once_in = 0;
//Calculate min basbet using onloss
while ( ((curBet * curLoss) - curBet).toFixed(8) < 0.00000001 ) {
curBet = (parseFloat(curBet) + 0.00000001).toFixed(8);
Bet2 = curBet;
}
//Simulate bets
while (curSaldo > curBet) {
curSaldo = curSaldo - curBet;
profit = ((parseFloat(curBet) * parseFloat(payout)) - (Saldo - curSaldo)).toFixed(8);
//if (nBet % multiply == 0) //modulo
curBet = curBet * curLoss;
nBet = nBet + 1;
}
//highlight persistance
//persistance = ((nBet / parseFloat(payout)) / parseFloat(payout)).toFixed(1);
persistance = ((nBet - 1) / parseFloat(payout)).toFixed(1);
//once in xxxx
once_in = (1 / (Math.pow( ((100 - parseFloat(chance).toFixed(2) )/100), (nBet - 1)) * 1)).toFixed(2);
//.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 });
//optimized raise on loss
optSaldo = Saldo;
optLoss = parseFloat(curLoss);
optBet = Bet2;
optnBet = nBet - 1;
optRun = "J";
do {optLoss = (parseFloat(optLoss) + 0.0001).toFixed(8);
if (optnBet < nBet - 1) {
optRun = "N";
optLoss = (parseFloat(optLoss) - 0.0002).toFixed(8);
optnBet = optnBet + 1;
break; }
optSaldo = Saldo;
optBet = Bet2;
optnBet = 0;
while (optSaldo > optBet) {
optSaldo = optSaldo - optBet;
optBet = optBet * optLoss;
optnBet = optnBet + 1;
}
} while (optRun === "J");
//coloring persistance
switch (true) {
case ( (parseInt(persistance)) >= 11):
highlight = 'style="color: goldenrod; font-weight: bold;"';
break;
case ( (parseInt(persistance)) >= 10):
highlight = 'style="color: green;"';
break;
case ( (parseInt(persistance)) >= 9):
highlight = 'style="color: blue;"';
break;
case ( (parseInt(persistance)) >= 8):
highlight = 'style="color: orange;"';
break;
default:
highlight = 'style="color: black;"';
}
//show only higher strategies
if (cb_high == true) {
if (cb_show_by == "P") {
if (persistance >= high_persistance) {
high_persistance = parseFloat(persistance);
show_result = 1; }
else {
show_result = 0; }
}
if (cb_show_by == "O") {
if (once_in >= high_once_in) {
high_once_in = parseFloat(once_in);
show_result = 1; }
else {
show_result = 0; }
}
}
else { show_result = 1; }
//calc once_in for display-formatting
once_in = (1 / (Math.pow( ((100 - parseFloat(chance).toFixed(2) )/100), (nBet - 1)) * 1)).toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 });
//Show the results
if (show_result == 1) {
$('#table_rows').append('<tr><td>' + run + //Sequence
'</td><td>' + parseFloat(chance).toFixed(2) + //Chance
'</td><td>' + parseFloat(payout).toFixed(2) + //Payout
'</td><td>' + Bet2 + //Base Bet
'</td><td>' + profit + //Profit on win
'</td><td>' + parseFloat((curLoss - 1)*100).toFixed(4) + '%' + //parseFloat(curLoss).toFixed(4) + //Raise on loss
'</td><td>' + parseFloat((optLoss - 1)*100).toFixed(4) + '%' + //parseFloat(curLoss).toFixed(4) + //Optimized Raise on
'</td><td>' + (nBet - 1) /*+ '/' + optnBet*/ + //Max loss streak
'</td><td ' + highlight + '>' + persistance + //Persistance
' / 10' +
'</td><td>' + once_in + ' bets' + //Odds of losing bets in a row once every
'</td></tr>');
}
run = run + 1;
chance = parseFloat(chance) + parseFloat(increment);
}
});
});
Alles anzeigen
Das Modul habe ich im Backend angelegt.
Es zeigt auf der Modulposition auf der Webseite auch das HTML an.
Aber der Button hat keine Funktion.
Irgendwas mach ich da wohl noch mit dem JS falsch.
Gruß
hagen