微件:GGLScratchGame:修订间差异

来自Limbo Wiki Mirror
Gaoice留言 | 贡献
无编辑摘要
标签(旧)WikiEditor
Gaoice留言 | 贡献
无编辑摘要
标签(旧)WikiEditor
第1行: 第1行:
<noinclude>
<div class="ggl-root">
赛博刮刮乐 · 完整结构版
</noinclude>


<includeonly>
  <!-- 彩票主背景 -->
  <img class="ggl-bg"
      src="https://wm.gaoice.run/images/彩票主背景.png">


<div class="ggl-root">
  <!-- 刮奖区域 -->
   <div class="ggl-ticket">
   <div class="ggl-scratch-area">
     <div class="ggl-scratch-area"></div>
     <div class="ggl-grid"></div>
   </div>
   </div>


   <div class="ggl-ui">
   <!-- 吉祥物 -->
    <div class="ggl-mascot" id="gglMascot">(`・ω・´) 等待扫描</div>
  <div class="ggl-mascot">(^▽^)</div>
    <button class="ggl-btn" id="gglDraw">来一张彩票</button>
 
    <button class="ggl-btn" id="gglScan">扫描结果</button>
  <!-- 气泡 -->
  <div class="ggl-bubble"></div>
 
  <!-- 控制区 -->
  <div class="ggl-controls">
    <button id="ggl-scan">扫描结果</button>
   </div>
   </div>
</div>
</div>
第19行: 第24行:
<style>
<style>
.ggl-root {
.ggl-root {
   max-width: 420px;
   position: relative;
   margin: 20px auto;
  width: 375px;
   margin: auto;
  aspect-ratio: 1075 / 1911;
   font-family: sans-serif;
   font-family: sans-serif;
}
}


/* 彩票背景 */
.ggl-bg {
.ggl-ticket {
  position: relative;
   width: 100%;
   width: 100%;
   height: 750px; /* ⚠️ 固定高度,避免 aspect-ratio 坑 */
   display: block;
  background-image: url("https://wm.gaoice.run/images/thumb/b/b6/%E5%9B%BE%E7%89%871.png/1075px-%E5%9B%BE%E7%89%871.png");
  background-size: cover;
  background-position: center;
}
}


/* 刮奖区(黄色块) */
.ggl-scratch-area {
.ggl-scratch-area {
   position: absolute;
   position: absolute;
   left: 11%;
   left: 10%;
   top: 23.5%;
   top: 18%;
   width: 78%;
   width: 80%;
   height: 53%;
   height: 53%;
}
}


/* 单格 */
.ggl-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(6, 1fr);
  gap: 6px;
  width: 100%;
  height: 100%;
}
 
.ggl-cell {
.ggl-cell {
   position: absolute;
   position: relative;
   width: 20%;
   overflow: hidden;
  height: 16.66%;
}
}


.ggl-reveal,
.ggl-cell img,
.ggl-cover {
.ggl-cell canvas {
   position: absolute;
   position: absolute;
   inset: 0;
   inset: 0;
   background-size: cover;
   width: 100%;
  height: 100%;
}
}


.ggl-reveal {
.ggl-mascot {
   background-image: url("https://wm.gaoice.run/images/thumb/4/4a/%E5%88%AE%E5%BC%80%E5%90%8E.jpg/559px-%E5%88%AE%E5%BC%80%E5%90%8E.jpg");
   position: absolute;
  left: 6%;
  bottom: 8%;
  font-size: 22px;
}
}


.ggl-cover {
  background-image: url("https://wm.gaoice.run/images/thumb/5/5a/%E5%88%AE%E5%BC%80%E5%89%8D.png/559px-%E5%88%AE%E5%BC%80%E5%89%8D.png");
  cursor: pointer;
}
.ggl-cell.scratched .ggl-cover {
  display: none;
}
/* 气泡 */
.ggl-bubble {
.ggl-bubble {
   position: absolute;
   position: absolute;
   bottom: 105%;
  left: 6%;
   left: 0;
   bottom: 13%;
   background: rgba(0,0,0,0.8);
   width: 60%;
   color: #0f0;
  min-height: 40px;
   font-size: 11px;
   background: rgba(255,255,255,.9);
  padding: 4px 6px;
   padding: 6px;
  display: none;
   font-size: 14px;
  z-index: 5;
}
}


.ggl-cell.scratched .ggl-bubble {
.ggl-controls {
   display: block;
   position: absolute;
  right: 6%;
  bottom: 8%;
}
}


/* UI */
#ggl-scan {
.ggl-ui {
   opacity: .3;
   margin-top: 8px;
}
}
 
#ggl-scan.active {
.ggl-mascot {
   opacity: 1;
  background: #111;
  color: #0f0;
  padding: 6px;
  font-size: 12px;
  margin-bottom: 6px;
}
 
.ggl-btn {
   width: 48%;
  margin-right: 2%;
}
}
</style>
</style>
第108行: 第100行:
<script>
<script>
(function () {
(function () {
  const grid = document.querySelector('.ggl-grid');
  const bubble = document.querySelector('.ggl-bubble');
  const mascot = document.querySelector('.ggl-mascot');
  const scanBtn = document.getElementById('ggl-scan');


var root = document.currentScript.parentNode;
  const STATES = [
var area = root.querySelector('.ggl-scratch-area');
    "无",
var mascot = root.querySelector('#gglMascot');
    "(・∀・)",
var drawBtn = root.querySelector('#gglDraw');
    "(ノ◕ヮ◕)ノ",
    "(・_・)",
    "(;゚Д゚)",
    null,
    "...",
    "别挠我痒痒",
    "你是谁?",
    "停下来",
    "平安喜乐。你知道的太多了"
  ];


/* 状态文本 1–11 */
  let scratchedCount = 0;
var states = {
  1: '',
  2: '(`・ω・´) 扫描中…',
  3: '(≧▽≦) 太棒了!',
  4: '(・_・?) 思考中',
  5: '(;゚Д゚) 不对劲',
  6: '你在看哪里?',
  7: '……',
  8: '哦、哈、别挠',
  9: '你是谁?',
  10: '停下来。',
  11: '平安喜乐。'
};


