Compare commits
10 Commits
fe6bf5cf29
...
6638ab99f3
| Author | SHA1 | Date | |
|---|---|---|---|
| 6638ab99f3 | |||
| f23a79d618 | |||
| 8110f39ef5 | |||
| 95f3dc7f20 | |||
| 2570012c59 | |||
| dc3e2f682e | |||
| 5485dce2d3 | |||
| 396d21bcf4 | |||
| 3fe8a47e04 | |||
| 50535ec777 |
@@ -2,3 +2,5 @@ __pycache__/
|
|||||||
*.pyc
|
*.pyc
|
||||||
*.pyo
|
*.pyo
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
cs2_simulator.db
|
||||||
|
*.log
|
||||||
|
|||||||
+2248
-61
File diff suppressed because it is too large
Load Diff
@@ -15,6 +15,14 @@ from rpu import get_user_rpu, calculate_rpu_level, get_rpu_description
|
|||||||
admin_router = APIRouter(prefix="/admin", tags=["admin"])
|
admin_router = APIRouter(prefix="/admin", tags=["admin"])
|
||||||
templates = Jinja2Templates(directory="templates")
|
templates = Jinja2Templates(directory="templates")
|
||||||
|
|
||||||
|
def money_filter(value):
|
||||||
|
try:
|
||||||
|
return "{:,.0f}".format(float(value)).replace(",", " ")
|
||||||
|
except (ValueError, TypeError):
|
||||||
|
return "0"
|
||||||
|
|
||||||
|
templates.env.filters["money"] = money_filter
|
||||||
|
|
||||||
# Загрузка конфигов
|
# Загрузка конфигов
|
||||||
CASES_FILE = Path("cases.json")
|
CASES_FILE = Path("cases.json")
|
||||||
MAINPAGE_FILE = Path("mainpage.json")
|
MAINPAGE_FILE = Path("mainpage.json")
|
||||||
@@ -93,8 +101,7 @@ async def admin_dashboard(
|
|||||||
|
|
||||||
recent_users = db.query(User).order_by(desc(User.created_at)).limit(10).all()
|
recent_users = db.query(User).order_by(desc(User.created_at)).limit(10).all()
|
||||||
|
|
||||||
return templates.TemplateResponse("admin/dashboard.html", {
|
return templates.TemplateResponse(request, "admin/dashboard.html", {
|
||||||
"request": request,
|
|
||||||
"user": admin,
|
"user": admin,
|
||||||
"total_users": total_users,
|
"total_users": total_users,
|
||||||
"total_items": total_items,
|
"total_items": total_items,
|
||||||
@@ -137,13 +144,13 @@ async def admin_users(
|
|||||||
"balance": u.balance,
|
"balance": u.balance,
|
||||||
"is_admin": u.is_admin,
|
"is_admin": u.is_admin,
|
||||||
"created_at": u.created_at,
|
"created_at": u.created_at,
|
||||||
"inventory_items": u.inventory_items,
|
"case_openings": db.query(CaseOpening).filter(CaseOpening.user_id == u.id).count(),
|
||||||
"case_openings": u.case_openings,
|
"contracts": db.query(Contract).filter(Contract.user_id == u.id).count(),
|
||||||
|
"inventory_count": db.query(InventoryItem).filter(InventoryItem.user_id == u.id).count(),
|
||||||
"rpu_level": round(calculate_rpu_level(rpu))
|
"rpu_level": round(calculate_rpu_level(rpu))
|
||||||
})
|
})
|
||||||
|
|
||||||
return templates.TemplateResponse("admin/users.html", {
|
return templates.TemplateResponse(request, "admin/users.html", {
|
||||||
"request": request,
|
|
||||||
"user": admin,
|
"user": admin,
|
||||||
"users": users_with_rpu,
|
"users": users_with_rpu,
|
||||||
"search": search
|
"search": search
|
||||||
@@ -168,8 +175,7 @@ async def admin_user_detail(
|
|||||||
InventoryItem.user_id == user_id
|
InventoryItem.user_id == user_id
|
||||||
).order_by(desc(InventoryItem.obtained_at)).limit(50).all()
|
).order_by(desc(InventoryItem.obtained_at)).limit(50).all()
|
||||||
|
|
||||||
return templates.TemplateResponse("admin/user_detail.html", {
|
return templates.TemplateResponse(request, "admin/user_detail.html", {
|
||||||
"request": request,
|
|
||||||
"user": admin,
|
"user": admin,
|
||||||
"target_user": target_user,
|
"target_user": target_user,
|
||||||
"total_items": total_items,
|
"total_items": total_items,
|
||||||
@@ -201,8 +207,7 @@ async def admin_cases(
|
|||||||
"image_url": item.get("image_url", "")
|
"image_url": item.get("image_url", "")
|
||||||
})
|
})
|
||||||
|
|
||||||
return templates.TemplateResponse("admin/cases.html", {
|
return templates.TemplateResponse(request, "admin/cases.html", {
|
||||||
"request": request,
|
|
||||||
"user": admin,
|
"user": admin,
|
||||||
"cases": cases,
|
"cases": cases,
|
||||||
"mainpage": mainpage,
|
"mainpage": mainpage,
|
||||||
@@ -282,6 +287,9 @@ async def admin_give_item(
|
|||||||
db.add(inventory_item)
|
db.add(inventory_item)
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
|
from achievements import check_collection_achievements
|
||||||
|
check_collection_achievements(db, user_id)
|
||||||
|
|
||||||
return JSONResponse({
|
return JSONResponse({
|
||||||
"success": True,
|
"success": True,
|
||||||
"message": f"Предмет '{item_data.get('market_hash_name')}' выдан пользователю {target_user.username}"
|
"message": f"Предмет '{item_data.get('market_hash_name')}' выдан пользователю {target_user.username}"
|
||||||
|
|||||||
+64
@@ -103,6 +103,66 @@ def load_custom_items() -> List[dict]:
|
|||||||
|
|
||||||
return custom_items
|
return custom_items
|
||||||
|
|
||||||
|
# ─── Генерация sub-вариаций цен и float ───────────────────────────────────
|
||||||
|
def generate_item_variants(num_variants: int = 6):
|
||||||
|
"""Для каждого предмета генерирует sub-вариации с разными ценами и float.
|
||||||
|
|
||||||
|
Оригиналы остаются на своих местах (индексы 0..N-1 не меняются),
|
||||||
|
sub-вариации добавляются в конец списка (индексы N..N+N*5-1),
|
||||||
|
чтобы не ломать ссылки по индексам (cases.json, база данных).
|
||||||
|
"""
|
||||||
|
global ALL_ITEMS
|
||||||
|
n_originals = len(ALL_ITEMS)
|
||||||
|
sub_variants = []
|
||||||
|
|
||||||
|
for idx, item in enumerate(ALL_ITEMS):
|
||||||
|
base_price = item.get("price_rub", 0)
|
||||||
|
wr = item.get("wear_range", [0, 1])
|
||||||
|
mid = item.get("mid_float_used", 0.5)
|
||||||
|
wr_min, wr_max = wr
|
||||||
|
f_range = max(wr_max - wr_min, 0.001)
|
||||||
|
|
||||||
|
# v=0 — сам оригинал (оставляем как есть)
|
||||||
|
# v=1..num_variants-1 — sub-вариации (добавляем в конец)
|
||||||
|
for v in range(1, num_variants):
|
||||||
|
variant = dict(item)
|
||||||
|
variant["is_subvariant"] = True
|
||||||
|
t = v / (num_variants - 1) if num_variants > 1 else 0
|
||||||
|
|
||||||
|
# price factor: 0.55 to 1.40 across variants
|
||||||
|
factor = 0.55 + t * 0.85
|
||||||
|
factor += random.uniform(-0.05, 0.05)
|
||||||
|
factor = max(0.30, min(1.50, factor))
|
||||||
|
|
||||||
|
p = int(base_price * factor)
|
||||||
|
if p >= 1_000_000:
|
||||||
|
prefix = p // 1000
|
||||||
|
suffix = random.randint(100, 999)
|
||||||
|
p = prefix * 1000 + suffix
|
||||||
|
elif p >= 100_000:
|
||||||
|
prefix = p // 100
|
||||||
|
suffix = random.randint(10, 99)
|
||||||
|
p = prefix * 100 + suffix
|
||||||
|
elif p >= 10_000:
|
||||||
|
prefix = p // 10
|
||||||
|
suffix = random.randint(1, 9)
|
||||||
|
p = prefix * 10 + suffix
|
||||||
|
variant["price_rub"] = max(p, 100)
|
||||||
|
variant["price_usd"] = round(variant["price_rub"] / 100, 2)
|
||||||
|
|
||||||
|
# float spreads across the wear range
|
||||||
|
float_offset = -0.4 + t * 0.8
|
||||||
|
float_offset += random.uniform(-0.1, 0.1)
|
||||||
|
new_mid = mid + float_offset * f_range
|
||||||
|
new_mid = max(wr_min + 0.001, min(wr_max - 0.001, new_mid))
|
||||||
|
variant["mid_float_used"] = round(new_mid, 4)
|
||||||
|
|
||||||
|
sub_variants.append(variant)
|
||||||
|
|
||||||
|
ALL_ITEMS = ALL_ITEMS + sub_variants
|
||||||
|
print(f"Сгенерировано {len(sub_variants)} sub-вариаций для {n_originals} предметов (x{num_variants})")
|
||||||
|
print(f"Оригиналы: индексы 0..{n_originals - 1}, sub-вариации: {n_originals}..{len(ALL_ITEMS) - 1}")
|
||||||
|
|
||||||
# ─── Загрузка основных данных ─────────────────────────────────────────────
|
# ─── Загрузка основных данных ─────────────────────────────────────────────
|
||||||
def load_base_items() -> List[dict]:
|
def load_base_items() -> List[dict]:
|
||||||
"""Загружает основные предметы из skins.json"""
|
"""Загружает основные предметы из skins.json"""
|
||||||
@@ -126,6 +186,10 @@ CUSTOM_ITEMS = load_custom_items()
|
|||||||
ALL_ITEMS = BASE_ITEMS + CUSTOM_ITEMS
|
ALL_ITEMS = BASE_ITEMS + CUSTOM_ITEMS
|
||||||
print(f"Всего предметов после объединения: {len(ALL_ITEMS):,}")
|
print(f"Всего предметов после объединения: {len(ALL_ITEMS):,}")
|
||||||
|
|
||||||
|
# Генерируем sub-вариации цен и float для каждого предмета
|
||||||
|
generate_item_variants(num_variants=6)
|
||||||
|
print(f"Всего предметов после генерации вариаций: {len(ALL_ITEMS):,}")
|
||||||
|
|
||||||
ITEM_BY_ID: Dict[int, dict] = {i: item for i, item in enumerate(ALL_ITEMS)}
|
ITEM_BY_ID: Dict[int, dict] = {i: item for i, item in enumerate(ALL_ITEMS)}
|
||||||
|
|
||||||
# ─── Глобальные кэши / индексы ──────────────────────────────────────────────
|
# ─── Глобальные кэши / индексы ──────────────────────────────────────────────
|
||||||
|
|||||||
@@ -1448,5 +1448,13 @@
|
|||||||
],
|
],
|
||||||
"image_url": "",
|
"image_url": "",
|
||||||
"description": ""
|
"description": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "dildo_case",
|
||||||
|
"display_name": "Dildo Case",
|
||||||
|
"price_open": 149.0,
|
||||||
|
"items": [],
|
||||||
|
"image_url": "",
|
||||||
|
"description": "Самые сомнительные предметы коллекции Dildo"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
+2483
-23
File diff suppressed because it is too large
Load Diff
+14
@@ -162,6 +162,7 @@ class Achievement(Base):
|
|||||||
requirement_value = Column(Integer, nullable=False) # how many
|
requirement_value = Column(Integer, nullable=False) # how many
|
||||||
reward_amount = Column(Float, default=0.0) # bonus rubles
|
reward_amount = Column(Float, default=0.0) # bonus rubles
|
||||||
sort_order = Column(Integer, default=0)
|
sort_order = Column(Integer, default=0)
|
||||||
|
hidden = Column(Boolean, default=False) # секретные достижения
|
||||||
|
|
||||||
user_achievements = relationship("UserAchievement", back_populates="achievement")
|
user_achievements = relationship("UserAchievement", back_populates="achievement")
|
||||||
|
|
||||||
@@ -195,6 +196,19 @@ class ActivityFeed(Base):
|
|||||||
|
|
||||||
Base.metadata.create_all(bind=engine)
|
Base.metadata.create_all(bind=engine)
|
||||||
|
|
||||||
|
# Миграция: добавляем колонку hidden если её нет
|
||||||
|
try:
|
||||||
|
from sqlalchemy import inspect
|
||||||
|
inspector = inspect(engine)
|
||||||
|
cols = [c["name"] for c in inspector.get_columns("achievements")]
|
||||||
|
if "hidden" not in cols:
|
||||||
|
from sqlalchemy import text
|
||||||
|
with engine.connect() as conn:
|
||||||
|
conn.execute(text("ALTER TABLE achievements ADD COLUMN hidden BOOLEAN DEFAULT 0"))
|
||||||
|
conn.commit()
|
||||||
|
except Exception as e:
|
||||||
|
print(f"[DB] Миграция hidden: {e}")
|
||||||
|
|
||||||
def get_db():
|
def get_db():
|
||||||
db = SessionLocal()
|
db = SessionLocal()
|
||||||
try:
|
try:
|
||||||
|
|||||||
+299
-119
@@ -17,10 +17,23 @@ from pathlib import Path
|
|||||||
from database import get_db, SessionLocal, User, InventoryItem, CaseOpening, Contract, Upgrade, UpgradeRPU
|
from database import get_db, SessionLocal, User, InventoryItem, CaseOpening, Contract, Upgrade, UpgradeRPU
|
||||||
from websocket_manager import manager, crash_game
|
from websocket_manager import manager, crash_game
|
||||||
from achievements import (
|
from achievements import (
|
||||||
seed_achievements, check_achievement, check_open_cases_achievements, check_contracts_achievements,
|
seed_achievements, check_achievement,
|
||||||
check_upgrade_achievements, check_rare_item_achievement, check_knife_achievement,
|
check_open_cases_achievements, check_contracts_achievements,
|
||||||
check_spent_achievements, check_balance_achievement, check_slot_match_achievement,
|
check_upgrade_achievements, check_upgrade_risk_achievements, check_upgrade_result_achievements,
|
||||||
check_slot_plays_achievements, check_inventory_achievement, get_user_achievements
|
check_rare_item_achievement, check_knife_achievement,
|
||||||
|
check_spent_achievements,
|
||||||
|
check_balance_achievements,
|
||||||
|
check_slot_match_achievements, check_slot_plays_achievements,
|
||||||
|
check_slot_match_count_achievements,
|
||||||
|
check_inventory_achievements,
|
||||||
|
check_dildo_achievements, check_dildo_contract_achievement,
|
||||||
|
check_crash_achievements, check_crash_cashout_achievements,
|
||||||
|
check_items_unboxed_achievements, check_total_profit_achievements,
|
||||||
|
check_achievements_count_achievements,
|
||||||
|
check_rare_item_count_achievements, check_knife_count_achievements,
|
||||||
|
check_midnight_case_achievement, check_exact_cases_achievement,
|
||||||
|
check_collection_achievements,
|
||||||
|
get_user_achievements
|
||||||
)
|
)
|
||||||
from auth import (
|
from auth import (
|
||||||
create_user, authenticate_user, create_access_token,
|
create_user, authenticate_user, create_access_token,
|
||||||
@@ -58,6 +71,14 @@ app.include_router(admin_router)
|
|||||||
app.mount("/static", StaticFiles(directory="static"), name="static")
|
app.mount("/static", StaticFiles(directory="static"), name="static")
|
||||||
templates = Jinja2Templates(directory="templates")
|
templates = Jinja2Templates(directory="templates")
|
||||||
|
|
||||||
|
def money_filter(value):
|
||||||
|
try:
|
||||||
|
return "{:,.0f}".format(float(value)).replace(",", " ")
|
||||||
|
except (ValueError, TypeError):
|
||||||
|
return "0"
|
||||||
|
|
||||||
|
templates.env.filters["money"] = money_filter
|
||||||
|
|
||||||
# Создаем отдельный роутер для API оригинального симулятора
|
# Создаем отдельный роутер для API оригинального симулятора
|
||||||
from backend import app as api_app
|
from backend import app as api_app
|
||||||
|
|
||||||
@@ -299,9 +320,9 @@ async def index(request: Request, user: Optional[User] = Depends(get_current_use
|
|||||||
if user:
|
if user:
|
||||||
return RedirectResponse(url="/cases")
|
return RedirectResponse(url="/cases")
|
||||||
|
|
||||||
return templates.TemplateResponse("index.html", {
|
return templates.TemplateResponse(request, "index.html", {
|
||||||
"request": request,
|
"user": None,
|
||||||
"user": None
|
"active_page": "home"
|
||||||
})
|
})
|
||||||
|
|
||||||
@app.get("/login", response_class=HTMLResponse)
|
@app.get("/login", response_class=HTMLResponse)
|
||||||
@@ -310,9 +331,9 @@ async def login_page(request: Request, user: Optional[User] = Depends(get_curren
|
|||||||
if user:
|
if user:
|
||||||
return RedirectResponse(url="/profile")
|
return RedirectResponse(url="/profile")
|
||||||
|
|
||||||
return templates.TemplateResponse("login.html", {
|
return templates.TemplateResponse(request, "login.html", {
|
||||||
"request": request,
|
"user": None,
|
||||||
"user": None
|
"active_page": "login"
|
||||||
})
|
})
|
||||||
|
|
||||||
@app.get("/register", response_class=HTMLResponse)
|
@app.get("/register", response_class=HTMLResponse)
|
||||||
@@ -321,9 +342,9 @@ async def register_page(request: Request, user: Optional[User] = Depends(get_cur
|
|||||||
if user:
|
if user:
|
||||||
return RedirectResponse(url="/profile")
|
return RedirectResponse(url="/profile")
|
||||||
|
|
||||||
return templates.TemplateResponse("register.html", {
|
return templates.TemplateResponse(request, "register.html", {
|
||||||
"request": request,
|
"user": None,
|
||||||
"user": None
|
"active_page": "register"
|
||||||
})
|
})
|
||||||
|
|
||||||
@app.get("/profile", response_class=HTMLResponse)
|
@app.get("/profile", response_class=HTMLResponse)
|
||||||
@@ -348,7 +369,7 @@ async def profile_page(
|
|||||||
|
|
||||||
inventory_items = db.query(InventoryItem).filter(
|
inventory_items = db.query(InventoryItem).filter(
|
||||||
InventoryItem.user_id == user.id
|
InventoryItem.user_id == user.id
|
||||||
).all()
|
).order_by(desc(InventoryItem.obtained_at)).all()
|
||||||
|
|
||||||
valuable_items = sorted(
|
valuable_items = sorted(
|
||||||
inventory_items,
|
inventory_items,
|
||||||
@@ -356,17 +377,54 @@ async def profile_page(
|
|||||||
reverse=True
|
reverse=True
|
||||||
)[:12]
|
)[:12]
|
||||||
|
|
||||||
return templates.TemplateResponse("profile.html", {
|
rarities = set()
|
||||||
"request": request,
|
types = set()
|
||||||
|
enriched_items = []
|
||||||
|
for item in inventory_items:
|
||||||
|
item_data = None
|
||||||
|
for idx, it in enumerate(ALL_ITEMS):
|
||||||
|
if it.get("_id", idx) == item.item_id:
|
||||||
|
item_data = it
|
||||||
|
break
|
||||||
|
if not item_data:
|
||||||
|
item_data = get_item(item.item_id)
|
||||||
|
image_url = ""
|
||||||
|
price_rub = 100
|
||||||
|
if item_data:
|
||||||
|
image_url = item_data.get("image_url", "")
|
||||||
|
price_rub = item_data.get("price_rub", 100)
|
||||||
|
enriched_items.append({
|
||||||
|
"id": item.id,
|
||||||
|
"item_id": item.item_id,
|
||||||
|
"name": item.market_hash_name,
|
||||||
|
"rarity": item.rarity,
|
||||||
|
"wear": item.wear,
|
||||||
|
"float": item.float_value,
|
||||||
|
"type": item.type,
|
||||||
|
"image_url": image_url,
|
||||||
|
"price_rub": price_rub
|
||||||
|
})
|
||||||
|
if item.rarity:
|
||||||
|
rarities.add(item.rarity)
|
||||||
|
if item.type:
|
||||||
|
types.add(item.type)
|
||||||
|
|
||||||
|
return templates.TemplateResponse(request, "profile.html", {
|
||||||
"user": user,
|
"user": user,
|
||||||
"total_items": total_items,
|
"total_items": total_items,
|
||||||
"cases_opened": cases_opened,
|
"cases_opened": cases_opened,
|
||||||
"contracts_completed": contracts_completed,
|
"contracts_completed": contracts_completed,
|
||||||
|
"balance": user.balance,
|
||||||
"recent_openings": recent_openings,
|
"recent_openings": recent_openings,
|
||||||
"recent_contracts": recent_contracts,
|
"recent_contracts": recent_contracts,
|
||||||
"valuable_items": valuable_items,
|
"valuable_items": valuable_items,
|
||||||
|
"inventory_items": enriched_items,
|
||||||
|
"rarities": sorted(rarities),
|
||||||
|
"types": sorted(types),
|
||||||
|
"rarity_order": RARITY_ORDER,
|
||||||
"is_public": False,
|
"is_public": False,
|
||||||
"profile_user": user
|
"profile_user": user,
|
||||||
|
"active_page": "profile"
|
||||||
})
|
})
|
||||||
|
|
||||||
# ═══════════════════════════════════════════════════════════════════════════════
|
# ═══════════════════════════════════════════════════════════════════════════════
|
||||||
@@ -399,17 +457,49 @@ async def public_profile_page(
|
|||||||
|
|
||||||
inventory_items = db.query(InventoryItem).filter(
|
inventory_items = db.query(InventoryItem).filter(
|
||||||
InventoryItem.user_id == profile_user.id
|
InventoryItem.user_id == profile_user.id
|
||||||
).all()
|
).order_by(desc(InventoryItem.obtained_at)).all()
|
||||||
|
|
||||||
rarity_order = {k: v for k, v in RARITY_ORDER.items()}
|
rarity_order = {k: v for k, v in RARITY_ORDER.items()}
|
||||||
|
|
||||||
|
rarities = set()
|
||||||
|
types = set()
|
||||||
|
enriched_items = []
|
||||||
|
for item in inventory_items:
|
||||||
|
item_data = None
|
||||||
|
for idx, it in enumerate(ALL_ITEMS):
|
||||||
|
if it.get("_id", idx) == item.item_id:
|
||||||
|
item_data = it
|
||||||
|
break
|
||||||
|
if not item_data:
|
||||||
|
item_data = get_item(item.item_id)
|
||||||
|
image_url = ""
|
||||||
|
price_rub = 100
|
||||||
|
if item_data:
|
||||||
|
image_url = item_data.get("image_url", "")
|
||||||
|
price_rub = item_data.get("price_rub", 100)
|
||||||
|
enriched_items.append({
|
||||||
|
"id": item.id,
|
||||||
|
"item_id": item.item_id,
|
||||||
|
"name": item.market_hash_name,
|
||||||
|
"rarity": item.rarity,
|
||||||
|
"wear": item.wear,
|
||||||
|
"float": item.float_value,
|
||||||
|
"type": item.type,
|
||||||
|
"image_url": image_url,
|
||||||
|
"price_rub": price_rub
|
||||||
|
})
|
||||||
|
if item.rarity:
|
||||||
|
rarities.add(item.rarity)
|
||||||
|
if item.type:
|
||||||
|
types.add(item.type)
|
||||||
|
|
||||||
valuable_items = sorted(
|
valuable_items = sorted(
|
||||||
inventory_items,
|
inventory_items,
|
||||||
key=lambda x: rarity_order.get(x.rarity, 0),
|
key=lambda x: rarity_order.get(x.rarity, 0),
|
||||||
reverse=True
|
reverse=True
|
||||||
)[:12]
|
)[:12]
|
||||||
|
|
||||||
return templates.TemplateResponse("profile.html", {
|
return templates.TemplateResponse(request, "profile.html", {
|
||||||
"request": request,
|
|
||||||
"user": current_user,
|
"user": current_user,
|
||||||
"profile_user": profile_user,
|
"profile_user": profile_user,
|
||||||
"is_public": True,
|
"is_public": True,
|
||||||
@@ -418,7 +508,12 @@ async def public_profile_page(
|
|||||||
"contracts_completed": contracts_completed,
|
"contracts_completed": contracts_completed,
|
||||||
"recent_openings": recent_openings,
|
"recent_openings": recent_openings,
|
||||||
"recent_contracts": recent_contracts,
|
"recent_contracts": recent_contracts,
|
||||||
"valuable_items": valuable_items
|
"valuable_items": valuable_items,
|
||||||
|
"inventory_items": enriched_items,
|
||||||
|
"rarities": sorted(rarities),
|
||||||
|
"types": sorted(types),
|
||||||
|
"rarity_order": RARITY_ORDER,
|
||||||
|
"active_page": "profile"
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
@@ -499,10 +594,10 @@ async def cases_page(
|
|||||||
|
|
||||||
#print(f"Всего секций для отображения: {len(sections)}")
|
#print(f"Всего секций для отображения: {len(sections)}")
|
||||||
|
|
||||||
return templates.TemplateResponse("cases.html", {
|
return templates.TemplateResponse(request, "cases.html", {
|
||||||
"request": request,
|
|
||||||
"user": user,
|
"user": user,
|
||||||
"sections": sections
|
"sections": sections,
|
||||||
|
"active_page": "cases"
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
@@ -556,74 +651,17 @@ async def contracts_page(
|
|||||||
has_contract = any(c >= 10 for c in group_counts.values())
|
has_contract = any(c >= 10 for c in group_counts.values())
|
||||||
has_knife_contract = len(knife_items) >= 10
|
has_knife_contract = len(knife_items) >= 10
|
||||||
|
|
||||||
return templates.TemplateResponse("contracts.html", {
|
return templates.TemplateResponse(request, "contracts.html", {
|
||||||
"request": request,
|
|
||||||
"user": user,
|
"user": user,
|
||||||
"inventory_items": all_items + knife_items,
|
"inventory_items": all_items + knife_items,
|
||||||
"has_contract": has_contract or has_knife_contract,
|
"has_contract": has_contract or has_knife_contract,
|
||||||
"knife_count": len(knife_items)
|
"knife_count": len(knife_items),
|
||||||
|
"active_page": "contracts"
|
||||||
})
|
})
|
||||||
|
|
||||||
@app.get("/inventory", response_class=HTMLResponse)
|
@app.get("/inventory")
|
||||||
async def inventory_page(
|
async def inventory_redirect():
|
||||||
request: Request,
|
return RedirectResponse(url="/profile")
|
||||||
db: Session = Depends(get_db),
|
|
||||||
user: User = Depends(get_current_user)
|
|
||||||
):
|
|
||||||
inventory_items = db.query(InventoryItem).filter(
|
|
||||||
InventoryItem.user_id == user.id
|
|
||||||
).order_by(desc(InventoryItem.obtained_at)).all()
|
|
||||||
|
|
||||||
rarities = set()
|
|
||||||
types = set()
|
|
||||||
|
|
||||||
enriched_items = []
|
|
||||||
for item in inventory_items:
|
|
||||||
# Ищем предмет по item_id
|
|
||||||
item_data = None
|
|
||||||
for idx, it in enumerate(ALL_ITEMS):
|
|
||||||
if it.get("_id", idx) == item.item_id:
|
|
||||||
item_data = it
|
|
||||||
break
|
|
||||||
|
|
||||||
# Если не нашли, пробуем get_item
|
|
||||||
if not item_data:
|
|
||||||
item_data = get_item(item.item_id)
|
|
||||||
|
|
||||||
image_url = ""
|
|
||||||
price_rub = 100
|
|
||||||
|
|
||||||
if item_data:
|
|
||||||
image_url = item_data.get("image_url", "")
|
|
||||||
price_rub = item_data.get("price_rub", 100)
|
|
||||||
|
|
||||||
enriched_items.append({
|
|
||||||
"id": item.id,
|
|
||||||
"item_id": item.item_id,
|
|
||||||
"name": item.market_hash_name,
|
|
||||||
"rarity": item.rarity,
|
|
||||||
"wear": item.wear,
|
|
||||||
"float": item.float_value,
|
|
||||||
"type": item.type,
|
|
||||||
"obtained_from": item.obtained_from,
|
|
||||||
"obtained_at": item.obtained_at,
|
|
||||||
"image_url": image_url,
|
|
||||||
"price_rub": price_rub
|
|
||||||
})
|
|
||||||
|
|
||||||
if item.rarity:
|
|
||||||
rarities.add(item.rarity)
|
|
||||||
if item.type:
|
|
||||||
types.add(item.type)
|
|
||||||
|
|
||||||
return templates.TemplateResponse("inventory.html", {
|
|
||||||
"request": request,
|
|
||||||
"user": user,
|
|
||||||
"inventory_items": enriched_items,
|
|
||||||
"rarities": sorted(rarities),
|
|
||||||
"types": sorted(types),
|
|
||||||
"rarity_order": RARITY_ORDER
|
|
||||||
})
|
|
||||||
|
|
||||||
# ─── API эндпоинты для веб-интерфейса ─────────────────────────────────────
|
# ─── API эндпоинты для веб-интерфейса ─────────────────────────────────────
|
||||||
|
|
||||||
@@ -855,8 +893,9 @@ async def api_open_case(
|
|||||||
|
|
||||||
# Проверка достижений
|
# Проверка достижений
|
||||||
unlocked_ach = []
|
unlocked_ach = []
|
||||||
|
open_count = db.query(CaseOpening).filter(CaseOpening.user_id == user.id).count()
|
||||||
unlocked_ach += check_open_cases_achievements(db, user.id)
|
unlocked_ach += check_open_cases_achievements(db, user.id)
|
||||||
total_spent = db.query(CaseOpening).filter(CaseOpening.user_id == user.id).count() * price_per_case
|
total_spent = open_count * price_per_case
|
||||||
unlocked_ach += check_spent_achievements(db, user.id, total_spent)
|
unlocked_ach += check_spent_achievements(db, user.id, total_spent)
|
||||||
|
|
||||||
# Проверка на редкий предмет
|
# Проверка на редкий предмет
|
||||||
@@ -866,7 +905,18 @@ async def api_open_case(
|
|||||||
if item_data:
|
if item_data:
|
||||||
unlocked_ach += check_knife_achievement(db, user.id, item_data)
|
unlocked_ach += check_knife_achievement(db, user.id, item_data)
|
||||||
|
|
||||||
unlocked_ach += check_inventory_achievement(db, user.id)
|
unlocked_ach += check_inventory_achievements(db, user.id)
|
||||||
|
unlocked_ach += check_dildo_achievements(db, user.id)
|
||||||
|
unlocked_ach += check_items_unboxed_achievements(db, user.id)
|
||||||
|
unlocked_ach += check_rare_item_count_achievements(db, user.id)
|
||||||
|
unlocked_ach += check_knife_count_achievements(db, user.id)
|
||||||
|
unlocked_ach += check_balance_achievements(db, user.id)
|
||||||
|
unlocked_ach += check_achievements_count_achievements(db, user.id)
|
||||||
|
unlocked_ach += check_midnight_case_achievement(db, user.id)
|
||||||
|
unlocked_ach += check_exact_cases_achievement(db, user.id, open_count)
|
||||||
|
unlocked_ach += check_collection_achievements(db, user.id)
|
||||||
|
profit = user.balance + total_spent
|
||||||
|
unlocked_ach += check_total_profit_achievements(db, user.id, profit)
|
||||||
|
|
||||||
# Запись активности — каждый предмет отдельно
|
# Запись активности — каждый предмет отдельно
|
||||||
for r in results:
|
for r in results:
|
||||||
@@ -1035,7 +1085,12 @@ async def api_submit_contract(
|
|||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
unlocked_ach = check_contracts_achievements(db, user.id)
|
unlocked_ach = check_contracts_achievements(db, user.id)
|
||||||
unlocked_ach += check_inventory_achievement(db, user.id)
|
unlocked_ach += check_inventory_achievements(db, user.id)
|
||||||
|
unlocked_ach += check_balance_achievements(db, user.id)
|
||||||
|
unlocked_ach += check_dildo_achievements(db, user.id)
|
||||||
|
unlocked_ach += check_dildo_contract_achievement(db, user.id)
|
||||||
|
unlocked_ach += check_collection_achievements(db, user.id)
|
||||||
|
unlocked_ach += check_achievements_count_achievements(db, user.id)
|
||||||
|
|
||||||
act = record_activity_own_session(user.id, user.username, "contract",
|
act = record_activity_own_session(user.id, user.username, "contract",
|
||||||
f"🔄 выполнил(а) контракт и получил(а) {result.received_item.market_hash_name}",
|
f"🔄 выполнил(а) контракт и получил(а) {result.received_item.market_hash_name}",
|
||||||
@@ -1116,6 +1171,111 @@ async def get_item_image(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@app.get("/web/api/inventory/item-detail/{inventory_id}")
|
||||||
|
async def api_item_detail(
|
||||||
|
inventory_id: int,
|
||||||
|
db: Session = Depends(get_db),
|
||||||
|
user: User = Depends(get_current_user)
|
||||||
|
):
|
||||||
|
"""Детальная информация о предмете с коллекцией"""
|
||||||
|
inv_item = db.query(InventoryItem).filter(
|
||||||
|
InventoryItem.id == inventory_id,
|
||||||
|
InventoryItem.user_id == user.id
|
||||||
|
).first()
|
||||||
|
if not inv_item:
|
||||||
|
# Also allow viewing if item exists (public profiles)
|
||||||
|
inv_item = db.query(InventoryItem).filter(
|
||||||
|
InventoryItem.id == inventory_id
|
||||||
|
).first()
|
||||||
|
if not inv_item:
|
||||||
|
return JSONResponse(status_code=404, content={"error": "Предмет не найден"})
|
||||||
|
|
||||||
|
item_data = get_item(inv_item.item_id)
|
||||||
|
if not item_data:
|
||||||
|
return JSONResponse(status_code=404, content={"error": "Данные предмета не найдены"})
|
||||||
|
|
||||||
|
collection = item_data.get("collection", "").strip()
|
||||||
|
# fallback to case name
|
||||||
|
if not collection or collection == "Без коллекции":
|
||||||
|
crates = item_data.get("crates_names", [])
|
||||||
|
if crates:
|
||||||
|
collection = f"Case: {crates[0]}"
|
||||||
|
|
||||||
|
item_resp = {
|
||||||
|
"id": inv_item.id,
|
||||||
|
"item_id": inv_item.item_id,
|
||||||
|
"name": inv_item.market_hash_name,
|
||||||
|
"rarity": inv_item.rarity,
|
||||||
|
"wear": inv_item.wear,
|
||||||
|
"float": inv_item.float_value,
|
||||||
|
"type": inv_item.type,
|
||||||
|
"price_rub": item_data.get("price_rub", 100),
|
||||||
|
"image_url": item_data.get("image_url", ""),
|
||||||
|
"collection": collection,
|
||||||
|
"weapon": item_data.get("weapon", ""),
|
||||||
|
"pattern": item_data.get("pattern", ""),
|
||||||
|
}
|
||||||
|
|
||||||
|
# Собираем все предметы коллекции
|
||||||
|
coll_items = []
|
||||||
|
all_owned = True
|
||||||
|
owned_names = set()
|
||||||
|
|
||||||
|
# Получаем все item_id из коллекции
|
||||||
|
from backend import COLLECTIONS_INDEX, extract_base_name, RARITY_ORDER
|
||||||
|
collection_ids = COLLECTIONS_INDEX.get(collection, [])
|
||||||
|
|
||||||
|
# Группируем по базовому имени (без учёта вариантов)
|
||||||
|
seen_base = {}
|
||||||
|
for cid in collection_ids:
|
||||||
|
citem = get_item(cid)
|
||||||
|
if not citem:
|
||||||
|
continue
|
||||||
|
base = extract_base_name(citem.get("market_hash_name", ""))
|
||||||
|
if base and base not in seen_base:
|
||||||
|
seen_base[base] = citem
|
||||||
|
|
||||||
|
# Все предметы пользователя — для проверки владения
|
||||||
|
user_items = db.query(InventoryItem.item_id).filter(
|
||||||
|
InventoryItem.user_id == user.id
|
||||||
|
).all()
|
||||||
|
user_item_ids = {iid for (iid,) in user_items}
|
||||||
|
|
||||||
|
# Сортируем по редкости (низшая → высшая)
|
||||||
|
sorted_bases = sorted(seen_base.values(), key=lambda x: RARITY_ORDER.get(x.get("rarity", "Unknown"), -1))
|
||||||
|
|
||||||
|
for citem in sorted_bases:
|
||||||
|
base = extract_base_name(citem.get("market_hash_name", ""))
|
||||||
|
owned = False
|
||||||
|
for u_id in user_item_ids:
|
||||||
|
u_item = get_item(u_id)
|
||||||
|
if u_item and extract_base_name(u_item.get("market_hash_name", "")) == base:
|
||||||
|
owned = True
|
||||||
|
owned_names.add(base)
|
||||||
|
break
|
||||||
|
|
||||||
|
if not owned:
|
||||||
|
all_owned = False
|
||||||
|
|
||||||
|
coll_items.append({
|
||||||
|
"base_name": base,
|
||||||
|
"market_hash_name": citem.get("market_hash_name", ""),
|
||||||
|
"weapon": citem.get("weapon", ""),
|
||||||
|
"pattern": citem.get("pattern", ""),
|
||||||
|
"rarity": citem.get("rarity", ""),
|
||||||
|
"rarity_level": RARITY_ORDER.get(citem.get("rarity", "Unknown"), -1),
|
||||||
|
"owned": owned,
|
||||||
|
"image_url": citem.get("image_url", ""),
|
||||||
|
})
|
||||||
|
|
||||||
|
return {
|
||||||
|
"item": item_resp,
|
||||||
|
"collection_name": collection if collection else "",
|
||||||
|
"items": coll_items,
|
||||||
|
"all_owned": all_owned,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def get_case_items(case_name: str) -> List[dict]:
|
def get_case_items(case_name: str) -> List[dict]:
|
||||||
"""Получает предметы кейса по его имени"""
|
"""Получает предметы кейса по его имени"""
|
||||||
items = []
|
items = []
|
||||||
@@ -1440,8 +1600,7 @@ async def case_detail_page(
|
|||||||
"image_url": item["image_url"]
|
"image_url": item["image_url"]
|
||||||
})
|
})
|
||||||
|
|
||||||
return templates.TemplateResponse("case_detail.html", {
|
return templates.TemplateResponse(request, "case_detail.html", {
|
||||||
"request": request,
|
|
||||||
"user": user,
|
"user": user,
|
||||||
"case_name": case_name,
|
"case_name": case_name,
|
||||||
"case_display_name": case_config.get('display_name', case_name),
|
"case_display_name": case_config.get('display_name', case_name),
|
||||||
@@ -1452,7 +1611,8 @@ async def case_detail_page(
|
|||||||
"items_by_rarity": items_by_rarity,
|
"items_by_rarity": items_by_rarity,
|
||||||
"sorted_rarities": sorted_rarities,
|
"sorted_rarities": sorted_rarities,
|
||||||
"rarities_count": rarities_count,
|
"rarities_count": rarities_count,
|
||||||
"case_items": case_items_json
|
"case_items": case_items_json,
|
||||||
|
"active_page": "cases"
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
@@ -1588,6 +1748,18 @@ async def api_open_slot_case(
|
|||||||
|
|
||||||
adjusted_weights = get_adjusted_weights(db, user.id)
|
adjusted_weights = get_adjusted_weights(db, user.id)
|
||||||
|
|
||||||
|
# Буст для слотов: чаще выпадают активки
|
||||||
|
SLOT_RARITY_BOOST = {
|
||||||
|
"Covert": 8,
|
||||||
|
"Classified": 4,
|
||||||
|
"Restricted": 2,
|
||||||
|
"Rare Special Item": 12,
|
||||||
|
"Extraordinary": 10
|
||||||
|
}
|
||||||
|
for rarity, boost in SLOT_RARITY_BOOST.items():
|
||||||
|
if rarity in adjusted_weights:
|
||||||
|
adjusted_weights[rarity] *= boost
|
||||||
|
|
||||||
# Баним: принудительно разные группы на всех барабанах
|
# Баним: принудительно разные группы на всех барабанах
|
||||||
if user.is_banned:
|
if user.is_banned:
|
||||||
group1, item1 = pick_slot_reel(grouped_items, adjusted_weights)
|
group1, item1 = pick_slot_reel(grouped_items, adjusted_weights)
|
||||||
@@ -1621,11 +1793,11 @@ async def api_open_slot_case(
|
|||||||
|
|
||||||
# Assign activations to each reel's target item
|
# Assign activations to each reel's target item
|
||||||
ACTIVATION_WEIGHTS = [
|
ACTIVATION_WEIGHTS = [
|
||||||
("extra_spin", 0.03),
|
("extra_spin", 0.10),
|
||||||
("double", 0.01),
|
("double", 0.04),
|
||||||
("guaranteed", 0.02),
|
("guaranteed", 0.07),
|
||||||
("free_spin", 0.02),
|
("free_spin", 0.07),
|
||||||
("quintuple", 0.005),
|
("quintuple", 0.02),
|
||||||
]
|
]
|
||||||
def pick_activation():
|
def pick_activation():
|
||||||
r = random.random()
|
r = random.random()
|
||||||
@@ -1637,6 +1809,8 @@ async def api_open_slot_case(
|
|||||||
return ""
|
return ""
|
||||||
|
|
||||||
reel_activations = [pick_activation() for _ in range(3)]
|
reel_activations = [pick_activation() for _ in range(3)]
|
||||||
|
activations_str = ', '.join(a if a else 'none' for a in reel_activations)
|
||||||
|
print(f"[SLOT] activations: {activations_str}")
|
||||||
|
|
||||||
match = False
|
match = False
|
||||||
prize_data = None
|
prize_data = None
|
||||||
@@ -1838,8 +2012,11 @@ async def api_open_slot_case(
|
|||||||
# Проверка достижений для слота
|
# Проверка достижений для слота
|
||||||
unlocked_ach = []
|
unlocked_ach = []
|
||||||
if match:
|
if match:
|
||||||
unlocked_ach += check_slot_match_achievement(db, user.id)
|
unlocked_ach += check_slot_match_achievements(db, user.id)
|
||||||
unlocked_ach += check_slot_plays_achievements(db, user.id)
|
unlocked_ach += check_slot_plays_achievements(db, user.id)
|
||||||
|
unlocked_ach += check_slot_match_count_achievements(db, user.id)
|
||||||
|
unlocked_ach += check_balance_achievements(db, user.id)
|
||||||
|
unlocked_ach += check_achievements_count_achievements(db, user.id)
|
||||||
|
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
@@ -2187,15 +2364,15 @@ async def upgrade_page(
|
|||||||
"probability": round(u.rpu_adjusted_probability or u.probability or 0, 1)
|
"probability": round(u.rpu_adjusted_probability or u.probability or 0, 1)
|
||||||
})
|
})
|
||||||
|
|
||||||
return templates.TemplateResponse("upgrade.html", {
|
return templates.TemplateResponse(request, "upgrade.html", {
|
||||||
"request": request,
|
|
||||||
"user": user,
|
"user": user,
|
||||||
"inventory_items": enriched_items,
|
"inventory_items": enriched_items,
|
||||||
"upgrade_rpu": upgrade_rpu,
|
"upgrade_rpu": upgrade_rpu,
|
||||||
"total_attempts": total_attempts,
|
"total_attempts": total_attempts,
|
||||||
"total_success": total_success,
|
"total_success": total_success,
|
||||||
"success_rate": round(success_rate, 1),
|
"success_rate": round(success_rate, 1),
|
||||||
"recent_upgrades": recent_upgrades
|
"recent_upgrades": recent_upgrades,
|
||||||
|
"active_page": "upgrade"
|
||||||
})
|
})
|
||||||
|
|
||||||
@app.post("/web/api/upgrade/calculate")
|
@app.post("/web/api/upgrade/calculate")
|
||||||
@@ -2402,6 +2579,12 @@ async def api_execute_upgrade(
|
|||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
unlocked_ach = check_upgrade_achievements(db, user.id)
|
unlocked_ach = check_upgrade_achievements(db, user.id)
|
||||||
|
unlocked_ach += check_upgrade_risk_achievements(db, user.id, input_price)
|
||||||
|
unlocked_ach += check_upgrade_result_achievements(db, user.id, success, base_probability, input_price)
|
||||||
|
unlocked_ach += check_dildo_achievements(db, user.id)
|
||||||
|
unlocked_ach += check_balance_achievements(db, user.id)
|
||||||
|
unlocked_ach += check_collection_achievements(db, user.id)
|
||||||
|
unlocked_ach += check_achievements_count_achievements(db, user.id)
|
||||||
|
|
||||||
if success:
|
if success:
|
||||||
act = record_activity_own_session(user.id, user.username, "upgrade",
|
act = record_activity_own_session(user.id, user.username, "upgrade",
|
||||||
@@ -2453,12 +2636,12 @@ async def achievements_page(
|
|||||||
total = len(achievements)
|
total = len(achievements)
|
||||||
unlocked = sum(1 for a in achievements if a["unlocked"])
|
unlocked = sum(1 for a in achievements if a["unlocked"])
|
||||||
|
|
||||||
return templates.TemplateResponse("achievements.html", {
|
return templates.TemplateResponse(request, "achievements.html", {
|
||||||
"request": request,
|
|
||||||
"user": user,
|
"user": user,
|
||||||
"achievements": achievements,
|
"achievements": achievements,
|
||||||
"total": total,
|
"total": total,
|
||||||
"unlocked": unlocked
|
"unlocked": unlocked,
|
||||||
|
"active_page": "achievements"
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
@@ -2485,8 +2668,7 @@ async def activity_page(
|
|||||||
):
|
):
|
||||||
activities = db.query(ActivityFeed).order_by(desc(ActivityFeed.created_at)).limit(50).all()
|
activities = db.query(ActivityFeed).order_by(desc(ActivityFeed.created_at)).limit(50).all()
|
||||||
|
|
||||||
return templates.TemplateResponse("activity.html", {
|
return templates.TemplateResponse(request, "activity.html", {
|
||||||
"request": request,
|
|
||||||
"user": user,
|
"user": user,
|
||||||
"activities": [
|
"activities": [
|
||||||
{
|
{
|
||||||
@@ -2499,7 +2681,8 @@ async def activity_page(
|
|||||||
"created_at": a.created_at.isoformat()
|
"created_at": a.created_at.isoformat()
|
||||||
}
|
}
|
||||||
for a in activities
|
for a in activities
|
||||||
]
|
],
|
||||||
|
"active_page": "activity"
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
@@ -2631,9 +2814,9 @@ async def crash_page(
|
|||||||
request: Request,
|
request: Request,
|
||||||
user: User = Depends(get_current_user)
|
user: User = Depends(get_current_user)
|
||||||
):
|
):
|
||||||
return templates.TemplateResponse("crash.html", {
|
return templates.TemplateResponse(request, "crash.html", {
|
||||||
"request": request,
|
|
||||||
"user": user,
|
"user": user,
|
||||||
|
"active_page": "crash"
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
@@ -2660,11 +2843,9 @@ async def api_crash_bet(
|
|||||||
CrActivity.user_id == user.id,
|
CrActivity.user_id == user.id,
|
||||||
CrActivity.activity_type == "crash"
|
CrActivity.activity_type == "crash"
|
||||||
).count() + 1
|
).count() + 1
|
||||||
unlocked_ach = []
|
unlocked_ach = check_crash_achievements(db, user.id, crash_count)
|
||||||
r1 = check_achievement(db, user.id, "crash_first", 1)
|
unlocked_ach += check_balance_achievements(db, user.id)
|
||||||
if r1: unlocked_ach.append(r1)
|
unlocked_ach += check_achievements_count_achievements(db, user.id)
|
||||||
r2 = check_achievement(db, user.id, "crash_pro", crash_count)
|
|
||||||
if r2: unlocked_ach.append(r2)
|
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
asyncio.ensure_future(manager.send_personal(user.id, {"type": "balance_update", "balance": user.balance}))
|
asyncio.ensure_future(manager.send_personal(user.id, {"type": "balance_update", "balance": user.balance}))
|
||||||
@@ -2697,10 +2878,9 @@ async def api_crash_cashout(
|
|||||||
user.balance += payout
|
user.balance += payout
|
||||||
|
|
||||||
# Проверка достижений
|
# Проверка достижений
|
||||||
unlocked_ach = []
|
unlocked_ach = check_crash_cashout_achievements(db, user.id, g.current_multiplier)
|
||||||
if g.current_multiplier >= 5.0:
|
unlocked_ach += check_balance_achievements(db, user.id)
|
||||||
r = check_achievement(db, user.id, "crash_5x", 1)
|
unlocked_ach += check_achievements_count_achievements(db, user.id)
|
||||||
if r: unlocked_ach.append(r)
|
|
||||||
|
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
|
|||||||
Executable
+16
@@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Deploy to remote server, excluding DB and other local-only files
|
||||||
|
rsync -av \
|
||||||
|
--exclude '.git' \
|
||||||
|
--exclude '__pycache__' \
|
||||||
|
--exclude '*.pyc' \
|
||||||
|
--exclude '.gitignore' \
|
||||||
|
--exclude 'cs2_simulator.db' \
|
||||||
|
--exclude '*.log' \
|
||||||
|
--exclude 'remote-deploy.sh' \
|
||||||
|
--delete \
|
||||||
|
/root/dodep-simulator/ \
|
||||||
|
root@zernmc.ru:/root/dodep/
|
||||||
|
|
||||||
|
ssh root@zernmc.ru "cd /root/dodep && pip install --break-system-packages -r requirements.txt 2>&1 | tail -5 && pkill -f 'uvicorn' 2>/dev/null; pkill -f 'python3.*backend' 2>/dev/null; sleep 2; rm -rf __pycache__ && setsid python3 -m uvicorn frontend:app --host 0.0.0.0 --port 13669 > /tmp/frontend.log 2>&1 &"
|
||||||
|
echo "Deployed and restarted."
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
fastapi>=0.139.0
|
||||||
|
uvicorn>=0.50.0
|
||||||
|
starlette>=1.3.1
|
||||||
|
jinja2>=3.1.6
|
||||||
|
markupsafe>=3.0.0
|
||||||
|
sqlalchemy>=2.0
|
||||||
|
python-jose[cryptography]
|
||||||
|
passlib
|
||||||
|
bcrypt
|
||||||
|
python-multipart
|
||||||
|
python-dateutil
|
||||||
|
aiofiles
|
||||||
|
tqdm
|
||||||
|
aiosqlite
|
||||||
+214
-43
@@ -3984,49 +3984,6 @@ h1, h2, h3, h4, h5, h6, .logo, .nav-link, .btn {
|
|||||||
|
|
||||||
/* Результат */
|
/* Результат */
|
||||||
/* Toast */
|
/* Toast */
|
||||||
.toast-container {
|
|
||||||
position: fixed;
|
|
||||||
top: 70px;
|
|
||||||
left: 50%;
|
|
||||||
transform: translateX(-50%);
|
|
||||||
z-index: 1000;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 0.4rem;
|
|
||||||
pointer-events: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.toast {
|
|
||||||
padding: 0.5rem 1rem;
|
|
||||||
border-radius: 8px;
|
|
||||||
font-size: 0.8rem;
|
|
||||||
font-weight: 600;
|
|
||||||
white-space: nowrap;
|
|
||||||
opacity: 0;
|
|
||||||
transform: translateY(-10px);
|
|
||||||
transition: all 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.2);
|
|
||||||
pointer-events: auto;
|
|
||||||
background: var(--bg-card);
|
|
||||||
border: 1px solid var(--border-color);
|
|
||||||
color: var(--text-primary);
|
|
||||||
box-shadow: 0 4px 20px rgba(0,0,0,0.5);
|
|
||||||
}
|
|
||||||
|
|
||||||
.toast.show {
|
|
||||||
opacity: 1;
|
|
||||||
transform: translateY(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
.toast.success {
|
|
||||||
border-color: #10b981;
|
|
||||||
box-shadow: 0 4px 20px rgba(16,185,129,0.3);
|
|
||||||
}
|
|
||||||
|
|
||||||
.toast.fail {
|
|
||||||
border-color: #ef4444;
|
|
||||||
box-shadow: 0 4px 20px rgba(239,68,68,0.2);
|
|
||||||
}
|
|
||||||
|
|
||||||
.upgrade-page .result-item-display img {
|
.upgrade-page .result-item-display img {
|
||||||
width: 72px;
|
width: 72px;
|
||||||
height: 60px;
|
height: 60px;
|
||||||
@@ -4486,4 +4443,218 @@ a:not(.btn):not(.nav-link):not(.logo) {
|
|||||||
}
|
}
|
||||||
a:not(.btn):not(.nav-link):not(.logo):hover {
|
a:not(.btn):not(.nav-link):not(.logo):hover {
|
||||||
border-bottom-color: var(--primary-color);
|
border-bottom-color: var(--primary-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* =============================================
|
||||||
|
🍞 Уведомления (Toast + Confirm)
|
||||||
|
============================================= */
|
||||||
|
|
||||||
|
.toast-container {
|
||||||
|
position: fixed;
|
||||||
|
top: 72px;
|
||||||
|
right: 16px;
|
||||||
|
z-index: 9999;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 8px;
|
||||||
|
pointer-events: none;
|
||||||
|
max-width: 380px;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toast {
|
||||||
|
background: var(--bg-elevated);
|
||||||
|
border: 1px solid var(--border-light);
|
||||||
|
border-radius: 10px;
|
||||||
|
padding: 12px 16px;
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 10px;
|
||||||
|
pointer-events: auto;
|
||||||
|
box-shadow: 0 8px 32px rgba(0,0,0,0.5);
|
||||||
|
animation: toastSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
|
||||||
|
transform-origin: top right;
|
||||||
|
position: relative;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toast::before {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
width: 3px;
|
||||||
|
border-radius: 3px 0 0 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toast-success::before { background: var(--success); }
|
||||||
|
.toast-error::before { background: var(--danger); }
|
||||||
|
.toast-info::before { background: var(--primary); }
|
||||||
|
.toast-warning::before { background: var(--warning); }
|
||||||
|
|
||||||
|
.toast-icon {
|
||||||
|
width: 24px;
|
||||||
|
height: 24px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
flex-shrink: 0;
|
||||||
|
border-radius: 6px;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toast-success .toast-icon { background: rgba(16,185,129,0.15); }
|
||||||
|
.toast-error .toast-icon { background: rgba(239,68,68,0.15); }
|
||||||
|
.toast-info .toast-icon { background: rgba(245,158,11,0.15); }
|
||||||
|
.toast-warning .toast-icon { background: rgba(245,158,11,0.15); }
|
||||||
|
|
||||||
|
.toast-content {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toast-title {
|
||||||
|
font-size: 0.82rem;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--text);
|
||||||
|
line-height: 1.3;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toast-message {
|
||||||
|
font-size: 0.75rem;
|
||||||
|
color: var(--text-dim);
|
||||||
|
margin-top: 2px;
|
||||||
|
line-height: 1.3;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toast-close {
|
||||||
|
width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
background: none;
|
||||||
|
border: none;
|
||||||
|
color: var(--text-muted);
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 0.75rem;
|
||||||
|
flex-shrink: 0;
|
||||||
|
border-radius: 4px;
|
||||||
|
transition: all 0.15s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toast-close:hover {
|
||||||
|
background: rgba(255,255,255,0.06);
|
||||||
|
color: var(--text);
|
||||||
|
}
|
||||||
|
|
||||||
|
.toast-removing {
|
||||||
|
animation: toastSlideOut 0.25s cubic-bezier(0.4, 0, 1, 1) forwards;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes toastSlideIn {
|
||||||
|
from { opacity: 0; transform: translateX(100%) scale(0.9); }
|
||||||
|
to { opacity: 1; transform: translateX(0) scale(1); }
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes toastSlideOut {
|
||||||
|
from { opacity: 1; transform: translateX(0) scale(1); }
|
||||||
|
to { opacity: 0; transform: translateX(100%) scale(0.9); }
|
||||||
|
}
|
||||||
|
|
||||||
|
/* =============================================
|
||||||
|
⚠️ Confirm диалог
|
||||||
|
============================================= */
|
||||||
|
|
||||||
|
.confirm-overlay {
|
||||||
|
position: fixed;
|
||||||
|
inset: 0;
|
||||||
|
background: rgba(0, 0, 0, 0.7);
|
||||||
|
backdrop-filter: blur(4px);
|
||||||
|
-webkit-backdrop-filter: blur(4px);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
z-index: 10000;
|
||||||
|
animation: confirmFadeIn 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.confirm-dialog {
|
||||||
|
background: var(--bg-card);
|
||||||
|
border: 1px solid var(--border-light);
|
||||||
|
border-radius: 14px;
|
||||||
|
padding: 24px;
|
||||||
|
max-width: 400px;
|
||||||
|
width: 90%;
|
||||||
|
animation: confirmScaleIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
|
||||||
|
box-shadow: 0 24px 80px rgba(0,0,0,0.6);
|
||||||
|
}
|
||||||
|
|
||||||
|
.confirm-dialog-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.confirm-dialog-icon {
|
||||||
|
width: 36px;
|
||||||
|
height: 36px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
border-radius: 10px;
|
||||||
|
font-size: 1.1rem;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.confirm-dialog-icon-warning { background: rgba(239,68,68,0.15); }
|
||||||
|
.confirm-dialog-icon-info { background: rgba(245,158,11,0.15); }
|
||||||
|
|
||||||
|
.confirm-dialog-title {
|
||||||
|
font-size: 1rem;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--text);
|
||||||
|
}
|
||||||
|
|
||||||
|
.confirm-dialog-message {
|
||||||
|
font-size: 0.88rem;
|
||||||
|
color: var(--text-dim);
|
||||||
|
line-height: 1.5;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
padding-left: 46px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.confirm-dialog-actions {
|
||||||
|
display: flex;
|
||||||
|
gap: 10px;
|
||||||
|
justify-content: flex-end;
|
||||||
|
}
|
||||||
|
|
||||||
|
.confirm-dialog-actions .btn {
|
||||||
|
min-width: 90px;
|
||||||
|
padding: 0.55rem 1.2rem;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.confirm-dialog .btn-danger {
|
||||||
|
background: var(--danger);
|
||||||
|
color: white;
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.confirm-dialog .btn-danger:hover {
|
||||||
|
background: #dc2626;
|
||||||
|
box-shadow: 0 4px 16px rgba(239,68,68,0.3);
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes confirmFadeIn {
|
||||||
|
from { opacity: 0; }
|
||||||
|
to { opacity: 1; }
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes confirmScaleIn {
|
||||||
|
from { opacity: 0; transform: scale(0.9) translateY(10px); }
|
||||||
|
to { opacity: 1; transform: scale(1) translateY(0); }
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,137 @@
|
|||||||
|
(function() {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
let toastId = 0;
|
||||||
|
|
||||||
|
const container = document.createElement('div');
|
||||||
|
container.className = 'toast-container';
|
||||||
|
container.id = 'toastContainer';
|
||||||
|
document.body.appendChild(container);
|
||||||
|
|
||||||
|
function escapeHtml(text) {
|
||||||
|
const d = document.createElement('div');
|
||||||
|
d.textContent = text || '';
|
||||||
|
return d.innerHTML;
|
||||||
|
}
|
||||||
|
|
||||||
|
window.Notify = {
|
||||||
|
toast: function(message, type, title) {
|
||||||
|
if (!message) return;
|
||||||
|
type = type || 'info';
|
||||||
|
const icons = { success: '✓', error: '✕', info: 'ℹ', warning: '⚠' };
|
||||||
|
const titles = { success: title || 'Успешно', error: title || 'Ошибка', info: title || 'Информация', warning: title || 'Внимание' };
|
||||||
|
const icon = icons[type] || 'ℹ';
|
||||||
|
const t = titles[type];
|
||||||
|
|
||||||
|
const id = ++toastId;
|
||||||
|
const el = document.createElement('div');
|
||||||
|
el.className = 'toast toast-' + type;
|
||||||
|
el.id = 'toast-' + id;
|
||||||
|
el.innerHTML =
|
||||||
|
'<div class="toast-icon">' + icon + '</div>' +
|
||||||
|
'<div class="toast-content">' +
|
||||||
|
'<div class="toast-title">' + escapeHtml(t) + '</div>' +
|
||||||
|
'<div class="toast-message">' + escapeHtml(message) + '</div>' +
|
||||||
|
'</div>' +
|
||||||
|
'<button class="toast-close" onclick="Notify.dismiss(' + id + ')">✕</button>';
|
||||||
|
|
||||||
|
container.appendChild(el);
|
||||||
|
|
||||||
|
const timeout = setTimeout(function() {
|
||||||
|
Notify.dismiss(id);
|
||||||
|
}, 4000);
|
||||||
|
|
||||||
|
el._timeout = timeout;
|
||||||
|
el._id = id;
|
||||||
|
|
||||||
|
return id;
|
||||||
|
},
|
||||||
|
|
||||||
|
success: function(message) {
|
||||||
|
return this.toast(message, 'success');
|
||||||
|
},
|
||||||
|
|
||||||
|
error: function(message) {
|
||||||
|
return this.toast(message, 'error');
|
||||||
|
},
|
||||||
|
|
||||||
|
info: function(message) {
|
||||||
|
return this.toast(message, 'info');
|
||||||
|
},
|
||||||
|
|
||||||
|
warning: function(message) {
|
||||||
|
return this.toast(message, 'warning');
|
||||||
|
},
|
||||||
|
|
||||||
|
dismiss: function(id) {
|
||||||
|
var el = document.getElementById('toast-' + id);
|
||||||
|
if (!el) return;
|
||||||
|
if (el._timeout) clearTimeout(el._timeout);
|
||||||
|
if (el.classList.contains('toast-removing')) return;
|
||||||
|
el.classList.add('toast-removing');
|
||||||
|
setTimeout(function() {
|
||||||
|
if (el.parentNode) el.parentNode.removeChild(el);
|
||||||
|
}, 250);
|
||||||
|
},
|
||||||
|
|
||||||
|
confirm: function(message, title, callback) {
|
||||||
|
if (typeof title === 'function') {
|
||||||
|
callback = title;
|
||||||
|
title = 'Подтверждение';
|
||||||
|
}
|
||||||
|
title = title || 'Подтверждение';
|
||||||
|
|
||||||
|
var overlay = document.createElement('div');
|
||||||
|
overlay.className = 'confirm-overlay';
|
||||||
|
overlay.innerHTML =
|
||||||
|
'<div class="confirm-dialog">' +
|
||||||
|
'<div class="confirm-dialog-header">' +
|
||||||
|
'<div class="confirm-dialog-icon confirm-dialog-icon-warning">⚠</div>' +
|
||||||
|
'<div class="confirm-dialog-title">' + escapeHtml(title) + '</div>' +
|
||||||
|
'</div>' +
|
||||||
|
'<div class="confirm-dialog-message">' + escapeHtml(message) + '</div>' +
|
||||||
|
'<div class="confirm-dialog-actions">' +
|
||||||
|
'<button class="btn btn-outline confirm-cancel">Отмена</button>' +
|
||||||
|
'<button class="btn btn-danger confirm-ok">Подтвердить</button>' +
|
||||||
|
'</div>' +
|
||||||
|
'</div>';
|
||||||
|
|
||||||
|
document.body.appendChild(overlay);
|
||||||
|
|
||||||
|
var result = false;
|
||||||
|
|
||||||
|
function close() {
|
||||||
|
if (overlay.parentNode) overlay.parentNode.removeChild(overlay);
|
||||||
|
if (callback) callback(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
overlay.querySelector('.confirm-cancel').addEventListener('click', function() {
|
||||||
|
result = false;
|
||||||
|
close();
|
||||||
|
});
|
||||||
|
|
||||||
|
overlay.querySelector('.confirm-ok').addEventListener('click', function() {
|
||||||
|
result = true;
|
||||||
|
close();
|
||||||
|
});
|
||||||
|
|
||||||
|
overlay.addEventListener('click', function(e) {
|
||||||
|
if (e.target === overlay) {
|
||||||
|
result = false;
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
document.addEventListener('keydown', function handler(e) {
|
||||||
|
if (e.key === 'Escape') {
|
||||||
|
result = false;
|
||||||
|
close();
|
||||||
|
document.removeEventListener('keydown', handler);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return overlay;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
})();
|
||||||
@@ -172,32 +172,37 @@
|
|||||||
</button>
|
</button>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
document.addEventListener('DOMContentLoaded', async () => {
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
const list = document.getElementById('activitySidebarList');
|
const list = document.getElementById('activitySidebarList');
|
||||||
const sidebar = document.getElementById('activitySidebar');
|
const sidebar = document.getElementById('activitySidebar');
|
||||||
document.body.classList.add('has-activity-sidebar');
|
document.body.classList.add('has-activity-sidebar');
|
||||||
|
|
||||||
// Восстанавливаем состояние из localStorage
|
|
||||||
if (localStorage.getItem('sidebar_closed') === 'true') {
|
if (localStorage.getItem('sidebar_closed') === 'true') {
|
||||||
sidebar.classList.add('closed');
|
sidebar.classList.add('closed');
|
||||||
document.body.classList.add('sidebar-closed');
|
document.body.classList.add('sidebar-closed');
|
||||||
document.getElementById('activityToggleBtn').classList.add('visible');
|
document.getElementById('activityToggleBtn').classList.add('visible');
|
||||||
}
|
}
|
||||||
|
|
||||||
WS.on('online_count', (data) => {
|
function loadActivities() {
|
||||||
document.getElementById('onlineCount').textContent = data.online || 0;
|
fetch('/web/api/activity?limit=10')
|
||||||
});
|
.then(r => r.json())
|
||||||
|
.then(data => {
|
||||||
try {
|
if (data.success && data.activities) {
|
||||||
const res = await fetch('/web/api/activity?limit=10');
|
renderActivities(data.activities);
|
||||||
const data = await res.json();
|
}
|
||||||
if (data.success && data.activities) {
|
})
|
||||||
renderActivities(data.activities);
|
.catch(() => {
|
||||||
}
|
if (list && !list.querySelector('.activity-sidebar-item')) {
|
||||||
} catch (e) {
|
list.innerHTML = '<div style="text-align:center;padding:2rem;color:var(--text-secondary);font-size:0.85rem;">Не удалось загрузить</div>';
|
||||||
if (list) list.innerHTML = '<div style="text-align:center;padding:2rem;color:var(--text-secondary);">Не удалось загрузить</div>';
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WS.on('online_count', (data) => {
|
||||||
|
const el = document.getElementById('onlineCount');
|
||||||
|
if (el) el.textContent = data.online || 0;
|
||||||
|
});
|
||||||
|
|
||||||
WS.on('activity', (data) => {
|
WS.on('activity', (data) => {
|
||||||
const act = data.activity;
|
const act = data.activity;
|
||||||
if (!act || !list) return;
|
if (!act || !list) return;
|
||||||
@@ -210,9 +215,13 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||||||
list.removeChild(list.lastChild);
|
list.removeChild(list.lastChild);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
WS.on('connected', loadActivities);
|
||||||
|
|
||||||
|
loadActivities();
|
||||||
});
|
});
|
||||||
|
|
||||||
const RARITY_COLORS = {
|
const ACTIVITY_RARITY_COLORS = {
|
||||||
'consumer-grade': '#b0b0b0', 'industrial-grade': '#5e98d9',
|
'consumer-grade': '#b0b0b0', 'industrial-grade': '#5e98d9',
|
||||||
'mil-spec': '#4b69ff', 'mil-spec-grade': '#4b69ff',
|
'mil-spec': '#4b69ff', 'mil-spec-grade': '#4b69ff',
|
||||||
'restricted': '#8847ff', 'classified': '#d32ce6',
|
'restricted': '#8847ff', 'classified': '#d32ce6',
|
||||||
@@ -231,7 +240,7 @@ function createActivityItem(act) {
|
|||||||
item.style.cursor = 'pointer';
|
item.style.cursor = 'pointer';
|
||||||
|
|
||||||
const raritySlug = (act.data && act.data.rarity || '').toLowerCase().replace(/ /g, '-').replace(/_/g, '-').replace(/™/g, '');
|
const raritySlug = (act.data && act.data.rarity || '').toLowerCase().replace(/ /g, '-').replace(/_/g, '-').replace(/™/g, '');
|
||||||
const rarityColor = RARITY_COLORS[raritySlug] || '';
|
const rarityColor = ACTIVITY_RARITY_COLORS[raritySlug] || '';
|
||||||
if (rarityColor) {
|
if (rarityColor) {
|
||||||
item.style.background = `rgba(${hexToRgb(rarityColor)}, 0.08)`;
|
item.style.background = `rgba(${hexToRgb(rarityColor)}, 0.08)`;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<nav class="navbar">
|
||||||
|
<div class="container">
|
||||||
|
<a href="/" class="logo">🎮 CS2 Simulator</a>
|
||||||
|
<div class="nav-links">
|
||||||
|
<a href="/cases" class="nav-link{% if active_page == 'cases' %} active{% endif %}">Кейсы</a>
|
||||||
|
<a href="/contracts" class="nav-link{% if active_page == 'contracts' %} active{% endif %}">Контракты</a>
|
||||||
|
<a href="/upgrade" class="nav-link{% if active_page == 'upgrade' %} active{% endif %}">🆙 Апгрейд</a>
|
||||||
|
{% if user %}
|
||||||
|
<a href="/crash" class="nav-link{% if active_page == 'crash' %} active{% endif %}">💥 Crash</a>
|
||||||
|
<a href="/profile" class="nav-link{% if active_page == 'profile' %} active{% endif %}">Профиль</a>
|
||||||
|
<a href="/activity" class="nav-link{% if active_page == 'activity' %} active{% endif %}">📰 Лента</a>
|
||||||
|
<a href="/achievements" class="nav-link{% if active_page == 'achievements' %} active{% endif %}">🏆 Достижения</a>
|
||||||
|
<span class="user-balance">{{ "{:,.0f}".format(user.balance).replace(',', ' ') }} ₽</span>
|
||||||
|
<button onclick="toggleSound()" class="btn btn-outline" id="soundToggle" title="Звук">🔊</button>
|
||||||
|
<button onclick="toggleSafeMode()" class="btn btn-outline" id="safeModeToggle" title="Режим записи">🎙️</button>
|
||||||
|
<button onclick="logout()" class="btn btn-outline">Выйти</button>
|
||||||
|
{% else %}
|
||||||
|
<a href="/activity" class="nav-link{% if active_page == 'activity' %} active{% endif %}">📰 Лента</a>
|
||||||
|
<button onclick="toggleSafeMode()" class="btn btn-outline" id="safeModeToggle" title="Режим записи">🎙️</button>
|
||||||
|
<a href="/login" class="btn btn-outline">Войти</a>
|
||||||
|
<a href="/register" class="btn btn-primary">Регистрация</a>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
+39
-22
@@ -6,6 +6,30 @@
|
|||||||
<title>Достижения - CS2 Simulator</title>
|
<title>Достижения - CS2 Simulator</title>
|
||||||
<link rel="stylesheet" href="/static/css/style.css">
|
<link rel="stylesheet" href="/static/css/style.css">
|
||||||
<style>
|
<style>
|
||||||
|
.achievement-card.secret {
|
||||||
|
border-color: #8b5cf6;
|
||||||
|
background: linear-gradient(135deg, rgba(139, 92, 246, 0.05), transparent);
|
||||||
|
}
|
||||||
|
.achievement-card.secret.unlocked {
|
||||||
|
border-color: #8b5cf6;
|
||||||
|
background: linear-gradient(135deg, rgba(139, 92, 246, 0.12), transparent);
|
||||||
|
}
|
||||||
|
.achievement-card.secret .achievement-icon {
|
||||||
|
background: rgba(139, 92, 246, 0.1);
|
||||||
|
}
|
||||||
|
.achievement-card.secret.unlocked .achievement-icon {
|
||||||
|
background: rgba(139, 92, 246, 0.2);
|
||||||
|
}
|
||||||
|
.achievement-card .secret-badge {
|
||||||
|
position: absolute;
|
||||||
|
top: 8px;
|
||||||
|
right: 8px;
|
||||||
|
font-size: 0.65rem;
|
||||||
|
background: rgba(139, 92, 246, 0.2);
|
||||||
|
color: #a78bfa;
|
||||||
|
padding: 2px 6px;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
.achievements-header {
|
.achievements-header {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
@@ -183,25 +207,7 @@
|
|||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<nav class="navbar">
|
{% include "_nav.html" %}
|
||||||
<div class="container">
|
|
||||||
<a href="/" class="logo">🎮 CS2 Simulator</a>
|
|
||||||
<div class="nav-links">
|
|
||||||
<a href="/cases" class="nav-link">Кейсы</a>
|
|
||||||
<a href="/contracts" class="nav-link">Контракты</a>
|
|
||||||
<a href="/upgrade" class="nav-link">🆙 Апгрейд</a>
|
|
||||||
<a href="/crash" class="nav-link">💥 Crash</a>
|
|
||||||
<a href="/inventory" class="nav-link">Инвентарь</a>
|
|
||||||
<a href="/achievements" class="nav-link active">🏆 Достижения</a>
|
|
||||||
<a href="/activity" class="nav-link">📰 Лента</a>
|
|
||||||
<a href="/profile" class="nav-link">Профиль</a>
|
|
||||||
<span class="user-balance">{{ "%.0f"|format(user.balance) }} ₽</span>
|
|
||||||
<button onclick="toggleSound()" class="btn btn-outline" id="soundToggle" title="Звук">🔊</button>
|
|
||||||
<button onclick="toggleSafeMode()" class="btn btn-outline" id="safeModeToggle" title="Режим записи">🎙️</button>
|
|
||||||
<button onclick="logout()" class="btn btn-outline">Выйти</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
|
|
||||||
<main class="container" style="padding: 2rem 1rem;">
|
<main class="container" style="padding: 2rem 1rem;">
|
||||||
<div class="achievements-header">
|
<div class="achievements-header">
|
||||||
@@ -236,19 +242,28 @@
|
|||||||
|
|
||||||
<div class="achievements-grid" id="achievementsGrid">
|
<div class="achievements-grid" id="achievementsGrid">
|
||||||
{% for ach in achievements %}
|
{% for ach in achievements %}
|
||||||
<div class="achievement-card {{ 'unlocked' if ach.unlocked else 'locked' }}"
|
<div class="achievement-card {{ 'unlocked' if ach.unlocked else 'locked' }} {{ 'secret' if ach.hidden else '' }}"
|
||||||
data-category="{{ ach.category }}">
|
data-category="{{ ach.category }}">
|
||||||
|
{% if ach.hidden and not ach.unlocked %}
|
||||||
|
<div class="achievement-icon">❓</div>
|
||||||
|
<div class="achievement-info">
|
||||||
|
<div class="achievement-title">???</div>
|
||||||
|
<div class="achievement-desc">Хммм... похоже что я не знаю как его открыть</div>
|
||||||
|
<div class="secret-badge">🔒 Секрет</div>
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
<div class="achievement-icon">{{ ach.icon }}</div>
|
<div class="achievement-icon">{{ ach.icon }}</div>
|
||||||
<div class="achievement-info">
|
<div class="achievement-info">
|
||||||
|
{% if ach.hidden %}<div class="secret-badge">🤫 Секрет</div>{% endif %}
|
||||||
<div class="achievement-title">{{ ach.title }}</div>
|
<div class="achievement-title">{{ ach.title }}</div>
|
||||||
<div class="achievement-desc">{{ ach.description }}</div>
|
<div class="achievement-desc">{{ ach.description }}</div>
|
||||||
{% if ach.reward_amount > 0 %}
|
{% if ach.reward_amount > 0 %}
|
||||||
<div class="achievement-reward">+{{ "%.0f"|format(ach.reward_amount) }} ₽</div>
|
<div class="achievement-reward">+{{ ach.reward_amount|money }} ₽</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="achievement-progress">
|
<div class="achievement-progress">
|
||||||
<div class="progress-bar">
|
<div class="progress-bar">
|
||||||
<div class="progress-fill {{ 'complete' if ach.unlocked else '' }}"
|
<div class="progress-fill {{ 'complete' if ach.unlocked else '' }}"
|
||||||
style="width: {{ (ach.progress / ach.requirement_value * 100)|round }}%"></div>
|
style="width: {{ (ach.progress / ach.requirement_value * 100)|round if ach.requirement_value > 0 else 100 }}%"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="progress-text">
|
<div class="progress-text">
|
||||||
{% if ach.unlocked %}
|
{% if ach.unlocked %}
|
||||||
@@ -259,6 +274,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
@@ -272,6 +288,7 @@
|
|||||||
|
|
||||||
<script src="/static/js/sounds.js"></script>
|
<script src="/static/js/sounds.js"></script>
|
||||||
<script src="/static/js/websocket.js"></script>
|
<script src="/static/js/websocket.js"></script>
|
||||||
|
<script src="/static/js/notifications.js"></script>
|
||||||
<script src="/static/js/safemode.js"></script>
|
<script src="/static/js/safemode.js"></script>
|
||||||
<script>
|
<script>
|
||||||
document.addEventListener('DOMContentLoaded', () => {
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
|
|||||||
+2
-33
@@ -97,35 +97,7 @@
|
|||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<nav class="navbar">
|
{% include "_nav.html" %}
|
||||||
<div class="container">
|
|
||||||
<a href="/" class="logo">🎮 CS2 Simulator</a>
|
|
||||||
<div class="nav-links">
|
|
||||||
{% if user %}
|
|
||||||
<a href="/cases" class="nav-link">Кейсы</a>
|
|
||||||
<a href="/contracts" class="nav-link">Контракты</a>
|
|
||||||
<a href="/upgrade" class="nav-link">🆙 Апгрейд</a>
|
|
||||||
<a href="/crash" class="nav-link">💥 Crash</a>
|
|
||||||
<a href="/inventory" class="nav-link">Инвентарь</a>
|
|
||||||
<a href="/activity" class="nav-link active">📰 Лента</a>
|
|
||||||
<a href="/achievements" class="nav-link">🏆 Достижения</a>
|
|
||||||
<a href="/profile" class="nav-link">Профиль</a>
|
|
||||||
<span class="user-balance">{{ "%.0f"|format(user.balance) }} ₽</span>
|
|
||||||
<button onclick="toggleSound()" class="btn btn-outline" id="soundToggle" title="Звук">🔊</button>
|
|
||||||
<button onclick="toggleSafeMode()" class="btn btn-outline" id="safeModeToggle" title="Режим записи">🎙️</button>
|
|
||||||
<button onclick="logout()" class="btn btn-outline">Выйти</button>
|
|
||||||
{% else %}
|
|
||||||
<a href="/cases" class="nav-link">Кейсы</a>
|
|
||||||
<a href="/contracts" class="nav-link">Контракты</a>
|
|
||||||
<a href="/upgrade" class="nav-link">🆙 Апгрейд</a>
|
|
||||||
<a href="/activity" class="nav-link active">📰 Лента</a>
|
|
||||||
<button onclick="toggleSafeMode()" class="btn btn-outline" id="safeModeToggle" title="Режим записи">🎙️</button>
|
|
||||||
<a href="/login" class="btn btn-outline">Войти</a>
|
|
||||||
<a href="/register" class="btn btn-primary">Регистрация</a>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
|
|
||||||
<main class="container" style="padding: 2rem 1rem;">
|
<main class="container" style="padding: 2rem 1rem;">
|
||||||
<div class="activity-header">
|
<div class="activity-header">
|
||||||
@@ -172,17 +144,16 @@
|
|||||||
|
|
||||||
<script src="/static/js/sounds.js"></script>
|
<script src="/static/js/sounds.js"></script>
|
||||||
<script src="/static/js/websocket.js"></script>
|
<script src="/static/js/websocket.js"></script>
|
||||||
|
<script src="/static/js/notifications.js"></script>
|
||||||
<script src="/static/js/safemode.js"></script>
|
<script src="/static/js/safemode.js"></script>
|
||||||
<script>
|
<script>
|
||||||
document.addEventListener('DOMContentLoaded', () => {
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
// Подключаемся к WS и слушаем новые активности
|
|
||||||
WS.on('activity', (data) => {
|
WS.on('activity', (data) => {
|
||||||
const act = data.activity;
|
const act = data.activity;
|
||||||
if (!act) return;
|
if (!act) return;
|
||||||
|
|
||||||
const feed = document.getElementById('activityFeed');
|
const feed = document.getElementById('activityFeed');
|
||||||
|
|
||||||
// Убираем empty state если есть
|
|
||||||
const empty = feed.querySelector('.activity-empty');
|
const empty = feed.querySelector('.activity-empty');
|
||||||
if (empty) empty.remove();
|
if (empty) empty.remove();
|
||||||
|
|
||||||
@@ -212,12 +183,10 @@
|
|||||||
|
|
||||||
feed.insertBefore(item, feed.firstChild);
|
feed.insertBefore(item, feed.firstChild);
|
||||||
|
|
||||||
// Ограничиваем до 100 элементов
|
|
||||||
while (feed.children.length > 100) {
|
while (feed.children.length > 100) {
|
||||||
feed.removeChild(feed.lastChild);
|
feed.removeChild(feed.lastChild);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Звук для новых активностей
|
|
||||||
if (act.activity_type === 'achievement') {
|
if (act.activity_type === 'achievement') {
|
||||||
SoundManager.achievement();
|
SoundManager.achievement();
|
||||||
} else if (act.activity_type === 'crash') {
|
} else if (act.activity_type === 'crash') {
|
||||||
|
|||||||
@@ -356,6 +356,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% block modals %}{% endblock %}
|
{% block modals %}{% endblock %}
|
||||||
|
<script src="/static/js/notifications.js"></script>
|
||||||
{% block scripts %}{% endblock %}
|
{% block scripts %}{% endblock %}
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
+30
-24
@@ -254,7 +254,7 @@ async function searchCaseItems() {
|
|||||||
|
|
||||||
async function saveCase() {
|
async function saveCase() {
|
||||||
const name = document.getElementById('caseNameInput').value.trim();
|
const name = document.getElementById('caseNameInput').value.trim();
|
||||||
if (!name) { alert('Введите название кейса'); return; }
|
if (!name) { Notify.error('Введите название кейса'); return; }
|
||||||
const fd = new FormData();
|
const fd = new FormData();
|
||||||
fd.append('case_name', name);
|
fd.append('case_name', name);
|
||||||
fd.append('display_name', document.getElementById('caseDisplayName').value);
|
fd.append('display_name', document.getElementById('caseDisplayName').value);
|
||||||
@@ -271,16 +271,18 @@ async function saveCase() {
|
|||||||
const r = await fetch(url, { method:'POST', body:fd });
|
const r = await fetch(url, { method:'POST', body:fd });
|
||||||
const d = await r.json();
|
const d = await r.json();
|
||||||
if (d.success) { window.location.reload(); }
|
if (d.success) { window.location.reload(); }
|
||||||
else alert(d.error || 'Ошибка');
|
else Notify.error(d.error || 'Ошибка');
|
||||||
}
|
}
|
||||||
|
|
||||||
async function deleteCase(name) {
|
async function deleteCase(name) {
|
||||||
if (!confirm(`Удалить кейс "${name}"?`)) return;
|
Notify.confirm(`Удалить кейс "${name}"?`, 'Подтверждение', async function(ok) {
|
||||||
const fd = new FormData(); fd.append('case_name', name);
|
if (!ok) return;
|
||||||
const r = await fetch(`/admin/api/cases/delete/${encodeURIComponent(name)}`, { method:'POST', body:fd });
|
const fd = new FormData(); fd.append('case_name', name);
|
||||||
const d = await r.json();
|
const r = await fetch(`/admin/api/cases/delete/${encodeURIComponent(name)}`, { method:'POST', body:fd });
|
||||||
if (d.success) window.location.reload();
|
const d = await r.json();
|
||||||
else alert(d.error);
|
if (d.success) window.location.reload();
|
||||||
|
else Notify.error(d.error);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// ─── All Items Browser ───────────────────────────────────────────────────────
|
// ─── All Items Browser ───────────────────────────────────────────────────────
|
||||||
@@ -318,15 +320,17 @@ async function confirmAddSection() {
|
|||||||
const r = await fetch('/admin/api/mainpage/section/add', { method:'POST', body:fd });
|
const r = await fetch('/admin/api/mainpage/section/add', { method:'POST', body:fd });
|
||||||
const d = await r.json();
|
const d = await r.json();
|
||||||
if (d.success) window.location.reload();
|
if (d.success) window.location.reload();
|
||||||
else alert(d.error);
|
else Notify.error(d.error);
|
||||||
}
|
}
|
||||||
async function deleteSection(tab) {
|
async function deleteSection(tab) {
|
||||||
if (!confirm(`Удалить секцию "${tab}"?`)) return;
|
Notify.confirm(`Удалить секцию "${tab}"?`, 'Подтверждение', async function(ok) {
|
||||||
const fd = new FormData(); fd.append('tab', tab);
|
if (!ok) return;
|
||||||
const r = await fetch('/admin/api/mainpage/section/delete', { method:'POST', body:fd });
|
const fd = new FormData(); fd.append('tab', tab);
|
||||||
const d = await r.json();
|
const r = await fetch('/admin/api/mainpage/section/delete', { method:'POST', body:fd });
|
||||||
if (d.success) window.location.reload();
|
const d = await r.json();
|
||||||
else alert(d.error);
|
if (d.success) window.location.reload();
|
||||||
|
else Notify.error(d.error);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function openAddCaseModal(tab) {
|
function openAddCaseModal(tab) {
|
||||||
@@ -345,17 +349,19 @@ async function confirmAddCase() {
|
|||||||
const r = await fetch('/admin/api/mainpage/section/add-case', { method:'POST', body:fd });
|
const r = await fetch('/admin/api/mainpage/section/add-case', { method:'POST', body:fd });
|
||||||
const d = await r.json();
|
const d = await r.json();
|
||||||
if (d.success) window.location.reload();
|
if (d.success) window.location.reload();
|
||||||
else alert(d.error);
|
else Notify.error(d.error);
|
||||||
}
|
}
|
||||||
async function removeCaseFromSection(tab, caseName) {
|
async function removeCaseFromSection(tab, caseName) {
|
||||||
if (!confirm(`Убрать "${caseName}" из "${tab}"?`)) return;
|
Notify.confirm(`Убрать "${caseName}" из "${tab}"?`, 'Подтверждение', async function(ok) {
|
||||||
const fd = new FormData();
|
if (!ok) return;
|
||||||
fd.append('tab', tab);
|
const fd = new FormData();
|
||||||
fd.append('case_name', caseName);
|
fd.append('tab', tab);
|
||||||
const r = await fetch('/admin/api/mainpage/section/remove-case', { method:'POST', body:fd });
|
fd.append('case_name', caseName);
|
||||||
const d = await r.json();
|
const r = await fetch('/admin/api/mainpage/section/remove-case', { method:'POST', body:fd });
|
||||||
if (d.success) window.location.reload();
|
const d = await r.json();
|
||||||
else alert(d.error);
|
if (d.success) window.location.reload();
|
||||||
|
else Notify.error(d.error);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="a-stat">
|
<div class="a-stat">
|
||||||
<div class="as-label">Общий баланс</div>
|
<div class="as-label">Общий баланс</div>
|
||||||
<div class="as-value">{{ "%.0f"|format(total_balance) }} ₽</div>
|
<div class="as-value">{{ total_balance|money }} ₽</div>
|
||||||
<div class="as-bar" style="width:40%;background:#34d399"></div>
|
<div class="as-bar" style="width:40%;background:#34d399"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="a-stat">
|
<div class="a-stat">
|
||||||
@@ -47,7 +47,7 @@
|
|||||||
<div><div class="as-value" style="font-size:1.2rem" style="color:#22c55e">{{ lucky_count }}</div><div class="as-label" style="font-size:0.7rem">🍀 Везучих</div></div>
|
<div><div class="as-value" style="font-size:1.2rem" style="color:#22c55e">{{ lucky_count }}</div><div class="as-label" style="font-size:0.7rem">🍀 Везучих</div></div>
|
||||||
<div><div class="as-value" style="font-size:1.2rem" style="color:#f59e0b">{{ normal_count }}</div><div class="as-label" style="font-size:0.7rem">📊 Обычных</div></div>
|
<div><div class="as-value" style="font-size:1.2rem" style="color:#f59e0b">{{ normal_count }}</div><div class="as-label" style="font-size:0.7rem">📊 Обычных</div></div>
|
||||||
<div><div class="as-value" style="font-size:1.2rem" style="color:#ef4444">{{ unlucky_count }}</div><div class="as-label" style="font-size:0.7rem">🌧️ Невезучих</div></div>
|
<div><div class="as-value" style="font-size:1.2rem" style="color:#ef4444">{{ unlucky_count }}</div><div class="as-label" style="font-size:0.7rem">🌧️ Невезучих</div></div>
|
||||||
<div><div class="as-value" style="font-size:1.2rem">{{ "%.0f"|format(total_spent) }} ₽</div><div class="as-label" style="font-size:0.7rem">Потрачено всего</div></div>
|
<div><div class="as-value" style="font-size:1.2rem">{{ total_spent|money }} ₽</div><div class="as-label" style="font-size:0.7rem">Потрачено всего</div></div>
|
||||||
</div>
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="a-empty"><div class="a-empty-icon">📭</div>Нет данных RPU</div>
|
<div class="a-empty"><div class="a-empty-icon">📭</div>Нет данных RPU</div>
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
<div class="a-stats" style="grid-template-columns:repeat(4,1fr)">
|
<div class="a-stats" style="grid-template-columns:repeat(4,1fr)">
|
||||||
<div class="a-stat">
|
<div class="a-stat">
|
||||||
<div class="as-label">Баланс</div>
|
<div class="as-label">Баланс</div>
|
||||||
<div class="as-value">{{ "%.0f"|format(target_user.balance) }} ₽</div>
|
<div class="as-value">{{ target_user.balance|money }} ₽</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="a-stat">
|
<div class="a-stat">
|
||||||
<div class="as-label">Предметов</div>
|
<div class="as-label">Предметов</div>
|
||||||
@@ -94,7 +94,7 @@
|
|||||||
<div class="a-modal">
|
<div class="a-modal">
|
||||||
<div class="a-modal-title">💰 Изменить баланс</div>
|
<div class="a-modal-title">💰 Изменить баланс</div>
|
||||||
<p style="font-size:0.85rem;color:rgba(255,255,255,0.5);margin-bottom:1rem">
|
<p style="font-size:0.85rem;color:rgba(255,255,255,0.5);margin-bottom:1rem">
|
||||||
Текущий: <strong style="color:#f59e0b">{{ "%.2f"|format(target_user.balance) }} ₽</strong>
|
Текущий: <strong style="color:#f59e0b">{{ target_user.balance|money }} ₽</strong>
|
||||||
</p>
|
</p>
|
||||||
<div class="a-mb">
|
<div class="a-mb">
|
||||||
<label class="a-label">Сумма</label>
|
<label class="a-label">Сумма</label>
|
||||||
@@ -180,8 +180,8 @@ async function updateBalance() {
|
|||||||
fd.append('operation', document.getElementById('balanceOperation').value);
|
fd.append('operation', document.getElementById('balanceOperation').value);
|
||||||
const res = await fetch(`/admin/api/user/${userId}/balance`, { method:'POST', body:fd });
|
const res = await fetch(`/admin/api/user/${userId}/balance`, { method:'POST', body:fd });
|
||||||
const d = await res.json();
|
const d = await res.json();
|
||||||
if (d.success) { alert(d.message); window.location.reload(); }
|
if (d.success) { Notify.success(d.message); window.location.reload(); }
|
||||||
else alert(d.error);
|
else Notify.error(d.error);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ====== GIVE ITEM ======
|
// ====== GIVE ITEM ======
|
||||||
@@ -205,31 +205,37 @@ async function giveItem(itemId) {
|
|||||||
const fd = new FormData(); fd.append('item_id', itemId);
|
const fd = new FormData(); fd.append('item_id', itemId);
|
||||||
const res = await fetch(`/admin/api/user/${userId}/give-item`, { method:'POST', body:fd });
|
const res = await fetch(`/admin/api/user/${userId}/give-item`, { method:'POST', body:fd });
|
||||||
const d = await res.json();
|
const d = await res.json();
|
||||||
if (d.success) { alert(d.message); closeModal('giveItemModal'); window.location.reload(); }
|
if (d.success) { Notify.success(d.message); closeModal('giveItemModal'); window.location.reload(); }
|
||||||
else alert(d.error);
|
else Notify.error(d.error);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ====== DELETE ITEM ======
|
// ====== DELETE ITEM ======
|
||||||
async function deleteItem(invId) {
|
async function deleteItem(invId) {
|
||||||
if (!confirm('Удалить предмет?')) return;
|
Notify.confirm('Удалить предмет?', 'Подтверждение', async function(ok) {
|
||||||
const res = await fetch(`/admin/api/user/${userId}/delete-item/${invId}`, { method:'POST' });
|
if (!ok) return;
|
||||||
const d = await res.json();
|
const res = await fetch(`/admin/api/user/${userId}/delete-item/${invId}`, { method:'POST' });
|
||||||
if (d.success) window.location.reload();
|
const d = await res.json();
|
||||||
else alert(d.error);
|
if (d.success) window.location.reload();
|
||||||
|
else Notify.error(d.error);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// ====== TOGGLE ADMIN / BAN ======
|
// ====== TOGGLE ADMIN / BAN ======
|
||||||
async function toggleAdmin() {
|
async function toggleAdmin() {
|
||||||
if (!confirm('Изменить статус админа?')) return;
|
Notify.confirm('Изменить статус админа?', 'Подтверждение', async function(ok) {
|
||||||
const res = await fetch(`/admin/api/user/${userId}/toggle-admin`, { method:'POST' });
|
if (!ok) return;
|
||||||
const d = await res.json();
|
const res = await fetch(`/admin/api/user/${userId}/toggle-admin`, { method:'POST' });
|
||||||
if (d.success) window.location.reload(); else alert(d.error);
|
const d = await res.json();
|
||||||
|
if (d.success) window.location.reload(); else Notify.error(d.error);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
async function toggleBan() {
|
async function toggleBan() {
|
||||||
if (!confirm('{{ "Забанить" if not target_user.is_banned else "Разбанить" }}?')) return;
|
Notify.confirm('{{ "Забанить" if not target_user.is_banned else "Разбанить" }}?', 'Подтверждение', async function(ok) {
|
||||||
const res = await fetch(`/admin/api/user/${userId}/toggle-ban`, { method:'POST' });
|
if (!ok) return;
|
||||||
const d = await res.json();
|
const res = await fetch(`/admin/api/user/${userId}/toggle-ban`, { method:'POST' });
|
||||||
if (d.success) window.location.reload(); else alert(d.error);
|
const d = await res.json();
|
||||||
|
if (d.success) window.location.reload(); else Notify.error(d.error);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// ====== RPU ======
|
// ====== RPU ======
|
||||||
@@ -277,16 +283,18 @@ async function saveRPU() {
|
|||||||
fd.append('auto_adjust', document.getElementById('rpuAutoAdjust').checked);
|
fd.append('auto_adjust', document.getElementById('rpuAutoAdjust').checked);
|
||||||
const res = await fetch(`/admin/api/user/${userId}/rpu/update`, { method:'POST', body:fd });
|
const res = await fetch(`/admin/api/user/${userId}/rpu/update`, { method:'POST', body:fd });
|
||||||
const d = await res.json();
|
const d = await res.json();
|
||||||
if (d.success) { alert(d.message); closeModal('rpuModal'); loadRPU(); }
|
if (d.success) { Notify.success(d.message); closeModal('rpuModal'); loadRPU(); }
|
||||||
else alert(d.error);
|
else Notify.error(d.error);
|
||||||
}
|
}
|
||||||
async function setRPUPreset(preset) {
|
async function setRPUPreset(preset) {
|
||||||
const names = { lucky:'🍀 Везучий', normal:'📊 Обычный', unlucky:'🌧️ Невезучий', very_unlucky:'💀 Проклятый' };
|
const names = { lucky:'🍀 Везучий', normal:'📊 Обычный', unlucky:'🌧️ Невезучий', very_unlucky:'💀 Проклятый' };
|
||||||
if (!confirm('Применить "'+names[preset]+'"?')) return;
|
Notify.confirm('Применить "'+names[preset]+'"?', 'Подтверждение', async function(ok) {
|
||||||
const fd = new FormData(); fd.append('preset', preset);
|
if (!ok) return;
|
||||||
const res = await fetch(`/admin/api/user/${userId}/rpu/preset`, { method:'POST', body:fd });
|
const fd = new FormData(); fd.append('preset', preset);
|
||||||
const d = await res.json();
|
const res = await fetch(`/admin/api/user/${userId}/rpu/preset`, { method:'POST', body:fd });
|
||||||
if (d.success) { alert(d.message); loadRPU(); } else alert(d.error);
|
const d = await res.json();
|
||||||
|
if (d.success) { Notify.success(d.message); loadRPU(); } else Notify.error(d.error);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', loadRPU);
|
document.addEventListener('DOMContentLoaded', loadRPU);
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<th>Статус</th>
|
<th>Статус</th>
|
||||||
<th>Кейсов</th>
|
<th>Кейсов</th>
|
||||||
<th>Контрактов</th>
|
<th>Контрактов</th>
|
||||||
<th>Достижений</th>
|
<th>Предметов</th>
|
||||||
<th></th>
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@@ -34,15 +34,15 @@
|
|||||||
{{ u.username }}
|
{{ u.username }}
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
<td>{{ "%.0f"|format(u.balance) }} ₽</td>
|
<td>{{ u.balance|money }} ₽</td>
|
||||||
<td>
|
<td>
|
||||||
{% if u.is_admin %}<span class="a-badge a-badge-admin">Админ</span>{% endif %}
|
{% if u.is_admin %}<span class="a-badge a-badge-admin">Админ</span>{% endif %}
|
||||||
{% if u.is_banned %}<span class="a-badge a-badge-banned">Забанен</span>{% endif %}
|
{% if u.is_banned %}<span class="a-badge a-badge-banned">Забанен</span>{% endif %}
|
||||||
{% if not u.is_admin and not u.is_banned %}<span class="a-badge a-badge-user">Игрок</span>{% endif %}
|
{% if not u.is_admin and not u.is_banned %}<span class="a-badge a-badge-user">Игрок</span>{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td>{{ u.case_openings|default(0) }}</td>
|
<td>{{ u.case_openings }}</td>
|
||||||
<td>{{ u.contracts|default(0) }}</td>
|
<td>{{ u.contracts }}</td>
|
||||||
<td>{{ u.achievements|default(0) }}</td>
|
<td>{{ u.inventory_count }}</td>
|
||||||
<td class="td-actions">
|
<td class="td-actions">
|
||||||
<a href="/admin/user/{{ u.id }}" class="a-btn a-btn-sm">✏️</a>
|
<a href="/admin/user/{{ u.id }}" class="a-btn a-btn-sm">✏️</a>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
+133
-153
@@ -214,35 +214,7 @@
|
|||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<nav class="navbar">
|
{% include "_nav.html" %}
|
||||||
<div class="container">
|
|
||||||
<a href="/" class="logo">🎮 CS2 Simulator</a>
|
|
||||||
<div class="nav-links">
|
|
||||||
{% if user %}
|
|
||||||
<a href="/cases" class="nav-link active">Кейсы</a>
|
|
||||||
<a href="/contracts" class="nav-link">Контракты</a>
|
|
||||||
<a href="/upgrade" class="nav-link">🆙 Апгрейд</a>
|
|
||||||
<a href="/crash" class="nav-link">💥 Crash</a>
|
|
||||||
<a href="/inventory" class="nav-link">Инвентарь</a>
|
|
||||||
<a href="/activity" class="nav-link">📰 Лента</a>
|
|
||||||
<a href="/achievements" class="nav-link">🏆 Достижения</a>
|
|
||||||
<a href="/profile" class="nav-link">Профиль</a>
|
|
||||||
<span class="user-balance">{{ "%.0f"|format(user.balance) }} ₽</span>
|
|
||||||
<button onclick="toggleSound()" class="btn btn-outline" id="soundToggle" title="Звук">🔊</button>
|
|
||||||
<button onclick="toggleSafeMode()" class="btn btn-outline" id="safeModeToggle" title="Режим записи">🎙️</button>
|
|
||||||
<button onclick="logout()" class="btn btn-outline">Выйти</button>
|
|
||||||
{% else %}
|
|
||||||
<a href="/cases" class="nav-link active">Кейсы</a>
|
|
||||||
<a href="/contracts" class="nav-link">Контракты</a>
|
|
||||||
<a href="/upgrade" class="nav-link">🆙 Апгрейд</a>
|
|
||||||
<a href="/activity" class="nav-link">📰 Лента</a>
|
|
||||||
<button onclick="toggleSafeMode()" class="btn btn-outline" id="safeModeToggle" title="Режим записи">🎙️</button>
|
|
||||||
<a href="/login" class="btn btn-outline">Войти</a>
|
|
||||||
<a href="/register" class="btn btn-primary">Регистрация</a>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
|
|
||||||
<main class="case-detail-container">
|
<main class="case-detail-container">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
@@ -255,7 +227,7 @@
|
|||||||
<p class="case-subtitle">{{ total_items }} предметов в кейсе</p>
|
<p class="case-subtitle">{{ total_items }} предметов в кейсе</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="case-info-badge">
|
<div class="case-info-badge">
|
||||||
<span class="case-price-tag">🔑 {{ "%.0f"|format(case_price) }} ₽ за шт.</span>
|
<span class="case-price-tag">🔑 {{ case_price|money }} ₽ за шт.</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -266,7 +238,7 @@
|
|||||||
<div class="count-buttons" id="countButtons"></div>
|
<div class="count-buttons" id="countButtons"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="total-price-display" id="totalPriceDisplay">
|
<div class="total-price-display" id="totalPriceDisplay">
|
||||||
<span>Итого:</span> {{ "%.0f"|format(case_price) }} ₽
|
<span>Итого:</span> {{ case_price|money }} ₽
|
||||||
</div>
|
</div>
|
||||||
<button class="btn btn-primary btn-large" onclick="startOpening()" id="openButton">
|
<button class="btn btn-primary btn-large" onclick="startOpening()" id="openButton">
|
||||||
🎲 Открыть
|
🎲 Открыть
|
||||||
@@ -389,9 +361,9 @@
|
|||||||
{% if item.min_price and item.max_price %}
|
{% if item.min_price and item.max_price %}
|
||||||
<div class="item-price-compact">
|
<div class="item-price-compact">
|
||||||
{% if item.min_price == item.max_price %}
|
{% if item.min_price == item.max_price %}
|
||||||
{{ "%.0f"|format(item.min_price) }} ₽
|
{{ item.min_price|money }} ₽
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ "%.0f"|format(item.min_price) }} - {{ "%.0f"|format(item.max_price) }} ₽
|
{{ item.min_price|money }} - {{ item.max_price|money }} ₽
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -603,7 +575,10 @@
|
|||||||
const hasFreeSpin = freeSpinActive;
|
const hasFreeSpin = freeSpinActive;
|
||||||
freeSpinActive = false;
|
freeSpinActive = false;
|
||||||
if (!hasFreeSpin && userBalance < totalPrice) {
|
if (!hasFreeSpin && userBalance < totalPrice) {
|
||||||
alert(`Недостаточно средств!\nНужно: ${totalPrice.toLocaleString()} ₽\nУ вас: ${Math.floor(userBalance).toLocaleString()} ₽`);
|
Notify.error(`Недостаточно средств! Нужно: ${totalPrice.toLocaleString()} ₽, у вас: ${Math.floor(userBalance).toLocaleString()} ₽`);
|
||||||
|
isOpening = false;
|
||||||
|
openButton.disabled = false;
|
||||||
|
openButton.textContent = isSlotCase ? '🎰 Крутить' : '🎲 Открыть';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
isOpening = true;
|
isOpening = true;
|
||||||
@@ -658,7 +633,7 @@
|
|||||||
if (data.new_balance !== undefined) userBalance = data.new_balance;
|
if (data.new_balance !== undefined) userBalance = data.new_balance;
|
||||||
await refreshUserBalance();
|
await refreshUserBalance();
|
||||||
} else {
|
} else {
|
||||||
alert(data.error || 'Ошибка при открытии');
|
Notify.error(data.error || 'Ошибка при открытии');
|
||||||
}
|
}
|
||||||
} else if (isFarmCase) {
|
} else if (isFarmCase) {
|
||||||
// ===== ФАРМ-КЕЙС: КАРТОЧКИ С АВТОПРОДАЖЕЙ ШЛАКА =====
|
// ===== ФАРМ-КЕЙС: КАРТОЧКИ С АВТОПРОДАЖЕЙ ШЛАКА =====
|
||||||
@@ -697,7 +672,7 @@
|
|||||||
}
|
}
|
||||||
await refreshUserBalance();
|
await refreshUserBalance();
|
||||||
} else {
|
} else {
|
||||||
alert(data.error || 'Ошибка при открытии');
|
Notify.error(data.error || 'Ошибка при открытии');
|
||||||
}
|
}
|
||||||
} else if (fast) {
|
} else if (fast) {
|
||||||
// ===== БЫСТРОЕ ОТКРЫТИЕ БЕЗ АНИМАЦИИ =====
|
// ===== БЫСТРОЕ ОТКРЫТИЕ БЕЗ АНИМАЦИИ =====
|
||||||
@@ -720,7 +695,7 @@
|
|||||||
if (data.new_balance !== undefined) userBalance = data.new_balance;
|
if (data.new_balance !== undefined) userBalance = data.new_balance;
|
||||||
await refreshUserBalance();
|
await refreshUserBalance();
|
||||||
} else {
|
} else {
|
||||||
alert(data.error || 'Ошибка при открытии');
|
Notify.error(data.error || 'Ошибка при открытии');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// ===== ОБЫЧНЫЙ КЕЙС: СКРОЛЛЫ (РУЛЕТКА) =====
|
// ===== ОБЫЧНЫЙ КЕЙС: СКРОЛЛЫ (РУЛЕТКА) =====
|
||||||
@@ -763,7 +738,7 @@
|
|||||||
})();
|
})();
|
||||||
|
|
||||||
if (!batchData.success) {
|
if (!batchData.success) {
|
||||||
alert(batchData.error || 'Ошибка при открытии');
|
Notify.error(batchData.error || 'Ошибка при открытии');
|
||||||
} else {
|
} else {
|
||||||
handleAchievements(batchData);
|
handleAchievements(batchData);
|
||||||
SoundManager.caseOpen();
|
SoundManager.caseOpen();
|
||||||
@@ -797,7 +772,7 @@
|
|||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error opening cases:', error);
|
console.error('Error opening cases:', error);
|
||||||
alert('Ошибка при открытии кейсов');
|
Notify.error('Ошибка при открытии кейсов');
|
||||||
} finally {
|
} finally {
|
||||||
isOpening = false;
|
isOpening = false;
|
||||||
openButton.disabled = false;
|
openButton.disabled = false;
|
||||||
@@ -1338,43 +1313,44 @@
|
|||||||
|
|
||||||
async function sellAllTopDrops() {
|
async function sellAllTopDrops() {
|
||||||
if (topDropItems.length === 0) {
|
if (topDropItems.length === 0) {
|
||||||
alert('Нет предметов для продажи');
|
Notify.error('Нет предметов для продажи');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const total = topDropItems.reduce((sum, i) => sum + (i.price || 100), 0);
|
const total = topDropItems.reduce((sum, i) => sum + (i.price || 100), 0);
|
||||||
if (!confirm(`Продать все топ-дропы за ${total.toLocaleString()} ₽?`)) return;
|
Notify.confirm('Продать все топ-дропы за ' + total.toLocaleString() + ' ₽?', 'Продажа', async function(confirmed) {
|
||||||
|
if (!confirmed) return;
|
||||||
try {
|
try {
|
||||||
const response = await fetch('/web/api/inventory/items');
|
const response = await fetch('/web/api/inventory/items');
|
||||||
const items = await response.json();
|
const items = await response.json();
|
||||||
|
|
||||||
const inventoryIds = [];
|
|
||||||
for (const item of topDropItems) {
|
|
||||||
const invItem = items.find(i => i.item_id === item.id &&
|
|
||||||
Math.abs(i.float - item.float) < 0.001);
|
|
||||||
if (invItem) {
|
|
||||||
inventoryIds.push(invItem.id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (inventoryIds.length > 0) {
|
|
||||||
const formData = new FormData();
|
|
||||||
formData.append('inventory_ids', JSON.stringify(inventoryIds));
|
|
||||||
|
|
||||||
await fetch('/web/api/inventory/sell/bulk', {
|
const inventoryIds = [];
|
||||||
method: 'POST',
|
for (const item of topDropItems) {
|
||||||
body: formData
|
const invItem = items.find(i => i.item_id === item.id &&
|
||||||
});
|
Math.abs(i.float - item.float) < 0.001);
|
||||||
|
if (invItem) {
|
||||||
|
inventoryIds.push(invItem.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inventoryIds.length > 0) {
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append('inventory_ids', JSON.stringify(inventoryIds));
|
||||||
|
|
||||||
|
await fetch('/web/api/inventory/sell/bulk', {
|
||||||
|
method: 'POST',
|
||||||
|
body: formData
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
await refreshUserBalance();
|
||||||
|
await refreshInventoryAjax();
|
||||||
|
topDropItems = [];
|
||||||
|
resetCaseUI();
|
||||||
|
} catch (error) {
|
||||||
|
Notify.error('Ошибка соединения');
|
||||||
}
|
}
|
||||||
|
});
|
||||||
await refreshUserBalance();
|
|
||||||
await refreshInventoryAjax();
|
|
||||||
topDropItems = [];
|
|
||||||
resetCaseUI();
|
|
||||||
} catch (error) {
|
|
||||||
alert('Ошибка соединения');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===== ЭФФЕКТЫ =====
|
// ===== ЭФФЕКТЫ =====
|
||||||
@@ -1749,102 +1725,104 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function sellResultItem(itemId) {
|
async function sellResultItem(itemId) {
|
||||||
if (!confirm('Продать этот предмет?')) return;
|
Notify.confirm('Продать этот предмет?', 'Продажа', async function(confirmed) {
|
||||||
|
if (!confirmed) return;
|
||||||
try {
|
try {
|
||||||
const response = await fetch('/web/api/inventory/items');
|
const response = await fetch('/web/api/inventory/items');
|
||||||
const items = await response.json();
|
const items = await response.json();
|
||||||
const inventoryItem = items.find(i => i.item_id === itemId);
|
const inventoryItem = items.find(i => i.item_id === itemId);
|
||||||
|
|
||||||
if (!inventoryItem) {
|
if (!inventoryItem) {
|
||||||
alert('Предмет не найден в инвентаре');
|
Notify.error('Предмет не найден в инвентаре');
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
const formData = new FormData();
|
|
||||||
formData.append('inventory_id', inventoryItem.id);
|
|
||||||
|
|
||||||
const sellResponse = await fetch('/web/api/inventory/sell', {
|
|
||||||
method: 'POST',
|
|
||||||
body: formData
|
|
||||||
});
|
|
||||||
|
|
||||||
const data = await sellResponse.json();
|
|
||||||
|
|
||||||
if (data.success) {
|
|
||||||
await refreshUserBalance();
|
|
||||||
await refreshInventoryAjax();
|
|
||||||
// Remove the sold item card from display
|
|
||||||
const cards = document.querySelectorAll('.result-card-enhanced');
|
|
||||||
for (const card of cards) {
|
|
||||||
const btn = card.querySelector('.btn-sell-result');
|
|
||||||
if (btn && btn.getAttribute('onclick')?.includes(itemId)) {
|
|
||||||
card.style.transition = 'all 0.3s ease';
|
|
||||||
card.style.opacity = '0';
|
|
||||||
card.style.transform = 'scale(0.8)';
|
|
||||||
setTimeout(() => card.remove(), 300);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
alert(data.error || 'Ошибка при продаже');
|
const formData = new FormData();
|
||||||
|
formData.append('inventory_id', inventoryItem.id);
|
||||||
|
|
||||||
|
const sellResponse = await fetch('/web/api/inventory/sell', {
|
||||||
|
method: 'POST',
|
||||||
|
body: formData
|
||||||
|
});
|
||||||
|
|
||||||
|
const data = await sellResponse.json();
|
||||||
|
|
||||||
|
if (data.success) {
|
||||||
|
Notify.success('Предмет продан за ' + data.sold_price.toFixed(0) + ' ₽');
|
||||||
|
await refreshUserBalance();
|
||||||
|
await refreshInventoryAjax();
|
||||||
|
const cards = document.querySelectorAll('.result-card-enhanced');
|
||||||
|
for (const card of cards) {
|
||||||
|
const btn = card.querySelector('.btn-sell-result');
|
||||||
|
if (btn && btn.getAttribute('onclick')?.includes(itemId)) {
|
||||||
|
card.style.transition = 'all 0.3s ease';
|
||||||
|
card.style.opacity = '0';
|
||||||
|
card.style.transform = 'scale(0.8)';
|
||||||
|
setTimeout(() => card.remove(), 300);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Notify.error(data.error || 'Ошибка при продаже');
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
Notify.error('Ошибка соединения');
|
||||||
}
|
}
|
||||||
} catch (error) {
|
});
|
||||||
alert('Ошибка соединения');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function sellAllResults() {
|
async function sellAllResults() {
|
||||||
if (!window.lastOpenedItems || window.lastOpenedItems.length === 0) {
|
if (!window.lastOpenedItems || window.lastOpenedItems.length === 0) {
|
||||||
alert('Нет предметов для продажи');
|
Notify.error('Нет предметов для продажи');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const total = window.lastOpenedItems.reduce((sum, i) => sum + (i.price || 100), 0);
|
const total = window.lastOpenedItems.reduce((sum, i) => sum + (i.price || 100), 0);
|
||||||
if (!confirm(`Продать все выпавшие предметы за ${total.toLocaleString()} ₽?`)) return;
|
Notify.confirm('Продать все выпавшие предметы за ' + total.toLocaleString() + ' ₽?', 'Продажа', async function(confirmed) {
|
||||||
|
if (!confirmed) return;
|
||||||
try {
|
try {
|
||||||
const response = await fetch('/web/api/inventory/items');
|
const response = await fetch('/web/api/inventory/items');
|
||||||
const items = await response.json();
|
const items = await response.json();
|
||||||
|
|
||||||
const inventoryIds = [];
|
const inventoryIds = [];
|
||||||
for (const resultItem of window.lastOpenedItems) {
|
for (const resultItem of window.lastOpenedItems) {
|
||||||
const invItem = items.find(i => i.item_id === resultItem.id &&
|
const invItem = items.find(i => i.item_id === resultItem.id &&
|
||||||
Math.abs(i.float - resultItem.float) < 0.001);
|
Math.abs(i.float - resultItem.float) < 0.001);
|
||||||
if (invItem) {
|
if (invItem) {
|
||||||
inventoryIds.push(invItem.id);
|
inventoryIds.push(invItem.id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
if (inventoryIds.length === 0) {
|
||||||
if (inventoryIds.length === 0) {
|
Notify.error('Предметы не найдены в инвентаре');
|
||||||
alert('Предметы не найдены в инвентаре');
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
const formData = new FormData();
|
||||||
const formData = new FormData();
|
formData.append('inventory_ids', JSON.stringify(inventoryIds));
|
||||||
formData.append('inventory_ids', JSON.stringify(inventoryIds));
|
|
||||||
|
const sellResponse = await fetch('/web/api/inventory/sell/bulk', {
|
||||||
const sellResponse = await fetch('/web/api/inventory/sell/bulk', {
|
method: 'POST',
|
||||||
method: 'POST',
|
body: formData
|
||||||
body: formData
|
});
|
||||||
});
|
|
||||||
|
const data = await sellResponse.json();
|
||||||
const data = await sellResponse.json();
|
|
||||||
|
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
await refreshUserBalance();
|
Notify.success('Продано ' + data.sold_count + ' предметов за ' + data.total_received.toFixed(0) + ' ₽');
|
||||||
await refreshInventoryAjax();
|
await refreshUserBalance();
|
||||||
// Clear results and reset UI
|
await refreshInventoryAjax();
|
||||||
const resultsDiv = document.getElementById('openingResults');
|
const resultsDiv = document.getElementById('openingResults');
|
||||||
resultsDiv.style.display = 'none';
|
resultsDiv.style.display = 'none';
|
||||||
resultsDiv.innerHTML = '';
|
resultsDiv.innerHTML = '';
|
||||||
window.lastOpenedItems = [];
|
window.lastOpenedItems = [];
|
||||||
} else {
|
} else {
|
||||||
alert(data.error || 'Ошибка при продаже');
|
Notify.error(data.error || 'Ошибка при продаже');
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
Notify.error('Ошибка соединения');
|
||||||
}
|
}
|
||||||
} catch (error) {
|
});
|
||||||
alert('Ошибка соединения');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function filterItems(rarity) {
|
function filterItems(rarity) {
|
||||||
@@ -1879,7 +1857,9 @@
|
|||||||
</script>
|
</script>
|
||||||
<script src="/static/js/sounds.js"></script>
|
<script src="/static/js/sounds.js"></script>
|
||||||
<script src="/static/js/websocket.js"></script>
|
<script src="/static/js/websocket.js"></script>
|
||||||
|
<script src="/static/js/notifications.js"></script>
|
||||||
<script src="/static/js/safemode.js"></script>
|
<script src="/static/js/safemode.js"></script>
|
||||||
|
<script src="/static/js/app.js"></script>
|
||||||
<script>
|
<script>
|
||||||
function handleAchievements(data) {
|
function handleAchievements(data) {
|
||||||
if (data && data.achievements_unlocked && Array.isArray(data.achievements_unlocked) && data.achievements_unlocked.length > 0) {
|
if (data && data.achievements_unlocked && Array.isArray(data.achievements_unlocked) && data.achievements_unlocked.length > 0) {
|
||||||
|
|||||||
+4
-31
@@ -155,35 +155,7 @@
|
|||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<nav class="navbar">
|
{% include "_nav.html" %}
|
||||||
<div class="container">
|
|
||||||
<a href="/" class="logo">🎮 CS2 Simulator</a>
|
|
||||||
<div class="nav-links">
|
|
||||||
{% if user %}
|
|
||||||
<a href="/cases" class="nav-link">Кейсы</a>
|
|
||||||
<a href="/contracts" class="nav-link">Контракты</a>
|
|
||||||
<a href="/upgrade" class="nav-link">🆙 Апгрейд</a>
|
|
||||||
<a href="/crash" class="nav-link">💥 Crash</a>
|
|
||||||
<a href="/inventory" class="nav-link">Инвентарь</a>
|
|
||||||
<a href="/activity" class="nav-link">📰 Лента</a>
|
|
||||||
<a href="/achievements" class="nav-link">🏆 Достижения</a>
|
|
||||||
<a href="/profile" class="nav-link">Профиль</a>
|
|
||||||
<span class="user-balance">{{ "%.2f"|format(user.balance) }} ₽</span>
|
|
||||||
<button onclick="toggleSound()" class="btn btn-outline" id="soundToggle" title="Звук">🔊</button>
|
|
||||||
<button onclick="toggleSafeMode()" class="btn btn-outline" id="safeModeToggle" title="Режим записи">🎙️</button>
|
|
||||||
<button onclick="logout()" class="btn btn-outline">Выйти</button>
|
|
||||||
{% else %}
|
|
||||||
<a href="/cases" class="nav-link">Кейсы</a>
|
|
||||||
<a href="/contracts" class="nav-link">Контракты</a>
|
|
||||||
<a href="/upgrade" class="nav-link">🆙 Апгрейд</a>
|
|
||||||
<a href="/activity" class="nav-link">📰 Лента</a>
|
|
||||||
<button onclick="toggleSafeMode()" class="btn btn-outline" id="safeModeToggle" title="Режим записи">🎙️</button>
|
|
||||||
<a href="/login" class="btn btn-outline">Войти</a>
|
|
||||||
<a href="/register" class="btn btn-primary">Регистрация</a>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
|
|
||||||
<main class="cases-container">
|
<main class="cases-container">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
@@ -203,7 +175,7 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
<span style="font-size: 3rem;">📦</span>
|
<span style="font-size: 3rem;">📦</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<span class="case-price-badge">{{ "%.0f"|format(case.price) }} ₽</span>
|
<span class="case-price-badge">{{ case.price|money }} ₽</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="case-info">
|
<div class="case-info">
|
||||||
<div class="case-title">{{ case.display_name }}</div>
|
<div class="case-title">{{ case.display_name }}</div>
|
||||||
@@ -222,7 +194,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="case-footer">
|
<div class="case-footer">
|
||||||
<span class="case-price">{{ "%.0f"|format(case.price) }} ₽</span>
|
<span class="case-price">{{ case.price|money }} ₽</span>
|
||||||
<span class="btn-open">Открыть</span>
|
<span class="btn-open">Открыть</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -243,6 +215,7 @@
|
|||||||
</script>
|
</script>
|
||||||
<script src="/static/js/sounds.js"></script>
|
<script src="/static/js/sounds.js"></script>
|
||||||
<script src="/static/js/websocket.js"></script>
|
<script src="/static/js/websocket.js"></script>
|
||||||
|
<script src="/static/js/notifications.js"></script>
|
||||||
<script src="/static/js/safemode.js"></script>
|
<script src="/static/js/safemode.js"></script>
|
||||||
<script>
|
<script>
|
||||||
function toggleSound() {
|
function toggleSound() {
|
||||||
|
|||||||
@@ -7,33 +7,7 @@
|
|||||||
<link rel="stylesheet" href="/static/css/style.css">
|
<link rel="stylesheet" href="/static/css/style.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<nav class="navbar">
|
{% include "_nav.html" %}
|
||||||
<div class="container">
|
|
||||||
<a href="/" class="logo">🎮 CS2 Simulator</a>
|
|
||||||
<div class="nav-links">
|
|
||||||
{% if user %}
|
|
||||||
<a href="/cases" class="nav-link">Кейсы</a>
|
|
||||||
<a href="/contracts" class="nav-link active">Контракты</a>
|
|
||||||
<a href="/upgrade" class="nav-link">🆙 Апгрейд</a>
|
|
||||||
<a href="/crash" class="nav-link">💥 Crash</a>
|
|
||||||
<a href="/inventory" class="nav-link">Инвентарь</a>
|
|
||||||
<a href="/achievements" class="nav-link">🏆 Достижения</a>
|
|
||||||
<a href="/profile" class="nav-link">Профиль</a>
|
|
||||||
<span class="user-balance">{{ "%.0f"|format(user.balance) }} ₽</span>
|
|
||||||
<button onclick="toggleSound()" class="btn btn-outline" id="soundToggle">🔊</button>
|
|
||||||
<button onclick="toggleSafeMode()" class="btn btn-outline" id="safeModeToggle">🎙️</button>
|
|
||||||
<button onclick="logout()" class="btn btn-outline">Выйти</button>
|
|
||||||
{% else %}
|
|
||||||
<a href="/cases" class="nav-link">Кейсы</a>
|
|
||||||
<a href="/contracts" class="nav-link active">Контракты</a>
|
|
||||||
<a href="/upgrade" class="nav-link">🆙 Апгрейд</a>
|
|
||||||
<button onclick="toggleSafeMode()" class="btn btn-outline" id="safeModeToggle">🎙️</button>
|
|
||||||
<a href="/login" class="btn btn-outline">Войти</a>
|
|
||||||
<a href="/register" class="btn btn-primary">Регистрация</a>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.ct-page { max-width: 1100px; margin: 0 auto; padding: 1rem 1.5rem 3rem; }
|
.ct-page { max-width: 1100px; margin: 0 auto; padding: 1rem 1.5rem 3rem; }
|
||||||
@@ -682,9 +656,9 @@
|
|||||||
ctClosePaper();
|
ctClosePaper();
|
||||||
setTimeout(() => ctShowResult(data.received_item, data.is_knife_contract), 200);
|
setTimeout(() => ctShowResult(data.received_item, data.is_knife_contract), 200);
|
||||||
} else {
|
} else {
|
||||||
SoundManager.error(); alert(data.error || 'Ошибка'); ctClosePaper();
|
SoundManager.error(); Notify.error(data.error || 'Ошибка'); ctClosePaper();
|
||||||
}
|
}
|
||||||
} catch(_) { SoundManager.error(); alert('Ошибка соединения'); ctClosePaper(); }
|
} catch(_) { SoundManager.error(); Notify.error('Ошибка соединения'); ctClosePaper(); }
|
||||||
btn.disabled = false; btn.textContent = '✍ ПОДПИСАТЬ';
|
btn.disabled = false; btn.textContent = '✍ ПОДПИСАТЬ';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -730,8 +704,10 @@
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<script src="/static/js/app.js"></script>
|
||||||
<script src="/static/js/sounds.js"></script>
|
<script src="/static/js/sounds.js"></script>
|
||||||
<script src="/static/js/websocket.js"></script>
|
<script src="/static/js/websocket.js"></script>
|
||||||
|
<script src="/static/js/notifications.js"></script>
|
||||||
<script src="/static/js/safemode.js"></script>
|
<script src="/static/js/safemode.js"></script>
|
||||||
{% if user %}{% include '_activity_sidebar.html' %}{% endif %}
|
{% if user %}{% include '_activity_sidebar.html' %}{% endif %}
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
+6
-23
@@ -65,25 +65,7 @@
|
|||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<nav class="navbar">
|
{% include "_nav.html" %}
|
||||||
<div class="container">
|
|
||||||
<a href="/" class="logo">🎮 CS2 Simulator</a>
|
|
||||||
<div class="nav-links">
|
|
||||||
<a href="/cases" class="nav-link">Кейсы</a>
|
|
||||||
<a href="/contracts" class="nav-link">Контракты</a>
|
|
||||||
<a href="/upgrade" class="nav-link">🆙 Апгрейд</a>
|
|
||||||
<a href="/crash" class="nav-link active">💥 Crash</a>
|
|
||||||
<a href="/inventory" class="nav-link">Инвентарь</a>
|
|
||||||
<a href="/achievements" class="nav-link">🏆 Достижения</a>
|
|
||||||
<a href="/activity" class="nav-link">📰 Лента</a>
|
|
||||||
<a href="/profile" class="nav-link">Профиль</a>
|
|
||||||
<span class="user-balance">{{ "%.0f"|format(user.balance) }} ₽</span>
|
|
||||||
<button onclick="toggleSound()" class="btn btn-outline" id="soundToggle">🔊</button>
|
|
||||||
<button onclick="toggleSafeMode()" class="btn btn-outline" id="safeModeToggle">🎙️</button>
|
|
||||||
<button onclick="logout()" class="btn btn-outline">Выйти</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
|
|
||||||
<main class="container" style="padding: 2rem 1rem;">
|
<main class="container" style="padding: 2rem 1rem;">
|
||||||
<div class="crash-layout">
|
<div class="crash-layout">
|
||||||
@@ -136,6 +118,7 @@
|
|||||||
|
|
||||||
<script src="/static/js/sounds.js"></script>
|
<script src="/static/js/sounds.js"></script>
|
||||||
<script src="/static/js/websocket.js"></script>
|
<script src="/static/js/websocket.js"></script>
|
||||||
|
<script src="/static/js/notifications.js"></script>
|
||||||
<script src="/static/js/safemode.js"></script>
|
<script src="/static/js/safemode.js"></script>
|
||||||
<script>
|
<script>
|
||||||
const canvas = document.getElementById('crashCanvas');
|
const canvas = document.getElementById('crashCanvas');
|
||||||
@@ -468,11 +451,11 @@
|
|||||||
updateUI();
|
updateUI();
|
||||||
} else {
|
} else {
|
||||||
SoundManager.error();
|
SoundManager.error();
|
||||||
alert(data.error);
|
Notify.error(data.error);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
SoundManager.error();
|
SoundManager.error();
|
||||||
alert('Ошибка соединения');
|
Notify.error('Ошибка соединения');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -491,11 +474,11 @@
|
|||||||
updateUI();
|
updateUI();
|
||||||
} else {
|
} else {
|
||||||
SoundManager.error();
|
SoundManager.error();
|
||||||
alert(data.error);
|
Notify.error(data.error);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
SoundManager.error();
|
SoundManager.error();
|
||||||
alert('Ошибка соединения');
|
Notify.error('Ошибка соединения');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-14
@@ -7,20 +7,7 @@
|
|||||||
<link rel="stylesheet" href="/static/css/style.css">
|
<link rel="stylesheet" href="/static/css/style.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<nav class="navbar">
|
{% include "_nav.html" %}
|
||||||
<div class="container">
|
|
||||||
<a href="/" class="logo">🎮 CS2 Simulator</a>
|
|
||||||
<div class="nav-links">
|
|
||||||
<a href="/cases" class="nav-link">Кейсы</a>
|
|
||||||
<a href="/contracts" class="nav-link">Контракты</a>
|
|
||||||
<a href="/upgrade" class="nav-link">🆙 Апгрейд</a>
|
|
||||||
<a href="/activity" class="nav-link">📰 Лента</a>
|
|
||||||
<button onclick="toggleSafeMode()" class="btn btn-outline" id="safeModeToggle" title="Режим записи">🎙️</button>
|
|
||||||
<a href="/login" class="btn btn-outline">Войти</a>
|
|
||||||
<a href="/register" class="btn btn-primary">Регистрация</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
|
|
||||||
<main class="hero">
|
<main class="hero">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|||||||
@@ -1,802 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="ru">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>Инвентарь - CS2 Simulator</title>
|
|
||||||
<link rel="stylesheet" href="/static/css/style.css">
|
|
||||||
<style>
|
|
||||||
.inventory-actions {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
margin-bottom: 1rem;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
gap: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.selection-controls {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 0.75rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.select-all-checkbox {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 0.5rem;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
.select-all-checkbox input {
|
|
||||||
width: 18px;
|
|
||||||
height: 18px;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
.sell-selected-btn {
|
|
||||||
padding: 0.5rem 1.5rem;
|
|
||||||
background: var(--danger-color);
|
|
||||||
color: white;
|
|
||||||
border: none;
|
|
||||||
border-radius: 8px;
|
|
||||||
cursor: pointer;
|
|
||||||
font-weight: 500;
|
|
||||||
transition: all 0.2s;
|
|
||||||
}
|
|
||||||
|
|
||||||
.sell-selected-btn:hover {
|
|
||||||
background: #dc2626;
|
|
||||||
transform: translateY(-1px);
|
|
||||||
}
|
|
||||||
|
|
||||||
.sell-selected-btn:disabled {
|
|
||||||
opacity: 0.5;
|
|
||||||
cursor: not-allowed;
|
|
||||||
}
|
|
||||||
|
|
||||||
.sell-all-btn {
|
|
||||||
padding: 0.5rem 1.5rem;
|
|
||||||
background: transparent;
|
|
||||||
color: var(--danger-color);
|
|
||||||
border: 1px solid var(--danger-color);
|
|
||||||
border-radius: 8px;
|
|
||||||
cursor: pointer;
|
|
||||||
font-weight: 500;
|
|
||||||
transition: all 0.2s;
|
|
||||||
}
|
|
||||||
|
|
||||||
.sell-all-btn:hover {
|
|
||||||
background: rgba(239, 68, 68, 0.1);
|
|
||||||
}
|
|
||||||
|
|
||||||
.inventory-skin-card {
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
.item-select-checkbox {
|
|
||||||
position: absolute;
|
|
||||||
top: 8px;
|
|
||||||
left: 8px;
|
|
||||||
width: 20px;
|
|
||||||
height: 20px;
|
|
||||||
cursor: pointer;
|
|
||||||
z-index: 10;
|
|
||||||
accent-color: var(--primary-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
.inventory-skin-card.selected-for-sale {
|
|
||||||
border-color: var(--danger-color);
|
|
||||||
box-shadow: 0 0 15px rgba(239, 68, 68, 0.3);
|
|
||||||
}
|
|
||||||
|
|
||||||
.selected-count-badge {
|
|
||||||
background: var(--danger-color);
|
|
||||||
color: white;
|
|
||||||
padding: 0.25rem 0.75rem;
|
|
||||||
border-radius: 20px;
|
|
||||||
font-size: 0.85rem;
|
|
||||||
font-weight: 500;
|
|
||||||
}
|
|
||||||
|
|
||||||
.total-price-badge {
|
|
||||||
background: var(--success-color);
|
|
||||||
color: white;
|
|
||||||
padding: 0.25rem 0.75rem;
|
|
||||||
border-radius: 20px;
|
|
||||||
font-size: 0.85rem;
|
|
||||||
font-weight: 500;
|
|
||||||
}
|
|
||||||
|
|
||||||
.item-actions {
|
|
||||||
display: flex;
|
|
||||||
gap: 0.5rem;
|
|
||||||
margin-top: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-sell-single {
|
|
||||||
flex: 1;
|
|
||||||
padding: 0.25rem;
|
|
||||||
background: transparent;
|
|
||||||
border: 1px solid var(--danger-color);
|
|
||||||
color: var(--danger-color);
|
|
||||||
border-radius: 4px;
|
|
||||||
cursor: pointer;
|
|
||||||
font-size: 0.75rem;
|
|
||||||
transition: all 0.2s;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-sell-single:hover {
|
|
||||||
background: var(--danger-color);
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
|
|
||||||
.filter-bar {
|
|
||||||
display: flex;
|
|
||||||
gap: 0.5rem;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
.bulk-sell-modal {
|
|
||||||
position: fixed;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
right: 0;
|
|
||||||
bottom: 0;
|
|
||||||
background: rgba(0, 0, 0, 0.8);
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
z-index: 1000;
|
|
||||||
}
|
|
||||||
|
|
||||||
.bulk-sell-content {
|
|
||||||
background: var(--bg-card);
|
|
||||||
padding: 2rem;
|
|
||||||
border-radius: 12px;
|
|
||||||
max-width: 400px;
|
|
||||||
width: 90%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.bulk-sell-content h3 {
|
|
||||||
margin-bottom: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.bulk-sell-options {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 0.5rem;
|
|
||||||
margin: 1.5rem 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.bulk-sell-option {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 0.75rem;
|
|
||||||
padding: 0.75rem;
|
|
||||||
background: var(--bg-dark);
|
|
||||||
border-radius: 8px;
|
|
||||||
cursor: pointer;
|
|
||||||
transition: all 0.2s;
|
|
||||||
}
|
|
||||||
|
|
||||||
.bulk-sell-option:hover {
|
|
||||||
background: var(--bg-light);
|
|
||||||
}
|
|
||||||
|
|
||||||
.bulk-sell-option input {
|
|
||||||
width: 18px;
|
|
||||||
height: 18px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.bulk-sell-actions {
|
|
||||||
display: flex;
|
|
||||||
gap: 1rem;
|
|
||||||
justify-content: flex-end;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<nav class="navbar">
|
|
||||||
<div class="container">
|
|
||||||
<a href="/" class="logo">🎮 CS2 Simulator</a>
|
|
||||||
<div class="nav-links">
|
|
||||||
<a href="/cases" class="nav-link">Кейсы</a>
|
|
||||||
<a href="/contracts" class="nav-link">Контракты</a>
|
|
||||||
<a href="/upgrade" class="nav-link">🆙 Апгрейд</a>
|
|
||||||
<a href="/crash" class="nav-link">💥 Crash</a>
|
|
||||||
<a href="/inventory" class="nav-link">Инвентарь</a>
|
|
||||||
<a href="/activity" class="nav-link">📰 Лента</a>
|
|
||||||
<a href="/achievements" class="nav-link">🏆 Достижения</a>
|
|
||||||
<a href="/profile" class="nav-link">Профиль</a>
|
|
||||||
<span class="user-balance">{{ "%.2f"|format(user.balance) }} ₽</span>
|
|
||||||
<button onclick="toggleSound()" class="btn btn-outline" id="soundToggle" title="Звук">🔊</button>
|
|
||||||
<button onclick="toggleSafeMode()" class="btn btn-outline" id="safeModeToggle" title="Режим записи">🎙️</button>
|
|
||||||
<button onclick="logout()" class="btn btn-outline">Выйти</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
|
|
||||||
<main class="inventory-container">
|
|
||||||
<div class="container">
|
|
||||||
<div class="inventory-header">
|
|
||||||
<div>
|
|
||||||
<h1>🎒 Инвентарь</h1>
|
|
||||||
<p class="page-subtitle">Всего предметов: <span id="totalItemsCount">{{ inventory_items|length }}</span></p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="inventory-actions">
|
|
||||||
<div class="selection-controls">
|
|
||||||
<label class="select-all-checkbox">
|
|
||||||
<input type="checkbox" id="selectAllCheckbox" onchange="toggleSelectAll()">
|
|
||||||
<span>Выбрать все</span>
|
|
||||||
</label>
|
|
||||||
<span class="selected-count-badge" id="selectedCountBadge" style="display: none;">0</span>
|
|
||||||
<span class="total-price-badge" id="totalPriceBadge" style="display: none;">0 ₽</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div style="display: flex; gap: 0.75rem;">
|
|
||||||
<button class="sell-selected-btn" id="sellSelectedBtn" onclick="sellSelected()" disabled>
|
|
||||||
💰 Продать выбранные
|
|
||||||
</button>
|
|
||||||
<button class="sell-all-btn" onclick="openBulkSellModal()">
|
|
||||||
📦 Массовая продажа
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="inventory-filters">
|
|
||||||
<div class="filter-bar">
|
|
||||||
<select id="rarityFilter" class="filter-select" onchange="filterItems()">
|
|
||||||
<option value="">Все редкости</option>
|
|
||||||
{% for rarity in rarities %}
|
|
||||||
<option value="{{ rarity }}">{{ rarity }}</option>
|
|
||||||
{% endfor %}
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<select id="typeFilter" class="filter-select" onchange="filterItems()">
|
|
||||||
<option value="">Все типы</option>
|
|
||||||
{% for type in types %}
|
|
||||||
<option value="{{ type }}">{{ type }}</option>
|
|
||||||
{% endfor %}
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<input type="text" id="searchInput" class="filter-select"
|
|
||||||
placeholder="Поиск по названию..." oninput="filterItems()">
|
|
||||||
|
|
||||||
<button onclick="resetFilters()" class="btn btn-outline">Сбросить</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{% if inventory_items %}
|
|
||||||
<div class="inventory-grid-detailed" id="inventoryGrid">
|
|
||||||
{% for item in inventory_items %}
|
|
||||||
<div class="inventory-skin-card rarity-{{ item.rarity|lower|replace(' ', '-') }}"
|
|
||||||
data-inventory-id="{{ item.id }}"
|
|
||||||
data-rarity="{{ item.rarity }}"
|
|
||||||
data-type="{{ item.type }}"
|
|
||||||
data-name="{{ item.name|lower }}"
|
|
||||||
data-price="{{ item.price_rub or 100 }}">
|
|
||||||
<input type="checkbox" class="item-select-checkbox"
|
|
||||||
onchange="onItemSelect(this)"
|
|
||||||
data-id="{{ item.id }}"
|
|
||||||
data-price="{{ item.price_rub or 100 }}">
|
|
||||||
|
|
||||||
<div class="skin-image-container">
|
|
||||||
<img src="{{ item.image_url or '/static/placeholder.png' }}"
|
|
||||||
alt="{{ item.name }}"
|
|
||||||
class="skin-image"
|
|
||||||
onerror="this.src='/static/placeholder.png'">
|
|
||||||
</div>
|
|
||||||
<div class="skin-info">
|
|
||||||
<div class="skin-name" title="{{ item.name }}">{{ item.name }}</div>
|
|
||||||
<div class="skin-details">
|
|
||||||
<span class="rarity-{{ item.rarity|lower|replace(' ', '-') }}">{{ item.rarity }}</span>
|
|
||||||
<span>Float: {{ "%.6f"|format(item.float) }}</span>
|
|
||||||
</div>
|
|
||||||
<div class="skin-details" style="margin-top: 5px;">
|
|
||||||
<span>{{ item.type }}</span>
|
|
||||||
<span>{{ item.wear }}</span>
|
|
||||||
</div>
|
|
||||||
<div class="skin-details" style="margin-top: 5px; color: var(--success-color);">
|
|
||||||
<span>💰 {{ "%.0f"|format(item.price_rub or 100) }} ₽</span>
|
|
||||||
</div>
|
|
||||||
<div class="item-actions">
|
|
||||||
<button onclick="sellSingleItem({{ item.id }})" class="btn-sell-single">
|
|
||||||
Продать
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
{% else %}
|
|
||||||
<div class="empty-state-large">
|
|
||||||
<div class="empty-icon">📭</div>
|
|
||||||
<h3>Ваш инвентарь пуст</h3>
|
|
||||||
<p>Откройте кейсы, чтобы получить первые предметы!</p>
|
|
||||||
<a href="/cases" class="btn btn-primary">Открыть кейсы</a>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
</main>
|
|
||||||
|
|
||||||
<!-- Модальное окно массовой продажи -->
|
|
||||||
<div id="bulkSellModal" class="bulk-sell-modal" style="display: none;">
|
|
||||||
<div class="bulk-sell-content">
|
|
||||||
<h3>📦 Массовая продажа</h3>
|
|
||||||
<p>Выберите редкости предметов для продажи:</p>
|
|
||||||
|
|
||||||
<div class="bulk-sell-options" id="bulkSellOptions">
|
|
||||||
<!-- Опции будут добавлены через JS -->
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div style="margin: 1rem 0;">
|
|
||||||
<p>Будет продано: <strong id="bulkSellCount">0</strong> предметов</p>
|
|
||||||
<p>Сумма: <strong id="bulkSellTotal" style="color: var(--success-color);">0 ₽</strong></p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="bulk-sell-actions">
|
|
||||||
<button class="btn btn-outline" onclick="closeBulkSellModal()">Отмена</button>
|
|
||||||
<button class="btn btn-primary" onclick="executeBulkSell()" style="background: var(--danger-color);">
|
|
||||||
Продать
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
let selectedItems = new Set();
|
|
||||||
let itemPrices = new Map();
|
|
||||||
|
|
||||||
// Инициализация цен
|
|
||||||
document.querySelectorAll('.inventory-skin-card').forEach(card => {
|
|
||||||
const id = parseInt(card.dataset.inventoryId);
|
|
||||||
const price = parseFloat(card.dataset.price);
|
|
||||||
itemPrices.set(id, price);
|
|
||||||
});
|
|
||||||
|
|
||||||
function onItemSelect(checkbox) {
|
|
||||||
const card = checkbox.closest('.inventory-skin-card');
|
|
||||||
const itemId = parseInt(checkbox.dataset.id);
|
|
||||||
|
|
||||||
if (checkbox.checked) {
|
|
||||||
selectedItems.add(itemId);
|
|
||||||
card.classList.add('selected-for-sale');
|
|
||||||
} else {
|
|
||||||
selectedItems.delete(itemId);
|
|
||||||
card.classList.remove('selected-for-sale');
|
|
||||||
document.getElementById('selectAllCheckbox').checked = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
updateSelectionUI();
|
|
||||||
}
|
|
||||||
|
|
||||||
function toggleSelectAll() {
|
|
||||||
const selectAll = document.getElementById('selectAllCheckbox');
|
|
||||||
const checkboxes = document.querySelectorAll('.item-select-checkbox');
|
|
||||||
|
|
||||||
checkboxes.forEach(cb => {
|
|
||||||
if (cb.closest('.inventory-skin-card').style.display !== 'none') {
|
|
||||||
cb.checked = selectAll.checked;
|
|
||||||
const card = cb.closest('.inventory-skin-card');
|
|
||||||
const itemId = parseInt(cb.dataset.id);
|
|
||||||
|
|
||||||
if (selectAll.checked) {
|
|
||||||
selectedItems.add(itemId);
|
|
||||||
card.classList.add('selected-for-sale');
|
|
||||||
} else {
|
|
||||||
selectedItems.delete(itemId);
|
|
||||||
card.classList.remove('selected-for-sale');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
updateSelectionUI();
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateSelectionUI() {
|
|
||||||
const count = selectedItems.size;
|
|
||||||
const countBadge = document.getElementById('selectedCountBadge');
|
|
||||||
const priceBadge = document.getElementById('totalPriceBadge');
|
|
||||||
const sellBtn = document.getElementById('sellSelectedBtn');
|
|
||||||
|
|
||||||
if (count > 0) {
|
|
||||||
countBadge.style.display = 'inline-block';
|
|
||||||
countBadge.textContent = `${count} выбрано`;
|
|
||||||
|
|
||||||
let total = 0;
|
|
||||||
selectedItems.forEach(id => {
|
|
||||||
total += itemPrices.get(id) || 100;
|
|
||||||
});
|
|
||||||
|
|
||||||
priceBadge.style.display = 'inline-block';
|
|
||||||
priceBadge.textContent = `${total.toFixed(0)} ₽`;
|
|
||||||
|
|
||||||
sellBtn.disabled = false;
|
|
||||||
} else {
|
|
||||||
countBadge.style.display = 'none';
|
|
||||||
priceBadge.style.display = 'none';
|
|
||||||
sellBtn.disabled = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function refreshBalance() {
|
|
||||||
try {
|
|
||||||
const response = await fetch('/web/api/user/balance');
|
|
||||||
const data = await response.json();
|
|
||||||
if (data.success) {
|
|
||||||
document.querySelectorAll('.user-balance').forEach(el => {
|
|
||||||
el.textContent = `${Math.floor(data.balance)} ₽`;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} catch (e) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function sellSingleItem(inventoryId) {
|
|
||||||
if (!confirm('Продать этот предмет?')) return;
|
|
||||||
SoundManager.click();
|
|
||||||
|
|
||||||
const formData = new FormData();
|
|
||||||
formData.append('inventory_id', inventoryId);
|
|
||||||
|
|
||||||
try {
|
|
||||||
const response = await fetch('/web/api/inventory/sell', {
|
|
||||||
method: 'POST',
|
|
||||||
body: formData
|
|
||||||
});
|
|
||||||
|
|
||||||
const data = await response.json();
|
|
||||||
|
|
||||||
if (data.success) {
|
|
||||||
SoundManager.balanceUpdate();
|
|
||||||
const card = document.querySelector(`.inventory-skin-card[data-id="${inventoryId}"]`);
|
|
||||||
if (card) {
|
|
||||||
card.style.transition = 'all 0.3s';
|
|
||||||
card.style.opacity = '0';
|
|
||||||
card.style.transform = 'scale(0.8)';
|
|
||||||
setTimeout(() => card.remove(), 300);
|
|
||||||
}
|
|
||||||
await refreshBalance();
|
|
||||||
} else {
|
|
||||||
SoundManager.error();
|
|
||||||
alert(data.error || 'Ошибка при продаже');
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
SoundManager.error();
|
|
||||||
alert('Ошибка соединения');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function sellSelected() {
|
|
||||||
if (selectedItems.size === 0) return;
|
|
||||||
|
|
||||||
let total = 0;
|
|
||||||
selectedItems.forEach(id => {
|
|
||||||
total += itemPrices.get(id) || 100;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!confirm(`Продать ${selectedItems.size} предметов за ${total.toFixed(0)} ₽?`)) return;
|
|
||||||
SoundManager.click();
|
|
||||||
|
|
||||||
const ids = Array.from(selectedItems);
|
|
||||||
|
|
||||||
const formData = new FormData();
|
|
||||||
formData.append('inventory_ids', JSON.stringify(ids));
|
|
||||||
|
|
||||||
try {
|
|
||||||
const response = await fetch('/web/api/inventory/sell/bulk', {
|
|
||||||
method: 'POST',
|
|
||||||
body: formData
|
|
||||||
});
|
|
||||||
|
|
||||||
const data = await response.json();
|
|
||||||
|
|
||||||
if (data.success) {
|
|
||||||
selectedItems.forEach(id => {
|
|
||||||
const card = document.querySelector(`.inventory-skin-card[data-id="${id}"]`);
|
|
||||||
if (card) {
|
|
||||||
card.style.transition = 'all 0.3s';
|
|
||||||
card.style.opacity = '0';
|
|
||||||
card.style.transform = 'scale(0.8)';
|
|
||||||
setTimeout(() => card.remove(), 300);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
selectedItems.clear();
|
|
||||||
await refreshBalance();
|
|
||||||
} else {
|
|
||||||
alert(data.error || 'Ошибка при продаже');
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
alert('Ошибка соединения');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function openBulkSellModal() {
|
|
||||||
const modal = document.getElementById('bulkSellModal');
|
|
||||||
const optionsDiv = document.getElementById('bulkSellOptions');
|
|
||||||
|
|
||||||
// Собираем уникальные редкости из видимых предметов
|
|
||||||
const rarities = new Set();
|
|
||||||
document.querySelectorAll('.inventory-skin-card').forEach(card => {
|
|
||||||
if (card.style.display !== 'none') {
|
|
||||||
rarities.add(card.dataset.rarity);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Создаем опции
|
|
||||||
optionsDiv.innerHTML = '';
|
|
||||||
Array.from(rarities).sort().forEach(rarity => {
|
|
||||||
const count = document.querySelectorAll(`.inventory-skin-card[data-rarity="${rarity}"]`).length;
|
|
||||||
|
|
||||||
const option = document.createElement('label');
|
|
||||||
option.className = 'bulk-sell-option';
|
|
||||||
option.innerHTML = `
|
|
||||||
<input type="checkbox" value="${rarity}" onchange="updateBulkSellCount()">
|
|
||||||
<span style="flex: 1;">
|
|
||||||
<span class="rarity-${rarity.toLowerCase().replace(/ /g, '-')}">${rarity}</span>
|
|
||||||
</span>
|
|
||||||
<span style="color: var(--text-secondary);">${count} шт.</span>
|
|
||||||
`;
|
|
||||||
optionsDiv.appendChild(option);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Добавляем опцию "Все"
|
|
||||||
const allOption = document.createElement('label');
|
|
||||||
allOption.className = 'bulk-sell-option';
|
|
||||||
allOption.innerHTML = `
|
|
||||||
<input type="checkbox" value="all" onchange="toggleAllRarities(this)">
|
|
||||||
<span style="flex: 1; font-weight: 500;">Все предметы</span>
|
|
||||||
<span style="color: var(--text-secondary);" id="totalVisibleCount">0</span>
|
|
||||||
`;
|
|
||||||
optionsDiv.insertBefore(allOption, optionsDiv.firstChild);
|
|
||||||
|
|
||||||
updateVisibleCount();
|
|
||||||
updateBulkSellCount();
|
|
||||||
|
|
||||||
modal.style.display = 'flex';
|
|
||||||
}
|
|
||||||
|
|
||||||
function closeBulkSellModal() {
|
|
||||||
document.getElementById('bulkSellModal').style.display = 'none';
|
|
||||||
}
|
|
||||||
|
|
||||||
function toggleAllRarities(checkbox) {
|
|
||||||
const checkboxes = document.querySelectorAll('#bulkSellOptions input[type="checkbox"]');
|
|
||||||
checkboxes.forEach(cb => {
|
|
||||||
if (cb !== checkbox) {
|
|
||||||
cb.checked = checkbox.checked;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
updateBulkSellCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateVisibleCount() {
|
|
||||||
const visibleCards = document.querySelectorAll('.inventory-skin-card:not([style*="display: none"])');
|
|
||||||
document.getElementById('totalVisibleCount').textContent = visibleCards.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateBulkSellCount() {
|
|
||||||
const selectedRarities = [];
|
|
||||||
document.querySelectorAll('#bulkSellOptions input[type="checkbox"]:checked').forEach(cb => {
|
|
||||||
if (cb.value && cb.value !== 'all') {
|
|
||||||
selectedRarities.push(cb.value);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const allChecked = document.querySelector('#bulkSellOptions input[value="all"]')?.checked;
|
|
||||||
|
|
||||||
let count = 0;
|
|
||||||
let total = 0;
|
|
||||||
|
|
||||||
document.querySelectorAll('.inventory-skin-card').forEach(card => {
|
|
||||||
if (card.style.display !== 'none') {
|
|
||||||
const rarity = card.dataset.rarity;
|
|
||||||
if (allChecked || selectedRarities.includes(rarity)) {
|
|
||||||
count++;
|
|
||||||
total += parseFloat(card.dataset.price) || 100;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
document.getElementById('bulkSellCount').textContent = count;
|
|
||||||
document.getElementById('bulkSellTotal').textContent = `${total.toFixed(0)} ₽`;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function executeBulkSell() {
|
|
||||||
const selectedRarities = [];
|
|
||||||
document.querySelectorAll('#bulkSellOptions input[type="checkbox"]:checked').forEach(cb => {
|
|
||||||
if (cb.value && cb.value !== 'all') {
|
|
||||||
selectedRarities.push(cb.value);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const allChecked = document.querySelector('#bulkSellOptions input[value="all"]')?.checked;
|
|
||||||
|
|
||||||
const idsToSell = [];
|
|
||||||
document.querySelectorAll('.inventory-skin-card').forEach(card => {
|
|
||||||
if (card.style.display !== 'none') {
|
|
||||||
const rarity = card.dataset.rarity;
|
|
||||||
if (allChecked || selectedRarities.includes(rarity)) {
|
|
||||||
idsToSell.push(parseInt(card.dataset.inventoryId));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (idsToSell.length === 0) {
|
|
||||||
alert('Выберите хотя бы одну редкость');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!confirm(`Продать ${idsToSell.length} предметов?`)) return;
|
|
||||||
|
|
||||||
const formData = new FormData();
|
|
||||||
formData.append('inventory_ids', JSON.stringify(idsToSell));
|
|
||||||
|
|
||||||
try {
|
|
||||||
const response = await fetch('/web/api/inventory/sell/bulk', {
|
|
||||||
method: 'POST',
|
|
||||||
body: formData
|
|
||||||
});
|
|
||||||
|
|
||||||
const data = await response.json();
|
|
||||||
|
|
||||||
if (data.success) {
|
|
||||||
await refreshBalance();
|
|
||||||
// Remove all cards with animation
|
|
||||||
document.querySelectorAll('.inventory-skin-card').forEach(card => {
|
|
||||||
card.style.transition = 'all 0.3s';
|
|
||||||
card.style.opacity = '0';
|
|
||||||
card.style.transform = 'scale(0.8)';
|
|
||||||
setTimeout(() => card.remove(), 300);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
alert(data.error || 'Ошибка при продаже');
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
alert('Ошибка соединения');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function filterItems() {
|
|
||||||
const rarityFilter = document.getElementById('rarityFilter').value.toLowerCase();
|
|
||||||
const typeFilter = document.getElementById('typeFilter').value.toLowerCase();
|
|
||||||
const searchQuery = document.getElementById('searchInput').value.toLowerCase();
|
|
||||||
|
|
||||||
const items = document.querySelectorAll('.inventory-skin-card');
|
|
||||||
let visibleCount = 0;
|
|
||||||
|
|
||||||
items.forEach(item => {
|
|
||||||
const rarity = item.dataset.rarity.toLowerCase();
|
|
||||||
const type = item.dataset.type.toLowerCase();
|
|
||||||
const name = item.dataset.name;
|
|
||||||
|
|
||||||
let visible = true;
|
|
||||||
|
|
||||||
if (rarityFilter && rarity !== rarityFilter) visible = false;
|
|
||||||
if (typeFilter && type !== typeFilter) visible = false;
|
|
||||||
if (searchQuery && !name.includes(searchQuery)) visible = false;
|
|
||||||
|
|
||||||
item.style.display = visible ? 'block' : 'none';
|
|
||||||
if (visible) visibleCount++;
|
|
||||||
});
|
|
||||||
|
|
||||||
document.getElementById('totalItemsCount').textContent = visibleCount;
|
|
||||||
|
|
||||||
// Сбрасываем выбор при фильтрации
|
|
||||||
selectedItems.clear();
|
|
||||||
document.querySelectorAll('.item-select-checkbox').forEach(cb => cb.checked = false);
|
|
||||||
document.querySelectorAll('.inventory-skin-card').forEach(c => c.classList.remove('selected-for-sale'));
|
|
||||||
document.getElementById('selectAllCheckbox').checked = false;
|
|
||||||
updateSelectionUI();
|
|
||||||
}
|
|
||||||
|
|
||||||
function resetFilters() {
|
|
||||||
document.getElementById('rarityFilter').value = '';
|
|
||||||
document.getElementById('typeFilter').value = '';
|
|
||||||
document.getElementById('searchInput').value = '';
|
|
||||||
filterItems();
|
|
||||||
}
|
|
||||||
|
|
||||||
async function logout() {
|
|
||||||
await fetch('/web/api/auth/logout', { method: 'POST' });
|
|
||||||
window.location.href = '/';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Закрытие модального окна по клику вне
|
|
||||||
document.getElementById('bulkSellModal').addEventListener('click', (e) => {
|
|
||||||
if (e.target.classList.contains('bulk-sell-modal')) {
|
|
||||||
closeBulkSellModal();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
<script src="/static/js/sounds.js"></script>
|
|
||||||
<script src="/static/js/websocket.js"></script>
|
|
||||||
<script src="/static/js/safemode.js"></script>
|
|
||||||
<script>
|
|
||||||
function toggleSound() {
|
|
||||||
const enabled = SoundManager.toggle();
|
|
||||||
document.getElementById('soundToggle').textContent = enabled ? '🔊' : '🔇';
|
|
||||||
}
|
|
||||||
document.addEventListener('DOMContentLoaded', () => {
|
|
||||||
const btn = document.getElementById('soundToggle');
|
|
||||||
if (btn) btn.textContent = localStorage.getItem('sound_enabled') !== 'false' ? '🔊' : '🔇';
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
<script>
|
|
||||||
// Живое обновление через WebSocket
|
|
||||||
WS.on('inventory_update', () => refreshInventory());
|
|
||||||
WS.on('item_sold', () => refreshInventory());
|
|
||||||
WS.on('balance_update', () => { if (typeof refreshBalance === 'function') refreshBalance(); });
|
|
||||||
|
|
||||||
let refreshTimeout;
|
|
||||||
function refreshInventory() {
|
|
||||||
clearTimeout(refreshTimeout);
|
|
||||||
refreshTimeout = setTimeout(() => {
|
|
||||||
fetch('/web/api/inventory/items')
|
|
||||||
.then(r => r.json())
|
|
||||||
.then(items => rebuildInventoryGrid(items))
|
|
||||||
.catch(() => {});
|
|
||||||
}, 800);
|
|
||||||
}
|
|
||||||
|
|
||||||
function rebuildInventoryGrid(items) {
|
|
||||||
const grid = document.getElementById('inventoryGrid');
|
|
||||||
if (!grid) return;
|
|
||||||
if (!items.length) {
|
|
||||||
grid.innerHTML = '<div class="empty-state-large"><div class="empty-icon">📭</div><h3>Ваш инвентарь пуст</h3><p>Откройте кейсы, чтобы получить первые предметы!</p><a href="/cases" class="btn btn-primary">Открыть кейсы</a></div>';
|
|
||||||
document.getElementById('selectAllCheckbox') && (document.getElementById('selectAllCheckbox').checked = false);
|
|
||||||
selectedItems.clear();
|
|
||||||
updateSelectionUI();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let html = '';
|
|
||||||
items.forEach(item => {
|
|
||||||
const rarityClass = (item.rarity || 'unknown').toLowerCase().replace(/\s+/g, '-');
|
|
||||||
const image = item.image_url || '/static/placeholder.png';
|
|
||||||
const floatStr = item.float !== null && item.float !== undefined ? 'Float: ' + item.float.toFixed(6) : '';
|
|
||||||
const wearStr = item.wear || '';
|
|
||||||
const typeStr = item.type || '';
|
|
||||||
html += `<div class="inventory-skin-card rarity-${rarityClass}"
|
|
||||||
data-inventory-id="${item.id}"
|
|
||||||
data-rarity="${item.rarity || ''}"
|
|
||||||
data-type="${typeStr}"
|
|
||||||
data-name="${(item.name || '').toLowerCase()}"
|
|
||||||
data-price="${item.price_rub || 100}">
|
|
||||||
<input type="checkbox" class="item-select-checkbox"
|
|
||||||
onchange="onItemSelect(this)"
|
|
||||||
data-id="${item.id}"
|
|
||||||
data-price="${item.price_rub || 100}">
|
|
||||||
<div class="skin-image-container">
|
|
||||||
<img src="${image}" alt="${item.name}" class="skin-image" onerror="this.src='/static/placeholder.png'">
|
|
||||||
</div>
|
|
||||||
<div class="skin-info">
|
|
||||||
<div class="skin-name" title="${item.name}">${item.name}</div>
|
|
||||||
<div class="skin-details">
|
|
||||||
<span class="rarity-${rarityClass}">${item.rarity || ''}</span>
|
|
||||||
<span>${floatStr}</span>
|
|
||||||
</div>
|
|
||||||
<div class="skin-details" style="margin-top:5px">
|
|
||||||
<span>${typeStr}</span>
|
|
||||||
<span>${wearStr}</span>
|
|
||||||
</div>
|
|
||||||
<div class="skin-details" style="margin-top:5px;color:var(--success-color)">
|
|
||||||
<span>💰 ${(item.price_rub || 100).toLocaleString()} ₽</span>
|
|
||||||
</div>
|
|
||||||
<div class="item-actions">
|
|
||||||
<button onclick="sellSingleItem(${item.id})" class="btn-sell-single">Продать</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>`;
|
|
||||||
});
|
|
||||||
grid.innerHTML = html;
|
|
||||||
selectedItems.clear();
|
|
||||||
updateSelectionUI();
|
|
||||||
document.getElementById('selectAllCheckbox') && (document.getElementById('selectAllCheckbox').checked = false);
|
|
||||||
if (typeof filterItems === 'function') filterItems();
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
{% include '_activity_sidebar.html' %}
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -7,15 +7,7 @@
|
|||||||
<link rel="stylesheet" href="/static/css/style.css">
|
<link rel="stylesheet" href="/static/css/style.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<nav class="navbar">
|
{% include "_nav.html" %}
|
||||||
<div class="container">
|
|
||||||
<a href="/" class="logo">🎮 CS2 Simulator</a>
|
|
||||||
<div class="nav-links">
|
|
||||||
<button onclick="toggleSafeMode()" class="btn btn-outline" id="safeModeToggle" title="Режим записи">🎙️</button>
|
|
||||||
<a href="/register" class="btn btn-outline">Регистрация</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
|
|
||||||
<main class="auth-container">
|
<main class="auth-container">
|
||||||
<div class="auth-card">
|
<div class="auth-card">
|
||||||
|
|||||||
+1109
-77
File diff suppressed because it is too large
Load Diff
@@ -7,15 +7,7 @@
|
|||||||
<link rel="stylesheet" href="/static/css/style.css">
|
<link rel="stylesheet" href="/static/css/style.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<nav class="navbar">
|
{% include "_nav.html" %}
|
||||||
<div class="container">
|
|
||||||
<a href="/" class="logo">🎮 CS2 Simulator</a>
|
|
||||||
<div class="nav-links">
|
|
||||||
<button onclick="toggleSafeMode()" class="btn btn-outline" id="safeModeToggle" title="Режим записи">🎙️</button>
|
|
||||||
<a href="/login" class="btn btn-outline">Войти</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
|
|
||||||
<main class="auth-container">
|
<main class="auth-container">
|
||||||
<div class="auth-card">
|
<div class="auth-card">
|
||||||
|
|||||||
+8
-48
@@ -7,35 +7,7 @@
|
|||||||
<link rel="stylesheet" href="/static/css/style.css">
|
<link rel="stylesheet" href="/static/css/style.css">
|
||||||
</head>
|
</head>
|
||||||
<body class="upgrade-page">
|
<body class="upgrade-page">
|
||||||
<nav class="navbar">
|
{% include "_nav.html" %}
|
||||||
<div class="container">
|
|
||||||
<a href="/" class="logo">🎮 CS2 Simulator</a>
|
|
||||||
<div class="nav-links">
|
|
||||||
{% if user %}
|
|
||||||
<a href="/cases" class="nav-link">Кейсы</a>
|
|
||||||
<a href="/contracts" class="nav-link">Контракты</a>
|
|
||||||
<a href="/upgrade" class="nav-link active">🆙 Апгрейд</a>
|
|
||||||
<a href="/crash" class="nav-link">💥 Crash</a>
|
|
||||||
<a href="/inventory" class="nav-link">Инвентарь</a>
|
|
||||||
<a href="/activity" class="nav-link">📰 Лента</a>
|
|
||||||
<a href="/achievements" class="nav-link">🏆 Достижения</a>
|
|
||||||
<a href="/profile" class="nav-link">Профиль</a>
|
|
||||||
<span class="user-balance">{{ "%.0f"|format(user.balance) }} ₽</span>
|
|
||||||
<button onclick="toggleSound()" class="btn btn-outline" id="soundToggle" title="Звук">🔊</button>
|
|
||||||
<button onclick="toggleSafeMode()" class="btn btn-outline" id="safeModeToggle" title="Режим записи">🎙️</button>
|
|
||||||
<button onclick="logout()" class="btn btn-outline">Выйти</button>
|
|
||||||
{% else %}
|
|
||||||
<a href="/cases" class="nav-link">Кейсы</a>
|
|
||||||
<a href="/contracts" class="nav-link">Контракты</a>
|
|
||||||
<a href="/upgrade" class="nav-link active">🆙 Апгрейд</a>
|
|
||||||
<a href="/activity" class="nav-link">📰 Лента</a>
|
|
||||||
<button onclick="toggleSafeMode()" class="btn btn-outline" id="safeModeToggle" title="Режим записи">🎙️</button>
|
|
||||||
<a href="/login" class="btn btn-outline">Войти</a>
|
|
||||||
<a href="/register" class="btn btn-primary">Регистрация</a>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
|
|
||||||
<main class="upgrade-container">
|
<main class="upgrade-container">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
@@ -109,7 +81,6 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="toastContainer" class="toast-container"></div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Target -->
|
<!-- Target -->
|
||||||
@@ -475,7 +446,7 @@
|
|||||||
if (isSpinning) return;
|
if (isSpinning) return;
|
||||||
const card = event.target.closest('.target-item-card');
|
const card = event.target.closest('.target-item-card');
|
||||||
if (card.classList.contains('disabled')) {
|
if (card.classList.contains('disabled')) {
|
||||||
alert('Этот предмет не подходит!');
|
Notify.error('Этот предмет не подходит!');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -596,19 +567,6 @@
|
|||||||
`).join('');
|
`).join('');
|
||||||
}
|
}
|
||||||
|
|
||||||
function showToast(message, type) {
|
|
||||||
const container = document.getElementById('toastContainer');
|
|
||||||
const toast = document.createElement('div');
|
|
||||||
toast.className = `toast ${type}`;
|
|
||||||
toast.textContent = message;
|
|
||||||
container.appendChild(toast);
|
|
||||||
requestAnimationFrame(() => toast.classList.add('show'));
|
|
||||||
setTimeout(() => {
|
|
||||||
toast.classList.remove('show');
|
|
||||||
setTimeout(() => toast.remove(), 300);
|
|
||||||
}, 3000);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function executeUpgrade() {
|
async function executeUpgrade() {
|
||||||
if (!selectedInput || !selectedTarget || isSpinning) return;
|
if (!selectedInput || !selectedTarget || isSpinning) return;
|
||||||
|
|
||||||
@@ -709,12 +667,12 @@
|
|||||||
document.getElementById('displayTargetPrice').textContent = `${Math.floor(data.received_item.price).toLocaleString()} ₽`;
|
document.getElementById('displayTargetPrice').textContent = `${Math.floor(data.received_item.price).toLocaleString()} ₽`;
|
||||||
document.getElementById('selectedTargetDisplay').style.borderColor = '#10b981';
|
document.getElementById('selectedTargetDisplay').style.borderColor = '#10b981';
|
||||||
document.getElementById('selectedTargetDisplay').style.boxShadow = '0 0 20px rgba(16,185,129,0.3)';
|
document.getElementById('selectedTargetDisplay').style.boxShadow = '0 0 20px rgba(16,185,129,0.3)';
|
||||||
showToast(`${getRandomPhrase('win')} ${data.received_item.name}`, 'success');
|
Notify.success(`${getRandomPhrase('win')} ${data.received_item.name}`);
|
||||||
SoundManager.wheelWin();
|
SoundManager.wheelWin();
|
||||||
} else {
|
} else {
|
||||||
document.getElementById('selectedInputDisplay').style.borderColor = '#ef4444';
|
document.getElementById('selectedInputDisplay').style.borderColor = '#ef4444';
|
||||||
document.getElementById('selectedInputDisplay').style.boxShadow = '0 0 20px rgba(239,68,68,0.3)';
|
document.getElementById('selectedInputDisplay').style.boxShadow = '0 0 20px rgba(239,68,68,0.3)';
|
||||||
showToast(getRandomPhrase('lose'), 'fail');
|
Notify.error(getRandomPhrase('lose'));
|
||||||
SoundManager.wheelLose();
|
SoundManager.wheelLose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -752,13 +710,13 @@
|
|||||||
// Запасной таймер на случай если transitionend не сработает
|
// Запасной таймер на случай если transitionend не сработает
|
||||||
setTimeout(showResult, spinDuration * 1000 + 300);
|
setTimeout(showResult, spinDuration * 1000 + 300);
|
||||||
} else {
|
} else {
|
||||||
alert(data.error || 'Ошибка');
|
Notify.error(data.error || 'Ошибка');
|
||||||
isSpinning = false;
|
isSpinning = false;
|
||||||
btn.disabled = false;
|
btn.disabled = false;
|
||||||
btn.textContent = '🎲 Апгрейд';
|
btn.textContent = '🎲 Апгрейд';
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
alert('Ошибка соединения');
|
Notify.error('Ошибка соединения');
|
||||||
isSpinning = false;
|
isSpinning = false;
|
||||||
btn.disabled = false;
|
btn.disabled = false;
|
||||||
btn.textContent = '🎲 Апгрейд';
|
btn.textContent = '🎲 Апгрейд';
|
||||||
@@ -797,7 +755,9 @@
|
|||||||
</script>
|
</script>
|
||||||
<script src="/static/js/sounds.js"></script>
|
<script src="/static/js/sounds.js"></script>
|
||||||
<script src="/static/js/websocket.js"></script>
|
<script src="/static/js/websocket.js"></script>
|
||||||
|
<script src="/static/js/notifications.js"></script>
|
||||||
<script src="/static/js/safemode.js"></script>
|
<script src="/static/js/safemode.js"></script>
|
||||||
|
<script src="/static/js/app.js"></script>
|
||||||
<script>
|
<script>
|
||||||
function handleAchievements(data) {
|
function handleAchievements(data) {
|
||||||
if (data && data.achievements_unlocked && Array.isArray(data.achievements_unlocked) && data.achievements_unlocked.length > 0) {
|
if (data && data.achievements_unlocked && Array.isArray(data.achievements_unlocked) && data.achievements_unlocked.length > 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user