fun-game.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. import TicTacToe from '../lib/tictactoe.js'
  2. let timeout = 60000
  3. let poin = 600
  4. let poin_lose = -100
  5. let poin_bot = 200
  6. global.suit = global.suit ? global.suit : {}
  7. //import MessageType from '@adiwajshing/baileys'
  8. let MessageType = (await import(global.baileys)).default
  9. let handler = async (m, { conn, text, command, usedPrefix, args }) => {
  10. let pp = 'https://telegra.ph/file/c7924bf0e0d839290cc51.jpg'
  11. let fkontak = { "key": { "participants":"[email protected]", "remoteJid": "status@broadcast", "fromMe": false, "id": "Halo" }, "message": { "contactMessage": { "vcard": `BEGIN:VCARD\nVERSION:3.0\nN:Sy;Bot;;;\nFN:y\nitem1.TEL;waid=${m.sender.split('@')[0]}:${m.sender.split('@')[0]}\nitem1.X-ABLabel:Ponsel\nEND:VCARD` }}, "participant": "[email protected]" }
  12. try {
  13. if (command == 'ppt' || command == 'pvp' || command == 'suit' || command == 'suitpvp') {
  14. const time = global.db.data.users[m.sender].wait + 30000;
  15. if (new Date() - global.db.data.users[m.sender].wait < 30000) return conn.fakeReply(m.chat, `*🕓 𝙃𝙚𝙮, 𝙀𝙨𝙥𝙚𝙧𝙖 ${msToTime(time - new Date())} 𝙖𝙣𝙩𝙚𝙨 𝙙𝙚 𝙪𝙨𝙖𝙧 𝙤𝙩𝙧𝙤𝙨 𝙘𝙤𝙢𝙖𝙣𝙙𝙤*`, m.sender, `ᴺᵒ ʰᵃᵍᵃⁿ ˢᵖᵃᵐ`, 'status@broadcast', null, fake);
  16. const guideText = `𝐏𝐢𝐞𝐝𝐫𝐚 🗿, 𝐏𝐚𝐩𝐞𝐥 📄 𝐨 𝐓𝐢𝐣𝐞𝐫𝐚 ✂️\n\n👾 𝙅𝙪𝙜𝙖𝙧 𝙘𝙤𝙣 𝙚𝙡 𝙗𝙤𝙩:\n• ${usedPrefix + command} piedra\n• ${usedPrefix + command} papel\n• ${usedPrefix + command} tijera\n\n🕹 𝙅𝙪𝙜𝙖𝙧 𝙘𝙤𝙣 𝙪𝙣 𝙪𝙨𝙪𝙖𝙧𝙞𝙤:\n${usedPrefix + command} @usuario`;
  17. if (!m.mentionedJid[0] && !args[0]) return conn.sendButton(m.chat, guideText, wm, pp, [['Piedra 🗿', `${usedPrefix + command} piedra`], ['Papel 📄', `${usedPrefix + command} papel`], ['Tijera ✂️', `${usedPrefix + command} tijera`]], m);
  18. const user = global.db.data.users[m.sender];
  19. const playerChoice = args[0]?.toLowerCase();
  20. const choices = ['piedra', 'papel', 'tijera'];
  21. const botChoice = choices[Math.floor(Math.random() * 3)];
  22. const name = conn.getName(m.sender);
  23. if (!m.mentionedJid[0] && choices.includes(playerChoice)) {
  24. global.db.data.users[m.sender].wait = new Date() * 1;
  25. const rules = { piedra: { beats: 'tijera', win: 1000, lose: 300, winType: 'coins', loseType: 'coins' },
  26. papel: { beats: 'piedra', win: 1000, lose: 300, winType: 'coins', loseType: 'xp' },
  27. tijera: { beats: 'papel', win: 1000, lose: 300, winType: 'coins', loseType: 'coins' }};
  28. let result, message;
  29. if (playerChoice === botChoice) {
  30. user.exp += 500;
  31. result = '𝙀𝙈𝙋𝘼𝙏𝙀 🤝';
  32. message = '🎁 Premios : 500 XP';
  33. } else if (rules[playerChoice].beats === botChoice) {
  34. user[rules[playerChoice].winType] += rules[playerChoice].win;
  35. result = '𝙃𝘼 𝙂𝘼𝙉𝘼𝘿𝙊! 🎉';
  36. message = `🎁 Premios : ${rules[playerChoice].win} ${rules[playerChoice].winType}`;
  37. } else {
  38. user[rules[playerChoice].loseType] -= rules[playerChoice].lose;
  39. result = '𝙃𝘼 𝙋𝙀𝙍𝘿𝙄𝘿𝙊! 🤡';
  40. message = `❌ Pérdida: -${rules[playerChoice].lose} ${rules[playerChoice].loseType}`;
  41. }
  42. conn.reply(m.chat, `\`「 ${result} 」\`\n\n👉 Tu: ${playerChoice}\n👉 El Bot: ${botChoice}\n${message}`, m, { contextInfo: {externalAdReply: { title: name, body: wm, thumbnail: img.getRandom(), sourceUrl: redes.getRandom()}}});
  43. }
  44. if (m.mentionedJid[0]) {
  45. if (Object.values(conn.suit).find(room => room.id.startsWith('suit') && [room.p, room.p2].includes(m.sender))) return m.reply(`⚠️ 𝙏𝙚𝙧𝙢𝙞𝙣𝙖 𝙩𝙪 𝙥𝙖𝙧𝙩𝙞𝙙𝙖 𝙖𝙣𝙩𝙚𝙨 𝙙𝙚 𝙞𝙣𝙞𝙘𝙞𝙖 𝙤𝙩𝙧𝙖`);
  46. if (Object.values(conn.suit).find(room => room.id.startsWith('suit') && [room.p, room.p2].includes(m.mentionedJid[0]))) return m.reply(`⚠️ 𝙀𝙡 𝙪𝙨𝙪𝙖𝙧𝙞𝙤 𝙮𝙖 𝙚𝙨𝙩𝙖́ 𝙟𝙪𝙜𝙖𝙣𝙙𝙤, 𝙚𝙨𝙥𝙚𝙧𝙖 𝙖 𝙦𝙪𝙚 𝙩𝙚𝙧𝙢𝙞𝙣𝙚`);
  47. const id = 'suit_' + new Date() * 1;
  48. const caption = `🎮👾 𝙋𝙑𝙋 - 𝙋𝙄𝙀𝘿𝙍𝘼, 𝙋𝘼𝙋𝙀𝙇 𝙊 𝙏𝙄𝙅𝙀𝙍𝘼 👾🎮\n\n@${m.sender.split`@`[0]} 𝘿𝙀𝙎𝘼𝙁𝙄𝘼 𝘼 @${m.mentionedJid[0].split`@`[0]}\n\n> _*Escribe (aceptar) para aceptar*_\n> _*Escribe (rechazar) para rechazar*_`;
  49. conn.suit[id] = {
  50. chat: await conn.sendMessage(m.chat, { text: caption, mentions: [m.sender, m.mentionedJid[0]] }),
  51. id: id,
  52. p: m.sender,
  53. p2: m.mentionedJid[0],
  54. status: 'wait',
  55. waktu: setTimeout(() => {
  56. if (conn.suit[id]) conn.reply(m.chat, `⏳ 𝙏𝙄𝙀𝙈𝙋𝙊 𝘼𝙂𝙊𝙏𝘼𝘿𝙊, 𝙀𝙇 𝙋𝙑𝙋 𝙎𝙀 𝘾𝘼𝙉𝘾𝙀𝙇𝘼`, m);
  57. delete conn.suit[id];
  58. }, timeout),
  59. poin: 1000,
  60. poin_lose: 300,
  61. poin_bot: 500,
  62. timeout
  63. }}
  64. }
  65. if (command == 'slot' || command == 'apostar' || command == 'slot1' || command == 'slot2' || command == 'slot3') {
  66. const slotTypes = {
  67. slot1: { currency: 'exp',
  68. name: 'Exp',
  69. emojis: ['💎', '⚡', '🪙'],
  70. cooldown: 60000,
  71. bonusWin: apuesta => apuesta * 2,
  72. consolation: 50,
  73. symbol: '⚡'
  74. },
  75. slot2: { currency: 'money',
  76. name: 'KantuCoins',
  77. emojis: ['🪙', '🔮', '🧿'],
  78. cooldown: 60000,
  79. bonusWin: apuesta => apuesta * 2,
  80. consolation: 30,
  81. symbol: '🪙'
  82. },
  83. slot3: {
  84. currency: 'limit',
  85. name: 'Diamantes',
  86. emojis: ['🪙', '💣', '💎'],
  87. cooldown: 30000,
  88. bonusWin: apuesta => apuesta * 2,
  89. consolation: 2,
  90. symbol: '💎'
  91. }}
  92. const fa = `${mg}𝙐𝙨𝙖𝙧 𝙙𝙚 𝙡𝙖 𝙨𝙞𝙜𝙪𝙞𝙚𝙣𝙩𝙚 𝙢𝙖𝙣𝙚𝙧𝙖:\n\n𝙀𝙟𝙚𝙢𝙥𝙡𝙤:\n*• ${usedPrefix}slot1 50* (aportas exp)\n*• ${usedPrefix}slot2 50* (aportas KantuCoins)\n*• ${usedPrefix}slot3 50* (aportas Diamantes)`.trim()
  93. const validateBet = (users, apuesta, currency, name) => {
  94. if (apuesta < 10) throw `⚠️ 𝐃𝐞𝐛𝐞𝐬 𝐚𝐩𝐨𝐬𝐭𝐚𝐫 𝐮𝐧 𝐦𝐢𝐧𝐢𝐦𝐨 𝐝𝐞 *10 ${name}*`
  95. if (users[currency] < apuesta) throw `⚠️ 𝐍𝐨 𝐭𝐢𝐞𝐧𝐞𝐬 𝐬𝐮𝐟𝐢𝐜𝐢𝐞𝐧𝐭𝐞𝐬 *${name}* 𝐩𝐚𝐫𝐚 𝐚𝐩𝐨𝐬𝐭𝐚r. 𝐈𝐧𝐭𝐞𝐫𝐚𝐜𝐭𝐮𝐚 𝐜𝐨𝐧 𝐞𝐥 𝐛𝐨𝐭 𝐩𝐚𝐫𝐚 𝐨𝐛𝐭𝐞𝐧𝐞𝐫 𝐦𝐚́𝐬 𝐫𝐞𝐜𝐮𝐫𝐬𝐨𝐬.`
  96. }
  97. const playSlot = async (m, conn, apuesta, config, users) => {
  98. const { currency, name, emojis, cooldown, bonusWin, consolation } = config
  99. const time = users.lastslot + cooldown
  100. if (new Date() - users.lastslot < cooldown) throw `*𝐕𝐮𝐞𝐥𝐯𝐚 𝐞𝐧: ${msToTime(time - new Date())} 𝐩𝐚𝐫𝐚 𝐜𝐨𝐧𝐭𝐢𝐧𝐮𝐚𝐫 𝐚𝐩𝐨𝐬𝐭𝐚𝐧𝐝𝐨 ${name}* 🎰`
  101. users.lastslot = Date.now()
  102. const a = Math.floor(Math.random() * emojis.length)
  103. const b = Math.floor(Math.random() * emojis.length)
  104. const c = Math.floor(Math.random() * emojis.length)
  105. const [x, y, z] = [[], [], []]
  106. for (let i = 0; i < 3; i++) {
  107. x[i] = emojis[(a + i) % emojis.length]
  108. y[i] = emojis[(b + i) % emojis.length]
  109. z[i] = emojis[(c + i) % emojis.length]
  110. }
  111. let end
  112. if (a === b && b === c) {
  113. end = `🥳 *¡QUÉ PRO! HAS GANADO +${bonusWin(apuesta)} ${name}*`
  114. users[currency] += apuesta
  115. } else if (a === b || a === c || b === c) {
  116. end = `😯 *¡CASI! VUELVE A INTENTAR*\n*BONO DE +${consolation} ${name}*`
  117. users[currency] += consolation
  118. } else {
  119. end = `😿 *¡HAS PERDIDO! ❌ -${apuesta} ${name}*`
  120. users[currency] -= apuesta
  121. }
  122. const hawemod = [
  123. `${x[0]} : ${y[1]} : ${z[0]}\n${z[1]} : ${y[0]} : ${x[0]}\n${z[2]} : ${x[1]} : ${y[2]}`,
  124. `${x[0]} : ${y[0]} : ${z[0]}\n${y[1]} : ${z[1]} : ${x[1]}\n${x[2]} : ${y[2]} : ${z[2]}`,
  125. `${x[0]} : ${y[1]} : ${z[0]}\n${y[1]} : ${z[2]} : ${x[1]}\n${x[2]} : ${y[1]} : ${z[2]}`
  126. ]
  127. const maxIterations = 25
  128. const arrayCasuale = generaArrayCasuale(hawemod, maxIterations)
  129. const array = [...arrayCasuale]
  130. const { key } = await conn.sendMessage(m.chat, { text: `🕹` }, { quoted: m })
  131. for (let i = 0; i < maxIterations; i++) {
  132. await conn.sendMessage(m.chat, {text: `🎰 | *RANURAS* | 🎰\n────────\n${array[i]}\n────────\n🎰 | *SLOTS* | 🎰`, edit: key }, { quoted: m })
  133. await new Promise(resolve => setTimeout(resolve, 50))
  134. }
  135. await conn.sendMessage(m.chat, { text: `🎰 | *RANURAS* | 🎰\n────────\n${x[0]} : ${y[0]} : ${z[0]}\n${x[1]} : ${y[1]} : ${z[1]}\n${x[2]} : ${y[2]} : ${z[2]}\n────────\n🎰 | *SLOTS* | 🎰\n\n${end}`, edit: key }, { quoted: m })
  136. }
  137. if (command === 'apostar' || command === 'slot') {
  138. if (!args[0]) return m.reply(fa)
  139. if (isNaN(args[0])) return m.reply(fa)
  140. const apuesta = parseInt(args[0])
  141. await conn.sendButton(m.chat, `*Elige en qué apostar tus ${apuesta}*`, botname, null, [['⚡ Exp', `.slot1 ${apuesta}`], ['🪙 KantuCoins', `.slot2 ${apuesta}`], ['💎 Diamantes', `.slot3 ${apuesta}`]], null, null, m)
  142. return
  143. }
  144. if (!args[0]) return m.reply(fa)
  145. if (isNaN(args[0])) return m.reply(fa)
  146. const apuesta = parseInt(args[0])
  147. const users = global.db.data.users[m.sender]
  148. const slotType = slotTypes[command]
  149. if (!slotType) return
  150. try {
  151. validateBet(users, apuesta, slotType.currency, slotType.name)
  152. await playSlot(m, conn, apuesta, slotType, users)
  153. } catch (e) {
  154. m.reply(e)
  155. }}
  156. if (command == 'tictactoe' || command == 'ttc' || command == 'ttt' || command == 'xo') {
  157. conn.game = conn.game ? conn.game : {}
  158. if (Object.values(conn.game).find(room => room.id.startsWith('tictactoe') && [room.game.playerX, room.game.playerO].includes(m.sender))) return m.reply(`⚠️ 𝙏𝙤𝙙𝙖𝙫𝙞𝙖 𝙖𝙡𝙜𝙪𝙞𝙚𝙣 𝙚𝙨𝙩𝙖 𝙟𝙪𝙜𝙖𝙣𝙙𝙤 𝙚𝙣 𝙡𝙖 𝙨𝙖𝙡𝙖 𝙨𝙞 𝙦𝙪𝙞𝙚𝙧𝙚 𝙖𝙗𝙖𝙣𝙙𝙤𝙣𝙖𝙧 𝙚𝙨𝙘𝙧𝙞𝙗𝙖 *salir*\n𝙏𝙖𝙢𝙗𝙞𝙚𝙣 𝙥𝙪𝙚𝙙𝙚𝙨 𝙚𝙡𝙞𝙢𝙞𝙣𝙖𝙧 𝙡𝙖 𝙨𝙖𝙡𝙖 𝙪𝙨𝙖𝙣𝙙𝙤 𝙚𝙡 𝙘𝙤𝙢𝙖𝙣𝙙𝙤 *${usedPrefix}delttt*`)
  159. if (!text) return m.reply(`*⚠️ 𝘿𝙚𝙗𝙚 𝙙𝙚 𝙖𝙜𝙧𝙚𝙜𝙖 𝙪𝙣 𝙣𝙤𝙢𝙗𝙧𝙚 𝙖 𝙡𝙖 𝙨𝙖𝙡𝙖\n𝙀𝙟𝙚𝙢𝙥𝙡𝙤\n${usedPrefix + command} Sala bot*`)
  160. let room = Object.values(conn.game).find(room => room.state === 'WAITING' && (text ? room.name === text : true))
  161. if (room) {
  162. await conn.reply(m.chat, `⚠️ 𝘼𝙡𝙜𝙪𝙞𝙚𝙣 𝙨𝙚 𝙝𝙖 𝙪𝙣𝙞𝙙𝙤 𝙖 𝙡𝙖 𝙨𝙖𝙡𝙖 *${text}*\n𝙔𝙖 𝙥𝙪𝙚𝙙𝙚𝙣 𝙟𝙪𝙜𝙖𝙧!! 😼`, fkontak, m)
  163. await conn.reply(m.chat, `⭕️ *Clásico Juego del Gato, 3 en raya o tateti* ❌\n\n*¿Cómo jugar?*\n_Responde al Juego con un Número, el mensaje debe contener la posiscion en la que quieras estar (1,2,3,4,5,6,7,8,9)_`, fkontak, m)
  164. room.o = m.chat
  165. room.game.playerO = m.sender
  166. room.state = 'PLAYING'
  167. let arr = room.game.render().map(v => {
  168. return {
  169. X: '❎',
  170. O: '⭕',
  171. 1: '1️⃣',
  172. 2: '2️⃣',
  173. 3: '3️⃣',
  174. 4: '4️⃣',
  175. 5: '5️⃣',
  176. 6: '6️⃣',
  177. 7: '7️⃣',
  178. 8: '8️⃣',
  179. 9: '9️⃣',
  180. }[v]})
  181. let str = `💖 𝙅𝙪𝙚𝙜𝙤 𝙩𝙖𝙩𝙚𝙩𝙞
  182. 🫂 𝙅𝙪𝙜𝙖𝙙𝙤𝙧𝙚𝙨:
  183. *┈┈┈┈┈┈┈┈┈*
  184. ❎ = @${room.game.playerX.split('@')[0]}
  185. ⭕ = @${room.game.playerO.split('@')[0]}
  186. *┈┈┈┈┈┈┈┈┈*
  187. ${arr.slice(0, 3).join('')}
  188. ${arr.slice(3, 6).join('')}
  189. ${arr.slice(6).join('')}
  190. *┈┈┈┈┈┈┈┈┈*
  191. 𝙏𝙪𝙧𝙣𝙤 𝙙𝙚:
  192. @${room.game.currentTurn.split('@')[0]}
  193. `.trim()
  194. if (room.x !== room.o) await conn.sendMessage(room.x, { text: str, mentions: this.parseMention(str)}, { quoted: fkontak, m })
  195. await conn.sendMessage(room.o, { text: str, mentions: conn.parseMention(str)}, { quoted: fkontak, m })
  196. } else {
  197. room = {
  198. id: 'tictactoe-' + (+new Date),
  199. x: m.chat,
  200. o: '',
  201. game: new TicTacToe(m.sender, 'o'),
  202. state: 'WAITING' }
  203. if (text) room.name = text
  204. let imgplay = `https://img.freepik.com/vector-premium/juego-tres-raya-icono-contorno-lineal-neon_7280-2422.jpg`
  205. conn.sendMessage(m.chat, { image: { url: imgplay }, caption: `😼 𝙅𝙪𝙚𝙜𝙤𝙨 𝙏𝙖𝙩𝙚𝙩𝙞
  206. 🐈 𝙀𝙨𝙥𝙚𝙧𝙖𝙣𝙙𝙤 𝙖𝙡 𝙨𝙚𝙜𝙪𝙣𝙙𝙤 𝙟𝙪𝙜𝙖𝙙𝙤𝙧 𝙥𝙪𝙚𝙙𝙚 𝙞𝙣𝙜𝙧𝙚𝙨𝙖 𝙪𝙨𝙖𝙣𝙙𝙤 𝙚𝙡 𝙘𝙤𝙢𝙖𝙣𝙙𝙤
  207. *${usedPrefix + command} ${text}*
  208. 𝙎𝙞 𝙦𝙪𝙞𝙚𝙧𝙚𝙨 𝙖𝙗𝙖𝙣𝙙𝙤𝙣𝙖𝙧 𝙡𝙖 𝙨𝙖𝙡𝙖 𝙪𝙨𝙖 𝙚𝙡 𝙘𝙤𝙢𝙖𝙣𝙙𝙤
  209. *${usedPrefix}delttt*` }, { mentions: conn.parseMention(text), quoted: fkontak })
  210. conn.game[room.id] = room
  211. }}
  212. if (command == 'math' || command == 'mates' || command == 'matemáticas') {
  213. // 60000 = 1 minuto // 30000 = 30 segundos // 15000 = 15 segundos // 10000 = 10 segundos
  214. let time = global.db.data.users[m.sender].wait + 60000
  215. if (new Date - global.db.data.users[m.sender].wait < 60000) return await conn.reply(m.chat, `*🕓 𝙀𝙎𝙋𝙀𝙍𝘼 ${Math.floor((time - new Date()) / 1000)} 𝙎𝙀𝙂𝙐𝙉𝘿𝙊𝙎 𝘼𝙉𝙏𝙀𝙎 𝘿𝙀 𝙑𝙊𝙇𝙑𝙀𝙍 𝘼 𝙅𝙐𝙂𝘼𝙍*`, fkontak, m)
  216. let mat = `${lenguajeGB['smsAvisoIIG']()}✨ 𝙋𝙪𝙚𝙙𝙚 𝙚𝙨𝙘𝙧𝙞𝙗𝙞 𝙡𝙖 𝙙𝙞𝙛𝙞𝙘𝙪𝙡𝙩𝙖𝙙
  217. *Nivel del dificultad*
  218. ${Object.keys(modes).join(' | ')}
  219. *Ejemplo:*
  220. ${usedPrefix + command} noob
  221. ${usedPrefix + command} impossible2
  222. 😼 *Mientras mas dificultad mayor recompensa*`.trim()
  223. if (args.length < 1) return await conn.reply(m.chat, mat, fkontak, m)
  224. let mode = args[0].toLowerCase()
  225. if (!(mode in modes)) return await conn.reply(m.chat, mat, fkontak, m)
  226. let id = m.chat
  227. if (id in global.math) return conn.reply(m.chat, `⚠️ *ᴛᴏᴅᴀᴠɪᴀ ʜᴀʏ ᴘʀᴇɢᴜɴᴛᴀ sɪɴ ʀᴇsᴘᴏɴᴅᴇʀ ᴇʟ ᴇsᴛᴇ ᴄʜᴀᴛ!!*`, global.math[id][0])
  228. //let ii = global.db.data.users[m.sender].limit += 10 math.dia
  229. let math = genMath(mode)
  230. global.math[id] = [
  231. await conn.reply(m.chat, `╭┄〔 *${wm}* 〕┄⊱
  232. ┆𝘾𝙪𝙖𝙡 𝙚𝙨 𝙧𝙚𝙨𝙪𝙡𝙩𝙖𝙙𝙤 𝙙𝙚: *${math.str} = ?*
  233. ┆┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈
  234. ┆🧭 𝙏𝙞𝙚𝙢𝙥𝙤: *${(math.time / 1000).toFixed(0)} segundos*
  235. ┆┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈
  236. ┆𝙍𝙚𝙨𝙥𝙤𝙣𝙙𝙚 𝙖 𝙚𝙨𝙩𝙚 𝙢𝙚𝙣𝙨𝙖𝙟𝙚 𝙮 𝙂𝙖𝙣𝙖
  237. ┆🏆 *${math.bonus}: XP*
  238. ╰━━━⊰ 𓃠 ${vs} ⊱━━━━დ`, m),
  239. math, 4,
  240. //await conn.reply(m.chat, `⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️⬆️𝙍𝙀𝙎𝙋𝙊𝙉𝘿𝘼 𝘼𝙇 𝙈𝙀𝙉𝙎𝘼𝙅𝙀 𝘿𝙀 𝘼𝙍𝙍𝙄𝘽𝘼 𝘾𝙊𝙉 𝙇𝘼 𝙍𝙀𝙎𝙋𝙐𝙀𝙎𝙏𝘼\n\n𝘼𝙉𝙎𝙒𝙀𝙍 𝙏𝙃𝙀 𝙈𝙀𝙎𝙎𝘼𝙂𝙀 𝘼𝘽𝙊𝙑𝙀 𝙏𝙊 𝙆𝙉𝙊𝙒 𝙔𝙊𝙐𝙍 𝘼𝙉𝙎𝙒𝙀𝙍\n\n${wm}`, fkontak, m), math, 4,
  241. setTimeout(() => {
  242. if (global.math[id]) conn.reply(m.chat, `⌛ sᴇ ᴀᴄᴀʙᴏ ᴇʟ ᴛɪᴇᴍᴘᴏ ʟᴀ ʀᴇsᴘᴜᴇsᴛᴀ ᴇs *${math.result}*`, global.math[id][0])
  243. delete global.math[id]
  244. }, math.time)
  245. ]
  246. global.db.data.users[m.sender].wait = new Date * 1
  247. }
  248. if (command == 'delttt' || command == 'deltt' || command == 'delxo' || command == 'deltictactoe') {
  249. let room = Object.values(conn.game).find(room => room.id.startsWith('tictactoe') && [room.game.playerX, room.game.playerO].includes(m.sender))
  250. if (room == undefined) return await conn.reply(m.chat, `⚠️ 𝙉𝙊 𝙀𝙎𝙏𝘼𝙎 𝙀𝙉 𝙉𝙄𝙉𝙂𝙐𝙉𝘼 𝙋𝘼𝙍𝙏𝙄𝘿𝘼 𝙀𝙉 𝙀𝙇 𝙅𝙐𝙀𝙂𝙊 𝙏𝙍𝙀𝙎 𝙀𝙉 𝙍𝘼𝙔𝘼\n\n💫 𝙄𝙉𝙄𝘾𝙄𝘼𝙍 𝙋𝘼𝙍𝙏𝙄𝘿𝘼 (${usedPrefix}ttt sala nueva)`, fkontak, m)
  251. delete conn.game[room.id]
  252. await conn.reply(m.chat, `⚠️ 𝙇𝘼 𝙎𝘼𝙇𝘼 𝙏𝙍𝙀𝙎 𝙀𝙉 𝙍𝘼𝙔𝘼 𝙁𝙐𝙀 𝙀𝙇𝙄𝙈𝙄𝙉𝘼𝘿𝘼`, fkontak, m)
  253. }} catch (e) {
  254. //await conn.reply(m.chat, `${lenguajeGB['smsMalError3']()}#report ${lenguajeGB['smsMensError2']()} ${usedPrefix + command}\n\n${wm}`, fkontak, m)
  255. console.log(e)}}
  256. handler.help = ["ppt", "suitpvp", "pvp", "slot", "apostar", "tictactoe", "ttt", "math", "matemáticas", "delttt"];
  257. handler.tags = ['game'];
  258. handler.command = /^(ppt|suitpvp|suit|pvp|moneda|suert|currency|luck|cara|Method|slot|apostar|slot1|slot2|slot3|tictactoe|ttc|ttt|xo|math|mates|matemáticas|delttt|deltt|delxo|deltictactoe)$/i
  259. handler.group = true
  260. handler.game = true
  261. handler.register = true
  262. export default handler
  263. function pickRandom(list) {
  264. return list[Math.floor(Math.random() * list.length)]}
  265. function msToTime(duration) {
  266. var milliseconds = parseInt((duration % 1000) / 100),
  267. seconds = Math.floor((duration / 1000) % 60),
  268. minutes = Math.floor((duration / (1000 * 60)) % 60),
  269. hours = Math.floor((duration / (1000 * 60 * 60)) % 24)
  270. hours = (hours < 10) ? "0" + hours : hours
  271. minutes = (minutes < 10) ? "0" + minutes : minutes
  272. seconds = (seconds < 10) ? "0" + seconds : seconds
  273. return minutes + " m " + seconds + " s "
  274. }
  275. let modes = {
  276. noob: [-3, 3,-3, 3, '+-', 15000, 30],
  277. easy: [-10, 10, -10, 10, '*/+-', 20000, 50],
  278. medium: [-40, 40, -20, 20, '*/+-', 30000, 200],
  279. hard: [-100, 100, -70, 70, '*/+-', 40000, 500],
  280. extreme: [-999999, 999999, -999999, 999999, '*/', 40000, 2500],
  281. impossible: [-99999999999, 99999999999, -99999999999, 999999999999, '*/', 50000, 5500],
  282. impossible2: [-999999999999999, 999999999999999, -999, 999, '/', 60000, 8500]
  283. }
  284. let operators = {
  285. '+': '+',
  286. '-': '-',
  287. '*': '×',
  288. '/': '÷'
  289. }
  290. // XP
  291. function genMath(mode) {
  292. let [a1, a2, b1, b2, ops, time, bonus] = modes[mode]
  293. let a = randomInt(a1, a2)
  294. let b = randomInt(b1, b2)
  295. let op = pickRandom([...ops])
  296. let result = (new Function(`return ${a} ${op.replace('/', '*')} ${b < 0 ? `(${b})` : b}`))()
  297. if (op == '/') [a, result] = [result, a]
  298. return {
  299. str: `${a} ${operators[op]} ${b}`,
  300. mode,
  301. time,
  302. bonus,
  303. result
  304. }}
  305. function generaArrayCasuale(array, ripetizioni) {
  306. let risultato = [];
  307. for (let i = 0; i < ripetizioni; i++) {
  308. risultato = risultato.concat(array);
  309. }
  310. return risultato;
  311. }
  312. function randomInt(from, to) {
  313. if (from > to) [from, to] = [to, from]
  314. from = Math.floor(from)
  315. to = Math.floor(to)
  316. return Math.floor((to - from) * Math.random() + from)
  317. }