CampFirePlay/public/index.html
Degradin b8debe8fc4 v5.9.3
MiniApp updates
2025-01-17 02:41:24 +03:00

407 lines
13 KiB
HTML
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.

<!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;
}
.container {
max-width: 600px;
margin: 20px auto;
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: inline-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: 50%;
}
.emoji {
font-size: 1.3em;
}
.resource-icon {
font-size: 1.5em;
}
.enterprise {
padding: 15px;
background-color: #f9f9f9;
border-radius: 10px;
margin-top: 10px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}
.profile-container {
position: relative;
width: 100px;
height: 100px;
margin: 0 auto;
}
.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-ring {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
z-index: 1;
}
svg {
transform: rotate(-90deg);
}
circle {
transition: stroke-dashoffset 1s;
}
.level-ring {
stroke-width: 10;
fill: transparent;
}
.profile-level-ring {
stroke: #e26f22;
}
.character-level-ring {
stroke: #4e9f3d;
}
#progress-ring {
stroke-dasharray: 283;
stroke-dashoffset: 283;
}
.level-circle {
position: absolute;
bottom: -7px;
right: 10px;
width: 30px;
height: 30px;
background-color: #e26f22;
border-radius: 50%;
color: white;
display: flex;
justify-content: center;
align-items: center;
font-weight: bold;
font-size: 14px;
}
.progress-bar {
margin-top: 15px;
background-color: #ddd;
border-radius: 10px;
height: 10px;
width: 100%;
}
.progress-hp {
height: 100%;
border-radius: 10px;
background-color: #e26f22;
transition: width 0.5s ease;
display: flex;
justify-content: center;
align-items: center;
font-weight: bold;
font-size: 14px;
}
.progress-stamina {
height: 100%;
border-radius: 10px;
background-color: #4ba100;
transition: width 0.5s ease;
display: flex;
justify-content: center;
align-items: center;
font-weight: bold;
font-size: 14px;
}
.fire-stats {
display: flex;
justify-content: space-between;
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;
}
.circle {
stroke-width: 10;
fill: transparent;
transform: rotate(-90deg);
}
.profile-level-ring {
stroke: #e26f22;
stroke-dasharray: 283;
stroke-dashoffset: 283;
}
.character-level-ring {
stroke: #4e9f3d;
stroke-dasharray: 283;
stroke-dashoffset: 283;
}
/* Для создания полукругов */
.circle {
transform-origin: center;
}
.profile-level-ring {
stroke-dasharray: 141.5; /* половина окружности */
}
.character-level-ring {
stroke-dasharray: 141.5; /* половина окружности */
transform: rotate(180deg); /* Поворот правого полукруга */
}
</style>
<script src="https://telegram.org/js/telegram-web-app.js"></script>
</head>
<body>
<div class="container">
<div class="title">📜 Меню игрока</div>
<div class="profile-container">
<div id="profile-img" class="profile-img"></div>
<div class="progress-ring">
<svg width="100" height="100">
<circle class="profile-level-ring circle" cx="50%" cy="50%" r="45%"/>
<circle class="character-level-ring circle" cx="50%" cy="50%" r="45%"/>
</svg>
<div id="level-circle" class="level-circle"></div>
</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')`;
}
// Полоса опыта (прогресс бар вокруг аватарки)
const progressRing = document.querySelectorAll("circle");
const expProgress = (user.profileExp / user.profileExpToUp) * 100;
const offset = 283 - (283 * expProgress) / 100;
progressRing[0].style.strokeDashoffset = offset; // Левый полукруг для уровня профиля
const characterProgress = (user.characterLevel / user.characterExpToUp) * 100;
const characterOffset = 283 - (283 * characterProgress) / 100;
progressRing[1].style.strokeDashoffset = characterOffset; // Правый полукруг для уровня персонажа
// Уровень в кружке
document.getElementById("level-circle").textContent = user.profileLevel;
// Установка прогресса HP и Стамины
const hpProgress = (user.hp / user.maxHp) * 100;
const staminaProgress = (user.stamina / user.maxStamina) * 100;
document.getElementById("hp-bar").textContent = `${hpProgress}%`;
document.getElementById('hp-bar').style.width = `${hpProgress}%`;
document.getElementById("stamina-bar").textContent = `${staminaProgress}%`;
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}
`;
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>