CampFirePlay/public/index.html
2025-01-18 01:37:29 +03:00

649 lines
18 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>
/* Общие стили */
<<<<<<< Updated upstream
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);
}
=======
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);
}
>>>>>>> Stashed changes
circle {
transition: stroke-dashoffset 1s;
}
<<<<<<< Updated upstream
.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;
}
=======
.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-origin: center;
}
.profile-level-ring {
stroke-dasharray: 141.5; /* Половина окружности */
}
.character-level-ring {
stroke-dasharray: 141.5; /* Половина окружности */
transform: rotate(180deg); /* Поворот правого полукруга */
}
>>>>>>> Stashed changes
</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">
<<<<<<< Updated upstream
<svg class="circle" width="100" height="100">
=======
<svg class="circle">
>>>>>>> Stashed changes
<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>
<<<<<<< Updated upstream
</div>
<p>Профиль</p>
</div>
<div class="progress-circle">
<div class="circle-container">
<svg class="circle" width="100" height="100">
=======
<p>Профиль</p>
</div>
<div class="circle-container">
<svg class="circle">
>>>>>>> Stashed changes
<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>
<<<<<<< Updated upstream
</div>
<p>Персонаж</p>
=======
<p>Персонаж</p>
</div>
>>>>>>> Stashed changes
</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;
<<<<<<< Updated upstream
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);
=======
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);
// Уровень в кружке
document.getElementById("level-circle").textContent = user.profileLevel;
>>>>>>> Stashed changes
// Установка прогресса 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");
<<<<<<< Updated upstream
progressBar.innerHTML = `<div class="progress-bar-inner" style="width: ${progress}%"></div>`;
=======
progressBar.innerHTML = `<div class="progress-hp" style="width: ${progress}%">${progress}%</div>`;
>>>>>>> Stashed changes
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>