This commit is contained in:
@@ -26071,10 +26071,10 @@ cr.getObjectRefTable = function () { return [
|
||||
cr.plugins_.Audio,
|
||||
cr.plugins_.Browser,
|
||||
cr.plugins_.Function,
|
||||
cr.plugins_.Sprite,
|
||||
cr.plugins_.SpriteFontPlus,
|
||||
cr.plugins_.TDVplugin,
|
||||
cr.plugins_.Text,
|
||||
cr.plugins_.Sprite,
|
||||
cr.plugins_.TDVplugin,
|
||||
cr.plugins_.Touch,
|
||||
cr.behaviors.Rex_MoveTo,
|
||||
cr.behaviors.Fade,
|
||||
|
||||
File diff suppressed because one or more lines are too long
Binary file not shown.
|
Before Width: | Height: | Size: 89 KiB After Width: | Height: | Size: 12 KiB |
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"version": 1769066087,
|
||||
"version": 1769236279,
|
||||
"fileList": [
|
||||
"data.js",
|
||||
"c2runtime.js",
|
||||
@@ -27,7 +27,6 @@
|
||||
"images/ao_vang_quan_xanh-sheet0.png",
|
||||
"images/sprite-sheet0.png",
|
||||
"images/khung_thoai-sheet0.png",
|
||||
"images/human-sheet0.png",
|
||||
"images/khung_thoai2-sheet0.png",
|
||||
"images/khung_diem-sheet0.png",
|
||||
"images/avatar-sheet0.png",
|
||||
|
||||
@@ -18,6 +18,7 @@ var tdv_sdk = {
|
||||
missingIndices: [], // lưu index các slot bị thiếu
|
||||
blankIndexes: [], // danh sách index bị trống
|
||||
missingWords: [],
|
||||
lastAnswerResult: null, // { correct: true/false, raw: data }
|
||||
|
||||
blankCount: 1, // số ô trống (server control)
|
||||
|
||||
@@ -377,6 +378,7 @@ var tdv_sdk = {
|
||||
|
||||
// ==================== TRACKING TỪ THEO VỊ TRÍ SLOT ====================
|
||||
placedWords: [], // Mảng lưu từ theo vị trí slot [0, 1, 2, 3, ...]
|
||||
userSequence: [], // sequence cuối cùng gửi cho SDK iframe
|
||||
canSubmit: 0, // 0 = chưa đủ từ, 1 = đủ từ có thể submit
|
||||
|
||||
// Reset mảng placedWords khi bắt đầu câu hỏi mới
|
||||
@@ -386,6 +388,41 @@ var tdv_sdk = {
|
||||
this.canSubmit = 0;
|
||||
console.log("🔄 Reset placedWords:", this.placedWords);
|
||||
},
|
||||
buildUserSequence: function () {
|
||||
var result = [];
|
||||
|
||||
for (var i = 0; i < this.correctWords.length; i++) {
|
||||
// blank slot → lấy user đặt
|
||||
if (this.isBlankIndex(i)) {
|
||||
result.push(this.placedWords[i] || "");
|
||||
}
|
||||
// preset slot → lấy từ đúng
|
||||
else {
|
||||
result.push(this.correctWords[i]);
|
||||
}
|
||||
}
|
||||
|
||||
this.userSequence = result;
|
||||
console.log("📦 User sequence built:", result);
|
||||
return result;
|
||||
},
|
||||
submitSequenceAnswer: function () {
|
||||
if (this.canSubmit !== 1) {
|
||||
console.warn("❌ Cannot submit – sequence incomplete");
|
||||
return;
|
||||
}
|
||||
|
||||
var sequence = this.buildUserSequence();
|
||||
|
||||
window.parent.postMessage({
|
||||
type: "SDK_CHECK_ANSWER",
|
||||
game_id: this.gameID,
|
||||
question_id: this.currentQuestion.id,
|
||||
choice: sequence
|
||||
}, "*");
|
||||
|
||||
console.log("📤 Sent sequence to SDK iframe:", sequence);
|
||||
},
|
||||
|
||||
// Alias cho tương thích
|
||||
resetPlacedLetters: function () {
|
||||
@@ -454,6 +491,42 @@ var tdv_sdk = {
|
||||
}
|
||||
}
|
||||
},
|
||||
handleAnswerResult: function (data) {
|
||||
// data ví dụ:
|
||||
// {
|
||||
// type: "SDK_ANSWER_RESULT",
|
||||
// question_id,
|
||||
// correct: true/false,
|
||||
// score_delta,
|
||||
// extra
|
||||
// }
|
||||
|
||||
this.lastAnswerResult = {
|
||||
correct: !!data.correct,
|
||||
raw: data
|
||||
};
|
||||
|
||||
console.log(
|
||||
data.correct ? "✅ Answer correct (SDK)" : "❌ Answer wrong (SDK)",
|
||||
data
|
||||
);
|
||||
|
||||
// Bắn trigger cho game (chưa xử lý ở C2 bước này)
|
||||
if (window['TDVTriger']) {
|
||||
window['TDVTriger'].runtime.trigger(
|
||||
cr.plugins_.TDVplugin.prototype.cnds.OnAnswerChecked,
|
||||
window['TDVTriger']
|
||||
);
|
||||
}
|
||||
},
|
||||
isLastAnswerCorrect: function () {
|
||||
return this.lastAnswerResult ? (this.lastAnswerResult.correct ? 1 : 0) : -1;
|
||||
},
|
||||
|
||||
getLastAnswerRaw: function () {
|
||||
return this.lastAnswerResult ? this.lastAnswerResult.raw : null;
|
||||
},
|
||||
|
||||
getMissingCount: function () {
|
||||
return this.missingWords.length;
|
||||
},
|
||||
@@ -1118,4 +1191,5 @@ window.addEventListener("message", function (event) {
|
||||
if (!event.data) return;
|
||||
if (event.data.type === "SERVER_PUSH_DATA") tdv_sdk.load(event.data.jsonData);
|
||||
if (event.data.type === "SERVER_PUSH_LEADERBOARD") tdv_sdk.loadLeaderboard(event.data.leaderboardData);
|
||||
if (event.data.type === "SDK_ANSWER_RESULT") { tdv_sdk.handleAnswerResult(event.data); }
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user