CampFirePlay/scenes/pocketsteal.js
2023-10-11 11:35:25 +03:00

154 lines
5.2 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const {
Telegraf,
Scenes,
Markup
} = require('telegraf')
const bot = new Telegraf(process.env.BOT_TOKEN)
const {
slots,
phones,
UserModel,
WorldModel,
SkillsModel,
PropertyModel
} = require('/workspace/degradin/Dev/Telegram/CampFire Play/config')
const {
spaces,
getSlot,
giveExp,
rand,
random,
setCooldown
} = require('/workspace/degradin/Dev/Telegram/CampFire Play/utils');
const steal = new Scenes.BaseScene('POCKET_STEAL');
steal.enter(async (ctx) => {
let user = await UserModel.findByPk(ctx.from.id)
let pocketsteal = user.pocketstealcd
if(user.level < 7) return ctx.editMessageText('Доступно с 7 уровня!')
let cooldown = setCooldown(user, 3600, pocketsteal)
if (user.pocketstealcd > cooldown.currentTime) return ctx.editMessageText(`📛 Данное действие будет доступно через ${cooldown.timeLeftInMinutes} мин.`);
user.pocketstealcd = cooldown.endTime
user.save()
ctx.editMessageText('Выберите объект', Markup.inlineKeyboard([
[
{text: 'Карман', callback_data: `POCKET_TARGET`},
{text: 'Бумажник', callback_data: `POCKET_WALLET`},
{text: 'Сумка', callback_data: `POCKET_BAG`}
]
]))
});
steal.action(`POCKET_TARGET`, async (ctx) => {
ctx.editMessageText('В кармане обнаружено', Markup.inlineKeyboard([
[
{text: 'Деньги', callback_data: `MONEY_IN_POCKET`},
{text: 'Телефон', callback_data: `PHONE`}
]
]))
});
steal.action(`MONEY_IN_POCKET`, async (ctx) => {
let user = await UserModel.findByPk(ctx.from.id)
let skill = await SkillsModel.findByPk(ctx.from.id)
let chance = rand(0, 100)
chance += skill.stealing.level
if(chance < 20) return ctx.editMessageText('Вы были замечены во время кражи.');
let moneyIn = rand(5, 1000)
user.dirtymoney += moneyIn
user.save()
return ctx.editMessageText(`Вы успешно украли Ð${spaces(moneyIn)} из кармана.`)
});
steal.action(`PHONE`, async (ctx) => {
let user = await UserModel.findByPk(ctx.from.id)
let property = await PropertyModel.findByPk(ctx.from.id);
let skill = await SkillsModel.findByPk(ctx.from.id)
let chance = rand(0, 100)
chance += skill.stealing.level
if(chance < 60) return ctx.editMessageText('Вы были замечены во время кражи.');
let randPhone = rand(1,10)
if (property.mobile.name) {
let dirtyMoney = Math.round(phones[randPhone].price/100*70)
user.dirtymoney += dirtyMoney
return await ctx.reply(`Вы сбыли украденный ${phones[randPhone].name} за Ð${dirtyMoney}`)
}
property.mobile = phones[randPhone]
await user.save()
await property.save()
return ctx.editMessageText(`Вы успешно украли ${phones[randPhone].name} из кармана.`)
});
steal.action(`POCKET_WALLET`, async (ctx) => {
ctx.editMessageText('В бумажнике обнаружено', Markup.inlineKeyboard([
[
{text: 'Деньги', callback_data: `MONEY_IN_WALLET`},
{text: 'Карточка', callback_data: `CARD_IN_WALLET`}
]
]))
});
steal.action(`MONEY_IN_WALLET`, async (ctx) => {
let user = await UserModel.findByPk(ctx.from.id)
let skill = await SkillsModel.findByPk(ctx.from.id)
let chance = rand(0, 100)
chance += skill.stealing.level
if(chance < 40) return ctx.editMessageText('Вы были замечены во время кражи.');
let moneyIn = rand(1000, 10000)
user.dirtymoney += moneyIn
user.save()
return ctx.editMessageText(`Вы успешно украли Ð${spaces(moneyIn)} из бумажника.`)
});
steal.action(`CARD_IN_WALLET`, async (ctx) => {
let user = await UserModel.findByPk(ctx.from.id)
let skill = await SkillsModel.findByPk(ctx.from.id)
let chance = rand(0, 100)
chance += skill.stealing.level
if(chance < 50) return ctx.editMessageText('Вы были замечены во время кражи.');
user.stealedcards += 1
user.save()
return ctx.editMessageText(`Вы успешно украли 💳 из бумажника.`)
});
steal.action(`POCKET_BAG`, async (ctx) => {
let user = await UserModel.findByPk(ctx.from.id)
let skill = await SkillsModel.findByPk(ctx.from.id)
let chance = rand(0, 100)
chance += skill.stealing.level
console.log(chance)
if(chance < 60) return ctx.editMessageText('Вы были замечены во время кражи.');
let times = rand(2,20)
let moneyIn = 0
let text = ``
let values = 0
for(i=1; i<=times; i++){
switch(i) {
case 2:
values = rand(10000, 50000)
moneyIn += values
text += `+ Ð${spaces(values)}\n`
break;
case 7:
values = rand(10000, 100000)
moneyIn += values
text += `+ Ð${spaces(values)}\n`
break;
default:
values = rand(100, 3000)
moneyIn += values
text += `+ Ð${spaces(values)}\n`
break;
}
}
user.dirtymoney += moneyIn
user.save()
return ctx.editMessageText(`Вы успешно украли сумку и сбыли все ценности из нее:\n${text}\nОбщий куш: Ð${spaces(moneyIn)}`)
});
steal.leave((ctx) => {
console.log('Завершено');
});
module.exports = steal