48 lines
1003 B
JavaScript
48 lines
1003 B
JavaScript
|
var bot1ID = 0;
|
||
|
var bot2ID = 0;
|
||
|
|
||
|
function randomizer(los_nr){
|
||
|
return (Math.random() * (charge_data[los_nr]['startPreis'] - charge_data[los_nr]['minPreis']) + charge_data[los_nr]['minPreis']);
|
||
|
};
|
||
|
function buyBot(bot){
|
||
|
los_nr = document.getElementById('los_nr').value;
|
||
|
var bet = randomizer(los_nr);
|
||
|
|
||
|
if(charge_data[los_nr]['vkPreis'] < bet){
|
||
|
setBotButtonStyle(bot, 'buyAction');
|
||
|
var botname = 'Bot' + bot;
|
||
|
kaufen(botname);
|
||
|
|
||
|
}
|
||
|
};
|
||
|
function botStart(bot){
|
||
|
setBotButtonStyle(bot, 'active');
|
||
|
|
||
|
if(bot == 1){
|
||
|
bot1ID = setInterval(function(){buyBot(1)}, 1000);
|
||
|
}
|
||
|
else if(bot == 2){
|
||
|
bot2ID = setInterval(function(){buyBot(2)}, 1000);
|
||
|
}
|
||
|
else{
|
||
|
alert("Fehler beim Aktivieren eines Bots");
|
||
|
}
|
||
|
|
||
|
};
|
||
|
function botStop(bot){
|
||
|
setBotButtonStyle(bot, 'inactive');
|
||
|
|
||
|
if(bot == 1){
|
||
|
clearInterval(bot1ID);
|
||
|
bot1ID = 0;
|
||
|
|
||
|
}
|
||
|
else if(bot == 2){
|
||
|
clearInterval(bot2ID);
|
||
|
bot2ID = 0;
|
||
|
}
|
||
|
else{
|
||
|
alert("Fehler beim Aktivieren eines Bots");
|
||
|
}
|
||
|
};
|