我参与编写JS用于鞅式赌博游戏。我创建了一个循环脚本。这个想法是游戏的概率为50/50,并且每次旋转时概率都会重置。你下注/下注。我设置了一个脚本,以减少我的损失并重置为我对胜利的原始出价。但我想创建一个max_bet限制,因为你在那些更高的旋转中损失了所有的钱。连续10次亏损=如果每次亏损加倍,您的原始出价将减少1023倍。
所以下面的脚本在第7次丢失时就停止了(如果(multiplyCalls< 5)请注意5因为0是开始,你还需要在没有双倍出价的情况下包括失败的第7次出价。所以基本上什么值得你说它去+2。抱歉这是技术性的,但只是解释为什么它是5而不是7。
然而,我发现这会带来负面影响,当它达到最大损失时,它会一直回到原始出价。正是在那些更高的旋转上,下注这么多钱。我想修改这个脚本,让它返回3个出价,而不是一直回到0.我只是无法弄清楚如何设置呼叫。
var startValue = '0.00000001', // Don't lower the decimal point more than 4x of current balance
stopPercentage = 0.001, // In %. I wouldn't recommend going past 0.08
maxWait = 777, // In milliseconds
stopped = false,
stopBefore = 1; // In minutes
multiplyCalls = 0; // <--- Added this global
var $loButton = $('#double_your_btc_bet_lo_button'),
$hiButton = $('#double_your_btc_bet_hi_button');
function multiply(){
if(multiplyCalls < 5){ // this sets the losses allowed, apply +2 (5 = 7 losses allowed)
var current = $('#double_your_btc_stake').val();
var multiply = (current * 2).toFixed(8);
$('#double_your_btc_stake').val(multiply);
multiplyCalls++; // increment
}else{
reset();
console.log('=== RESETING ===');
}
}
function getRandomWait(){
var wait = Math.floor(Math.random() * maxWait ) + 100;
console.log('Waiting for ' + wait + 'ms before next bet.');
return wait ;
}
function startGame(){
console.log('Game started!');
reset();
$loButton.trigger('click');
}
function stopGame(){
console.log('Game will stop soon! Let me finish.');
stopped = true;
}
function reset(){
$('#double_your_btc_stake').val(startValue);
}
// quick and dirty hack if you have very little bitcoins like 0.0000001
function deexponentize(number){
return number * 1000000;
}
function iHaveEnoughMoni(){
var balance = deexponentize(parseFloat($('#balance').text()));
var current = deexponentize($('#double_your_btc_stake').val());
return ((balance*2)/100) * (current*2) > stopPercentage/100;
}
function stopBeforeRedirect(){
var minutes = parseInt($('title').text());
if( minutes < stopBefore )
{
console.log('Approaching redirect! Stop the game so we don\'t get redirected while loosing.');
stopGame();
return true;
}
return false;
}
// Unbind old shit
$('#double_your_btc_bet_lose').unbind();
$('#double_your_btc_bet_win').unbind();
// Loser
$('#double_your_btc_bet_lose').bind("DOMSubtreeModified",function(event){
if( $(event.currentTarget).is(':contains("lose")') )
{
console.log('You LOST! Multiplying your bet and betting again.');
multiply();
setTimeout(function(){
$loButton.trigger('click');
}, getRandomWait());
//$loButton.trigger('click');
}
});
// Winner
$('#double_your_btc_bet_win').bind("DOMSubtreeModified",function(event){
if( $(event.currentTarget).is(':contains("win")') )
{
if( stopBeforeRedirect() )
{
return;
}
if( iHaveEnoughMoni() )
{
console.log('You WON! But don\'t be greedy. Restarting!');
reset();
if( stopped )
{
stopped = false;
return false;
}
}
else
{
console.log('You WON! Betting again');
}
setTimeout(function(){
$loButton.trigger('click');
}, getRandomWait());
multiplyCalls = 0; // reset value
}
答案 0 :(得分:0)
这似乎是一个逻辑问题而不是JS问题,但是......
如果我理解正确,你想在第4次下注时记录下注的价值(在你的代码中意味着multiplyCalls === 2
,对吧?)。如果是这样,请在顶部设置一个名为maxBet
的变量来保存该信息。
在multiply
功能中,您可以在maxBet
时写信至multiplyCalls == 2
,然后检查maxBet > multiply
(一旦您完成了这项工作。
e.g。
var maxBet = 0;
function multiply(){
if(multiplyCalls < 5){ // this sets the losses allowed, apply +2 (5 = 7 losses allowed)
var current = $('#double_your_btc_stake').val();
if(multiplyCalls === 2){
maxBet = current;
}
var multiply = (current * 2).toFixed(8);
if (multiply > maxBet) {
multiple = maxBet;
}
$('#double_your_btc_stake').val(multiply);
multiplyCalls++; // increment
}else{
reset();
console.log('=== RESETING ===');
}
}
这是什么意思?如果没有,我希望它能让你更近一点!