← back to browse
goat command

crash1

Crash game

0
views
0
likes
0
installs

Aliases: c1

raw source
const mongoose = require("mongoose");

const bankUserSchema = new mongoose.Schema({
userID: { type: String, required: true, unique: true },
balance: { type: Number, default: 0 }
});

const BankUser = mongoose.models.DiabloBankUser || mongoose.model("DiabloBankUser", bankUserSchema);

let statsDB = {};

module.exports = {
config: {
name: "crash1",
aliases: ["c1"],
version: "1.6",
author: "Sazzad",
countDown: 5,
role: 0,
shortDescription: "Crash game",
longDescription: "Plane ure jaoar age cashout koro",
category: "game",
guide: { en: "{p}crash1 50 | {p}crash1 all | {p}crash1 max" }
},

formatMoney: function (num) {
if (num >= 1000000) return (num / 1000000).toFixed(2).replace(/\.00$/, "") + "B";
if (num >= 1000000) return (num / 1000000).toFixed(2).replace(/\.00$/, "") + "M";
return num.toLocaleString();
},

parseBet: function(str, balance) {
str = str.toLowerCase().replace(/,/g, "");
if (str === "all") return Math.min(balance, 69000000);
if (str === "max") return 69000000;
if (str.includes("b")) return parseFloat(str) * 1000000;
if (str.includes("m")) return parseFloat(str) * 1000000;
if (str.includes("k")) return parseFloat(str) * 1000;
return parseFloat(str);
},

onStart: async function ({ api, event, args, message }) {
const sendMsg = (txt) => message.reply(txt);
const userID = event.senderID;

let user = await BankUser.findOne({ userID });
if (!user) user = await BankUser.create({ userID, balance: 1000 });

const now = Date.now();
const ONE_HOUR = 3600000;
const MAX_PLAY = 20;

if (!statsDB[userID]) statsDB[userID] = { plays: 0, playsLeft: MAX_PLAY, lastReset: now };
let stats = statsDB[userID];

if (now - stats.lastReset >= ONE_HOUR) {
stats.playsLeft = MAX_PLAY;
stats.lastReset = now;
}

if (stats.playsLeft <= 0) {
let msLeft = ONE_HOUR - (now - stats.lastReset);
let m = Math.floor(msLeft / 60000);
let s = Math.floor((msLeft % 60000) / 1000);
return sendMsg(`⏳ 𝐋𝐈𝐌𝐈𝐓 𝐒𝐄𝐒𝐇!\n1𝐡𝐫 𝐩𝐨𝐫 𝐚𝐛𝐚𝐫 20 𝐭𝐚 𝐤𝐡𝐞𝐥𝐚 𝐩𝐚𝐛𝐚\n🕒 𝐁𝐚𝐤𝐢: ${m}𝐦 ${s}𝐬`);
}

let bet = 50;
if (args[0]) bet = this.parseBet(args[0], user.balance);

if (isNaN(bet)) return sendMsg(`❌ Thik moto bet dao. Ex: #crash1 50 | #crash1 all`);
if (bet < 50) return sendMsg(`❌ Minimum bet 50`);
if (bet > 69000000) return sendMsg(`❌ Max bet 69,000,000,000`);
if (user.balance < bet) return sendMsg(`💸 Balance kom! Tor balance: $${this.formatMoney(user.balance)}`);

stats.plays++;
stats.playsLeft--;
user.balance -= bet;

// 60% loss chance
const roll = Math.random();
let crashPoint;
if (roll < 0.60) {
crashPoint = Math.random() * 0.5 + 1.00; // 1.00x - 1.50x e crash
} else {
crashPoint = Math.random() * 8.5 + 1.50; // 1.50x - 10.00x e crash
}

const playerCashout = crashPoint - (Math.random() * 0.3 + 0.05);

let result = "";
let payout = 0;

if (playerCashout < crashPoint) {
payout = bet * playerCashout;
user.balance += payout;
result = `🟢 𝐂𝐀𝐒𝐇𝐎𝐔𝐓 𝐀𝐓 ${playerCashout.toFixed(2)}x`;
} else {
result = `💥 𝐂𝐑𝐀𝐒𝐇𝐄𝐃 𝐀𝐓 ${crashPoint.toFixed(2)}x`;
}

await user.save();
const used = MAX_PLAY - stats.playsLeft;

return sendMsg( `🌌 ━━ 𝑺𝑨𝒁𝒁𝑨𝑫'𝑺 𝑪𝑹𝑨𝑺𝑯 ━━ 🌌
✈️ 𝐏𝐋𝐀𝐍𝐄 𝐅𝐋𝐘𝐈𝐍𝐆...

${result}
💰 𝐁𝐞𝐭: $${this.formatMoney(bet)}
${payout > 0? `🟢 𝐖𝐨𝐧: +$${this.formatMoney(payout)}` : `🔴 𝐋𝐨𝐬𝐬: -$${this.formatMoney(bet)}`}
💳 𝐖𝐚𝐥𝐞𝐭: $${this.formatMoney(user.balance)}
📊 𝐋𝐢𝐦𝐢𝐭𝐬: ${used}/20` );
}
};

View raw file