starting v0.1
Добавлены пресеты имущества Стоимость материалов отображается в Мире Прочие исправления и проверки
This commit is contained in:
parent
bf8d59b0f7
commit
f83f8ca0ab
117
index.js
117
index.js
@ -77,7 +77,7 @@ bot.use(async (ctx, next) => {
|
||||
telegram_id: id
|
||||
})
|
||||
} else {}
|
||||
if (whitelist.includes(id) == false) return ctx.reply(`У вас пока нет доступа к боту. Следите за обновлениями в группе: t.me/CampFireGameBotNews`)
|
||||
//if (whitelist.includes(id) == false) return ctx.reply(`У вас пока нет доступа к боту. Следите за обновлениями в группе: t.me/CampFireGameBotNews`)
|
||||
if (block !== null) {
|
||||
if (block.isBlocked == true && block.time > Date.now() / 1000) return ctx.reply(`У вас активная блокировка по причине: ${block.reason}.\nОставшееся время: ${Math.trunc((block.time - Date.now()/1000)/60)} мин.`)
|
||||
block.isBlocked = false
|
||||
@ -110,7 +110,7 @@ bot.command('start', async (ctx) => {
|
||||
return await ctx.reply('Главное меню', Markup
|
||||
.keyboard([
|
||||
['😎 Профиль', '💳 Баланс'], // Row1 with 2 buttons
|
||||
['🗄️ Работать', '🎁 Бонус'], // Row2 with 2 buttons
|
||||
['🗄️ Работать', '🌐 Организация', '🎁 Бонус'], // Row2 with 2 buttons
|
||||
['📢 Вакансии', '🔵 Имущество', '📞 Пригласить'] // Row3 with 3 buttons
|
||||
])
|
||||
.oneTime()
|
||||
@ -118,11 +118,11 @@ bot.command('start', async (ctx) => {
|
||||
)
|
||||
})
|
||||
|
||||
bot.hears('Меню', async (ctx) => {
|
||||
bot.hears('▶️ Меню', async (ctx) => {
|
||||
return await ctx.reply('Main Menu', Markup
|
||||
.keyboard([
|
||||
['😎 Профиль', '💳 Баланс'], // Row1 with 2 buttons
|
||||
['🗄️ Работать', '🎁 Бонус'], // Row2 with 2 buttons
|
||||
['🗄️ Работать', '🌐 Организация', '🎁 Бонус'], // Row2 with 2 buttons
|
||||
['📢 Вакансии', '🔵 Имущество', '📞 Пригласить'] // Row3 with 3 buttons
|
||||
])
|
||||
.oneTime()
|
||||
@ -198,7 +198,18 @@ bot.hears('🎁 Бонус', async (ctx) => {
|
||||
text += `⏩ ¤${money*2}\n`;
|
||||
}
|
||||
}
|
||||
//uplvl(user);
|
||||
|
||||
let business = await BusinessModel.findOne({
|
||||
where: {
|
||||
owner: user.business.id
|
||||
}
|
||||
})
|
||||
if(business != null){
|
||||
let mats = rand(3, 10)
|
||||
text += `⏩ ${mats} Материалов в организацию\n`
|
||||
business.materials += mats
|
||||
business.save()
|
||||
}
|
||||
await user.save();
|
||||
await world.save();
|
||||
return ctx.reply(`
|
||||
@ -251,6 +262,7 @@ bot.hears('Мир', async (ctx) => {
|
||||
let world = await WorldModel.findByPk(1)
|
||||
return ctx.reply(`
|
||||
Баланс мира: ¤${spaces(world.balance)}
|
||||
Стоимость материалов: ¤${spaces(world.matPrice)}
|
||||
`)
|
||||
})
|
||||
|
||||
@ -270,7 +282,8 @@ bot.hears('📢 Вакансии', async (ctx) => {
|
||||
.keyboard([
|
||||
['Дворник', 'Промоутер'], // Row1 with 2 buttons
|
||||
['Официант', 'Бармен'], // Row2 with 2 buttons
|
||||
['Кассир', 'ПВЗ Дикие Ягоды', 'Слесарь'] // Row3 with 3 buttons
|
||||
['Кассир', 'ПВЗ Дикие Ягоды', 'Слесарь'],
|
||||
['💤 Уволиться', '▶️ Меню'] // Row3 with 3 buttons
|
||||
])
|
||||
.oneTime()
|
||||
.resize()
|
||||
@ -521,7 +534,7 @@ bot.hears('🗄️ Работать', async (ctx) => {
|
||||
price: 600
|
||||
}, {
|
||||
name: "Вагиноимитатор",
|
||||
price: "600"
|
||||
price: 600
|
||||
}].random()
|
||||
world.balance -= payday
|
||||
world.balance -= Number(stealed.price)
|
||||
@ -604,7 +617,8 @@ bot.hears('🔵 Имущество', async (ctx) => {
|
||||
let user = await UserModel.findByPk(ctx.from.id);
|
||||
return await ctx.reply(`Места для покупки`, Markup
|
||||
.keyboard([
|
||||
['Жилье', 'Телефоны', 'Автосалон'] // Row3 with 3 buttons
|
||||
['Жилье', 'Телефоны', 'Автосалон'],
|
||||
['▶️ Меню'] // Row3 with 3 buttons
|
||||
])
|
||||
.oneTime()
|
||||
.resize())
|
||||
@ -651,6 +665,7 @@ bot.command('buy', async (ctx) => {
|
||||
if (!ctx.args[1] || !ctx.args[2]) return ctx.reply(`Не указан аргумент.`)
|
||||
if (!Number(ctx.args[2])) return ctx.reply(`Неверно указан параметр.`)
|
||||
if (ctx.args[1] == "house") {
|
||||
if (user.money < houses[ctx.args[2]].price) return await ctx.reply(`У вас недостаточно средств!`)
|
||||
user.money -= houses[ctx.args[2]].price
|
||||
world.balance += houses[ctx.args[2]].price
|
||||
property.house = houses[ctx.args[2]]
|
||||
@ -660,6 +675,7 @@ bot.command('buy', async (ctx) => {
|
||||
return await ctx.reply(`Вы купили ${houses[ctx.args[2]].name}`)
|
||||
}
|
||||
if (ctx.args[1] == "car") {
|
||||
if (user.money < cars[ctx.args[2]].price) return await ctx.reply(`У вас недостаточно средств!`)
|
||||
user.money -= cars[ctx.args[2]].price
|
||||
world.balance += cars[ctx.args[2]].price
|
||||
property.car = cars[ctx.args[2]]
|
||||
@ -669,6 +685,7 @@ bot.command('buy', async (ctx) => {
|
||||
return await ctx.reply(`Вы купили ${cars[ctx.args[2]].name}`)
|
||||
}
|
||||
if (ctx.args[1] == "phone") {
|
||||
if (user.money < phones[ctx.args[2]].price) return await ctx.reply(`У вас недостаточно средств!`)
|
||||
user.money -= phones[ctx.args[2]].price
|
||||
world.balance += phones[ctx.args[2]].price
|
||||
property.mobile = phones[ctx.args[2]]
|
||||
@ -678,6 +695,7 @@ bot.command('buy', async (ctx) => {
|
||||
return await ctx.reply(`Вы купили ${phones[ctx.args[2]].name}`)
|
||||
}
|
||||
if (ctx.args[1] == "equipment") {
|
||||
if (user.money < weaponshop[ctx.args[2]].price) return await ctx.reply(`У вас недостаточно средств!`)
|
||||
if (ctx.args[1] == weaponshop[ctx.args[2]].type) {
|
||||
user.money -= weaponshop[ctx.args[2]].price
|
||||
world.balance += weaponshop[ctx.args[2]].price
|
||||
@ -698,26 +716,48 @@ bot.command('buy', async (ctx) => {
|
||||
return await ctx.reply(`Вы купили.`)
|
||||
})
|
||||
|
||||
bot.hears('Организация', async (ctx) => {
|
||||
bot.hears('🌐 Организация', async (ctx) => {
|
||||
let user = await UserModel.findByPk(ctx.from.id)
|
||||
let business = await BusinessModel.findOne({
|
||||
where: {
|
||||
owner: ctx.from.id
|
||||
}
|
||||
})
|
||||
if (business === null) return await ctx.reply(`У вас нет организации.`)
|
||||
console.log(business)
|
||||
return await ctx.reply(`Ваша организация\n${business.name}\nБаланс: ¤${business.balance}\nСырье: ${business.materials}\nРабочих: ${business.users.length}`)
|
||||
if(business === null){
|
||||
business = await BusinessModel.findOne({
|
||||
where: {
|
||||
owner: user.business.id
|
||||
}
|
||||
})
|
||||
return await ctx.reply(`Организация\n${business.name}\nБаланс: ¤${business.balance}\nСырье: ${business.materials}\nРабочих: ${business.users.length}`, Markup.keyboard([
|
||||
['📶 Отработка'],
|
||||
['⬅️ Покинуть', '▶️ Меню'] // Row3 with 3 buttons
|
||||
])
|
||||
.oneTime()
|
||||
.resize())
|
||||
}
|
||||
if (business.owner == ctx.from.id){
|
||||
return await ctx.reply(`Ваша организация\n${business.name}\nБаланс: ¤${business.balance}\nСырье: ${business.materials} (Для закупки: [/materials Кол-во])\nРабочих: ${business.users.length} (Для приглашения: [/invite ID])\nОтработок: ${business.checks}`, Markup.keyboard([
|
||||
['📶 Отработка'],
|
||||
['💸 Payday', '▶️ Меню']
|
||||
])
|
||||
.oneTime()
|
||||
.resize())
|
||||
}
|
||||
})
|
||||
|
||||
bot.hears('Отработка', async (ctx) => {
|
||||
bot.hears('📶 Отработка', async (ctx) => {
|
||||
let user = await UserModel.findByPk(ctx.from.id)
|
||||
let business = await BusinessModel.findOne({
|
||||
where: {
|
||||
owner: ctx.from.id
|
||||
}
|
||||
})
|
||||
if (user.business == null) return await ctx.reply(`Вы не работаете в организации.`)
|
||||
let timer = user.worktime
|
||||
let cooldown = setCooldown(user, 3600, timer)
|
||||
if (user.worktime > cooldown.currentTime) return ctx.reply(`📛 Работа в организации будет доступна через ${cooldown.timeLeftInMinutes} минут(у/ы)`);
|
||||
if (business.materials <= 10) return ctx.reply(`📛 В организации недостаточно материалов для отработки.`);
|
||||
if (business.materials < 10) return ctx.reply(`📛 В организации недостаточно материалов для отработки.`);
|
||||
user.business = {
|
||||
id: user.business.id,
|
||||
checks: user.business.checks + 1,
|
||||
@ -730,10 +770,12 @@ bot.hears('Отработка', async (ctx) => {
|
||||
return await ctx.reply(`Вы отработали час на ${business.name}`)
|
||||
})
|
||||
|
||||
bot.hears('Payday', async (ctx) => {
|
||||
bot.hears('💸 Payday', async (ctx) => {
|
||||
let user = null
|
||||
let business = await BusinessModel.findOne({
|
||||
where: {
|
||||
owner: ctx.from.id
|
||||
}
|
||||
})
|
||||
let world = await WorldModel.findByPk(1)
|
||||
if (business === null) return await ctx.reply(`У вас нет организации.`)
|
||||
@ -753,9 +795,14 @@ bot.hears('Payday', async (ctx) => {
|
||||
for (i = 0; i < business.users.length; i++) { // Общая внесенная сумма всеми участниками
|
||||
user = await UserModel.findByPk(business.users[i])
|
||||
profit += user.business.checks * moneyList
|
||||
text += `${user.username} нарабатывает ¤${user.business.checks * moneyList} [¤${moneyList}*${user.business.checks}] в баланс организации.\n`
|
||||
user.business = {
|
||||
id: user.business.id,
|
||||
checks: 0,
|
||||
percent: user.business.percent
|
||||
}
|
||||
text += `Профит: ${profit}\n`
|
||||
user.save()
|
||||
}
|
||||
text += `Наработка за текущий период: ${profit}\n`
|
||||
let profitCheck = profit
|
||||
for (i = 0; i < business.users.length; i++) { // Процент выплаты участникам
|
||||
user = await UserModel.findByPk(business.users[i])
|
||||
@ -764,7 +811,7 @@ bot.hears('Payday', async (ctx) => {
|
||||
user.money += piece
|
||||
giveExp(user, business.checks)
|
||||
user.save()
|
||||
text += `${user.username} получает ¤${piece}\nОстаток выплат: ¤${profitCheck}\n`
|
||||
text += `${user.username} получает ¤${piece}\n`
|
||||
}
|
||||
if (profitCheck > 0) {
|
||||
business.balance += profitCheck
|
||||
@ -778,30 +825,43 @@ bot.hears('Payday', async (ctx) => {
|
||||
bot.command('materials', async (ctx) => {
|
||||
ctx.args = ctx.update.message.text.split(' ')
|
||||
let user = await UserModel.findByPk(ctx.from.id)
|
||||
let world = await WorldModel.findByPk(1)
|
||||
let business = await BusinessModel.findOne({
|
||||
where: {
|
||||
owner: ctx.from.id
|
||||
}
|
||||
})
|
||||
if (business === null) return await ctx.reply(`У вас нет организации.`)
|
||||
if (!ctx.args[1]) return ctx.reply(`Не указан аргумент.`)
|
||||
if (!Number(ctx.args[1])) return ctx.reply(`Количество должно быть числом.`)
|
||||
if (ctx.args[1] < 1) return ctx.reply(`Минимальное количество для покупки - 1`)
|
||||
business.balance -= Number(world.matPrice*ctx.args[1])
|
||||
business.materials += ctx.args[1]
|
||||
if (ctx.args[1] > business.balance) return ctx.reply(`Недостаточно средств на балансе организации.`)
|
||||
let count = Number(ctx.args[1])
|
||||
business.balance -= world.matPrice*count
|
||||
business.materials += count
|
||||
business.save()
|
||||
return await ctx.reply(`Закуплено ${ctx.args[1]} материалов для организации`)
|
||||
return await ctx.reply(`Закуплено ${ctx.args[1]} материалов для организации на сумму ${world.matPrice*count}`)
|
||||
})
|
||||
|
||||
bot.command('percent', async (ctx) => {
|
||||
ctx.args = ctx.update.message.text.split(' ')
|
||||
let user = await UserModel.findByPk(ctx.from.id)
|
||||
let business = await BusinessModel.findOne({
|
||||
where: {
|
||||
owner: ctx.from.id
|
||||
}
|
||||
})
|
||||
if (business === null) return await ctx.reply(`У вас нет организации.`)
|
||||
if (!ctx.args[1] || !ctx.args[2]) return ctx.reply(`Не указан аргумент.`)
|
||||
if (!Number(ctx.args[2])) return ctx.reply(`Процент должен быть числом от 1 до 100.`)
|
||||
if (ctx.args[2] < 1 || ctx.args[2] > 100) return ctx.reply(`Минимальный процент 1 | Максимальный процент 100.`)
|
||||
let change = await UserModel.findByPk(ctx.args[1])
|
||||
ctx.args[1] = ctx.args[1].slice(1)
|
||||
console.log(ctx.args)
|
||||
let change = await UserModel.findOne({
|
||||
where: {
|
||||
username: ctx.args[1]
|
||||
}
|
||||
})
|
||||
change.business = {
|
||||
id: change.business.id,
|
||||
checks: change.business.checks,
|
||||
@ -814,7 +874,9 @@ bot.command('percent', async (ctx) => {
|
||||
bot.command('business', async (ctx) => {
|
||||
let user = await UserModel.findByPk(ctx.from.id)
|
||||
let business = await BusinessModel.findOne({
|
||||
where: {
|
||||
owner: ctx.from.id
|
||||
}
|
||||
})
|
||||
let world = await WorldModel.findByPk(1)
|
||||
ctx.args = ctx.update.message.text.split(' ')
|
||||
@ -897,7 +959,9 @@ bot.on('callback_query', async ctx => {
|
||||
let user = await UserModel.findByPk(ctx.update.callback_query.from.id)
|
||||
if (data != 0) {
|
||||
let business = await BusinessModel.findOne({
|
||||
where: {
|
||||
owner: data
|
||||
}
|
||||
})
|
||||
user.business = {
|
||||
id: data,
|
||||
@ -1007,15 +1071,24 @@ function weaponShopUpdate() {
|
||||
fs.writeFileSync('json/weaponshop.json', JSON.stringify(weaponshop, null, "\t"))
|
||||
}
|
||||
|
||||
async function matPriceUpdate() {
|
||||
let world = await WorldModel.findByPk(1)
|
||||
let price = rand(35, 170)
|
||||
world.matPrice = price
|
||||
world.save()
|
||||
}
|
||||
|
||||
setInterval(() => {
|
||||
var today = new Date();
|
||||
let hours = today.getHours();
|
||||
if (hours == "0" || hours == "12" || hours == "23") {
|
||||
weaponShopUpdate()
|
||||
matPriceUpdate()
|
||||
}
|
||||
}, 360000);
|
||||
|
||||
weaponShopUpdate()
|
||||
matPriceUpdate()
|
||||
|
||||
start()
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
{
|
||||
"0": {
|
||||
"name": "AK-47",
|
||||
"name": "SCAR-H",
|
||||
"price": 1000,
|
||||
"type": "weapon"
|
||||
},
|
||||
"1": {
|
||||
"name": "M4A1",
|
||||
"name": "Glock",
|
||||
"price": 1000,
|
||||
"type": "weapon"
|
||||
},
|
||||
@ -20,27 +20,27 @@
|
||||
"type": "weapon"
|
||||
},
|
||||
"4": {
|
||||
"name": "M4A1",
|
||||
"name": "Deagle",
|
||||
"price": 1000,
|
||||
"type": "weapon"
|
||||
},
|
||||
"5": {
|
||||
"name": "Картонные накладки",
|
||||
"price": 1000,
|
||||
"type": "equipment"
|
||||
},
|
||||
"6": {
|
||||
"name": "Бронежилет M5",
|
||||
"price": 1000,
|
||||
"type": "equipment"
|
||||
},
|
||||
"6": {
|
||||
"name": "Бронежилет M3",
|
||||
"price": 1000,
|
||||
"type": "equipment"
|
||||
},
|
||||
"7": {
|
||||
"name": "Бронежилет M6",
|
||||
"name": "Бронежилет M2",
|
||||
"price": 1000,
|
||||
"type": "equipment"
|
||||
},
|
||||
"8": {
|
||||
"name": "Кольчуга",
|
||||
"name": "Картонные накладки",
|
||||
"price": 1000,
|
||||
"type": "equipment"
|
||||
},
|
||||
|
@ -4,7 +4,8 @@ const {DataTypes} = require('sequelize');
|
||||
const World = sequelize.define('world', {
|
||||
id: {type: DataTypes.INTEGER, primaryKey: true, unique: true},
|
||||
balance: {type: DataTypes.INTEGER, defaultValue: 50000000},
|
||||
transactionfee: {type: DataTypes.INTEGER, defaultValue: 1}
|
||||
transactionfee: {type: DataTypes.INTEGER, defaultValue: 1},
|
||||
matPrice: {type: DataTypes.INTEGER, defaultValue: 100}
|
||||
})
|
||||
|
||||
module.exports = World;
|
||||
|
@ -1,42 +1,42 @@
|
||||
{
|
||||
"1": {
|
||||
"name": "Car2",
|
||||
"price": 0
|
||||
"name": "Электросамокат",
|
||||
"price": 16000
|
||||
},
|
||||
"2": {
|
||||
"name": "Car3",
|
||||
"price": 10
|
||||
"name": "ВАЗ 2115",
|
||||
"price": 90000
|
||||
},
|
||||
"3": {
|
||||
"name": "Car4",
|
||||
"price": 20
|
||||
"name": "Lada Priora",
|
||||
"price": 300000
|
||||
},
|
||||
"4": {
|
||||
"name": "Car5",
|
||||
"price": 30
|
||||
"name": "Renault Logan",
|
||||
"price": 650000
|
||||
},
|
||||
"5": {
|
||||
"name": "Car6",
|
||||
"price": 40
|
||||
"name": "Hyundai Solaris",
|
||||
"price": 800000
|
||||
},
|
||||
"6": {
|
||||
"name": "Car7",
|
||||
"price": 50
|
||||
"name": "Kia Rio",
|
||||
"price": 900000
|
||||
},
|
||||
"7": {
|
||||
"name": "Car86",
|
||||
"price": 60
|
||||
"name": "Ford Focus",
|
||||
"price": 1100000
|
||||
},
|
||||
"8": {
|
||||
"name": "Car8",
|
||||
"price": 70
|
||||
"name": "Volkswagen Polo",
|
||||
"price": 1300000
|
||||
},
|
||||
"9": {
|
||||
"name": "Car9",
|
||||
"price": 80
|
||||
"name": "Mazda 3",
|
||||
"price": 1450000
|
||||
},
|
||||
"10": {
|
||||
"name": "Car10",
|
||||
"price": 90
|
||||
"name": "Mercedes Benz E-200",
|
||||
"price": 2000000
|
||||
}
|
||||
}
|
@ -4,39 +4,39 @@
|
||||
"price": 100
|
||||
},
|
||||
"2": {
|
||||
"name": "Дом",
|
||||
"price": 100
|
||||
"name": "Комната в общаге",
|
||||
"price": 50000
|
||||
},
|
||||
"3": {
|
||||
"name": "Дом2",
|
||||
"price": 100
|
||||
"name": "Квартира в малосемейке",
|
||||
"price": 150000
|
||||
},
|
||||
"4": {
|
||||
"name": "Дом3",
|
||||
"price": 100
|
||||
"name": "1-комнатная квартира в сталинке",
|
||||
"price": 300000
|
||||
},
|
||||
"5": {
|
||||
"name": "Дом4",
|
||||
"price": 100
|
||||
"name": "3-комнатная квартира в сталинке",
|
||||
"price": 500000
|
||||
},
|
||||
"6": {
|
||||
"name": "Дом5",
|
||||
"price": 100
|
||||
"name": "Студия с евроремонтом",
|
||||
"price": 2000000
|
||||
},
|
||||
"7": {
|
||||
"name": "Дом6",
|
||||
"price": 100
|
||||
"name": "2-комнатная квартира с евроремонтом в панельке",
|
||||
"price": 2000000
|
||||
},
|
||||
"8": {
|
||||
"name": "Дом7",
|
||||
"price": 100
|
||||
"name": "2-этажный дом",
|
||||
"price": 5000000
|
||||
},
|
||||
"9": {
|
||||
"name": "Дом8",
|
||||
"price": 100
|
||||
"name": "Таунхаус",
|
||||
"price": 10000000
|
||||
},
|
||||
"10": {
|
||||
"name": "Дом9",
|
||||
"price": 100
|
||||
"name": "Дворец",
|
||||
"price": 50000000
|
||||
}
|
||||
}
|
@ -1 +1,42 @@
|
||||
{}
|
||||
{
|
||||
"1": {
|
||||
"name": "Nokia 3310",
|
||||
"price": 300
|
||||
},
|
||||
"2": {
|
||||
"name": "BQ 6868L",
|
||||
"price": 4500
|
||||
},
|
||||
"3": {
|
||||
"name": "Realme C21Y",
|
||||
"price": 7000
|
||||
},
|
||||
"4": {
|
||||
"name": "Xiaomi Redmi 10C",
|
||||
"price": 10500
|
||||
},
|
||||
"5": {
|
||||
"name": "Samsung Galaxy A13",
|
||||
"price": 15500
|
||||
},
|
||||
"6": {
|
||||
"name": "Xiaomi Redmi Note 12S",
|
||||
"price": 22000
|
||||
},
|
||||
"7": {
|
||||
"name": "Nothing Phone 2",
|
||||
"price": 45000
|
||||
},
|
||||
"8": {
|
||||
"name": "Samsung S23 Ultra",
|
||||
"price": 109000
|
||||
},
|
||||
"9": {
|
||||
"name": "IPhone 14 Pro Max",
|
||||
"price": 170000
|
||||
},
|
||||
"10": {
|
||||
"name": "IPhone 15 Pro Max",
|
||||
"price": 190000
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user