update PostMess
All checks were successful
Deploy to Production / deploy (push) Successful in 8s

This commit is contained in:
Đặng Minh Quang
2026-03-02 14:15:28 +07:00
parent d13909a632
commit 3c79990d24
6 changed files with 56 additions and 39 deletions

View File

@@ -26020,10 +26020,10 @@ cr.getObjectRefTable = function () { return [
cr.plugins_.Audio, cr.plugins_.Audio,
cr.plugins_.Browser, cr.plugins_.Browser,
cr.plugins_.Function, cr.plugins_.Function,
cr.plugins_.SenaPlugin,
cr.plugins_.Sprite, cr.plugins_.Sprite,
cr.plugins_.Text, cr.plugins_.Text,
cr.plugins_.Touch, cr.plugins_.Touch,
cr.plugins_.SenaPlugin,
cr.behaviors.Rex_MoveTo, cr.behaviors.Rex_MoveTo,
cr.behaviors.Fade, cr.behaviors.Fade,
cr.behaviors.DragnDrop, cr.behaviors.DragnDrop,
@@ -26054,32 +26054,6 @@ cr.getObjectRefTable = function () { return [
cr.plugins_.SenaPlugin.prototype.exps.getOptionsCount, cr.plugins_.SenaPlugin.prototype.exps.getOptionsCount,
cr.plugins_.Text.prototype.acts.SetText, cr.plugins_.Text.prototype.acts.SetText,
cr.plugins_.SenaPlugin.prototype.exps.getQuestionValue, cr.plugins_.SenaPlugin.prototype.exps.getQuestionValue,
cr.plugins_.Function.prototype.cnds.OnFunction,
cr.system_object.prototype.exps.max,
cr.plugins_.SenaPlugin.prototype.exps.getHintCount,
cr.plugins_.Text.prototype.acts.Destroy,
cr.plugins_.Sprite.prototype.acts.Destroy,
cr.plugins_.SenaPlugin.prototype.acts.CalcObjectPositions,
cr.system_object.prototype.exps.layoutwidth,
cr.plugins_.Text.prototype.acts.SetFontSize,
cr.system_object.prototype.cnds.Repeat,
cr.system_object.prototype.cnds.Compare,
cr.plugins_.SenaPlugin.prototype.exps.getHintValue,
cr.system_object.prototype.exps.loopindex,
cr.system_object.prototype.acts.CreateObject,
cr.plugins_.Sprite.prototype.acts.SetX,
cr.plugins_.SenaPlugin.prototype.exps.getPosXbyIndex,
cr.plugins_.Sprite.prototype.acts.SetY,
cr.plugins_.SenaPlugin.prototype.exps.getPosYbyIndex,
cr.plugins_.Sprite.prototype.acts.SetAnimFrame,
cr.plugins_.Sprite.prototype.acts.SetWidth,
cr.plugins_.Sprite.prototype.acts.SetHeight,
cr.plugins_.Sprite.prototype.exps.X,
cr.plugins_.Sprite.prototype.exps.Y,
cr.plugins_.SenaPlugin.prototype.exps.getOptionsValue,
cr.system_object.prototype.acts.AddVar,
cr.system_object.prototype.cnds.Else,
cr.plugins_.Text.prototype.acts.MoveToTop,
cr.behaviors.DragnDrop.prototype.cnds.OnDragStart, cr.behaviors.DragnDrop.prototype.cnds.OnDragStart,
cr.behaviors.DragnDrop.prototype.cnds.IsEnabled, cr.behaviors.DragnDrop.prototype.cnds.IsEnabled,
cr.plugins_.Sprite.prototype.acts.MoveToTop, cr.plugins_.Sprite.prototype.acts.MoveToTop,
@@ -26088,10 +26062,19 @@ cr.getObjectRefTable = function () { return [
cr.system_object.prototype.cnds.PickByComparison, cr.system_object.prototype.cnds.PickByComparison,
cr.plugins_.Sprite.prototype.cnds.CompareInstanceVar, cr.plugins_.Sprite.prototype.cnds.CompareInstanceVar,
cr.plugins_.Sprite.prototype.cnds.IsOverlapping, cr.plugins_.Sprite.prototype.cnds.IsOverlapping,
cr.plugins_.Text.prototype.acts.MoveToTop,
cr.behaviors.DragnDrop.prototype.cnds.OnDrop, cr.behaviors.DragnDrop.prototype.cnds.OnDrop,
cr.plugins_.Sprite.prototype.cnds.PickDistance,
cr.plugins_.Sprite.prototype.exps.X,
cr.plugins_.Sprite.prototype.exps.Y,
cr.plugins_.Sprite.prototype.acts.SetPos, cr.plugins_.Sprite.prototype.acts.SetPos,
cr.plugins_.Sprite.prototype.acts.SetWidth,
cr.plugins_.Sprite.prototype.acts.SetHeight,
cr.system_object.prototype.cnds.Else,
cr.behaviors.Rex_MoveTo.prototype.acts.SetTargetPos, cr.behaviors.Rex_MoveTo.prototype.acts.SetTargetPos,
cr.plugins_.Function.prototype.cnds.OnFunction,
cr.system_object.prototype.cnds.ForEach, cr.system_object.prototype.cnds.ForEach,
cr.system_object.prototype.acts.AddVar,
cr.system_object.prototype.cnds.CompareVar, cr.system_object.prototype.cnds.CompareVar,
cr.plugins_.Sprite.prototype.exps.Count, cr.plugins_.Sprite.prototype.exps.Count,
cr.plugins_.Sprite.prototype.acts.SetVisible, cr.plugins_.Sprite.prototype.acts.SetVisible,
@@ -26099,20 +26082,39 @@ cr.getObjectRefTable = function () { return [
cr.plugins_.Sprite.prototype.cnds.IsVisible, cr.plugins_.Sprite.prototype.cnds.IsVisible,
cr.plugins_.SenaPlugin.prototype.acts.PauseGame, cr.plugins_.SenaPlugin.prototype.acts.PauseGame,
cr.behaviors.Flash.prototype.acts.Flash, cr.behaviors.Flash.prototype.acts.Flash,
cr.system_object.prototype.cnds.Repeat,
cr.plugins_.SenaPlugin.prototype.exps.getHintCount,
cr.system_object.prototype.cnds.Compare,
cr.plugins_.SenaPlugin.prototype.exps.getHintValue,
cr.system_object.prototype.exps.loopindex,
cr.system_object.prototype.exps.left, cr.system_object.prototype.exps.left,
cr.system_object.prototype.exps.len, cr.system_object.prototype.exps.len,
cr.plugins_.SenaPlugin.prototype.acts.Finish, cr.plugins_.SenaPlugin.prototype.acts.Finish,
cr.plugins_.SenaPlugin.prototype.cnds.OnCorrect, cr.plugins_.SenaPlugin.prototype.cnds.OnCorrect,
cr.system_object.prototype.acts.CreateObject,
cr.plugins_.Audio.prototype.acts.SetPaused,
cr.plugins_.SenaPlugin.prototype.cnds.OnWrong, cr.plugins_.SenaPlugin.prototype.cnds.OnWrong,
cr.system_object.prototype.cnds.EveryTick, cr.system_object.prototype.cnds.EveryTick,
cr.system_object.prototype.exps.max,
cr.plugins_.SenaPlugin.prototype.exps.getTimeLimit, cr.plugins_.SenaPlugin.prototype.exps.getTimeLimit,
cr.plugins_.SenaPlugin.prototype.exps.getElapsedTime, cr.plugins_.SenaPlugin.prototype.exps.getElapsedTime,
cr.system_object.prototype.exps["int"], cr.system_object.prototype.exps["int"],
cr.system_object.prototype.cnds.TriggerOnce, cr.system_object.prototype.cnds.TriggerOnce,
cr.plugins_.Sprite.prototype.acts.SetAnimFrame,
cr.plugins_.Audio.prototype.acts.SetMuted, cr.plugins_.Audio.prototype.acts.SetMuted,
cr.system_object.prototype.acts.SetLayerVisible, cr.system_object.prototype.acts.SetLayerVisible,
cr.plugins_.Text.prototype.acts.SetVisible, cr.plugins_.Text.prototype.acts.SetVisible,
cr.system_object.prototype.cnds.LayerVisible, cr.system_object.prototype.cnds.LayerVisible,
cr.behaviors.Fade.prototype.acts.RestartFade, cr.behaviors.Fade.prototype.acts.RestartFade,
cr.behaviors.Sin.prototype.acts.SetActive cr.behaviors.Sin.prototype.acts.SetActive,
cr.plugins_.Text.prototype.acts.Destroy,
cr.plugins_.Sprite.prototype.acts.Destroy,
cr.plugins_.SenaPlugin.prototype.acts.CalcObjectPositions,
cr.system_object.prototype.exps.layoutwidth,
cr.plugins_.Text.prototype.acts.SetFontSize,
cr.plugins_.Sprite.prototype.acts.SetX,
cr.plugins_.SenaPlugin.prototype.exps.getPosXbyIndex,
cr.plugins_.Sprite.prototype.acts.SetY,
cr.plugins_.SenaPlugin.prototype.exps.getPosYbyIndex,
cr.plugins_.SenaPlugin.prototype.exps.getOptionsValue
];}; ];};

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

View File

@@ -1,5 +1,5 @@
{ {
"version": 1772161869, "version": 1772435489,
"fileList": [ "fileList": [
"data.js", "data.js",
"c2runtime.js", "c2runtime.js",
@@ -15,7 +15,7 @@
"images/khung_timer-sheet0.png", "images/khung_timer-sheet0.png",
"images/pause-sheet0.png", "images/pause-sheet0.png",
"images/pause-sheet1.png", "images/pause-sheet1.png",
"images/board-sheet0.png", "images/boardsetting-sheet0.png",
"images/bgm-sheet0.png", "images/bgm-sheet0.png",
"images/bgm-sheet1.png", "images/bgm-sheet1.png",
"images/pauseicon-sheet0.png", "images/pauseicon-sheet0.png",
@@ -41,7 +41,6 @@
"icon-128.png", "icon-128.png",
"icon-256.png", "icon-256.png",
"loading-logo.png", "loading-logo.png",
"bg.mp4",
"sena_sdk.js" "sena_sdk.js"
] ]
} }

View File

@@ -119,6 +119,7 @@ SenaSDK.prototype.loadFromPostMessage = function (inputJson, callback) {
console.warn("⚠️ Sena SDK: tdv_sdk not found, storing data locally"); console.warn("⚠️ Sena SDK: tdv_sdk not found, storing data locally");
self.data = inputJson.data; self.data = inputJson.data;
self.correctAnswer = inputJson.answer; self.correctAnswer = inputJson.answer;
self._parseGameCode(); // Thêm dòng này để SDK đọc đuôi thời gian T30
if (callback) callback(true); if (callback) callback(true);
} }
return true; return true;
@@ -154,7 +155,7 @@ SenaSDK.prototype.loadFromPostMessage = function (inputJson, callback) {
// Lưu trữ danh sách gốc // Lưu trữ danh sách gốc
self.masterList = [...self.data.options]; self.masterList = [...self.data.options];
// Tính tổng số level // Tính tổng số level
self.totalLevels = Math.ceil(self.masterList.length / self.itemCount); self.totalLevels = Math.ceil(self.masterList.length / 6);
self.currentLevel = 0; self.currentLevel = 0;
// Load Level 1 ngay lập tức để self.data.options chỉ chứa 6 card đầu // Load Level 1 ngay lập tức để self.data.options chỉ chứa 6 card đầu
@@ -518,7 +519,7 @@ SenaSDK.prototype._loadFromServer = function (
// Lưu trữ danh sách gốc // Lưu trữ danh sách gốc
self.masterList = [...self.data.options]; self.masterList = [...self.data.options];
// Tính tổng số level // Tính tổng số level
self.totalLevels = Math.ceil(self.masterList.length / self.itemCount); self.totalLevels = Math.ceil(self.masterList.length / 6);
self.currentLevel = 0; self.currentLevel = 0;
// Load Level 1 ngay lập tức để self.data.options chỉ chứa 6 card đầu // Load Level 1 ngay lập tức để self.data.options chỉ chứa 6 card đầu
@@ -1037,6 +1038,10 @@ SenaSDK.prototype.getHintValue = function (index) {
SenaSDK.prototype.start = function () { SenaSDK.prototype.start = function () {
let self = this; let self = this;
// LUÔN GÁN THỜI GIAN BẮT ĐẦU Ở ĐÂY
self.startTime = Date.now();
console.log("🎮 Sena SDK: Game Started");
// Nếu là matching game, forward sang tdv_sdk.start() // Nếu là matching game, forward sang tdv_sdk.start()
if (self.isMatchingGame) { if (self.isMatchingGame) {
console.log("🎮 Sena SDK: Matching game - forwarding start() to tdv_sdk"); console.log("🎮 Sena SDK: Matching game - forwarding start() to tdv_sdk");
@@ -1051,7 +1056,6 @@ SenaSDK.prototype.start = function () {
if (self.shuffle && self.data && self.data.options) { if (self.shuffle && self.data && self.data.options) {
self.shuffleArray(self.data.options); self.shuffleArray(self.data.options);
} }
self.startTime = Date.now();
// Additional logic for tracking can be added here if needed // Additional logic for tracking can be added here if needed
}; };
@@ -1103,6 +1107,20 @@ SenaSDK.prototype.end = function (answer, callback) {
`Result: ${correctCount}/${totalPairs} correct - ${isCorrect ? "CORRECT" : "INCORRECT"}`, `Result: ${correctCount}/${totalPairs} correct - ${isCorrect ? "CORRECT" : "INCORRECT"}`,
); );
// [NEW] Universal PostMessage for BE
window.parent.postMessage(
{
type: "GAME_RESULT",
payload: {
game_id: self.gameID || self.gameCode,
result: isCorrect ? "CORRECT" : "INCORRECT",
time_spent: duration,
},
},
"*",
);
console.log("📤 Sena SDK: GAME_RESULT sent successfully");
if (callback) callback(isCorrect); if (callback) callback(isCorrect);
return { return {
isCorrect: isCorrect, isCorrect: isCorrect,
@@ -1202,9 +1220,7 @@ SenaSDK.prototype.end = function (answer, callback) {
// [BƯỚC 3] Log và Return // [BƯỚC 3] Log và Return
// ----------------------------------------------------------- // -----------------------------------------------------------
console.log(`Time spent: ${duration}s`); console.log(`Time spent: ${duration}s`);
console.log( console.log(`Result: ${isCorrect ? "CORRECT" : "INCORRECT"}`);
`Result: ${isCorrect ? "CORRECT" : "INCORRECT"} (User: ${result.userAnswer} vs Correct: ${result.correctAnswer})`,
);
if (callback) callback(result.isCorrect); if (callback) callback(result.isCorrect);
return result; // Return full object for debug return result; // Return full object for debug
@@ -1733,7 +1749,7 @@ SenaSDK.prototype.loadLevelG5 = function (levelIndex) {
if (self.gameType !== 5 || !self.masterList) return false; if (self.gameType !== 5 || !self.masterList) return false;
self.currentLevel = levelIndex; self.currentLevel = levelIndex;
let count = self.itemCount; // Số card tối đa mỗi trang (VD: 6) let count = 6; // Khóa cứng max 6 card/trang cho G5
window.Sena_TotalLevels = Math.ceil(self.masterList.length / count); window.Sena_TotalLevels = Math.ceil(self.masterList.length / count);

Binary file not shown.