393 lines
13 KiB
HTML
393 lines
13 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="ru">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<title>Меню игрока</title>
|
||
<style>
|
||
/* Общие стили */
|
||
body {
|
||
font-family: 'Arial', sans-serif;
|
||
margin: 0;
|
||
padding: 0;
|
||
background-color: #f4f7fc;
|
||
color: #333;
|
||
display: flex;
|
||
justify-content: center;
|
||
align-items: center;
|
||
}
|
||
|
||
/* Контейнер для контента */
|
||
.container {
|
||
max-width: 600px;
|
||
width: 100%;
|
||
background: white;
|
||
padding: 20px;
|
||
border-radius: 15px;
|
||
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
|
||
font-size: 16px;
|
||
}
|
||
|
||
/* Заголовки */
|
||
.title {
|
||
font-size: 28px;
|
||
font-weight: bold;
|
||
text-align: center;
|
||
margin-bottom: 20px;
|
||
color: #e26f22;
|
||
}
|
||
|
||
.section {
|
||
margin-bottom: 20px;
|
||
}
|
||
|
||
.section h2 {
|
||
font-size: 20px;
|
||
margin-bottom: 10px;
|
||
color: #e26f22;
|
||
}
|
||
|
||
.section p {
|
||
margin: 5px 0;
|
||
}
|
||
|
||
.section span {
|
||
font-weight: bold;
|
||
}
|
||
|
||
/* Кнопка */
|
||
.button {
|
||
display: block;
|
||
background-color: #e26f22;
|
||
color: white;
|
||
padding: 10px 20px;
|
||
text-decoration: none;
|
||
border-radius: 5px;
|
||
font-size: 16px;
|
||
margin-top: 20px;
|
||
text-align: center;
|
||
width: 100%;
|
||
}
|
||
|
||
/* Профиль */
|
||
.profile-section {
|
||
display: flex;
|
||
justify-content: space-between;
|
||
align-items: center;
|
||
margin-bottom: 20px;
|
||
}
|
||
|
||
.profile-img {
|
||
width: 100px;
|
||
height: 100px;
|
||
border-radius: 50%;
|
||
background-size: cover;
|
||
background-position: center;
|
||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||
}
|
||
|
||
.progress-circle {
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
}
|
||
|
||
.circle-container {
|
||
position: relative;
|
||
width: 100px;
|
||
height: 100px;
|
||
margin-bottom: 10px;
|
||
}
|
||
|
||
.circle {
|
||
stroke-width: 10;
|
||
fill: transparent;
|
||
transform-origin: center;
|
||
transform: rotate(-90deg);
|
||
}
|
||
|
||
.background-ring {
|
||
stroke: #ddd;
|
||
}
|
||
|
||
.progress-ring {
|
||
stroke: #e26f22;
|
||
stroke-dasharray: 251;
|
||
stroke-dashoffset: 251;
|
||
transition: stroke-dashoffset 1s;
|
||
}
|
||
|
||
.circle-text {
|
||
position: absolute;
|
||
top: 50%;
|
||
left: 50%;
|
||
transform: translate(-50%, -50%);
|
||
font-size: 18px;
|
||
font-weight: bold;
|
||
}
|
||
|
||
/* Прогресс-бары */
|
||
.progress-bar {
|
||
background-color: #ddd;
|
||
border-radius: 10px;
|
||
height: 10px;
|
||
width: 100%;
|
||
margin-bottom: 10px;
|
||
overflow: hidden;
|
||
}
|
||
|
||
.progress-hp, .progress-stamina {
|
||
height: 100%;
|
||
border-radius: 10px;
|
||
transition: width 0.5s ease;
|
||
display: flex;
|
||
justify-content: center;
|
||
align-items: center;
|
||
font-weight: bold;
|
||
font-size: 14px;
|
||
color: white;
|
||
}
|
||
|
||
.progress-hp {
|
||
background-color: #e26f22;
|
||
}
|
||
|
||
.progress-stamina {
|
||
background-color: #4ba100;
|
||
}
|
||
|
||
/* Статистика игрока */
|
||
.fire-stats {
|
||
display: grid;
|
||
grid-template-columns: repeat(2, 1fr);
|
||
gap: 10px;
|
||
background-color: #f9f9f9;
|
||
padding: 10px;
|
||
margin-top: 15px;
|
||
border-radius: 8px;
|
||
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
|
||
}
|
||
|
||
.fire-stats .stat {
|
||
text-align: center;
|
||
}
|
||
|
||
.fire-stats .stat span {
|
||
font-weight: bold;
|
||
}
|
||
|
||
/* Предприятия */
|
||
.enterprise {
|
||
padding: 15px;
|
||
background-color: #f9f9f9;
|
||
border-radius: 10px;
|
||
margin-top: 10px;
|
||
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
|
||
}
|
||
|
||
.enterprise strong {
|
||
display: block;
|
||
margin-bottom: 5px;
|
||
}
|
||
|
||
.progress-bar-inner {
|
||
background-color: #e26f22;
|
||
height: 10px;
|
||
border-radius: 5px;
|
||
transition: width 0.5s ease;
|
||
}
|
||
</style>
|
||
<script src="https://telegram.org/js/telegram-web-app.js"></script>
|
||
</head>
|
||
<body>
|
||
<div class="container">
|
||
<div class="title">📜 Меню игрока</div>
|
||
|
||
<div class="profile-section">
|
||
<div id="profile-img" class="profile-img"></div>
|
||
<div class="progress-circle">
|
||
<div class="circle-container">
|
||
<svg class="circle" width="100" height="100">
|
||
<circle class="background-ring" cx="50" cy="50" r="40"></circle>
|
||
<circle class="progress-ring" id="profile-progress" cx="50" cy="50" r="40"></circle>
|
||
</svg>
|
||
<div class="circle-text" id="profile-level">0</div>
|
||
</div>
|
||
<p>Профиль</p>
|
||
</div>
|
||
<div class="progress-circle">
|
||
<div class="circle-container">
|
||
<svg class="circle" width="100" height="100">
|
||
<circle class="background-ring" cx="50" cy="50" r="40"></circle>
|
||
<circle class="progress-ring" id="character-progress" cx="50" cy="50" r="40"></circle>
|
||
</svg>
|
||
<div class="circle-text" id="character-level">0</div>
|
||
</div>
|
||
<p>Персонаж</p>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="progress-bar">
|
||
<div class="progress-hp" id="hp-bar"></div>
|
||
</div>
|
||
|
||
<div class="progress-bar">
|
||
<div class="progress-stamina" id="stamina-bar"></div>
|
||
</div>
|
||
|
||
<div class="fire-stats">
|
||
<div class="stat">
|
||
<p>Сила</p>
|
||
<span id="force">—</span>
|
||
</div>
|
||
<div class="stat">
|
||
<p>Интеллект</p>
|
||
<span id="intelligence">—</span>
|
||
</div>
|
||
<div class="stat">
|
||
<p>Выносливость</p>
|
||
<span id="endurance">—</span>
|
||
</div>
|
||
<div class="stat">
|
||
<p>Стойкость</p>
|
||
<span id="resilience">—</span>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="section">
|
||
<h2>👤 Личные данные</h2>
|
||
<p>Имя: <span id="name">—</span></p>
|
||
<p>Telegram ID: <span id="telegramID">—</span></p>
|
||
</div>
|
||
|
||
<div class="section">
|
||
<h2>👤 Профиль</h2>
|
||
<p>Деньги: ₽<span id="money">—</span></p>
|
||
<p>Грязные деньги: ₽<span id="dirtymoney">—</span></p>
|
||
</div>
|
||
|
||
<div class="section">
|
||
<h2>🏢 Организация</h2>
|
||
<p>Название: <span id="business-name">—</span></p>
|
||
<p>Баланс: ₽<span id="business-balance">—</span></p>
|
||
<p>Материалы: <span id="business-materials">—</span></p>
|
||
</div>
|
||
|
||
<div class="section">
|
||
<h2>🏭 Предприятия</h2>
|
||
<div id="enterprises">
|
||
<p>Нет активных предприятий.</p>
|
||
</div>
|
||
</div>
|
||
|
||
<a href="https://t.me/CampFireGameBot" class="button">🏠 Перейти в чат бота</a>
|
||
</div>
|
||
|
||
<script>
|
||
const tg = window.Telegram.WebApp;
|
||
const playerId = tg.initDataUnsafe.user.id;
|
||
|
||
fetch(`/player/${playerId}`)
|
||
.then(response => response.json())
|
||
.then(data => {
|
||
const { user, business, enterprises } = data;
|
||
|
||
// Личные данные
|
||
document.getElementById("name").textContent = user.name || user.username;
|
||
document.getElementById("telegramID").textContent = user.telegramID;
|
||
|
||
// Профиль
|
||
document.getElementById("money").textContent = user.money;
|
||
document.getElementById("dirtymoney").textContent = user.dirtymoney;
|
||
|
||
// Устанавливаем картинку профиля
|
||
const profileImg = document.getElementById("profile-img");
|
||
const profilePhotoUrl = tg.initDataUnsafe.user.photo_url;
|
||
|
||
if (profilePhotoUrl) {
|
||
profileImg.style.backgroundImage = `url(${profilePhotoUrl})`;
|
||
} else {
|
||
profileImg.style.backgroundImage = `url('https://via.placeholder.com/100')`;
|
||
}
|
||
|
||
// Уровни профиля и персонажа
|
||
document.getElementById("profile-level").textContent = user.profileLevel;
|
||
document.getElementById("character-level").textContent = user.characterLevel;
|
||
|
||
const profileProgress = document.getElementById("profile-progress");
|
||
const characterProgress = document.getElementById("character-progress");
|
||
profileProgress.style.strokeDashoffset = 251 - (251 * user.profileLevel / 100);
|
||
characterProgress.style.strokeDashoffset = 251 - (251 * user.characterLevel / 100);
|
||
|
||
// Установка прогресса HP и Стамины
|
||
const hpProgress = (user.hp / user.maxHp) * 100;
|
||
const staminaProgress = (user.stamina / user.maxStamina) * 100;
|
||
|
||
document.getElementById("hp-bar").style.width = `${hpProgress}%`;
|
||
document.getElementById("stamina-bar").style.width = `${staminaProgress}%`;
|
||
|
||
// Характеристики FIRE
|
||
document.getElementById("force").textContent = user.force;
|
||
document.getElementById("intelligence").textContent = user.intelligence;
|
||
document.getElementById("endurance").textContent = user.endurance;
|
||
document.getElementById("resilience").textContent = user.resilience;
|
||
|
||
// Организация
|
||
document.getElementById("business-name").textContent = business.name;
|
||
document.getElementById("business-balance").textContent = business.balance;
|
||
document.getElementById("business-materials").textContent = business.materials;
|
||
|
||
// Предприятия
|
||
const enterprisesDiv = document.getElementById("enterprises");
|
||
if (enterprises.length > 0) {
|
||
enterprisesDiv.innerHTML = "";
|
||
enterprises.forEach(ent => {
|
||
const div = document.createElement("div");
|
||
div.classList.add("enterprise");
|
||
div.innerHTML = `
|
||
<strong>${ent.name}</strong><br>
|
||
Тип ресурса: ${getResourceIcon(ent.resourceType)} ${getResourceName(ent.resourceType)}<br>
|
||
Уровень: ${ent.level}<br>
|
||
Эффективность: ${ent.efficiency}/час<br>
|
||
Заполненность склада: ${ent.currentResources}/${ent.warehouseCapacity}
|
||
`;
|
||
// Добавляем прогрессбар заполненности склада
|
||
const progress = (ent.currentResources / ent.warehouseCapacity) * 100;
|
||
const progressBar = document.createElement("div");
|
||
progressBar.classList.add("progress-bar");
|
||
progressBar.innerHTML = `<div class="progress-bar-inner" style="width: ${progress}%"></div>`;
|
||
div.appendChild(progressBar);
|
||
enterprisesDiv.appendChild(div);
|
||
});
|
||
}
|
||
})
|
||
.catch(err => {
|
||
console.error("Ошибка загрузки данных:", err);
|
||
});
|
||
|
||
function getResourceIcon(resource) {
|
||
switch (resource.toLowerCase()) {
|
||
case 'wood': return '🌳';
|
||
case 'metall': return '🛠️';
|
||
case 'oil': return '🛢️';
|
||
case 'coal': return '⛏️';
|
||
case 'gold': return '💰';
|
||
case 'diamond': return '💎';
|
||
default: return '⚙️';
|
||
}
|
||
}
|
||
|
||
function getResourceName(resource) {
|
||
switch (resource.toLowerCase()) {
|
||
case 'wood': return 'Дерево';
|
||
case 'metall': return 'Металл';
|
||
case 'oil': return 'Нефть';
|
||
case 'coal': return 'Уголь';
|
||
case 'gold': return 'Золото';
|
||
case 'diamond': return 'Алмазы';
|
||
default: return 'Ресурс';
|
||
}
|
||
}
|
||
</script>
|
||
</body>
|
||
</html> |