|
| 1 | +function init() { |
| 2 | + console.log('hello Simulator'); |
| 3 | + $$("bet_currency_selection").define("options", [ |
| 4 | + {id:1,value:"BTC"}, |
| 5 | + ]); |
| 6 | + minBetAmount = 0.1; |
| 7 | + $$("manual_bet_amount").setValue(minBetAmount); |
| 8 | + $$("auto_bet_base_amount").setValue(minBetAmount); |
| 9 | + $$("manual_bet_chance").setValue(49.5); |
| 10 | + $$("auto_bet_base_chance").setValue(49.5); |
| 11 | + $$("bet_currency_selection").refresh(); |
| 12 | + $$("bet_house_edge_selection").show(); |
| 13 | +} |
| 14 | + |
| 15 | +function checkParams(p,ch){ |
| 16 | + //console.log(p,ch); |
| 17 | + if(p < 0.00000001 || p > 1000000000*1000000000) { |
| 18 | + return false |
| 19 | + } |
| 20 | + if(ch>99 || ch<0.0001) { |
| 21 | + return false |
| 22 | + } |
| 23 | + return true; |
| 24 | +} |
| 25 | + |
| 26 | +function initScriptBalance(currencyValue, cb){ |
| 27 | + getInfo(function(userinfo){ |
| 28 | + if(userinfo.info.success == 'true'){ |
| 29 | + try { |
| 30 | + fengari.load('balance='+userinfo.info.balance)(); |
| 31 | + fengari.load('bets='+userinfo.info.bets)(); |
| 32 | + fengari.load('wins='+userinfo.info.wins)(); |
| 33 | + fengari.load('losses='+userinfo.info.losses)(); |
| 34 | + fengari.load('profit='+userinfo.info.profit)(); |
| 35 | + } catch(err){ |
| 36 | + console.error(err.message); |
| 37 | + webix.message({type: 'error', text: err.message}); |
| 38 | + return false; |
| 39 | + } |
| 40 | + cb(); |
| 41 | + } |
| 42 | + }); |
| 43 | +} |
| 44 | + |
| 45 | +function getBalance(userinfo){ |
| 46 | + let balance = userinfo.info.balance |
| 47 | + return balance; |
| 48 | +} |
| 49 | + |
| 50 | +function getActProfit(userinfo){ |
| 51 | + let actProfit = userinfo.currentInfo.profit * 100000000; |
| 52 | + //console.log('actprofit:'+actProfit); |
| 53 | + return actProfit; |
| 54 | +} |
| 55 | + |
| 56 | +function getCurrProfit(ret){ |
| 57 | + let currProfit = ret.betInfo.profit |
| 58 | + //console.log('currprofit:'+currProfit); |
| 59 | + return currProfit; |
| 60 | +} |
| 61 | + |
| 62 | +function getCurrentBetId(ret){ |
| 63 | + let betId = ret.betInfo.id; |
| 64 | + //console.log('currentBetId:'+betId); |
| 65 | + return betId; |
| 66 | +} |
| 67 | + |
| 68 | +function getCurrentRoll(ret){ |
| 69 | + let roll = ret.betInfo.roll_number; |
| 70 | + //console.log('currentRoll:'+roll); |
| 71 | + return roll; |
| 72 | +} |
| 73 | + |
| 74 | +async function outError(ret){ |
| 75 | + let mess = ret.err; |
| 76 | + return await retryError(mess); |
| 77 | +} |
| 78 | + |
| 79 | +function isError(ret){ |
| 80 | + if(typeof ret.err != "undefined") |
| 81 | + return false; |
| 82 | + else |
| 83 | + return true; |
| 84 | +} |
| 85 | + |
| 86 | +function getWinStatus(ret){ |
| 87 | + return ret.betInfo.win; |
| 88 | +} |
| 89 | + |
| 90 | +function setDatatable(ret){ |
| 91 | + let chanceStr = '<font size="3" color="red">'+ ret.betInfo.condition + ' '+ ret.betInfo.target +'</font>'; |
| 92 | + if(ret.betInfo.win){ |
| 93 | + chanceStr = '<font size="3" color="green">'+ ret.betInfo.condition + ' '+ ret.betInfo.target +'</font>'; |
| 94 | + } |
| 95 | + let profitStr = '<font size="3" color="red">' + ret.betInfo.profit+ '</font>'; |
| 96 | + if(ret.betInfo.profit>0) { |
| 97 | + profitStr = '<font size="3" color="green">' + ret.betInfo.profit + '</font>'; |
| 98 | + } |
| 99 | + $$('bet_datatable').add({ |
| 100 | + bet_datatable_id:ret.betInfo.id, |
| 101 | + bet_datatable_amount:ret.betInfo.amount, |
| 102 | + bet_datatable_low_high:ret.betInfo.condition, |
| 103 | + bet_datatable_payout:ret.betInfo.payout, |
| 104 | + bet_datatable_bet_chance:chanceStr, |
| 105 | + bet_datatable_actual_chance:ret.betInfo.roll_number, |
| 106 | + bet_datatable_profit:profitStr, |
| 107 | + },0); |
| 108 | +} |
| 109 | + |
| 110 | +function setStats(userinfo, cv){ |
| 111 | + if(userinfo.info.success == 'true'){ |
| 112 | + $$('bet_total_stats').setValues({ |
| 113 | + bet_total_stats_balance:userinfo.info.balance, |
| 114 | + bet_total_stats_win:userinfo.info.wins, |
| 115 | + bet_total_stats_loss:userinfo.info.losses, |
| 116 | + bet_total_stats_bet:userinfo.info.bets, |
| 117 | + bet_total_stats_profit:userinfo.info.profit, |
| 118 | + bet_total_stats_wagered:userinfo.info.wagered, |
| 119 | + }); |
| 120 | + $$('bet_current_stats').setValues({ |
| 121 | + bet_current_stats_balance:userinfo.currentInfo.balance, |
| 122 | + bet_current_stats_win:userinfo.currentInfo.wins, |
| 123 | + bet_current_stats_loss:userinfo.currentInfo.losses, |
| 124 | + bet_current_stats_bet:userinfo.currentInfo.bets, |
| 125 | + bet_current_stats_profit:userinfo.currentInfo.profit, |
| 126 | + bet_current_stats_wagered:userinfo.currentInfo.wagered, |
| 127 | + }); |
| 128 | + } |
| 129 | +} |
0 commit comments