var tickets = [
  for (let i = 0; i < 30; i++) {
  [2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
    const cell = document.createElement('div');
  [3,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]
    cell.className = 'ggl-cell';
];
    cell.dataset.state = (i % 11) + 1;


var currentTicket = 0;
    cell.innerHTML = `
      <img src="https://wm.gaoice.run/images/刮开后.png">
      <canvas></canvas>
    `;
    grid.appendChild(cell);
    initScratch(cell);
  }


function renderTicket() {
  function initScratch(cell) {
  area.innerHTML = '';
    const canvas = cell.querySelector('canvas');
  var data = tickets[currentTicket] || [];
    const ctx = canvas.getContext('2d');
  mascot.textContent = '(`・ω・´) 新的彩票';


  for (var i = 0; i < 30; i++) {
    requestAnimationFrame(() => {
    var cell = document.createElement('div');
      canvas.width = cell.clientWidth;
    cell.className = 'ggl-cell';
      canvas.height = cell.clientHeight;
    cell.style.left = (i % 5) * 20 + '%';
    cell.style.top = Math.floor(i / 5) * 16.66 + '%';


    var reveal = document.createElement('div');
      const cover = new Image();
     reveal.className = 'ggl-reveal';
      cover.src = "https://wm.gaoice.run/images/刮开前.png";
      cover.onload = () => {
        ctx.drawImage(cover, 0, 0, canvas.width, canvas.height);
      };
     });


     var cover = document.createElement('div');
     let down = false;
    cover.className = 'ggl-cover';


     var bubble = document.createElement('div');
     canvas.addEventListener('pointerdown', () => down = true);
     bubble.className = 'ggl-bubble';
    canvas.addEventListener('pointerup', () => down = false);
     canvas.addEventListener('pointerleave', () => down = false);


     (function (state) {
     canvas.addEventListener('pointermove', e => {
       cover.onclick = function () {
       if (!down) return;
        cell.classList.add('scratched');
      const r = canvas.getBoundingClientRect();
        bubble.textContent = states[state] || '';
      ctx.globalCompositeOperation = 'destination-out';
        if (state === 2) mascot.textContent = states[2];
      ctx.beginPath();
       };
      ctx.arc(e.clientX - r.left, e.clientY - r.top, 18, 0, Math.PI * 2);
     })(data[i] || 1);
       ctx.fill();
     });


     cell.appendChild(reveal);
     canvas.addEventListener('pointerup', () => onReveal(cell));
    cell.appendChild(cover);
    cell.appendChild(bubble);
    area.appendChild(cell);
   }
   }
}


drawBtn.onclick = function () {
  function onReveal(cell) {
  renderTicket();
    if (cell.dataset.revealed) return;
  currentTicket++;
    cell.dataset.revealed = 1;
};
    scratchedCount++;
 
    const state = +cell.dataset.state;
 
    if (state <= 5) {
      mascot.textContent = STATES[state];
      bubble.textContent = "中奖了?";
    }
    if (state === 6) {
      mascot.textContent = "";
      bubble.textContent = "……你真的在刮吗?";
    }
    if (state === 7) {
      bubble.textContent = "……";
    }
    if (state === 8) {
      bubble.textContent = "哦 嗯 嘿 哈";
    }
    if (state === 9) {
      bubble.textContent = "你是谁?";
    }
    if (state === 10) {
      bubble.textContent = "停下来";
      scanBtn.classList.add("active");
    }
    if (state === 11) {
      bubble.textContent = STATES[10];
      setTimeout(() => {
        document.body.style.filter = "invert(1)";
        setTimeout(() => {
          location.href = "/index.php?title=六世恶言之一";
        }, 1200);
      }, 800);
    }
  }


renderTicket();
  scanBtn.addEventListener('click', () => {
    if (!scanBtn.classList.contains('active')) return;
    bubble.textContent = "扫描中……";
  });


})();
})();
</script>
</script>
</includeonly>

