Skip to content

Instantly share code, notes, and snippets.

@dersonsena
Created July 30, 2024 20:16
Show Gist options
  • Save dersonsena/ece2c5b7daf473c00ff7d93eaf18eb49 to your computer and use it in GitHub Desktop.
Save dersonsena/ece2c5b7daf473c00ff7d93eaf18eb49 to your computer and use it in GitHub Desktop.
async determinarResultado(probabilidadeGanho: number, probabilidadebonus: number, id: number, gamecode: string) {
const resultadoAleatorio = Math.random()
const callpending = await this.getcall(id, gamecode)
let numeroAleatorio = 0
if (callpending.length > 0 && callpending[0].status === "pending" && callpending[0].gamecode === `${gamecode}`) {
return {
result: "bonus",
gamecode: gamecode,
json: callpending[0].jsonname,
idcall: callpending[0].id,
}
}
if (resultadoAleatorio < probabilidadeGanho) {
if (resultadoAleatorio < probabilidadebonus) {
const user = await this.getuserbyid(id)
if (user[0].isinfluencer === 1) {
numeroAleatorio = Math.floor(Math.random() * 6) + 1
await this.addcall(gamecode, id, numeroAleatorio)
} else {
numeroAleatorio = Math.floor(Math.random() * (12 - 7 + 1)) + 7
await this.addcall(gamecode, id, numeroAleatorio)
}
return { result: "ganho" }
} else {
return { result: "ganho" }
}
} else {
return { result: "perda" }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment