diff --git a/bot.js b/bot.js
index a57634b..10be812 100644
--- a/bot.js
+++ b/bot.js
@@ -248,7 +248,7 @@ bot.command('profile', (ctx) => {
[
{
text: "Открыть профиль",
- web_app: { url: "https://cmpfire.ru:3000/profile" }, // Замените на ваш URL
+ web_app: { url: "https://web-bot.campfiregg.ru/" }, // Замените на ваш URL
},
],
],
diff --git a/public/index.html b/public/index.html
index 89c56c4..536a73e 100644
--- a/public/index.html
+++ b/public/index.html
@@ -1,65 +1,163 @@
-
+
-
Загрузка...
-
Уровень: —
-
Опыт: — / —
-
Баланс: — ₽
-
Дом: —
-
Машина: —
-
Телефон: —
+
+
📜 Меню игрока
+
+
+
👤 Личные данные
+
Имя: —
+
Уровень: —
+
Опыт: —
+
Здоровье: — / —
+
Деньги: ₽—
+
Грязные деньги: ₽—
+
+
+
+
🏢 Организация
+
Название: —
+
Баланс: ₽—
+
Материалы: —
+
+
+
+
🏭 Предприятия
+
+
Нет активных предприятий.
+
+
+
+
🏠 Перейти в чат бота
+
diff --git a/rpg.js b/rpg.js
index 6c60767..baca75d 100644
--- a/rpg.js
+++ b/rpg.js
@@ -2064,6 +2064,37 @@ rpg.action(/miss_\d+/, async (ctx) => {
});
+rpg.command("start_battle", async (ctx) => {
+ const character = await CharacterModel.findOne({ where: { telegram_id: ctx.from.id } });
+
+ if (!character) {
+ return ctx.reply("Ваш персонаж не найден. Создайте его, чтобы начать играть!");
+ }
+
+ // Поиск или создание новой битвы
+ const enemy = await Enemy.findByPk(1); // Случайный враг
+ const battle = await Battle.create({
+ character: character.telegram_id,
+ enemy: enemy.id,
+ enemy_hp: enemy.hp,
+ logs: [],
+ status: "active",
+ });
+
+ // Генерация ссылки на Miniapp
+ const miniappUrl = `https://web-bot.campfiregg.ru/battle?battleId=${battle.id}&playerId=${character.telegram_id}`;
+
+ await ctx.reply(
+ `⚔️ Битва началась!\nВаш противник: ${enemy.name}\n🛡️ Уровень: ${enemy.level}\n❤️ Здоровье: ${enemy.hp}\n\nПерейдите в мини-приложение, чтобы продолжить:`,
+ {
+ reply_markup: {
+ inline_keyboard: [
+ [{ text: "Открыть битву", web_app: { url: miniappUrl } }],
+ ],
+ },
+ }
+ );
+});
module.exports = rpg;
diff --git a/server.js b/server.js
index 8c935c4..9a3e435 100644
--- a/server.js
+++ b/server.js
@@ -1,30 +1,48 @@
const express = require('express');
+const { UserModel, CharacterModel, BusinessModel, EnterpriseModel } = global.config;
const app = express();
-const { UserModel, PropertyModel, expToUp } = global.config;
-// Настраиваем сервер для выдачи статических файлов
-app.use(express.static('public'));
+app.use(express.static('public')); // Для выдачи HTML и статики
-// Эндпоинт для получения данных профиля
-app.get('/profile/:id', async (req, res) => {
- const id = req.params.id;
- const user = await UserModel.findByPk(id);
- const property = await PropertyModel.findByPk(id);
+// Эндпоинт для получения всех данных игрока
+app.get('/player/:id', async (req, res) => {
+ const playerId = req.params.id;
- if (!user) return res.status(404).send({ error: 'Пользователь не найден' });
+ try {
+ console.log(playerId)
+ const user = await UserModel.findOne({ where: { telegram_id: req.params.id } });
+ const character = await CharacterModel.findOne({ where: { telegram_id: playerId } });
+ let business = await BusinessModel.findOne({ where: { owner: playerId.toString() } })
+ if(business === null){
+ business = await BusinessModel.findOne( {where: { owner: user.business.id} } )
+ }
+ const enterprises = await EnterpriseModel.findAll({ where: { playerId } });
- res.send({
- username: user.username,
- level: user.level,
- exp: user.exp,
- expToNextLevel: expToUp[user.level],
- money: user.money,
- house: property.house ? property.house.name : "Бездомный",
- car: property.car1 ? property.car1.name : "Пешком",
- mobile: property.mobile ? property.mobile.name : "Нет",
- });
+ if (!user || !character) {
+ return res.status(404).json({ error: "Игрок не найден." });
+ }
+
+ res.json({
+ user: {
+ username: user.username,
+ name: user.name,
+ level: user.level,
+ exp: user.exp,
+ hp: character.hp,
+ max_hp: character.max_hp,
+ money: user.money,
+ dirtymoney: character.dirtymoney,
+ },
+ business: business || { name: "Отсутствует", balance: 0, materials: 0, users: [] },
+ enterprises: enterprises || [],
+ });
+ } catch (err) {
+ console.error(err);
+ res.status(500).json({ error: 'Ошибка сервера' });
+ }
});
+
// Запуск сервера
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => console.log(`Сервер запущен на порту ${PORT}`));