diff --git a/www/html/Game/public/js/play.js b/www/html/Game/public/js/play.js index 85a47a8..81f7b18 100644 --- a/www/html/Game/public/js/play.js +++ b/www/html/Game/public/js/play.js @@ -34,6 +34,7 @@ } let nick = (params.get('nick') || '').trim() || readStoredDisplayName() || 'ผู้เล่น'; const previewMode = params.get('preview') === '1'; + const specialQuizForceDebug = params.get('sqForce') === '1'; const forceDefaultCharacter = params.get('defaultChar') === '1'; const editorEmbedReturn = params.get('editorEmbed') === '1'; if (previewMode && editorEmbedReturn) { @@ -15540,6 +15541,9 @@ return; } myId = socket.id; + if (specialQuizForceDebug) { + try { socket.emit('special-quiz-force', { on: true }); } catch (eF) { /* ignore */ } + } let botSlots = parseInt(res.botSlotCount, 10); if ((!botSlots || botSlots < 1) && res.maxPlayers > 0 && res.maxPlayers < 6) { botSlots = 6 - res.maxPlayers; diff --git a/www/html/Game/public/play.html b/www/html/Game/public/play.html index 939d6c6..460d332 100644 --- a/www/html/Game/public/play.html +++ b/www/html/Game/public/play.html @@ -3939,7 +3939,7 @@ - +
v —
diff --git a/www/html/Game/server.js b/www/html/Game/server.js index d99804e..ca6c70d 100644 --- a/www/html/Game/server.js +++ b/www/html/Game/server.js @@ -521,8 +521,10 @@ function maybeSpawnSpecialQuizForRun(space) { const card = set && set.specialCard; const hasCard = !!(card && (card.cardId || card.imageUrl)); if (!questions.length || !hasCard) { console.log('[special-quiz] skip:no-questions-or-card', mapId, 'L' + level + '_C' + caseId, 'q=' + questions.length, 'card=' + hasCard); return; } + const forced = !!space.forceSpecialQuiz; const roll = Math.random(); - if (roll > SPECIAL_QUIZ_SPAWN_CHANCE) { console.log('[special-quiz] skip:roll', mapId, roll.toFixed(3), '>', SPECIAL_QUIZ_SPAWN_CHANCE.toFixed(3)); return; } + if (!forced && roll > SPECIAL_QUIZ_SPAWN_CHANCE) { console.log('[special-quiz] skip:roll', mapId, roll.toFixed(3), '>', SPECIAL_QUIZ_SPAWN_CHANCE.toFixed(3)); return; } + if (forced) console.log('[special-quiz] FORCE-spawn (debug)', mapId); const md = (space.mapId && maps.get(space.mapId)) || space.mapData; if (!md) { console.log('[special-quiz] skip:no-map', mapId); return; } const tile = pickSpecialQuizSpawnTile(md); @@ -5324,6 +5326,15 @@ io.on('connection', (socket) => { }); /** ผู้เล่นเดินชนไอคอนคำถามพิเศษ — ใครชนก่อนเป็นคนเปิดเซสชันให้ทั้งห้อง */ + /** debug: บังคับ spawn ไอคอนทุกรอบในเซสชันนี้ (เปิดด้วย ?sqForce=1) */ + socket.on('special-quiz-force', (data) => { + const sid = socket.data.spaceId; + const space = sid ? spaces.get(sid) : null; + if (!space || !space.peers.has(socket.id)) return; + space.forceSpecialQuiz = !!(data && data.on); + console.log('[special-quiz] force flag =', space.forceSpecialQuiz, 'by', socket.id); + }); + socket.on('special-quiz-collide', (_data, cb) => { const reply = typeof cb === 'function' ? cb : () => {}; const sid = socket.data.spaceId;