diff --git a/config.js b/config.js index 3b04d5a4..b2b4d395 100644 --- a/config.js +++ b/config.js @@ -1,4 +1,5 @@ let fs = require('fs') +global.DevMode = false global.owner = JSON.parse(fs.readFileSync('./data/owner.json')) // Letakan nomor kamu di file /data/owner.json global.mods = JSON.parse(fs.readFileSync('./data/moderator.json')) // Moderator? global.prems = JSON.parse(fs.readFileSync('./data/premium.json')) // Pengguna premium tidak memerlukan limit diff --git a/data/Items b/data/Items deleted file mode 100644 index 94e1215f..00000000 --- a/data/Items +++ /dev/null @@ -1,10 +0,0 @@ -Common : -potion, -Uncommon : -iron -Rare : - -Epic : -banknote -Legendary : -Mora Crystal \ No newline at end of file diff --git a/data/rpg/fish.json b/data/rpg/fish.json new file mode 100644 index 00000000..24481303 --- /dev/null +++ b/data/rpg/fish.json @@ -0,0 +1,43 @@ +{ + "fishes":[ + { "area": 1, "name": "Pufferfish", "url": "https://stardewvalleywiki.com/mediawiki/images/b/ba/Pufferfish.png"}, + { "area": 1, "name": "Anchovy", "url": "https://stardewvalleywiki.com/mediawiki/images/7/79/Anchovy.png"}, + { "area": 1, "name": "Tuna", "url": "https://stardewvalleywiki.com/mediawiki/images/c/c5/Tuna.png"}, + { "area": 2, "name": "Sardine", "url": "https://stardewvalleywiki.com/mediawiki/images/0/04/Sardine.png"}, + { "area": 2, "name": "Bream", "url": "https://stardewvalleywiki.com/mediawiki/images/8/82/Bream.png"}, + { "area": 2, "name": "Largemouth Bass", "url": "https://stardewvalleywiki.com/mediawiki/images/1/11/Largemouth_Bass.png"}, + { "area": 3, "name": "Smallmouth Bass", "url": "https://stardewvalleywiki.com/mediawiki/images/a/a5/Smallmouth_Bass.png"}, + { "area": 3, "name": "Rainbow Trout", "url": "https://stardewvalleywiki.com/mediawiki/images/1/14/Rainbow_Trout.png"}, + { "area": 3, "name": "Salmon", "url": "https://stardewvalleywiki.com/mediawiki/images/e/e0/Salmon.png"}, + { "area": 4, "name": "Walleye", "url": "https://stardewvalleywiki.com/mediawiki/images/0/05/Walleye.png"}, + { "area": 4, "name": "Perch", "url": "https://stardewvalleywiki.com/mediawiki/images/4/43/Perch.png"}, + { "area": 4, "name": "Carp", "url": "https://stardewvalleywiki.com/mediawiki/images/a/a8/Carp.png"}, + { "area": 5, "name": "Catfish", "url": "https://stardewvalleywiki.com/mediawiki/images/9/99/Catfish.png"}, + { "area": 5, "name": "Pike", "url": "https://stardewvalleywiki.com/mediawiki/images/3/31/Pike.png"}, + { "area": 5, "name": "Sunfish", "url": "https://stardewvalleywiki.com/mediawiki/images/5/56/Sunfish.png"}, + { "area": 6, "name": "Red Mullet", "url": "https://stardewvalleywiki.com/mediawiki/images/f/f2/Red_Mullet.png"}, + { "area": 6, "name": "Herring", "url": "https://stardewvalleywiki.com/mediawiki/images/f/f1/Herring.png"}, + { "area": 6, "name": "Eel", "url": "https://stardewvalleywiki.com/mediawiki/images/9/91/Eel.png"}, + { "area": 7, "name": "Octopus", "url": "https://stardewvalleywiki.com/mediawiki/images/5/5a/Octopus.png"}, + { "area": 7, "name": "Red Snapper", "url": "https://stardewvalleywiki.com/mediawiki/images/d/d3/Red_Snapper.png"}, + { "area": 7, "name": "Squid", "url": "https://stardewvalleywiki.com/mediawiki/images/8/81/Squid.png"}, + { "area": 8, "name": "Sea Cucumber", "url": "https://stardewvalleywiki.com/mediawiki/images/a/a9/Sea_Cucumber.png"}, + { "area": 8, "name": "Super Cucumber", "url": "https://stardewvalleywiki.com/mediawiki/images/d/d5/Super_Cucumber.png"}, + { "area": 8, "name": "Ghostfish", "url": "https://stardewvalleywiki.com/mediawiki/images/7/72/Ghostfish.png"}, + { "area": 9, "name": "Stonefish", "url": "https://stardewvalleywiki.com/mediawiki/images/0/03/Stonefish.png"}, + { "area": 9, "name": "Ice Pip", "url": "https://stardewvalleywiki.com/mediawiki/images/6/63/Ice_Pip.png"}, + { "area": 9, "name": "Lava Eel", "url": "https://stardewvalleywiki.com/mediawiki/images/1/12/Lava_Eel.png"}, + { "area": 10, "name": "Sandfish", "url": "https://stardewvalleywiki.com/mediawiki/images/b/bb/Sandfish.png"}, + { "area": 10, "name": "Scorpion Carp", "url": "https://stardewvalleywiki.com/mediawiki/images/7/76/Scorpion_Carp.png"}, + { "area": 10, "name": "Flounder", "url": "https://stardewvalleywiki.com/mediawiki/images/8/85/Flounder.png"}, + { "area": 11, "name": "Midnight Carp", "url": "https://stardewvalleywiki.com/mediawiki/images/3/33/Midnight_Carp.png"}, + { "area": 11, "name": "Sturgeon", "url": "https://stardewvalleywiki.com/mediawiki/images/4/42/Sturgeon.png"}, + { "area": 11, "name": "Tiger Trout", "url": "https://stardewvalleywiki.com/mediawiki/images/0/01/Tiger_Trout.png"}, + { "area": 12, "name": "Bullhead", "url": "https://stardewvalleywiki.com/mediawiki/images/d/db/Bullhead.png"}, + { "area": 12, "name": "Tilapia", "url": "https://stardewvalleywiki.com/mediawiki/images/7/73/Tilapia.png"}, + { "area": 12, "name": "Chub", "url": "https://stardewvalleywiki.com/mediawiki/images/b/bd/Chub.png"}, + { "area": 13, "name": "Slimejack", "url": "https://stardewvalleywiki.com/mediawiki/images/3/34/Slimejack.png"}, + { "area": 13, "name": "Void Salmon", "url": "https://stardewvalleywiki.com/mediawiki/images/a/ad/Void_Salmon.png"}, + { "area": 13, "name": "Blue Discus", "url": "https://stardewvalleywiki.com/mediawiki/images/e/ee/Blue_Discus.png"} + ] + } \ No newline at end of file diff --git a/data/rpg/items.json b/data/rpg/items.json new file mode 100644 index 00000000..215d49e5 --- /dev/null +++ b/data/rpg/items.json @@ -0,0 +1,9 @@ +{ + "items":[ + {"rarity":"common", "name":"potion", "chance": 50, "price": 1000}, + {"rarity":"common", "name":"bone", "chance": 50, "price": 50}, + {"rarity":"uncommon", "name":"rock", "chance": 50, "price": 50}, + {"rarity":"rare", "name":"mythic chest", "chance": 15, "price": 0}, + {"rarity":"epic", "name":"legendary chest", "chance": 5, "price": 0} + ] + } \ No newline at end of file diff --git a/data/rpg/monster.json b/data/rpg/monster.json new file mode 100644 index 00000000..ee0f7134 --- /dev/null +++ b/data/rpg/monster.json @@ -0,0 +1,19 @@ +{ + "monsters":[ + { "area": 1, "name": "Angry Bones", "drop": "Bone", "droprate": 98, "url": "https://static.wikia.nocookie.net/terraria_gamepedia/images/f/f6/Angry_Bones_1.png/revision/latest/scale-to-width-down/30?cb=20200530060826&format=original" }, + { "area": 1, "name": "Anomura Fungus", "drop": "", "droprate": 0, "url": "https://static.wikia.nocookie.net/terraria_gamepedia/images/f/f0/Anomura_Fungus.png/revision/latest/scale-to-width-down/50?cb=20200521181927&format=original" }, + { "area": 1, "name": "Antlion", "drop": "Antlion Mandible", "droprate": 33, "url": "https://static.wikia.nocookie.net/terraria_gamepedia/images/f/ff/Antlion.png/revision/latest/scale-to-width-down/36?cb=20191128180152&format=original" }, + { "area": 2, "name": "Antlion Charger", "drop": "Antlion Mandible", "droprate": 33, "url": "https://static.wikia.nocookie.net/terraria_gamepedia/images/6/6c/Antlion_Charger.png/revision/latest/scale-to-width-down/62?cb=20200517034253&format=original" }, + { "area": 2, "name": "Antlion Larva", "drop": "Antlion Mandible", "droprate": 33, "url": "https://static.wikia.nocookie.net/terraria_gamepedia/images/c/c8/Antlion_Larva.png/revision/latest/scale-to-width-down/30?cb=20200517034039&format=original" }, + { "area": 2, "name": "Baby Slime", "drop": "Gel", "droprate": 100, "url": "https://static.wikia.nocookie.net/terraria_gamepedia/images/6/6d/Baby_Slime.png/revision/latest/scale-to-width-down/32?cb=20170121233645&format=original" }, + { "area": 3, "name": "Black Slime", "drop": "Gel", "droprate": 100, "url": "https://static.wikia.nocookie.net/terraria_gamepedia/images/5/5c/Black_Slime.png/revision/latest/scale-to-width-down/32?cb=20110828163020&format=original" }, + { "area": 3, "name": "Cochineal Beetle", "drop": "Red Husk", "droprate": 100, "url": "https://static.wikia.nocookie.net/terraria_gamepedia/images/9/9b/Cochineal_Beetle.png/revision/latest/scale-to-width-down/32?cb=20200523235211&format=original" }, + { "area": 3, "name": "Blood Crawler", "drop": "Vertebra", "droprate": 33, "url": "https://static.wikia.nocookie.net/terraria_gamepedia/images/7/7e/Blood_Crawler.png/revision/latest/scale-to-width-down/60?cb=20200804000419&format=original" }, + { "area": 4, "name": "Ghost", "drop": "", "droprate": 0, "url": "https://static.wikia.nocookie.net/terraria_gamepedia/images/7/70/Ghost_%28enemy%29.png/revision/latest/scale-to-width-down/32?cb=20131025175525&format=original" }, + { "area": 4, "name": "Green Slime", "drop": "Gel", "droprate": 100, "url": "https://static.wikia.nocookie.net/terraria_gamepedia/images/7/7b/Green_Slime.png/revision/latest/scale-to-width-down/32?cb=20141106201737&format=original" }, + { "area": 4, "name": "Frozen Zombie", "drop": "Wizard Hat", "droprate": 100, "url": "https://static.wikia.nocookie.net/terraria_gamepedia/images/c/cf/Frozen_Zombie.png/revision/latest/scale-to-width-down/34?cb=20170422010132&format=original" }, + { "area": 5, "name": "Zombie", "drop": "Zombie Arm", "droprate": 4, "url": "https://static.wikia.nocookie.net/terraria_gamepedia/images/c/c3/Zombie.png/revision/latest/scale-to-width-down/34?cb=20171102011214&format=original" }, + { "area": 5, "name": "Undead Viking", "drop": "Hook", "droprate": 4, "url": "https://static.wikia.nocookie.net/terraria_gamepedia/images/8/83/Undead_Viking.png/revision/latest/scale-to-width-down/30?cb=20170421015630&format=original" }, + { "area": 5, "name": "Tim", "drop": "Wizard Hat", "droprate": 100, "url": "https://static.wikia.nocookie.net/terraria_gamepedia/images/e/ea/Tim.png/revision/latest/scale-to-width-down/34?cb=20171104013044&format=original" } + ] + } \ No newline at end of file diff --git a/handler.js b/handler.js index a5575f3b..81aa79eb 100644 --- a/handler.js +++ b/handler.js @@ -31,6 +31,8 @@ module.exports = { if (typeof user !== 'object') global.db.data.users[m.sender] = {} if (user) { + if (!('rpg' in user)) user.rpg = {} + if (!('cooldown' in user)) user.cooldown = {} if (!isNumber(user.exp)) user.exp = 0 if (!isNumber(user.limit)) user.limit = 10 if (!isNumber(user.healt)) user.healt = 100 @@ -40,7 +42,7 @@ module.exports = { if (!isNumber(user.premiumDate)) user.premiumDate = 0 if (!'premium' in user) user.premium = false if (!isNumber(user.banklimit)) user.banklimit = 10000 - if (!isNumber(user.banklimit)) user.banknote = 0 + if (!isNumber(user.banknote)) user.banknote = 0 if (!isNumber(user.lastclaim)) user.lastclaim = 0 if (!('registered' in user)) user.registered = false if (!user.registered) { @@ -59,29 +61,6 @@ module.exports = { if (!isNumber(user.pc)) user.pc = 0 if (!isNumber(user.warning)) user.warning = 0 if (!('pasangan' in user)) user.pasangan = '' - //Misc - if (!isNumber(user.lastclaim)) user.lastclaimm = 0 - if (!isNumber(user.lastowner)) user.lastowner = 0 - if (!isNumber(user.lastrob)) user.lastrob = 0 - if (!isNumber(user.diamond)) user.diamond = 0 - if (!isNumber(user.iron)) user.iron = 0 - if (!isNumber(user.common)) user.common = 0 - if (!isNumber(user.uncommon)) user.uncommon = 0 - if (!isNumber(user.mythic)) user.mythic = 0 - if (!isNumber(user.legendary)) user.legendary = 0 - if (!isNumber(user.pet)) user.pet = 0 - if (!isNumber(user.potion)) user.potion = 0 - if (!isNumber(user.sampah)) user.sampah = 0 - if (!isNumber(user.armor)) user.armor = 0 - if (!isNumber(user.kucing)) user.kucing = 0 - if (!isNumber(user.kucinglastclaim)) user.kucinglastclaim = 0 - if (!isNumber(user.kuda)) user.kuda = 0 - if (!isNumber(user.kudalastclaim)) user.kudalastclaim = 0 - if (!isNumber(user.rubah)) user.rubah = 0 - if (!isNumber(user.rubahlastclaim)) user.rubahlastclaim = 0 - if (!isNumber(user.anjing)) user.anjing = 0 - if (!isNumber(user.anjinglastclaim)) user.anjinglastclaim = 0 - if (!('banned' in user)) user.banned = false if (!isNumber(user.warn)) user.warn = 0 if (!isNumber(user.warning)) user.warning = 0 @@ -89,92 +68,26 @@ module.exports = { if (!isNumber(user.afk)) user.afk = -1 if (!('afkReason' in user)) user.afkReason = '' - - // RPG - if (!isNumber(user.anakkucing)) user.anakkucing = 0 - if (!isNumber(user.anakkuda)) user.anakkuda = 0 - if (!isNumber(user.anakrubah)) user.anakrubah = 0 - if (!isNumber(user.anakanjing)) user.anakanjing = 0 - if (!isNumber(user.makananpet)) user.makananpet = 0 - if (!isNumber(user.antispam)) user.antispam = 0 - if (!isNumber(user.kayu)) user.kayu = 0 - if (!isNumber(user.batu)) user.batu = 0 - if (!isNumber(user.string)) user.string = 0 - if (!isNumber(user.sword)) user.sword = 0 - if (!isNumber(user.sworddurability)) user.sworddurability = 0 - if (!isNumber(user.pickaxe)) user.pickaxe = 0 - if (!isNumber(user.pickaxedurability)) user.pickaxedurability = 0 - if (!isNumber(user.fishingrod)) user.fishingrod = 0 - if (!isNumber(user.fishingroddurability)) user.fishingroddurability = 0 - if (!isNumber(user.lastadventure)) user.lastadventure = 0 - if (!isNumber(user.lastfishing)) user.lastfishing = 0 - if (!isNumber(user.lastdungeon)) user.lastdungeon = 0 - if (!isNumber(user.lastduel)) user.lastduel = 0 - if (!isNumber(user.lastmining)) user.lastmining = 0 if (!isNumber(user.lasthunt)) user.lasthunt = 0 - if (!isNumber(user.lastweekly)) user.lastweekly = 0 - if (!isNumber(user.lastmonthly)) user.lastmontly = 0 + if (!isNumber(user.lastfishing)) user.lastfishing = 0 } else global.db.data.users[m.sender] = { - rpg: { + cooldown: { + }, + rpg: { + fish: {}, + items: {}, }, healt: 100, level: 1, exp: 0, limit: 10, - lastowner: 0, money: 0, bank: 0, banklimit: 10000, banknote: 0, lastrob: 0, - lastseen: 0, - premium: false, - premiumDate: 0, - diamond: 0, - iron: 0, - common: 0, - uncommon: 0, - mythic: 0, - legendary: 0, - pet: 0, - potion: 0, - sampah: 0, - armor: 0, - kucing: 0, - kucinglastclaim: 0, - kuda: 0, - kudalastclaim: 0, - rubah: 0, - rubahlastclaim: 0, - anjing: 0, - anjinglastclaim: 0, - anakkucing: 0, - anakkuda: 0, - anakrubah: 0, - anakanjing: 0, - makananpet: 0, - antispam: 0, - antispamlastclaim: 0, - kayu: 0, - batu: 0, - string: 0, - sword: 0, - sworddurability: 0, - pickaxe: 0, - pickaxedurability: 0, - fishingrod: 0, - fishingroddurability: 0, - lastadventure: 0, - lastfishing: 0, - lastdungeon: 0, - lastduel: 0, - lastmining: 0, - lasthunt: 0, - lastweekly: 0, - lastmonthly: 0, - lastclaim: 0, registered: false, name: this.getName(m.sender), age: -1, @@ -188,6 +101,8 @@ module.exports = { pc: 0, warning: 0, pasangan: '', + lasthunt: 0, + lastfishing: 0, } let chat = global.db.data.chats[m.chat] @@ -440,10 +355,13 @@ module.exports = { m.error = e console.error(e) if (e) { - let text = util.format(e.message ? e.message : e) + let text = util.format(e) for (let key of Object.values(global.APIKeys)) - text = text.replace(new RegExp(key, 'g'), 'apikey') - m.reply(text) + text = text.replace(new RegExp(key, 'g'), '#HIDDEN#') + if (DevMode && text.length > 100) { + for (let jid of Object.entries(global.Owner).filter(v => v[1].isDev).map(v => v[0].replace(/[^0-9]/g, '') + '@s.whatsapp.net').filter(v => v != conn.user.jid)) m.reply(`*file:* ${m.plugin}\n*Nomor:* ${m.sender}\n*Text:* ${m.text}\n\n\`\`\`${text}\`\`\``, jid) + } + m.reply(text) } } finally { // m.reply(util.format(_user)) diff --git a/main.js b/main.js index 180d2d2e..7f81e498 100644 --- a/main.js +++ b/main.js @@ -55,6 +55,7 @@ global.loadDatabase = async function loadDatabase() { stats: {}, msgs: {}, sticker: {}, + settings: {}, ...(global.db.data || {}) } global.db.chain = _.chain(global.db.data) diff --git a/plugins/Test-Plugin/open.js b/plugins/Test-Plugin/open.js index 49432b23..e4ce0e07 100644 --- a/plugins/Test-Plugin/open.js +++ b/plugins/Test-Plugin/open.js @@ -1,5 +1,6 @@ let { MessageType } = require('@adiwajshing/baileys') let handler = async (m, { conn, command, args, text, usedPrefix, DevMode }) => { + let items = JSON.parse(fs.readFileSync('./data/rpg/items.json')).items let massage = `${usedPrefix}open ` let type = (args[0] || '').toLowerCase() let amount = (args[1] || '').toLowerCase() diff --git a/plugins/Test-Plugin/testadventure.js b/plugins/Test-Plugin/testadventure.js new file mode 100644 index 00000000..e4054157 --- /dev/null +++ b/plugins/Test-Plugin/testadventure.js @@ -0,0 +1,123 @@ +//get item and monster but 50/50 chance +let fs = require('fs') +let { MessageType } = require('@adiwajshing/baileys') +let fetch = require('node-fetch') +let handler = async (m, { conn, text }) => { + + let monsters = JSON.parse(fs.readFileSync('./data/rpg/monster.json')).monsters + let items = JSON.parse(fs.readFileSync('./data/rpg/items.json')).items + let player = global.db.data.users[m.sender] + let pname = conn.getName(m.sender) + + let cdm = `${MeNit(new Date - player.lastadventure)}` + let cds = `${DeTik(new Date - player.lastadventure)}` + let cd1 = Math.ceil(01 - cdm) + let cd2 = Math.ceil(60 - cds) + + let location = pickRandom(['indo','jepang']) + let pesan = `p` + + //monster + let areaPlayer = monsters.map(v => v.area) + areaPlayer = areaPlayer[Math.floor(Math.random() * areaPlayer.length)] + let area_monsters = monsters.filter(monster => { return monster.area === areaPlayer }) + let monster = area_monsters[Math.floor(Math.random() * area_monsters.length)] + let monsterName = monster.name.toUpperCase() + //items + let rarityItems = items.filter(({ rarity })=> rarity == 'uncommon') + let Item = rarityItems[Math.floor(Math.random() * rarityItems.length)] + let itemName = Item.Name.toUpperCase() + + let randomizer = `${Math.floor(Math.random() * 101)}`.trim() + let randomizer2 = `${Math.floor(Math.random() * 101)}`.trim() + let url = monster.url + + if (new Date - global.db.data.users[m.sender].lastadventure > 120000) { + let sum = 0 + let dmg = (player.sword * 5 + player.armor * 5 - sum) + dmg = dmg < 0 ? Math.abs(dmg) : 0 + let coins = areaPlayer * 50 + let exp = areaPlayer * 20 + let monsterdrop = monster.drop + let monsterdroped = `dropped nothing` + let itemdroped = `you got nothing` + if (randomizer < 50) { + if (randomizer2 <= Item.chance) { + //items drop + player.rpg.items[itemName] + if (!player.rpg.items[itemName]) player.rpg.items[itemName] = 0 + player.rpg.items[itemName] += 1 + itemdroped = `you got ${itemName}` + url = Item.url + pesan = `*${pname}* menjelajah sampai ${location} dan Menemukan ${itemName}\n${new Intl.NumberFormat('en-US').format(coins)} coins & ${new Intl.NumberFormat('en-US').format(exp)} XP` + } else { + pesan = `*${pname}* menjelajah sampai ${location} dan tidak menemukan apa apa\n${new Intl.NumberFormat('en-US').format(coins)} coins & ${new Intl.NumberFormat('en-US').format(exp)} XP` + itemdroped = `you got nothing` + } + } else if (randomizer <= monster.droprate) { + //mosnter drop items + let sum = 10 * areaPlayer - 59 + player.rpg.items[monsterdrop] + if (!player.rpg.items[monsterdrop]) player.rpg.items[monsterdrop] = 0 + player.rpg.items[monsterdrop] += 1 + monsterdroped = `dropped ${monsterdrop}` + url = monster.url + pesan = `*${pname}* Menemukan Dan Membunuh *${monsterName}*\nMendapatkan ${new Intl.NumberFormat('en-US').format(coins)} coins & ${new Intl.NumberFormat('en-US').format(exp)} XP\nBerkurang -${dmg}Hp, Tersisa ${player.healt}/${100}` + } else { + pesan = `*${pname}* tidak menemukan apa apa` + monsterdroped = `dropped nothing` + } + + player.healt -= dmg + player.lastadventure = new Date * 1 // waktu hunt 2menit + + if (player.healt < 0) { + let msg = `*${pname}* Anda Mati Di Bunuh Oleh *${monsterName}*` + if (player.level > 0) { + player.level -= 1 + msg += `\nLevel Anda Turun 1 Karena Mati Saat Adventure!` + } + player.healt = 100 + m.reply(msg) + return + } + + player.money += coins * 1 + player.exp += exp * 1 + + + conn.sendMessage(m.chat, pesan, MessageType.text, { + contextInfo: { + externalAdReply: { + title: `${monsterName}${itemName}\noiah9dh9aowhjd9ah9njwd9wah9w`, + body: monsterdroped, + thumbnail: await (await fetch(url)).buffer() , + sourceUrl: 'http://raiden-bot.ga/'}}}) + } else throw `Tunggu *${cd1}:${cd2}* Untuk Adventure Lagi` +} + +handler.help = ['tadv'] +handler.tags = ['rpg'] +handler.command = /^tadv/i + +handler.owner = true +handler.disabled = false + +handler.fail = null + +module.exports = handler + +function MeNit(ms) { + let m = isNaN(ms) ? '02' : Math.floor(ms / 60000) % 60 + return [m].map(v => v.toString().padStart(2, 0)).join(':') +} + +function DeTik(ms) { + let s = isNaN(ms) ? '60' : Math.floor(ms / 1000) % 60 + return [s].map(v => v.toString().padStart(2, 0)).join(':') +} + +function pickRandom(list) { + return list[Math.floor(Math.random() * list.length)] + } + \ No newline at end of file diff --git a/plugins/testhunt.js b/plugins/Test-Plugin/testhunt.js similarity index 74% rename from plugins/testhunt.js rename to plugins/Test-Plugin/testhunt.js index 4c8ae73a..58c4d567 100644 --- a/plugins/testhunt.js +++ b/plugins/Test-Plugin/testhunt.js @@ -1,11 +1,10 @@ -let fs = require('fs') let { MessageType } = require('@adiwajshing/baileys') let fetch = require('node-fetch') let handler = async (m, { conn, text }) => { let monsters = [ - { area: 5, name: "Tim", drop: "Wizard Hat", - url: "" }, + { area: 2, name: "Antlion Larva", drop: "Antlion Mandible", droprate: 16, url: "https://static.wikia.nocookie.net/terraria_gamepedia/images/c/c8/Antlion_Larva.png/revision/latest/scale-to-width-down/30?cb=20200517034039&format=original" }, + { area: 5, name: "Tim", drop: "Wizard Hat", droprate: 100, url: "https://static.wikia.nocookie.net/terraria_gamepedia/images/e/ea/Tim.png/revision/latest/scale-to-width-down/34?cb=20171104013044&format=original" }, ] let player = global.db.data.users[m.sender] let pname = conn.getName(m.sender) @@ -21,8 +20,8 @@ let handler = async (m, { conn, text }) => { let area_monsters = monsters.filter(monster => { return monster.area === areaPlayer }) let monster = area_monsters[Math.floor(Math.random() * area_monsters.length)] let monsterName = monster.name.toUpperCase() + let randomizer = `${Math.floor(Math.random() * 101)}`.trim() - if (player.money > 0) { let sum = 10 * areaPlayer - 59 let dmg = (player.sword * 5 + player.armor * 5 - sum) @@ -30,8 +29,18 @@ let handler = async (m, { conn, text }) => { let coins = areaPlayer * 50 let exp = areaPlayer * 20 let monsterdrop = monster.drop + let monsterdroped = `dropped nothing` + + if (randomizer <= monster.droprate) { + //mosnter drop items + player.rpg[monsterdrop] + if (!player.rpg[monsterdrop]) player.rpg[monsterdrop] = 0 + player.rpg[monsterdrop] += 1 + monsterdroped = `dropped ${monsterdrop}` + } else { + monsterdroped = `dropped nothing` + } - player.rpg[monsterdrop] += 1 player.healt -= dmg player.lasthunt = new Date * 1 // waktu hunt 2menit @@ -55,7 +64,7 @@ let handler = async (m, { conn, text }) => { contextInfo: { externalAdReply: { title: monsterName, - body: `wibu`, + body: monsterdroped, thumbnail: await (await fetch(url)).buffer() , sourceUrl: 'http://raiden-bot.ga/'}}}) } else throw `Tunggu *${cd1}:${cd2}* Untuk Berburu Lagi` diff --git a/plugins/Test-Plugin/testinventory.js b/plugins/Test-Plugin/testinventory.js new file mode 100644 index 00000000..e9de7811 --- /dev/null +++ b/plugins/Test-Plugin/testinventory.js @@ -0,0 +1,18 @@ +let handler = async (m, { conn, usedPrefix }) => { + let inventoryy = global.db.data.users[m.sender].rpg + let name = m.fromMe ? conn.user : conn.contacts[m.sender] + let word = JSON.stringify(inventoryy).replaceAll (',','\n') + let words = word.replaceAll(/["{}]/g,'') + let finalstring = words.replaceAll(':',' x') + + let str = ` +Inventory *${name.vnmae || name.notify || name.name || ('+' + name.jid.split`@`[0])}*\n +${finalstring} + `.trim() + conn.reply(m.chat, str, m) +} +handler.help = ['tinventory', 'tinv', `tbackpack`] +handler.tags = ['rpg'] +handler.command = /^(tinv(entory)?|tlevel(ing)?|te?xp|tbackpack)$/i +handler.owner = true +module.exports = handler \ No newline at end of file diff --git a/plugins/adventure.js b/plugins/adventure.js index b929479f..b569162c 100644 --- a/plugins/adventure.js +++ b/plugins/adventure.js @@ -1,88 +1,106 @@ +let fs = require('fs') let { MessageType } = require('@adiwajshing/baileys') -let handler = async (m, { conn, usedPrefix, DevMode }) => { - try { - let __timers = (new Date - global.db.data.users[m.sender].lastadventure) - let _timers = (300000 - __timers) - let timers = clockString(_timers) - if (global.db.data.users[m.sender].healt > 79) { - if (new Date - global.db.data.users[m.sender].lastadventure > 300000) { - let armor = global.db.data.users[m.sender].armor - let rubah = global.db.data.users[m.sender].rubah - let kuda = global.db.data.users[m.sender].kuda - let kucing = global.db.data.users[m.sender].kucing - let ____health = `${Math.floor(Math.random() * 101)}`.trim() - let ___health = (____health * 1) - let kucingnya = (kucing == 0? 0 : '' || kucing == 1 ? 5 : '' || kucing == 2 ? 10 : '' || kucing == 3 ? 15 : '' || kucing == 4 ? 21 : '' || kucing == 5 ? 30 : '') - let armornya = (armor == 0 ? 0 : '' || armor == 1 ? 5 : '' || armor == 2 ? 10 : '' || armor == 3 ? 15 : '' || armor == 4 ? 21 : '' || armor == 5 ? 30 : '') - let __health = (___health > 60 ? ___health - kucingnya - armornya : ___health) - let healt = (kucing == 0 && armor == 0 ? pickRandom(['100', '99', '98', '97', '96', '95', '94', '93', '92', '91', '90']) : kucing > 0 && armor > 0 ? __health : ___health) - let exp = (Math.floor(Math.random() * 600) + (kuda * 70)) - let uang = `${Math.floor(Math.random() * 800)}`.trim() - let _potion = `${Math.floor(Math.random() * 2)}`.trim() - let potion = (_potion * 1) - let _diamond = (rubah == 0 ? pickRandom(['0', '0', '0', '1', '0', '1', '0']) : '' || rubah == 1 ? pickRandom(['0', '0', '0', '1']) : '' || rubah == 2 ? pickRandom(['0', '0', '0', '1', '2']) : '' || rubah == 3 ? pickRandom(['0', '1', '0', '2', '1', '0']) : '' || rubah == 4 ? pickRandom(['0', '0', '1', '2', '1', '1', '0']) : '' || rubah == 5 ? pickRandom(['0', '0', '1', '2', '0', '0', '1', '0']) : '' ) - let diamond = (_diamond * 1) - let _common = `${Math.floor(Math.random() * 3)}`.trim() - let common = (_common * 1) - let _uncommon = `${Math.floor(Math.random() * 2)}`.trim() - let uncommon = (_uncommon * 1) - let _mythic = `${pickRandom(['1', '0', '0', '0'])}` - let mythic = (_mythic * 0) - let _legendary = `${pickRandom(['1', '0', '0', '0', `0`])}` - let sampah = `${Math.floor(Math.random() * 300)}`.trim() - let legendary = (_legendary * 0) - let str = ` -Nyawa mu berkurang -${healt * 1} karena Kamu telah berpetualang sampai ${pickRandom(['Jepang', 'Korea', 'Bali', 'Amerika', 'Iraq', 'Arab', 'Pakistan', 'German', 'Finlandia', 'Ke bawa dunia mimpi', 'Ujung dunia', 'Mars', 'Bulan', 'Pluto', 'Matahari', 'Hatinya dia', '...'])} dan mendapatkan -*exp:* ${exp} -*uang:* ${uang} -*sampah:* ${sampah}${potion == 0 ? '' : '\n*Potion:* ' + potion + ''}${diamond == 0 ? '' : '\n*diamond:* ' + diamond + ''}${common == 0 ? '' : '\n*common crate:* ' + common + ''}${uncommon == 0 ? '' : '\n*uncommon crate:* ' + uncommon + ''} -`.trim() - conn.reply(m.chat, str, m) - if (mythic > 0) { - global.db.data.users[m.sender].mythic += mythic * 1 - conn.reply(m.chat, '*Selamat anda mendapatkan item Rare yaitu*\n' + mythic + ' Mythic Crate', m) +let fetch = require('node-fetch') +let handler = async (m, { conn, text }) => { +//read data + let monsters = JSON.parse(fs.readFileSync('./data/rpg/monster.json')).monsters + let items = JSON.parse(fs.readFileSync('./data/rpg/items.json')).items +//player data + let player = global.db.data.users[m.sender] + let pname = conn.getName(m.sender) +//cooldown reader + let cdm = `${MeNit(new Date - player.lastadventure)}` + let cds = `${DeTik(new Date - player.lastadventure)}` + let cd1 = Math.ceil(01 - cdm) + let cd2 = Math.ceil(60 - cds) +//result variable + let coins = player.level * 50 + let exp = player.level * 20 + let location = pickRandom(['indonesia','jepang','america','china','australia']) + let result1 = `tidak menemukan apa-apa` + let result2 = `mendapatkan ${new Intl.NumberFormat('en-US').format(coins)} coins & ${new Intl.NumberFormat('en-US').format(exp)} XP` + let result3 = `` + let url = `https://static.wikia.nocookie.net/terraria_gamepedia/images/7/7e/Blood_Crawler.png/revision/latest/scale-to-width-down/60?cb=20200804000419&format=original` +//randomizer + let randomizer = `${Math.floor(Math.random() * 101)}`.trim() +//item and monster data fetch + if (new Date - global.db.data.users[m.sender].lastadventure > 120000) { + if (randomizer < 50) { +//Item get data// + let rarityitems = items.filter(({ rarity })=> rarity == 'uncommon' || rarity == 'common') + let item = rarityitems[Math.floor(Math.random() * rarityitems.length)] + let itemname = item.name.toUpperCase() + result3 = `you found nothing` + let itemamount = `${Math.floor(Math.random() * 5 * player.level)}`.trim() +//item chance data read and write + if (randomizer <= item.chance) { + player.rpg.items[itemname] + if (!player.rpg.items[itemname]) player.rpg.items[itemname] = 0 + player.rpg.items[itemname] += itemamount + result1 = `` + result3 = `menemukan ${itemname} x${itemamount}` + //url = item.url } - if (legendary > 0) { - global.db.data.users[m.sender].legendary += legendary * 1 - conn.reply(m.chat, '*Selamat anda mendapatkan item Epic yaitu*\n' + legendary + ' Legendary Crate', m) - } - global.db.data.users[m.sender].healt -= healt * 1 - global.db.data.users[m.sender].exp += exp * 1 - global.db.data.users[m.sender].money += uang * 1 - global.db.data.users[m.sender].potion += potion * 1 - global.db.data.users[m.sender].diamond += diamond * 1 - global.db.data.users[m.sender].common += common * 1 - global.db.data.users[m.sender].uncommon += uncommon * 1 - global.db.data.users[m.sender].sampah += sampah * 1 - global.db.data.users[m.sender].lastadventure = new Date * 1 - } else conn.reply(m.chat, `Anda sudah berpetualang dan kelelahan, silahkan coba *${timers}* lagi`, m) - } else conn.reply(m.chat, 'Minimal 80 health untuk bisa berpetualang, beli nyawa dulu dengan ketik *' + usedPrefix + 'shop buy potion *\ndan ketik *' + usedPrefix + 'use potion *\n\n_Untuk mendapat money dan potion gratis ketik_ *' + usedPrefix + 'claim*', m) - } catch (e) { - console.log(e) - conn.reply(m.chat, 'Error', m) - if (DevMode) { - let file = require.resolve(__filename) - for (let jid of global.owner.map(v => v.replace(/[^0-9]/g, '') + '@s.whatsapp.net').filter(v => v != conn.user.jid)) { - conn.sendMessage(jid, file + ' error\nNo: *' + m.sender.split`@`[0] + '*\nCommand: *' + m.text + '*\n\n*' + e + '*', MessageType.text) + } else { +//Monster get data// + let area_monsters = monsters.filter(({ area })=> area <= 3) + let monster = area_monsters[Math.floor(Math.random() * area_monsters.length)] + let monstername = monster.name.toUpperCase() +//data read and write + let sum = monster.area + let dmg = (player.sword * 5 + player.armor * 5 - sum) + dmg = dmg < 0 ? Math.abs(dmg) : 0 + player.healt -= dmg + let monsterdrop = monster.drop + result3 = monstername + url = monster.url + if (player.healt < 0) { + if (randomizer <= monster.droprate) + player.rpg.items[monsterdrop] + if (!player.rpg.items[monsterdrop]) player.rpg.items[monsterdrop] = 0 + player.rpg.items[monsterdrop] += 1 + result1 = `menemukan dan membunuh *${monstername}*` + result2 = `mendapatkan ${monsterdrop}\n${new Intl.NumberFormat('en-US').format(coins)} coins & ${new Intl.NumberFormat('en-US').format(exp)} XP` + } else { + player.healt = 0 + result1 = `menemukan *${monstername}* tapi gagal membunuhnya` } } - } + player.money += coins * player.level + player.exp += exp * player.level + player.lastadventure = new Date * 1 + let pesan = `*${pname}* menjelajah sampai *${location}* dan ${result1} *${result2}*` + conn.sendMessage(m.chat, pesan, MessageType.text, { //send massage + contextInfo: { + externalAdReply: { + title: result3, + body: result1, + thumbnail: await (await fetch(url)).buffer() , + sourceUrl: 'http://raiden-bot.ga/'}}}) + } else throw `Tunggu *${cd1}:${cd2}* Untuk Adventure Lagi` } -handler.help = ['adventure', 'petualang', 'berpetualang', 'mulung', 'work'] + +handler.help = ['adventure'] handler.tags = ['rpg'] -handler.command = /^(adventure|(ber)?petualang(ang)?|mulung|work)$/i +handler.command = /^adventure/i + +handler.owner = true +handler.disabled = false handler.fail = null module.exports = handler -function pickRandom(list) { - return list[Math.floor(Math.random() * list.length)] +function MeNit(ms) { + let m = isNaN(ms) ? '02' : Math.floor(ms / 60000) % 60 + return [m].map(v => v.toString().padStart(2, 0)).join(':') } -function clockString(ms) { - let h = Math.floor(ms / 3600000) - let m = Math.floor(ms / 60000) % 60 - let s = Math.floor(ms / 1000) % 60 - console.log({ms,h,m,s}) - return [h, m, s].map(v => v.toString().padStart(2, 0) ).join(':') -} \ No newline at end of file + +function DeTik(ms) { + let s = isNaN(ms) ? '60' : Math.floor(ms / 1000) % 60 + return [s].map(v => v.toString().padStart(2, 0)).join(':') +} + +function pickRandom(list) { + return list[Math.floor(Math.random() * list.length)] + } \ No newline at end of file diff --git a/plugins/fish.js b/plugins/fish.js index 03bc0d30..e2ef91a4 100644 --- a/plugins/fish.js +++ b/plugins/fish.js @@ -3,47 +3,7 @@ let { MessageType } = require('@adiwajshing/baileys') let fetch = require('node-fetch') let handler = async (m, { conn, text }) => { - let fishes = [ - { area: 1, name: "Pufferfish", url: "https://stardewvalleywiki.com/mediawiki/images/b/ba/Pufferfish.png"}, - { area: 1, name: "Anchovy", url: "https://stardewvalleywiki.com/mediawiki/images/7/79/Anchovy.png"}, - { area: 1, name: "Tuna", url: "https://stardewvalleywiki.com/mediawiki/images/c/c5/Tuna.png"}, - { area: 2, name: "Sardine", url: "https://stardewvalleywiki.com/mediawiki/images/0/04/Sardine.png"}, - { area: 2, name: "Bream", url: "https://stardewvalleywiki.com/mediawiki/images/8/82/Bream.png"}, - { area: 2, name: "Largemouth Bass", url: "https://stardewvalleywiki.com/mediawiki/images/1/11/Largemouth_Bass.png"}, - { area: 3, name: "Smallmouth Bass", url: "https://stardewvalleywiki.com/mediawiki/images/a/a5/Smallmouth_Bass.png"}, - { area: 3, name: "Rainbow Trout", url: "https://stardewvalleywiki.com/mediawiki/images/1/14/Rainbow_Trout.png"}, - { area: 3, name: "Salmon", url: "https://stardewvalleywiki.com/mediawiki/images/e/e0/Salmon.png"}, - { area: 4, name: "Walleye", url: "https://stardewvalleywiki.com/mediawiki/images/0/05/Walleye.png"}, - { area: 4, name: "Perch", url: "https://stardewvalleywiki.com/mediawiki/images/4/43/Perch.png"}, - { area: 4, name: "Carp", url: "https://stardewvalleywiki.com/mediawiki/images/a/a8/Carp.png"}, - { area: 5, name: "Catfish", url: "https://stardewvalleywiki.com/mediawiki/images/9/99/Catfish.png"}, - { area: 5, name: "Pike", url: "https://stardewvalleywiki.com/mediawiki/images/3/31/Pike.png"}, - { area: 5, name: "Sunfish", url: "https://stardewvalleywiki.com/mediawiki/images/5/56/Sunfish.png"}, - { area: 6, name: "Red Mullet", url: "https://stardewvalleywiki.com/mediawiki/images/f/f2/Red_Mullet.png"}, - { area: 6, name: "Herring", url: "https://stardewvalleywiki.com/mediawiki/images/f/f1/Herring.png"}, - { area: 6, name: "Eel", url: "https://stardewvalleywiki.com/mediawiki/images/9/91/Eel.png"}, - { area: 7, name: "Octopus", url: "https://stardewvalleywiki.com/mediawiki/images/5/5a/Octopus.png"}, - { area: 7, name: "Red Snapper", url: "https://stardewvalleywiki.com/mediawiki/images/d/d3/Red_Snapper.png"}, - { area: 7, name: "Squid", url: "https://stardewvalleywiki.com/mediawiki/images/8/81/Squid.png"}, - { area: 8, name: "Sea Cucumber", url: "https://stardewvalleywiki.com/mediawiki/images/a/a9/Sea_Cucumber.png"}, - { area: 8, name: "Super Cucumber", url: "https://stardewvalleywiki.com/mediawiki/images/d/d5/Super_Cucumber.png"}, - { area: 8, name: "Ghostfish", url: "https://stardewvalleywiki.com/mediawiki/images/7/72/Ghostfish.png"}, - { area: 9, name: "Stonefish", url: "https://stardewvalleywiki.com/mediawiki/images/0/03/Stonefish.png"}, - { area: 9, name: "Ice Pip", url: "https://stardewvalleywiki.com/mediawiki/images/6/63/Ice_Pip.png"}, - { area: 9, name: "Lava Eel", url: "https://stardewvalleywiki.com/mediawiki/images/1/12/Lava_Eel.png"}, - { area: 10, name: "Sandfish", url: "https://stardewvalleywiki.com/mediawiki/images/b/bb/Sandfish.png"}, - { area: 10, name: "Scorpion Carp", url: "https://stardewvalleywiki.com/mediawiki/images/7/76/Scorpion_Carp.png"}, - { area: 10, name: "Flounder", url: "https://stardewvalleywiki.com/mediawiki/images/8/85/Flounder.png"}, - { area: 11, name: "Midnight Carp", url: "https://stardewvalleywiki.com/mediawiki/images/3/33/Midnight_Carp.png"}, - { area: 11, name: "Sturgeon", url: "https://stardewvalleywiki.com/mediawiki/images/4/42/Sturgeon.png"}, - { area: 11, name: "Tiger Trout", url: "https://stardewvalleywiki.com/mediawiki/images/0/01/Tiger_Trout.png"}, - { area: 12, name: "Bullhead", url: "https://stardewvalleywiki.com/mediawiki/images/d/db/Bullhead.png"}, - { area: 12, name: "Tilapia", url: "https://stardewvalleywiki.com/mediawiki/images/7/73/Tilapia.png"}, - { area: 12, name: "Chub", url: "https://stardewvalleywiki.com/mediawiki/images/b/bd/Chub.png"}, - { area: 13, name: "Slimejack", url: "https://stardewvalleywiki.com/mediawiki/images/3/34/Slimejack.png"}, - { area: 13, name: "Void Salmon", url: "https://stardewvalleywiki.com/mediawiki/images/a/ad/Void_Salmon.png"}, - { area: 13, name: "Blue Discus", url: "https://stardewvalleywiki.com/mediawiki/images/e/ee/Blue_Discus.png"}, - ] + let fishes = JSON.parse(fs.readFileSync('./data/rpg/fish.json')).fishes let player = global.db.data.users[m.sender] let pname = conn.getName(m.sender) @@ -59,15 +19,23 @@ let handler = async (m, { conn, text }) => { let fishName = fishtype.name.toUpperCase() if (new Date - global.db.data.users[m.sender].lastfishing > 120000) { + if (player.fishingrod > 0) { let durability = areaPlayer * 2 let coins = areaPlayer * 50 let exp = areaPlayer * 20 + let fishdrop = fishName + let fishdroped = `you got nothing` + + //fish + player.rpg.fish[fishdrop] + if (!player.rpg.fish[fishdrop]) player.rpg.fish[fishdrop] = 0 + player.rpg.fish[fishdrop] += 1 + fishdroped = `you got ${fishdrop}` player.fishingroddurability -= durability player.lastfishing = new Date * 1 // waktu fish 4menit - if (player.fishingroddurability < 0) { - player.fishingrod = 0 + player.fishingrod -= 1 let msg = `*${pname}* Fishingrod anda hancur` player.fishingroddurability = 0 m.reply(msg) @@ -82,16 +50,16 @@ let handler = async (m, { conn, text }) => { contextInfo: { externalAdReply: { title: fishName, - body: 'wibu', + body: fishdroped, thumbnail: await (await fetch(url)).buffer() , sourceUrl: 'http://raiden-bot.ga/'}}}) + } else throw `anda membutuh kan fishing rod untuk memancing\nbeli fishingrod di shop` } else throw `Tunggu *${cd1}:${cd2}* Untuk Memancing Lagi` } handler.help = ['fish'] handler.tags = ['rpg'] handler.command = /^fish/i -handler.fishingrod = 1 handler.disabled = false diff --git a/plugins/hunt.js b/plugins/hunt.js index 93205c32..105d77b5 100644 --- a/plugins/hunt.js +++ b/plugins/hunt.js @@ -2,24 +2,9 @@ let fs = require('fs') let { MessageType } = require('@adiwajshing/baileys') let fetch = require('node-fetch') let handler = async (m, { conn, text }) => { + - let monsters = [ - { area: 1, name: "Angry Bones", url: "https://static.wikia.nocookie.net/terraria_gamepedia/images/f/f6/Angry_Bones_1.png/revision/latest/scale-to-width-down/30?cb=20200530060826&format=original" }, - { area: 1, name: "Anomura Fungus", url: "https://static.wikia.nocookie.net/terraria_gamepedia/images/f/f0/Anomura_Fungus.png/revision/latest/scale-to-width-down/50?cb=20200521181927&format=original" }, - { area: 1, name: "Antlion", url: "https://static.wikia.nocookie.net/terraria_gamepedia/images/f/ff/Antlion.png/revision/latest/scale-to-width-down/36?cb=20191128180152&format=original" }, - { area: 2, name: "Antlion Charger", url: "https://static.wikia.nocookie.net/terraria_gamepedia/images/6/6c/Antlion_Charger.png/revision/latest/scale-to-width-down/62?cb=20200517034253&format=original" }, - { area: 2, name: "Antlion Larva", url: "https://static.wikia.nocookie.net/terraria_gamepedia/images/c/c8/Antlion_Larva.png/revision/latest/scale-to-width-down/30?cb=20200517034039&format=original" }, - { area: 2, name: "Baby Slime", url: "https://static.wikia.nocookie.net/terraria_gamepedia/images/6/6d/Baby_Slime.png/revision/latest/scale-to-width-down/32?cb=20170121233645&format=original" }, - { area: 3, name: "Black Slime", url: "https://static.wikia.nocookie.net/terraria_gamepedia/images/5/5c/Black_Slime.png/revision/latest/scale-to-width-down/32?cb=20110828163020&format=original" }, - { area: 3, name: "Cochineal Beetle", url: "https://static.wikia.nocookie.net/terraria_gamepedia/images/9/9b/Cochineal_Beetle.png/revision/latest/scale-to-width-down/32?cb=20200523235211&format=original" }, - { area: 3, name: "Blood Crawler", url: "https://static.wikia.nocookie.net/terraria_gamepedia/images/7/7e/Blood_Crawler.png/revision/latest/scale-to-width-down/60?cb=20200804000419&format=original" }, - { area: 4, name: "Ghost", url: "https://static.wikia.nocookie.net/terraria_gamepedia/images/7/70/Ghost_%28enemy%29.png/revision/latest/scale-to-width-down/32?cb=20131025175525&format=original" }, - { area: 4, name: "Green Slime", url: "https://static.wikia.nocookie.net/terraria_gamepedia/images/7/7b/Green_Slime.png/revision/latest/scale-to-width-down/32?cb=20141106201737&format=original" }, - { area: 4, name: "Frozen Zombie", url: "https://static.wikia.nocookie.net/terraria_gamepedia/images/c/cf/Frozen_Zombie.png/revision/latest/scale-to-width-down/34?cb=20170422010132&format=original" }, - { area: 5, name: "Zombie", url: "https://static.wikia.nocookie.net/terraria_gamepedia/images/c/c3/Zombie.png/revision/latest/scale-to-width-down/34?cb=20171102011214&format=original" }, - { area: 5, name: "Undead Viking", url: "https://static.wikia.nocookie.net/terraria_gamepedia/images/8/83/Undead_Viking.png/revision/latest/scale-to-width-down/30?cb=20170421015630&format=original" }, - { area: 5, name: "Tim", url: "https://static.wikia.nocookie.net/terraria_gamepedia/images/e/ea/Tim.png/revision/latest/scale-to-width-down/34?cb=20171104013044&format=original" }, - ] + let monsters = JSON.parse(fs.readFileSync('./data/rpg/monster.json')).monsters let player = global.db.data.users[m.sender] let pname = conn.getName(m.sender) @@ -34,14 +19,27 @@ let handler = async (m, { conn, text }) => { let area_monsters = monsters.filter(monster => { return monster.area === areaPlayer }) let monster = area_monsters[Math.floor(Math.random() * area_monsters.length)] let monsterName = monster.name.toUpperCase() + let randomizer = `${Math.floor(Math.random() * 101)}`.trim() - if (new Date - global.db.data.users[m.sender].lasthunt > 120000) { let sum = 10 * areaPlayer - 59 let dmg = (player.sword * 5 + player.armor * 5 - sum) dmg = dmg < 0 ? Math.abs(dmg) : 0 let coins = areaPlayer * 50 let exp = areaPlayer * 20 + let monsterdrop = monster.drop + let monsterdroped = `dropped nothing` + + if (randomizer <= monster.droprate) { + //mosnter drop items + player.rpg.items[monsterdrop] + if (!player.rpg.items[monsterdrop]) player.rpg.items[monsterdrop] = 0 + player.rpg.items[monsterdrop] += 1 + monsterdroped = `dropped ${monsterdrop}` + } else { + monsterdroped = `dropped nothing` + } + player.healt -= dmg player.lasthunt = new Date * 1 // waktu hunt 2menit @@ -65,7 +63,7 @@ let handler = async (m, { conn, text }) => { contextInfo: { externalAdReply: { title: monsterName, - body: `wibu`, + body: monsterdroped, thumbnail: await (await fetch(url)).buffer() , sourceUrl: 'http://raiden-bot.ga/'}}}) } else throw `Tunggu *${cd1}:${cd2}* Untuk Berburu Lagi` @@ -75,6 +73,7 @@ handler.help = ['hunt'] handler.tags = ['rpg'] handler.command = /^hunt/i +handler.owner = true handler.disabled = false handler.fail = null diff --git a/plugins/inv.js b/plugins/inv.js index e6bad871..37a94dab 100644 --- a/plugins/inv.js +++ b/plugins/inv.js @@ -1,5 +1,6 @@ let levelling = require('../lib/levelling') let handler = async (m, { conn, usedPrefix }) => { + let inventoryy = global.db.data.users[m.sender].rpg let kayu = global.db.data.users[m.sender].kayu let healt = global.db.data.users[m.sender].healt let armor = global.db.data.users[m.sender].armor @@ -8,7 +9,6 @@ let handler = async (m, { conn, usedPrefix }) => { let banknote = global.db.data.users[m.sender].banknote let pet = global.db.data.users[m.sender].pet let fishingrod = global.db.data.users[m.sender].fishingrod - let fishingroddurability = global.db.data.users[m.sender].fishingroddurability let kucing = global.db.data.users[m.sender].kucing let _kucing = global.db.data.users[m.sender].anakkucing let rubah = global.db.data.users[m.sender].rubah @@ -27,19 +27,6 @@ let handler = async (m, { conn, usedPrefix }) => { let bank = global.db.data.users[m.sender].bank let exp = global.db.data.users[m.sender].exp let sampah = global.db.data.users[m.sender].sampah - let as = global.db.data.users[m.sender].as - let paus = global.db.data.users[m.sender].paus - let kepiting = global.db.data.users[m.sender].kepiting - let gurita = global.db.data.users[m.sender].gurita - let cumi = global.db.data.users[m.sender].cumi - let buntal = global.db.data.users[m.sender].buntal - let dory = global.db.data.users[m.sender].dory - let lumba = global.db.data.users[m.sender].lumba - let lobster = global.db.data.users[m.sender].lobster - let hiu = global.db.data.users[m.sender].hiu - let udang = global.db.data.users[m.sender].udang - let ikan = global.db.data.users[m.sender].ikan - let orca = global.db.data.users[m.sender].orca let { max } = levelling.xpRange(level, exp, global.multiplier) let name = m.fromMe ? conn.user : conn.contacts[m.sender] let sortedmoney = Object.entries(global.db.data.users).sort((a, b) => b[1].money - a[1].money) @@ -60,6 +47,11 @@ let handler = async (m, { conn, usedPrefix }) => { let usersuncommon = sorteduncommon.map(v => v[0]) let usersmythic = sortedmythic.map(v => v[0]) let userslegendary = sortedlegendary.map(v => v[0]) + let word = JSON.stringify(inventoryy).replaceAll (',','\n') + let words = word.replaceAll(/["{}]/g,'') + let wordss = words.replaceAll(':',' x') + let wordsss = wordss.replace("fish x","*FISH*\n") + let finalstring = wordsss.replace("items x","*ITEMS*\n") let str = ` Inventory *${name.vnmae || name.notify || name.name || ('+' + name.jid.split`@`[0])}*\n Health: *${healt}* @@ -71,15 +63,7 @@ Exp: *${exp}*\n Warn: *${warn}* Banned: *No* \n${readMore}\n -*Inventory* -Fishingrod: *${fishingrod}* -Kayu: *${kayu}* -Diamond: *${diamond}* -Potion: *${potion}* -Sampah: *${sampah}* -Makanan Pet: *${makananpet}* -Banknote: *${banknote}* -Total inv: *${diamond + potion + sampah + makananpet + banknote + kayu}* item\n +${finalstring} *Crate* Common: *${common}* Uncommon: *${uncommon}* diff --git a/plugins/sewabot.js b/plugins/sewabot.js index e5922878..3a40dfd2 100644 --- a/plugins/sewabot.js +++ b/plugins/sewabot.js @@ -1,4 +1,4 @@ -let handler = m => m.reply('*OPEN JASA SEWA BOT*\n\nSewa 7 Hari / Grup : 5k\nSewa 30 Hari / Grup : 15k\n\n*Trial 5 Hari : Ketik .Trial *\n\n*Payment :*\n*_Dana_*\nMinat?PC\nWa.me/6282324892737') +let handler = m => m.reply('*OPEN JASA SEWA BOT*\n\nSewa 7 hari / Grup : 5k\nSewa 30 hari / Grup : 15k\n\n*Free Trial 5 Hari Ketik .Trial *\n*Payment :*\n*_Dana_*\nMinat?PC\nWa.me/6289602213818') handler.help = ['sewabot'] handler.tags = ['about'] diff --git a/plugins/shop copy.js b/plugins/shop copy.js new file mode 100644 index 00000000..055a73a9 --- /dev/null +++ b/plugins/shop copy.js @@ -0,0 +1,37 @@ +let { MessageType } = require('@adiwajshing/baileys') +let handler = async (m, { conn, command, args, usedPrefix, DevMode }) => { + const _armor = global.db.data.users[m.sender].armor + const armor = (_armor == 0 ? 20000 : '' || _armor == 1 ? 49999 : '' || _armor == 2 ? 99999 : '' || _armor == 3 ? 149999 : '' || _armor == 4 ? 299999 : '') + let items = JSON.parse(fs.readFileSync('./data/rpg/items.json')).items + let item = items.filter(({ name })=> name == args[1]) + let player = global.db.data.users[m.sender] + let amount = args[2] + let itemname = item.name + if (args[0] == "buy") { + if (args[1] == item ) { + if (item.price = 0) { + m.reply(`kamu tidak bisa membeli *${itemname}*`) + } else if (player.money >= item.price) { + player.rpg.items[itemname] + if (!player.rpg.items[itemname]) player.rpg.items[itemname] = 0 + player.money -= (item.price * amount) + player.rpg.items[itemname] += amount + } + } else throw 'mau beli apa mas?' + } + } catch (e) { + conn.reply(m.chat, Kchat, m) + console.log(e) + if (DevMode) { + for (let jid of global.owner.map(v => v.replace(/[^0-9]/g, '') + '@s.whatsapp.net').filter(v => v != conn.user.jid)) { + conn.sendMessage(jid, 'shop.js error\nNo: *' + m.sender.split`@`[0] + '*\nCommand: *' + m.text + '*\n\n*' + e + '*', MessageType.text) + } + } + } +} + +handler.help = ['buy ', 'sell '] +handler.tags = ['rpg'] + +handler.command = /^(buy|beli|sell|jual)$/i +module.exports = handler \ No newline at end of file