I have ZERO interest in favouring a winner since i am only taking a 3% fee.
The fact you're taking a fee has nothing to do with whether or not you would play on your site and use information that only you have access to to gain an unfair advantage over players. You could easily do this undetected and make more money.
Again, i am at the opposing end of traditional casinos that take 97% instead of 3% and that i showed in one of my first messages in the posts i wrote you.
The traditional casino doesn't take 97%. If they offer a game with a 3% house edge, they will profit 3% of the total wagered, just like you.
Provably fair is a nonsense as you already know
You're uninformed about provably fair. Do some research.
I am not a scammer, i can even show you the source code since i am the programmer myself,
Cool, post it.
i never bet against my players and i can show that as well.
Cool, prove it. Make it so that you couldn't exploit the players even if you wanted to also...of course this would require a provably fair system which you think is nonsense.
Stock Market Mania
var ev
var resolver = require('./openTradesResolver')
var arr = require('../../arrays')
var winner = require('./winner')
var objects = require ('../../objects')
var autoPilot= require ('../../auto-pilot')
var pause
module.exports = function (socket, breakCB, event, stockPotSchema, User, stockSchema, cb) {
function getRandomIntInclusive(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min; //The maximum is inclusive and the minimum is inclusive
}
var time = 0
function callback() {
var interval1 = setInterval(() => {
resolver(stockValue, time, arr.openTrades, () => {
if (time === 0) {
objects.stockPlayers = 0
clearInterval(interval1)
winner(socket, ev, User, stockSchema, () => {
ev = Date.now()
event(ev)
breakCB(15)
pause = 15
stockPotSchema.find({}, (err, rrr) => {
var pot = 0
rrr.forEach((obj) => {
pot = pot + obj.pot
})
stockPotSchema.remove({}, () => {
stockPotSchema.create({
pot: pot,
event: ev
}).then((rs) => {
autoPilot.preStock(pause, ev, socket)
var int = setInterval(() => {
stockSchema.countDocuments({event: ev}, (err, count) => {
if(count >= 1) {
socket.of('/api/stock-market-mania').emit('remaining', {remaining: 0})
clearInterval(int)
pause = 14
var interval2 = setInterval(() => {
breakCB(pause)
if (pause === 5) {
arr.openTrades.length = 0
}
if (pause === 0) {
clearInterval(interval2)
stockSchema.countDocuments({event: ev}, (err, count) => {
objects.stockPlayers = count !== undefined ? count : 0
socket.of('/api/online').emit('players', {rocket: objects.rocketPlayers, keno: objects.kenoPlayers, stock: objects.stockPlayers})
})
time = 45
setTimeout(callback)
socket.of('/api/stock-market-mania').emit('break', {break: pause})
}
else {
socket.of('/api/stock-market-mania').emit('break', {break: pause})
}
pause--
}, 1000)
}
else {
socket.of('/api/stock-market-mania').emit('remaining', {remaining: 10 - count})
}
})
}, 1000)
})
})
})
})
}
})
time--
if (time >= 0){
var stockValue = getRandomIntInclusive(0, 10000)
cb(time, stockValue)
autoPilot.stockMarketManiaDecision(ev, stockValue, socket)
}
socket.of('/api/stock-market-mania').emit('stock-plot', {stockValue: stockValue, time: time})
}, 1000)
}
callback()
}
The Open Trades Resolver:
module.exports = function (stockValue, time, arr, cb) {
if (arr.length > 0) {
if (time > 0) {
arr.forEach((v) => {
if (v.direction === 'buy') {
const cap = ((stockValue / v.entry) * v.investment - v.investment) + v.capital
if (cap <= 0) {
v.betSchema.findByIdAndUpdate(v.betSchemaId, {status: 'settled', exit: stockValue, pl: (stockValue / v.entry) * v.investment - v.investment}, {new: true}, (e, r) => {
if (r && r !== null && r !== undefined) {
v.stockSchema.updateOne({_id: v.stockSchemaId, 'trades._id': r._id}, {capital: cap, $set:{'trades.$.status': 'settled', 'trades.$.exit': r.exit}}, {new: true}, (e2, r2) => {
arr.splice(arr.indexOf(v), 1)
var pl = (r.exit/r.entry) * r.investment - r.investment
if (v.soc) {
v.soc.emit('enter', {capital: cap, direction: v.direction, status: r.status, entry: r.entry, exit: r.exit, pl: pl})
}
v.socket.of('/api/stock-market-mania').emit('table', {avatar: v.avatar, username: v.username, capital: cap})
})
}
})
}
else {
if (v.soc) {
v.soc.emit('enter', {capital: cap, direction: v.direction, status: 'open'})
}
}
}
if (v.direction === 'sell') {
const cap = (v.investment - (stockValue / v.entry) * v.investment) + v.capital
if (cap <= 0) {
v.betSchema.findByIdAndUpdate(v.betSchemaId, {status: 'settled', exit: stockValue, pl: v.investment - (stockValue / v.entry) * v.investment}, {new: true}, (e, r) => {
if (r && r !== null && r !== undefined) {
v.stockSchema.updateOne({_id: v.stockSchemaId, 'trades._id': r._id}, {capital: cap, $set:{'trades.$.status': 'settled', 'trades.$.exit': r.exit}}, {new: true}, (e2, r2) => {
arr.splice(arr.indexOf(v), 1)
var pl = r.investment - (r.exit/r.entry) * r.investment
if (v.soc) {
v.soc.emit('enter', {capital: cap, direction: v.direction, status: r.status, entry: r.entry, exit: r.exit, pl: pl})
}
v.socket.of('/api/stock-market-mania').emit('table', {avatar: v.avatar, username: v.username, capital: cap})
})
}
})
}
else {
if (v.soc) {
v.soc.emit('enter', {capital: cap, direction: v.direction, status: 'open'})
}
}
}
})
}
if (time === 0) {
arr.forEach((v) => {
if (v.direction === 'buy') {
const cap = ((stockValue / v.entry) * v.investment - v.investment) + v.capital
v.betSchema.findByIdAndUpdate(v.betSchemaId, {status: 'settled', exit: stockValue, pl: (stockValue / v.entry) * v.investment - v.investment}, {new: true}, (e, r) => {
if (r && r !== null && r !== undefined) {
v.stockSchema.updateOne({_id: v.stockSchemaId, 'trades._id': r._id}, {capital: cap, $set:{'trades.$.status': 'settled', 'trades.$.exit': r.exit}}, {new: true}, (e2, r2) => {
var pl = (r.exit/r.entry) * r.investment - r.investment
if (v.soc) {
v.soc.emit('enter', {capital: cap, direction: v.direction, status: r.status, entry: r.entry, exit: r.exit, pl: pl})
}
v.socket.of('/api/stock-market-mania').emit('table', {avatar: v.avatar, username: v.username, capital: cap})
})
}
})
}
if (v.direction === 'sell') {
const cap = (v.investment - (stockValue / v.entry) * v.investment) + v.capital
v.betSchema.findByIdAndUpdate(v.betSchemaId, {status: 'settled', exit: stockValue, pl: v.investment - (stockValue / v.entry) * v.investment}, {new: true}, (e, r) => {
if (r && r !== null && r !== undefined) {
v.stockSchema.updateOne({_id: v.stockSchemaId, 'trades._id': r._id}, {capital: cap, $set:{'trades.$.status': 'settled', 'trades.$.exit': r.exit}}, {new: true}, (e2, r2) => {
var pl = r.investment - (r.exit/r.entry) * r.investment
if (v.soc) {
v.soc.emit('enter', {capital: cap, direction: v.direction, status: r.status, entry: r.entry, exit: r.exit, pl: pl})
}
v.socket.of('/api/stock-market-mania').emit('table', {avatar: v.avatar, username: v.username, capital: cap})
})
}
})
}
})
arr.length = 0
}
cb()
}
else {
cb()
}
}
Deciding the winner:
var stockPotSchema = require ('../../models/Stock Market Mania/stock-pot.model')
var stockBetSchema = require ('../../models/Stock Market Mania/bet.model')
var topEarners = require ('../../models/Top 3/top-earners.model')
module.exports = function (socket, event, User, stockSchema, callback) {
stockSchema.aggregate([
{$match: {event: event} },
{$group: {
_id: "$capital",
winners: {$push:'$username'}
}},
{$sort:{_id:-1}},
{$limit:1}
]).then((res) => {
if (res.length > 0 && event) {
stockPotSchema.findOne({event: event}, (e, r) => {
var partialPot = r.pot / res[0].winners.length
res[0].winners.forEach((winner) => {
User.findOneAndUpdate({username: winner}, {$inc:{accountValue: partialPot}}, {new:true}, (e1, r1) => {
topEarners.create({
username: r1.username,
avatar: r1.avatar,
winnings: partialPot,
timeOfInsertionms: Date.now()
}).then(() => {})
socket.of('/api/stock-market-mania').emit('table', {avatar: r1.avatar, event: event, username: winner, capital: res[0]._id, result: 'winner'})
})
})
stockPotSchema.findByIdAndRemove(r._id, (e123, r123) => {
stockBetSchema.remove({}, () => {
stockSchema.updateMany({}, {$set:{trades:[]}}, () => {
callback()
})
})
})
})
}
else {
stockBetSchema.remove({}, () => {
stockSchema.updateMany({}, {$set:{trades:[]}}, () => {
callback()
})
})
}
})
}
Here s the auto-pilot:
exports.preStock = function (stockPause, stockEvent, socket) {
stockArr.forEach((player) => {
User.findOne({username: player.username}, (e1, resp) => {
if(player.noOfGames !== 0 && resp.accountValue >= Math.pow(2, player.tickets - 1)) {
if (player.noOfGames !== -1) {
const index = stockArr.indexOf(player)
stockArr.splice(index, 1, {
username: player.username,
avatar: player.avatar,
leverage: player.leverage,
tickets: player.tickets,
noOfGames: player.noOfGames - 1
})
}
if (resp.accountValue >= Math.pow(2, player.tickets - 1)) {
stockSchema.findOne({username: player.username, event: stockEvent}, (err, res) => {
if (stockPause > 0 && (!res || res === null || res === undefined)) {
stockSchema.create({
username: player.username,
avatar: player.avatar,
ticketsPrice: Math.pow(2, player.tickets - 1),
tickets: player.tickets,
leverage: player.tickets,
timeOfInsertion: new Date(Date.now()),
timeOfInsertionms: Date.now(),
event: stockEvent
}).then((val) => {
topTickets.create({
username: val.username,
avatar: val.avatar,
tickets: val.tickets,
timeOfInsertionms: Date.now()
}).then(() => {})
// soc.emit('buy-ticket', {tickets: val.tickets, event: val.event})
socket.of('/api/stock-market-mania').emit('table', {avatar: val.avatar, username: val.username, event: val.event, capital: val.capital})
User.findOneAndUpdate({username: val.username}, {$inc: {accountValue: -val.ticketsPrice}}, (e, r555) => {
revenue.findOneAndUpdate({game: 'Stock Market Mania'}, {$inc:{amount: 0.03 * val.ticketsPrice}}, {new: true}, (ex, rx) => {
if (rx && rx !== undefined && rx !== null) {
stockPotSchema.findOneAndUpdate({event: val.event}, {$inc:{pot: 0.97 * val.ticketsPrice}}, {new: true}, (e2, r2) => {
socket.of('/api/stock-market-mania').emit('pot', {pot: r2.pot})
})
}
else {
revenue.create({
game: 'Stock Market Mania',
amount: 0.03 * val.ticketsPrice
}).then(() => {
stockPotSchema.findOneAndUpdate({event: val.event}, {$inc:{pot: 0.97 * val.ticketsPrice}}, {new: true}, (e2, r2) => {
socket.of('/api/stock-market-mania').emit('pot', {pot: r2.pot})
})
})
}
})
})
})
}
else{
}
})
}
}
else {
autoPilot.findOneAndUpdate({username: player.username}, {
stock: false,
avatar: player.avatar,
$set:{'stockSettings.$.leverage': 0,
'stockSettings.$.tickets': 0,
'stockSettings.$.noOfGames': 0}
}, {new: true}, (e, r) => {
const index = stockArr.indexOf(player)
stockArr.splice(index, 1)
})
}
})
})
}
function stockMarketManiaTrade (user, direction, stockEvent, stockValue, socket) {
stockSchema.findOne({username: user.username, event: stockEvent}, (e, r) => {
if (!r || r === null || r === undefined) {}
else {
const obj1 = r.trades.find((v) => {return v.direction === direction && v.status === 'open'})
const obj2 = r.trades.find((v) => {return v.direction !== direction && v.status === 'open' })
if (obj1 === undefined && obj2 === undefined) {
if (r.leverage * r.capital >= stockValue) {
const investment = Math.floor((r.leverage * r.capital)/stockValue) * stockValue
stockBetSchema.create({
direction: direction,
entry: stockValue,
investment: investment,
status: 'open'
}).then((r1) => {
stockSchema.findByIdAndUpdate(r._id, {$push:{trades: r1}}, {new: true}, (e2, r2) => {
array.openTrades.push({avatar: user.avatar , socket: socket, username: user.username, capital: r.capital, entry: r1.entry, direction: r1.direction, betSchema: stockBetSchema, betSchemaId: r1._id, investment: r1.investment, stockSchema: stockSchema, stockSchemaId: r._id})
})
})
}
}
else if (obj1 !== undefined && obj2 === undefined) {
}
else if (obj1 === undefined && obj2 !== undefined) {
var trade = array.openTrades.find((v) => {return v.betSchemaId === obj2._id})
var index = array.openTrades.indexOf(trade)
array.openTrades.splice(index, 1)
stockBetSchema.findByIdAndUpdate(obj2._id, {status: 'settled', exit: stockValue}, {new: true}, (e3, r3) => {
if (r3 && r3 !== null && r3 !== undefined) {
var pl
var cap
if (r3.direction === 'buy') {
cap = ((stockValue / r3.entry) * r3.investment - r3.investment) + r.capital
pl = (r3.exit/r3.entry) * r3.investment - r3.investment
}
if (r3.direction === 'sell') {
cap = (r3.investment - (stockValue / r3.entry) * r3.investment) + r.capital
pl = r3.investment - (r3.exit/r3.entry) * r3.investment
}
stockSchema.updateOne({_id:r._id, 'trades._id': r3._id}, {capital: cap, $set:{'trades.$.status': 'settled', 'trades.$.exit': r3.exit}}, (a, b) => {
socket.of('/api/stock-market-mania').emit('table', {avatar: user.avatar, username: user.username, capital: cap})
})
}
})
}
else if (obj1 !== undefined && obj2 !== undefined) {
}
}
})
}
exports.stockMarketManiaDecision = function (ev, stockValue, socket) {
stockArr.forEach((v) => {
var decision = getRandomIntInclusive(0, 1)
if (decision === 1) {
stockMarketManiaTrade(v, 'buy', ev, stockValue, socket)
}
else if (decision === 0) {
stockMarketManiaTrade(v, 'sell', ev, stockValue, socket)
}
})
}