Files
001code-html--cocos/rank-badges.html
刘宇飞 6e0a1fbcbb Initial commit of 001code-html Scratch frontend project.
Includes scratch-gui, scratch-vm, scratch-blocks, scratch-render, scratch-l10n, and deployment config.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-16 15:37:45 +08:00

896 lines
33 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>称号等级预览</title>
<style>
body {
margin: 0;
padding: 20px;
font-family: 'Arial Black', Arial, sans-serif;
background: linear-gradient(135deg, #1e3c72, #2a5298);
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
}
.title {
color: white;
font-size: 36px;
margin-bottom: 30px;
text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
text-align: center;
}
.ranks-container {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 20px;
max-width: 1200px;
width: 100%;
}
.rank-item {
display: flex;
flex-direction: column;
align-items: center;
background: rgba(255, 255, 255, 0.1);
padding: 20px;
border-radius: 15px;
backdrop-filter: blur(10px);
border: 1px solid rgba(255, 255, 255, 0.2);
transition: transform 0.3s ease;
}
.rank-item:hover {
transform: translateY(-5px);
}
.rank-badge {
width: 128px;
height: 32px;
border-radius: 16px;
display: flex;
align-items: center;
justify-content: center;
position: relative;
overflow: hidden;
box-shadow: 0 0 15px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.3);
margin-bottom: 15px;
}
.rank-badge::before {
content: '';
position: absolute;
top: -50%;
left: -50%;
width: 200%;
height: 200%;
background: linear-gradient(45deg, transparent, rgba(255,255,255,0.2), transparent);
animation: shine 3s infinite;
}
.rank-text {
font-size: 12px;
font-weight: 900;
z-index: 2;
position: relative;
letter-spacing: 0.5px;
}
.rank-info {
text-align: center;
color: white;
}
.rank-name {
font-size: 16px;
font-weight: bold;
margin-bottom: 5px;
}
.rank-score {
font-size: 12px;
opacity: 0.8;
}
/* 坚韧黑铁 - 呼吸效果 */
.rank-1 {
background: linear-gradient(45deg, #2c3e50, #34495e);
border: 2px solid #95a5a6;
box-shadow: 0 0 10px rgba(149, 165, 166, 0.3);
animation: breathe 3s ease-in-out infinite;
}
.rank-1 .rank-text {
color: #ecf0f1;
text-shadow: 2px 2px 4px rgba(0,0,0,0.9), 0 0 8px #95a5a6;
}
/* 英勇黄铜 - 光扫描效果 */
.rank-2 {
background: linear-gradient(45deg, #b7950b, #f39c12);
border: 2px solid #f1c40f;
box-shadow: 0 0 20px rgba(241, 196, 15, 0.4);
animation: bronzeGlow 2s ease-in-out infinite;
}
.rank-2 .rank-text {
color: #ffffff;
text-shadow: 3px 3px 6px rgba(0,0,0,0.9), 0 0 12px #f1c40f;
font-weight: 900;
animation: bronzeTextGlow 2s ease-in-out infinite;
}
.rank-2::before {
content: '';
position: absolute;
top: -50%;
left: -50%;
width: 200%;
height: 200%;
background: linear-gradient(45deg, transparent, rgba(241, 196, 15, 0.3), transparent);
animation: bronzeScan 3s infinite;
}
/* 不屈白银 - 光扫描效果 */
.rank-3 {
background: linear-gradient(45deg, #85929e, #d5dbdb);
border: 2px solid #f8f9fa;
box-shadow: 0 0 25px rgba(248, 249, 250, 0.5);
position: relative;
animation: silverGlow 2.5s ease-in-out infinite;
}
.rank-3::before {
content: '';
position: absolute;
top: -50%;
left: -50%;
width: 200%;
height: 200%;
background: linear-gradient(45deg, transparent, rgba(248, 249, 250, 0.4), transparent);
animation: silverScan 3.5s infinite;
}
.rank-3 .rank-text {
color: #2c3e50;
text-shadow: 3px 3px 6px rgba(255,255,255,0.8), 0 0 12px #f8f9fa;
font-weight: 900;
animation: silverTextGlow 2.5s ease-in-out infinite;
}
/* 荣耀黄金 - 光扫描效果 */
.rank-4 {
background: linear-gradient(45deg, #b7950b, #f1c40f);
border: 2px solid #fff3cd;
box-shadow: 0 0 30px rgba(241, 196, 15, 0.6);
animation: goldGlow 2s ease-in-out infinite;
}
.rank-4 .rank-text {
color: #ffffff;
text-shadow: 3px 3px 6px rgba(0,0,0,0.9), 0 0 15px #fff3cd;
font-weight: 900;
animation: goldTextGlow 2s ease-in-out infinite;
}
.rank-4::before {
content: '';
position: absolute;
top: -50%;
left: -50%;
width: 200%;
height: 200%;
background: linear-gradient(45deg, transparent, rgba(255, 243, 205, 0.4), transparent);
animation: goldScan 3s infinite;
}
/* 华贵铂金 - 光扫描效果 */
.rank-5 {
background: linear-gradient(45deg, #5d6d7e, #aeb6bf);
border: 2px solid #d5dbdb;
box-shadow: 0 0 35px rgba(213, 219, 219, 0.7);
animation: platinumGlow 2s ease-in-out infinite;
}
.rank-5 .rank-text {
color: #ffffff;
text-shadow: 3px 3px 6px rgba(0,0,0,0.9), 0 0 18px #d5dbdb;
font-weight: 900;
animation: platinumTextGlow 2s ease-in-out infinite;
}
.rank-5::before {
content: '';
position: absolute;
top: -50%;
left: -50%;
width: 200%;
height: 200%;
background: linear-gradient(45deg, transparent, rgba(213, 219, 219, 0.4), transparent);
animation: platinumScan 2.5s infinite;
}
/* 璀璨钻石 - 闪烁爆发 */
.rank-6 {
background: linear-gradient(45deg, #1abc9c, #16a085);
border: 2px solid #a3e4d7;
box-shadow: 0 0 40px rgba(163, 228, 215, 0.8);
animation: sparkle 1.5s ease-in-out infinite;
}
.rank-6 .rank-text {
color: #ffffff;
text-shadow: 3px 3px 6px rgba(0,0,0,0.9), 0 0 20px #a3e4d7, 0 0 30px #1abc9c;
font-weight: 900;
animation: sparkleText 1.5s ease-in-out infinite;
}
.rank-6::before {
content: '';
position: absolute;
top: -5px;
left: -5px;
right: -5px;
bottom: -5px;
background: conic-gradient(#1abc9c, #a3e4d7, #16a085, #1abc9c);
border-radius: 21px;
z-index: -1;
animation: diamondSpin 2s linear infinite;
}
.rank-6::after {
content: '';
position: absolute;
top: 50%;
left: 50%;
width: 4px;
height: 4px;
background: #a3e4d7;
border-radius: 50%;
transform: translate(-50%, -50%);
animation: sparkBurst 1.5s ease-out infinite;
box-shadow: 0 0 10px #a3e4d7;
}
/* 超凡大师 - 魔法脉冲 */
.rank-7 {
background: linear-gradient(45deg, #8e44ad, #9b59b6);
border: 2px solid #d7bde2;
box-shadow: 0 0 45px rgba(215, 189, 226, 0.9);
animation: magicPulse 1.2s ease-in-out infinite;
}
.rank-7 .rank-text {
color: #ffffff;
text-shadow: 3px 3px 6px rgba(0,0,0,0.9), 0 0 25px #d7bde2, 0 0 35px #8e44ad;
font-weight: 900;
animation: magicTextGlow 1.2s ease-in-out infinite;
}
.rank-7::before {
content: '';
position: absolute;
top: -6px;
left: -6px;
right: -6px;
bottom: -6px;
background: conic-gradient(#8e44ad, #d7bde2, #9b59b6, #8e44ad);
border-radius: 22px;
z-index: -1;
animation: magicRotate 2s linear infinite;
}
.rank-7::after {
content: '';
position: absolute;
top: -8px;
left: -8px;
right: -8px;
bottom: -8px;
background: radial-gradient(circle, transparent 70%, #d7bde2 70%, #d7bde2 80%, transparent 80%);
border-radius: 24px;
z-index: -1;
animation: magicOrbit 3s linear infinite;
}
/* 傲世宗师 - 烈焰风暴 */
.rank-8 {
background: linear-gradient(45deg, #e74c3c, #c0392b);
border: 2px solid #fadbd8;
box-shadow: 0 0 60px rgba(250, 219, 216, 1.2), 0 0 100px rgba(231, 76, 60, 0.6);
animation: magicPulse 1.2s ease-in-out infinite;
}
.rank-8 .rank-text {
color: #ffffff;
text-shadow: 3px 3px 6px rgba(0,0,0,0.9), 0 0 40px #fadbd8, 0 0 60px #e74c3c, 0 0 80px #c0392b;
font-weight: 900;
animation: magicTextGlow 1.2s ease-in-out infinite;
}
.rank-8::before {
content: '';
position: absolute;
top: -6px;
left: -6px;
right: -6px;
bottom: -6px;
background: conic-gradient(#ff6b6b, #d73643, #ff4757, #ff6b6b);
border-radius: 22px;
z-index: -1;
animation: magicRotate 2s linear infinite;
}
.rank-8::after {
content: '';
position: absolute;
top: -8px;
left: -8px;
right: -8px;
bottom: -8px;
background: radial-gradient(circle, transparent 50%, #ff6b6b 50%, #ff6b6b 60%, transparent 60%);
border-radius: 24px;
z-index: -1;
animation: magicOrbit 3s linear infinite;
}
/* 最强王者 - 终极效果 */
.rank-9 {
background: linear-gradient(45deg, #f39c12, #e67e22, #d35400);
border: 3px solid #fdeaa7;
box-shadow: 0 0 50px rgba(253, 234, 167, 0.9), 0 0 100px rgba(243, 156, 18, 0.5);
animation: pulse 0.8s infinite alternate, rainbow 4s linear infinite;
}
.rank-9 .rank-text {
color: #ffffff;
text-shadow: 3px 3px 6px rgba(0,0,0,0.9), 0 0 35px #fdeaa7, 0 0 50px #f39c12, 0 0 70px #e67e22;
font-weight: 900;
animation: textGlow 2s infinite alternate;
}
.rank-9::after {
content: '';
position: absolute;
top: -5px;
left: -5px;
right: -5px;
bottom: -5px;
background: linear-gradient(45deg, #f39c12, #e67e22, #d35400, #f39c12);
border-radius: 21px;
z-index: -1;
animation: rotate 1s linear infinite;
}
@keyframes shine {
0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
50% { transform: translateX(100%) translateY(100%) rotate(45deg); }
100% { transform: translateX(100%) translateY(100%) rotate(45deg); }
}
/* 1. 呼吸效果 - 坚韧黑铁 */
@keyframes breathe {
0% { transform: scale(1); box-shadow: 0 0 10px rgba(149, 165, 166, 0.3); }
50% { transform: scale(1.05); box-shadow: 0 0 20px rgba(149, 165, 166, 0.6); }
100% { transform: scale(1); box-shadow: 0 0 10px rgba(149, 165, 166, 0.3); }
}
/* 2. 光扫描效果 - 英勇黄铜 */
@keyframes bronzeGlow {
0% { box-shadow: 0 0 20px rgba(241, 196, 15, 0.4); }
50% { box-shadow: 0 0 35px rgba(241, 196, 15, 0.8); }
100% { box-shadow: 0 0 20px rgba(241, 196, 15, 0.4); }
}
@keyframes bronzeTextGlow {
0% { text-shadow: 3px 3px 6px rgba(0,0,0,0.9), 0 0 12px #f1c40f; }
50% { text-shadow: 3px 3px 6px rgba(0,0,0,0.9), 0 0 20px #f1c40f, 0 0 30px #f39c12; }
100% { text-shadow: 3px 3px 6px rgba(0,0,0,0.9), 0 0 12px #f1c40f; }
}
@keyframes bronzeScan {
0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
100% { transform: translateX(100%) translateY(100%) rotate(45deg); }
}
/* 3. 光扫描效果 - 不屈白银 */
@keyframes silverGlow {
0% { box-shadow: 0 0 25px rgba(248, 249, 250, 0.5); }
50% { box-shadow: 0 0 40px rgba(248, 249, 250, 0.9); }
100% { box-shadow: 0 0 25px rgba(248, 249, 250, 0.5); }
}
@keyframes silverScan {
0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
100% { transform: translateX(100%) translateY(100%) rotate(45deg); }
}
@keyframes silverTextGlow {
0% { text-shadow: 3px 3px 6px rgba(255,255,255,0.8), 0 0 12px #f8f9fa; }
50% { text-shadow: 3px 3px 6px rgba(255,255,255,0.8), 0 0 25px #f8f9fa, 0 0 35px #d5dbdb; }
100% { text-shadow: 3px 3px 6px rgba(255,255,255,0.8), 0 0 12px #f8f9fa; }
}
/* 4. 光扫描效果 - 荣耀黄金 */
@keyframes goldGlow {
0% { box-shadow: 0 0 30px rgba(241, 196, 15, 0.6); }
50% { box-shadow: 0 0 50px rgba(241, 196, 15, 1.0); }
100% { box-shadow: 0 0 30px rgba(241, 196, 15, 0.6); }
}
@keyframes goldTextGlow {
0% { text-shadow: 3px 3px 6px rgba(0,0,0,0.9), 0 0 15px #fff3cd; }
50% { text-shadow: 3px 3px 6px rgba(0,0,0,0.9), 0 0 30px #fff3cd, 0 0 40px #f1c40f; }
100% { text-shadow: 3px 3px 6px rgba(0,0,0,0.9), 0 0 15px #fff3cd; }
}
@keyframes goldScan {
0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
100% { transform: translateX(100%) translateY(100%) rotate(45deg); }
}
/* 5. 光扫描效果 - 华贵铂金 */
@keyframes platinumGlow {
0% { box-shadow: 0 0 35px rgba(213, 219, 219, 0.7); }
50% { box-shadow: 0 0 55px rgba(213, 219, 219, 1.1); }
100% { box-shadow: 0 0 35px rgba(213, 219, 219, 0.7); }
}
@keyframes platinumTextGlow {
0% { text-shadow: 3px 3px 6px rgba(0,0,0,0.9), 0 0 18px #d5dbdb; }
50% { text-shadow: 3px 3px 6px rgba(0,0,0,0.9), 0 0 35px #d5dbdb, 0 0 45px #aeb6bf; }
100% { text-shadow: 3px 3px 6px rgba(0,0,0,0.9), 0 0 18px #d5dbdb; }
}
@keyframes platinumScan {
0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
100% { transform: translateX(100%) translateY(100%) rotate(45deg); }
}
/* 6. 闪烁爆发 - 璀璨钻石 */
@keyframes sparkle {
0% { transform: scale(1); box-shadow: 0 0 40px rgba(163, 228, 215, 0.8); }
50% { transform: scale(1.02); box-shadow: 0 0 60px rgba(163, 228, 215, 1.2); }
100% { transform: scale(1); box-shadow: 0 0 40px rgba(163, 228, 215, 0.8); }
}
@keyframes sparkleText {
0% { text-shadow: 3px 3px 6px rgba(0,0,0,0.9), 0 0 20px #a3e4d7, 0 0 30px #1abc9c; }
50% { text-shadow: 3px 3px 6px rgba(0,0,0,0.9), 0 0 30px #a3e4d7, 0 0 40px #1abc9c, 0 0 50px #16a085; }
100% { text-shadow: 3px 3px 6px rgba(0,0,0,0.9), 0 0 20px #a3e4d7, 0 0 30px #1abc9c; }
}
@keyframes diamondSpin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
@keyframes sparkBurst {
0% { transform: translate(-50%, -50%) scale(0); opacity: 1; }
50% { transform: translate(-50%, -50%) scale(3); opacity: 0.8; }
100% { transform: translate(-50%, -50%) scale(5); opacity: 0; }
}
/* 7. 魔法脉冲 - 超凡大师 */
@keyframes magicPulse {
0% { transform: scale(1); box-shadow: 0 0 45px rgba(215, 189, 226, 0.9); }
50% { transform: scale(1.03); box-shadow: 0 0 80px rgba(215, 189, 226, 1.5); }
100% { transform: scale(1); box-shadow: 0 0 45px rgba(215, 189, 226, 0.9); }
}
@keyframes magicTextGlow {
0% { text-shadow: 3px 3px 6px rgba(0,0,0,0.9), 0 0 25px #d7bde2, 0 0 35px #8e44ad; }
50% { text-shadow: 3px 3px 6px rgba(0,0,0,0.9), 0 0 40px #d7bde2, 0 0 60px #8e44ad, 0 0 80px #9b59b6; }
100% { text-shadow: 3px 3px 6px rgba(0,0,0,0.9), 0 0 25px #d7bde2, 0 0 35px #8e44ad; }
}
@keyframes magicRotate {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
@keyframes magicOrbit {
0% { transform: rotate(0deg); }
100% { transform: rotate(-360deg); }
}
/* 8. 烈焰风暴 - 傲世宗师 */
@keyframes flameGlow {
0% { box-shadow: 0 0 60px rgba(250, 219, 216, 1.2), 0 0 100px rgba(231, 76, 60, 0.6); }
50% { box-shadow: 0 0 80px rgba(250, 219, 216, 1.5), 0 0 120px rgba(231, 76, 60, 0.8); }
100% { box-shadow: 0 0 60px rgba(250, 219, 216, 1.2), 0 0 100px rgba(231, 76, 60, 0.6); }
}
@keyframes flameTextGlow {
0% { text-shadow: 3px 3px 6px rgba(0,0,0,0.9), 0 0 40px #fadbd8, 0 0 60px #e74c3c, 0 0 80px #c0392b; }
50% { text-shadow: 3px 3px 6px rgba(0,0,0,0.9), 0 0 60px #fadbd8, 0 0 80px #e74c3c, 0 0 100px #c0392b; }
100% { text-shadow: 3px 3px 6px rgba(0,0,0,0.9), 0 0 40px #fadbd8, 0 0 60px #e74c3c, 0 0 80px #c0392b; }
}
@keyframes flameRotate {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
@keyframes flameOrbit {
0% { transform: rotate(0deg); }
100% { transform: rotate(-360deg); }
}
/* 通用动画 */
@keyframes pulse {
0% { box-shadow: 0 0 20px rgba(255,255,255,0.3); }
100% { box-shadow: 0 0 40px rgba(255,255,255,0.6); }
}
@keyframes rotate {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
@keyframes rainbow {
0% { filter: hue-rotate(0deg); }
100% { filter: hue-rotate(360deg); }
}
@keyframes textGlow {
0% { text-shadow: 3px 3px 6px rgba(0,0,0,0.9), 0 0 18px #d5dbdb; }
50% { text-shadow: 3px 3px 6px rgba(0,0,0,0.9), 0 0 30px #d5dbdb, 0 0 40px #aeb6bf; }
100% { text-shadow: 3px 3px 6px rgba(0,0,0,0.9), 0 0 18px #d5dbdb; }
}
.description {
margin-top: 30px;
color: white;
text-align: center;
max-width: 800px;
font-size: 14px;
opacity: 0.9;
}
/* 测试区域样式 */
.test-section {
margin-top: 50px;
padding: 20px;
background: rgba(255, 255, 255, 0.1);
border-radius: 15px;
backdrop-filter: blur(10px);
border: 1px solid rgba(255, 255, 255, 0.2);
}
.test-controls {
display: flex;
gap: 10px;
margin-bottom: 20px;
flex-wrap: wrap;
justify-content: center;
}
.test-button {
padding: 8px 16px;
background: rgba(255, 255, 255, 0.2);
border: none;
border-radius: 8px;
color: white;
cursor: pointer;
font-size: 12px;
transition: background 0.3s;
}
.test-button:hover {
background: rgba(255, 255, 255, 0.3);
}
.test-result {
display: flex;
justify-content: center;
min-height: 60px;
align-items: center;
}
.test-title {
color: white;
font-size: 18px;
margin-bottom: 15px;
text-align: center;
}
</style>
</head>
<body>
<h1 class="title">🏆 称号等级系统预览 🏆</h1>
<div class="ranks-container">
<div class="rank-item">
<div class="rank-badge rank-1">
<div class="rank-text">坚韧黑铁</div>
</div>
<div class="rank-info">
<div class="rank-name">坚韧黑铁</div>
<div class="rank-score">0 - 999 积分</div>
</div>
</div>
<div class="rank-item">
<div class="rank-badge rank-2">
<div class="rank-text">英勇黄铜</div>
</div>
<div class="rank-info">
<div class="rank-name">英勇黄铜</div>
<div class="rank-score">1000 - 1999 积分</div>
</div>
</div>
<div class="rank-item">
<div class="rank-badge rank-3">
<div class="rank-text">不屈白银</div>
</div>
<div class="rank-info">
<div class="rank-name">不屈白银</div>
<div class="rank-score">2000 - 2999 积分</div>
</div>
</div>
<div class="rank-item">
<div class="rank-badge rank-4">
<div class="rank-text">荣耀黄金</div>
</div>
<div class="rank-info">
<div class="rank-name">荣耀黄金</div>
<div class="rank-score">3000 - 3999 积分</div>
</div>
</div>
<div class="rank-item">
<div class="rank-badge rank-5">
<div class="rank-text">华贵铂金</div>
</div>
<div class="rank-info">
<div class="rank-name">华贵铂金</div>
<div class="rank-score">4000 - 4999 积分</div>
</div>
</div>
<div class="rank-item">
<div class="rank-badge rank-6">
<div class="rank-text">璀璨钻石</div>
</div>
<div class="rank-info">
<div class="rank-name">璀璨钻石</div>
<div class="rank-score">5000 - 5999 积分</div>
</div>
</div>
<div class="rank-item">
<div class="rank-badge rank-7">
<div class="rank-text">超凡大师</div>
</div>
<div class="rank-info">
<div class="rank-name">超凡大师</div>
<div class="rank-score">6000 - 6999 积分</div>
</div>
</div>
<div class="rank-item">
<div class="rank-badge rank-8">
<div class="rank-text">傲世宗师</div>
</div>
<div class="rank-info">
<div class="rank-name">傲世宗师</div>
<div class="rank-score">7000 - 7999 积分</div>
</div>
</div>
<div class="rank-item">
<div class="rank-badge rank-9">
<div class="rank-text">最强王者</div>
</div>
<div class="rank-info">
<div class="rank-name">最强王者</div>
<div class="rank-score">8000+ 积分</div>
</div>
</div>
</div>
<!-- 测试区域 -->
<div class="test-section">
<h2 class="test-title">🎯 徽章生成器测试</h2>
<div class="test-controls">
<button class="test-button" onclick="testBadge(1)">坚韧黑铁</button>
<button class="test-button" onclick="testBadge(2)">英勇黄铜</button>
<button class="test-button" onclick="testBadge(3)">不屈白银</button>
<button class="test-button" onclick="testBadge(4)">荣耀黄金</button>
<button class="test-button" onclick="testBadge(5)">华贵铂金</button>
<button class="test-button" onclick="testBadge(6)">璀璨钻石</button>
<button class="test-button" onclick="testBadge(7)">超凡大师</button>
<button class="test-button" onclick="testBadge(8)">傲世宗师</button>
<button class="test-button" onclick="testBadge(9)">最强王者</button>
</div>
<div class="test-result" id="testResult">
<p style="color: white; opacity: 0.7;">点击上方按钮测试徽章生成器</p>
</div>
</div>
<script>
/**
* 称号等级系统 - 徽章生成器
* 根据传入的ID(1-9)生成对应的徽章HTML元素包含完整的动画效果
*/
class RankBadgeGenerator {
constructor() {
// 称号数据配置
this.rankData = {
1: { name: '坚韧黑铁', scoreRange: '0 - 999 积分' },
2: { name: '英勇黄铜', scoreRange: '1000 - 1999 积分' },
3: { name: '不屈白银', scoreRange: '2000 - 2999 积分' },
4: { name: '荣耀黄金', scoreRange: '3000 - 3999 积分' },
5: { name: '华贵铂金', scoreRange: '4000 - 4999 积分' },
6: { name: '璀璨钻石', scoreRange: '5000 - 5999 积分' },
7: { name: '超凡大师', scoreRange: '6000 - 6999 积分' },
8: { name: '傲世宗师', scoreRange: '7000 - 7999 积分' },
9: { name: '最强王者', scoreRange: '8000+ 积分' }
};
}
/**
* 根据ID获取徽章HTML元素
* @param {number} id - 徽章ID (1-9)
* @returns {HTMLElement|null} 返回包含动画效果的徽章元素
*/
getBadgeById(id) {
// 验证ID有效性
if (!this.isValidId(id)) {
console.error(`无效的徽章ID: ${id}请传入1-9之间的数字`);
return null;
}
const rankInfo = this.rankData[id];
// 创建徽章容器
const badgeContainer = document.createElement('div');
badgeContainer.className = 'rank-item';
// 创建徽章元素
const badge = document.createElement('div');
badge.className = `rank-badge rank-${id}`;
// 创建徽章文本
const badgeText = document.createElement('div');
badgeText.className = 'rank-text';
badgeText.textContent = rankInfo.name;
// 创建徽章信息
const rankInfoDiv = document.createElement('div');
rankInfoDiv.className = 'rank-info';
const rankName = document.createElement('div');
rankName.className = 'rank-name';
rankName.textContent = rankInfo.name;
const rankScore = document.createElement('div');
rankScore.className = 'rank-score';
rankScore.textContent = rankInfo.scoreRange;
// 组装元素
badge.appendChild(badgeText);
rankInfoDiv.appendChild(rankName);
rankInfoDiv.appendChild(rankScore);
badgeContainer.appendChild(badge);
badgeContainer.appendChild(rankInfoDiv);
return badgeContainer;
}
/**
* 仅获取徽章部分(不包含信息文本)
* @param {number} id - 徽章ID (1-9)
* @returns {HTMLElement|null} 返回纯徽章元素
*/
getBadgeOnly(id) {
if (!this.isValidId(id)) {
console.error(`无效的徽章ID: ${id}请传入1-9之间的数字`);
return null;
}
const rankInfo = this.rankData[id];
// 创建徽章元素
const badge = document.createElement('div');
badge.className = `rank-badge rank-${id}`;
// 创建徽章文本
const badgeText = document.createElement('div');
badgeText.className = 'rank-text';
badgeText.textContent = rankInfo.name;
badge.appendChild(badgeText);
return badge;
}
/**
* 获取徽章信息不包含HTML元素
* @param {number} id - 徽章ID (1-9)
* @returns {Object|null} 返回徽章信息对象
*/
getBadgeInfo(id) {
if (!this.isValidId(id)) {
console.error(`无效的徽章ID: ${id}请传入1-9之间的数字`);
return null;
}
return {
id: id,
name: this.rankData[id].name,
scoreRange: this.rankData[id].scoreRange,
className: `rank-${id}`
};
}
/**
* 验证ID是否有效
* @param {number} id - 要验证的ID
* @returns {boolean} 是否有效
*/
isValidId(id) {
return Number.isInteger(id) && id >= 1 && id <= 9;
}
/**
* 获取所有徽章信息
* @returns {Array} 所有徽章信息数组
*/
getAllBadgeInfo() {
return Object.keys(this.rankData).map(id => this.getBadgeInfo(parseInt(id)));
}
}
// 创建全局实例
const rankBadgeGenerator = new RankBadgeGenerator();
/**
* 便捷方法根据ID获取徽章
* @param {number} id - 徽章ID (1-9)
* @returns {HTMLElement|null} 徽章元素
*/
function getBadgeById(id) {
return rankBadgeGenerator.getBadgeById(id);
}
/**
* 便捷方法:仅获取徽章部分
* @param {number} id - 徽章ID (1-9)
* @returns {HTMLElement|null} 纯徽章元素
*/
function getBadgeOnly(id) {
return rankBadgeGenerator.getBadgeOnly(id);
}
/**
* 便捷方法:获取徽章信息
* @param {number} id - 徽章ID (1-9)
* @returns {Object|null} 徽章信息
*/
function getBadgeInfo(id) {
return rankBadgeGenerator.getBadgeInfo(id);
}
/**
* 测试函数:在测试区域显示指定徽章
* @param {number} id - 徽章ID (1-9)
*/
function testBadge(id) {
const testResult = document.getElementById('testResult');
testResult.innerHTML = ''; // 清空之前的结果
const badge = getBadgeById(id);
if (badge) {
testResult.appendChild(badge);
console.log(`成功生成徽章 ID: ${id}`, getBadgeInfo(id));
} else {
testResult.innerHTML = `<p style="color: #ff6b6b;">生成徽章失败ID: ${id}</p>`;
}
}
// 使用示例(在控制台中测试)
console.log('=== 称号等级系统徽章生成器 ===');
console.log('使用方法:');
console.log('1. getBadgeById(id) - 获取完整徽章(包含信息)');
console.log('2. getBadgeOnly(id) - 仅获取徽章部分');
console.log('3. getBadgeInfo(id) - 获取徽章信息');
console.log('4. testBadge(id) - 在页面中测试显示');
console.log('');
console.log('示例:');
console.log('const badge = getBadgeById(9); // 获取最强王者徽章');
console.log('document.body.appendChild(badge); // 添加到页面');
// 页面加载完成后的初始化
document.addEventListener('DOMContentLoaded', function() {
console.log('称号等级系统已加载,可以使用徽章生成器了!');
});
</script>
</body>
</html>