2026年2月1日 (日) 17:37的版本

 <img class="ggl-bg"
      src="https://wm.gaoice.run/images/彩票主背景.png">
(^▽^)
   <button id="ggl-scan">扫描结果</button>

<style> .ggl-root {

 position: relative;
 width: 375px;
 margin: auto;
 aspect-ratio: 1075 / 1911;
 font-family: sans-serif;

}

.ggl-bg {

 width: 100%;
 display: block;

}

.ggl-scratch-area {

 position: absolute;
 left: 10%;
 top: 18%;
 width: 80%;
 height: 53%;

}

.ggl-grid {

 display: grid;
 grid-template-columns: repeat(5, 1fr);
 grid-template-rows: repeat(6, 1fr);
 gap: 6px;
 width: 100%;
 height: 100%;

}

.ggl-cell {

 position: relative;
 overflow: hidden;

}

.ggl-cell img, .ggl-cell canvas {

 position: absolute;
 inset: 0;
 width: 100%;
 height: 100%;

}

.ggl-mascot {

 position: absolute;
 left: 6%;
 bottom: 8%;
 font-size: 22px;

}

.ggl-bubble {

 position: absolute;
 left: 6%;
 bottom: 13%;
 width: 60%;
 min-height: 40px;
 background: rgba(255,255,255,.9);
 padding: 6px;
 font-size: 14px;

}

.ggl-controls {

 position: absolute;
 right: 6%;
 bottom: 8%;

}

  1. ggl-scan {
 opacity: .3;

}

  1. ggl-scan.active {
 opacity: 1;

} </style>

<script> (function () {

 const grid = document.querySelector('.ggl-grid');
 const bubble = document.querySelector('.ggl-bubble');
 const mascot = document.querySelector('.ggl-mascot');
 const scanBtn = document.getElementById('ggl-scan');
 const STATES = [
   "无",
   "(・∀・)",
   "(ノ◕ヮ◕)ノ",
   "(・_・)",
   "(;゚Д゚)",
   null,
   "...",
   "别挠我痒痒",
   "你是谁?",
   "停下来",
   "平安喜乐。你知道的太多了"
 ];
 let scratchedCount = 0;
 for (let i = 0; i < 30; i++) {
   const cell = document.createElement('div');
   cell.className = 'ggl-cell';
   cell.dataset.state = (i % 11) + 1;
   cell.innerHTML = `
     <img src="https://wm.gaoice.run/images/刮开后.png">
     <canvas></canvas>
   `;
   grid.appendChild(cell);
   initScratch(cell);
 }
 function initScratch(cell) {
   const canvas = cell.querySelector('canvas');
   const ctx = canvas.getContext('2d');
   requestAnimationFrame(() => {
     canvas.width = cell.clientWidth;
     canvas.height = cell.clientHeight;
     const cover = new Image();
     cover.src = "https://wm.gaoice.run/images/刮开前.png";
     cover.onload = () => {
       ctx.drawImage(cover, 0, 0, canvas.width, canvas.height);
     };
   });
   let down = false;
   canvas.addEventListener('pointerdown', () => down = true);
   canvas.addEventListener('pointerup', () => down = false);
   canvas.addEventListener('pointerleave', () => down = false);
   canvas.addEventListener('pointermove', e => {
     if (!down) return;
     const r = canvas.getBoundingClientRect();
     ctx.globalCompositeOperation = 'destination-out';
     ctx.beginPath();
     ctx.arc(e.clientX - r.left, e.clientY - r.top, 18, 0, Math.PI * 2);
     ctx.fill();
   });
   canvas.addEventListener('pointerup', () => onReveal(cell));
 }
 function onReveal(cell) {
   if (cell.dataset.revealed) return;
   cell.dataset.revealed = 1;
   scratchedCount++;
   const state = +cell.dataset.state;
   if (state <= 5) {
     mascot.textContent = STATES[state];
     bubble.textContent = "中奖了?";
   }
   if (state === 6) {
     mascot.textContent = "";
     bubble.textContent = "……你真的在刮吗?";
   }
   if (state === 7) {
     bubble.textContent = "……";
   }
   if (state === 8) {
     bubble.textContent = "哦 嗯 嘿 哈";
   }
   if (state === 9) {
     bubble.textContent = "你是谁?";
   }
   if (state === 10) {
     bubble.textContent = "停下来";
     scanBtn.classList.add("active");
   }
   if (state === 11) {
     bubble.textContent = STATES[10];
     setTimeout(() => {
       document.body.style.filter = "invert(1)";
       setTimeout(() => {
         location.href = "/index.php?title=六世恶言之一";
       }, 1200);
     }, 800);
   }
 }
 scanBtn.addEventListener('click', () => {
   if (!scanBtn.classList.contains('active')) return;
   bubble.textContent = "扫描中……";
 });

})(); </script>