Skip to content

Commit 2a596ea

Browse files
author
bot
committed
stats 3 & balance changing in simulator
1 parent d91c262 commit 2a596ea

File tree

6 files changed

+194
-40
lines changed

6 files changed

+194
-40
lines changed

src/api/controllers/apiController.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ exports.raw = async function(req, res) {
449449
let data = {};
450450
data.data = ret;
451451
data.ext = ext[ext.length - 1];
452-
data.name = 'gits_'+path.basename(rawurl) ;
452+
data.name = 'gist_'+path.basename(rawurl) ;
453453
let filePath = path.resolve(path.join(process.execPath, '../script/'+data.ext+'/')+data.name);
454454
if(isMobile(req)) {
455455
filePath = path.resolve(path.join(__dirname, '../../script/'+data.ext+'/'+data.name));

src/api/models/simulator.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ module.exports = class Simulator extends BaseDice {
4848
async clear(req) {
4949
console.log('loading....');
5050
let userName = req.session.username;
51-
let currency = req.body.Currency;
51+
let currency = req.query.currency;
52+
let balance = req.query.balance;
5253

5354
let info = {};
5455

@@ -116,6 +117,10 @@ module.exports = class Simulator extends BaseDice {
116117
info.currentInfo.balance=1.000000000;
117118
}
118119
}
120+
if(balance) {
121+
info.info.balance=parseFloat(balance);
122+
info.currentInfo.balance=parseFloat(balance);
123+
}
119124

120125
info.info.balance=info.info.balance.toFixed(8);
121126

src/console.js

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ var needSimulatorActiveKeySites = ['Simulator'];
5151

5252
var nums = 0, currency = 'btc', base = 0, isloop = false, iswin = false;
5353
var code;
54+
var startTime = new Date(), settime, difftime = 0;
5455
var basebet = 0.00000001, nextbet = 0.00000001, chance = 90, bethigh = false;
55-
var previousbet = 0, win = false, currentprofit = 0, balance = 0, bets = 0, wins = 0, losses = 0, profit = 0, currentstreak = 0, currentroll = 0 ,wagered = 0;
56+
var previousbet = 0, win = false, currentprofit = 0, balance = 0, bets = 0, wins = 0, losses = 0, profit = 0, currentstreak = 0, currentroll = 0 ,wagered = 0, totalprofit = 0;
5657
var maxwinstreak = 0, maxlossstreak = 0, maxwinstreakamount = 0, maxlossstreakamount = 0, maxstreakamount = 0, minstreakamount = 0, maxbetamount = 0 ;
5758
var lastbet = {id:0,chance:chance, date:'',roll:49.5,amount:nextbet,nonce:1000,serverhash:'mydice',serverseed:'mydice',clientseed:'',profit:profit,uid:1000,high:bethigh};
5859
var currencies = ['BTC', 'Doge', 'LTC', 'ETH'];
@@ -146,24 +147,30 @@ var contrib = require('blessed-contrib');
146147
var screen = blessed.screen();
147148
var grid = new contrib.grid({rows: 4, cols: 4, screen: screen});
148149

149-
var table1 = grid.set(0, 0, 1.4, 1.0, contrib.table,
150+
var table1 = grid.set(0, 0, 1.4, 0.8, contrib.table,
150151
{ keys: true
151152
, fg: 'green'
152153
, label: 'Total Status'
153154
, columnSpacing: 1
154155
, columnWidth: [10, 12]});
155-
var table2 = grid.set(0, 1.0, 1.4, 1.0, contrib.table,
156+
var table2 = grid.set(0, 0.8, 1.4, 0.8, contrib.table,
156157
{ keys: true
157158
, fg: 'green'
158159
, label: 'Current Status 1'
159160
, columnSpacing: 1
160161
, columnWidth: [10, 12]});
161-
var table3 = grid.set(0, 2.0, 1.4, 1.2, contrib.table,
162+
var table3 = grid.set(0, 1.6, 1.4, 0.8, contrib.table,
162163
{ keys: true
163164
, fg: 'green'
164165
, label: 'Current Status 2'
165166
, columnSpacing: 1
166167
, columnWidth: [18, 12]});
168+
var table5 = grid.set(0, 2.4, 1.4, 0.8, contrib.table,
169+
{ keys: true
170+
, fg: 'green'
171+
, label: 'Current Status 3'
172+
, columnSpacing: 1
173+
, columnWidth: [24]});
167174
var table4 = grid.set(0, 3.2, 1.4, 0.8, contrib.table,
168175
{ keys: true
169176
, fg: 'green'
@@ -185,6 +192,14 @@ table4.setData(
185192
, data:
186193
[['Start(Enter)'],
187194
['Stop(S)'],['Quit(Ctrl-C)']] });
195+
table5.setData(
196+
{ headers: ['Info']
197+
, data:
198+
[['TIME:0:0:0:0'],
199+
['BETS:0'],
200+
['PROFIT/H:0'],
201+
['PROFIT/D:0'],
202+
['AVGPROFIT:0']] });
188203

189204
screen.key(['C-c'], function(ch, key) {
190205
return process.exit(0);
@@ -200,6 +215,7 @@ screen.key(['enter'],async function(ch, key) {
200215
console.log("The script is still running!");
201216
return false;
202217
}
218+
betTime();
203219
console.log("Script start!");
204220
isloop = true;
205221
let i = 0;
@@ -215,6 +231,7 @@ screen.key(['enter'],async function(ch, key) {
215231
betfunc = (() => {
216232
(async() => {
217233
if(!isloop){
234+
stopBetTime();
218235
console.log("Script stopped!");
219236
isloop = false;
220237
return false;
@@ -238,7 +255,7 @@ screen.key(['enter'],async function(ch, key) {
238255
let dice = Factory.create(req.body.site);
239256
await login(req);
240257

241-
screen.render()
258+
screen.render();
242259

243260
console.log = function (message) {
244261
try {
@@ -283,7 +300,7 @@ async function betScript(req) {
283300
console.error(err);
284301
}
285302
} else {
286-
isloop = outError(ret);
303+
isloop = false;
287304
}
288305
if (isloop) {
289306
return true;
@@ -369,6 +386,7 @@ function setBetToLua(ret, currencyValue, currentAmount){
369386
win = getWinStatus(ret);
370387
currentprofit = getCurrProfit(ret);
371388
currentroll = getCurrentRoll(ret);
389+
totalprofit = totalprofit + currentprofit;
372390
bets = bets + 1;
373391
if(getWinStatus(ret)){
374392
wins = wins + 1;
@@ -377,6 +395,29 @@ function setBetToLua(ret, currencyValue, currentAmount){
377395
}
378396
lastbet = {id:getCurrentBetId(ret),chance:chance, date:getBetDate(ret),roll:currentroll,amount:currentAmount,nonce:getNonce(ret),serverhash:getServerHash(ret),serverseed:getServerSeed(ret),clientseed:getClientSeed(ret),profit:profit,uid:getUid(ret),high:bethigh};
379397
}
398+
function betTime() {
399+
difftime++;
400+
dayf = difftime/(24*60*60);
401+
day = Math.floor(dayf);
402+
hourf = (dayf - day) * 24;
403+
hour = Math.floor(hourf);
404+
minf = (hourf-hour) * 60;
405+
min = Math.floor(minf);
406+
secf = (minf- min) * 60;
407+
sec = Math.floor(secf);
408+
table5.setData(
409+
{ headers: ['Info']
410+
, data:
411+
[['TIME:'+day+':'+hour+':'+min+':'+sec],
412+
['BETS:'+ bets],
413+
['PROFIT/H:'+ parseFloat(totalprofit/(dayf*24)).toFixed(10)],
414+
['PROFIT/D:'+ parseFloat(totalprofit/dayf).toFixed(10)],
415+
['AVGPROFIT:'+parseFloat(totalprofit/bets).toFixed(10) ]] });
416+
settime = setTimeout(function(){ betTime() }, 1000);
417+
}
418+
function stopBetTime() {
419+
clearTimeout(settime);
420+
}
380421

381422
function sleep(ms) {
382423
return new Promise(resolve => setTimeout(resolve, ms));

src/package.json.console

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "mydicebot-console-200503",
2+
"name": "mydicebot-console-200516",
33
"version": "1.0.0",
44
"description": "MyDiceBot - Bet more, earn more!",
55
"homepage": "https://mydicebot.com",

src/public/js/Simulator/info.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ function init() {
2424
$$("auto_bet_base_chance").setValue(49.5);
2525
$$("bet_currency_selection").refresh();
2626
$$("bet_house_edge_selection").show();
27+
$$("bet_sim_balance").show();
2728
}
2829

2930
function checkParams(p,ch){

0 commit comments

Comments
 (0)