Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
248 changes: 109 additions & 139 deletions public/css/logic_game.css
Original file line number Diff line number Diff line change
@@ -1,139 +1,109 @@
body {
font-family: sans-serif;
background:
linear-gradient(to bottom, rgba(255, 255, 255, 0.04) 1px, transparent 1px) 0 0/100% 3rem,
radial-gradient(1000px 500px at 15% 20%, rgba(0, 0, 0, 0.35) 0%, transparent 60%) no-repeat,
radial-gradient(1000px 500px at 85% 80%, rgba(0, 0, 0, 0.35) 0%, transparent 60%) no-repeat,
var(--navy-900);
}

h2 {
margin-bottom: 10px;
}

.list {
list-style: none;
padding: 10px;
min-height: 60px;
margin: 10px 0;
box-shadow: inset 0 0.125rem 0.5rem rgba(0, 0, 0, 2);
border-radius: 0.70rcap;
}

li {
padding: 8px;
margin: 5px;
background: #4caf50;
color: white;
cursor: grab;
border-radius: 6px;
}

.block {
padding: 8px;
margin: 5px;
background: #4caf50;
color: white;
cursor: grab;
border-radius: 6px;
}

.if-block {
background: #ff9800;
color: white;
padding: 10px;
border-radius: 6px;
margin: 8px 0;
cursor: grab;
}

.if-title {
font-weight: bold;
color: #004a99;
margin-bottom: 5px;
}

.branch {
border: 2px dashed #666;
padding: 8px;
min-height: 40px;
margin: 6px 0;
background: #fafafa;
}

.branch-label {
font-size: 12px;
font-weight: bold;
}

.container {
margin: 10px 2rem 10px 2rem;
border-radius: 1.125rem;
padding: 2.5rem clamp(1.75rem, 1vw, 25rem);
background:
linear-gradient(180deg, rgba(255, 255, 255, .08), rgba(255, 255, 255, .02)) padding-box,
radial-gradient(120% 140% at 100% 0%, rgba(224, 133, 0, .30), transparent 40%) padding-box,
radial-gradient(120% 140% at 0% 100%, rgba(0, 95, 163, .35), transparent 40%) padding-box;
box-shadow:
0 0.625rem 1.875rem rgba(0, 0, 0, .45),
inset 0 0.0625rem 0 rgba(255, 255, 255, .06);
backdrop-filter: blur(0.875rem) saturate(120%);
border: 0.0625rem solid rgba(255, 255, 255, .10);
}

.btn_submitlogic {
--_ring: rgba(0, 95, 163, .38);
padding: 1.5rem 6.25rem;
border: 0;
border-radius: 0.75rem;
font: 700 1.625rem/1 "Inter", system-ui, sans-serif;
letter-spacing: 0.01em;
color: var(--white);
background: linear-gradient(90deg, var(--blue-600), var(--orange-500));
box-shadow:
0 0.5rem 1.5rem rgba(0, 0, 0, .45),
0 0 0 0 var(--_ring);
cursor: pointer;
transition: transform 0.06s ease, box-shadow 0.2s ease, filter 0.2s ease;
display: inline-flex;
align-items: center;
min-width: 360px;
gap: 0.625rem;
margin: 20px auto;
/* เพิ่มระยะห่างและจัดให้อยู่ตรงกลาง */
}

.btn_submitlogic:hover {
filter: saturate(115%);
}

.btn_submitlogic:active {
transform: translateY(0.0625rem);
}

.btn_submitlogic:focus-visible {
box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, .45), 0 0 0 0.375rem var(--_ring);
}

.result {
box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 2);
border-radius: 0.70rem;
margin: 10px 0;
padding: 10px;
min-height: 60px;
font-size: 1.25rem;
font-weight: bold;
}

.level-header {
text-align: center;
margin-bottom: 20px;
}

.level-select {
margin: 10px 0 20px 0;
padding: 8px;
border-radius: 6px;
border: 1px solid #ffffff;
font-size: 1rem;
}
body { font-family: sans-serif;
background:
linear-gradient(to bottom, rgba(255,255,255,0.04) 1px, transparent 1px) 0 0/100% 3rem,
radial-gradient(1000px 500px at 15% 20%, rgba(0,0,0,0.35) 0%, transparent 60%) no-repeat,
radial-gradient(1000px 500px at 85% 80%, rgba(0,0,0,0.35) 0%, transparent 60%) no-repeat,
var(--navy-900);
}
h2 { margin-bottom: 10px; }
.list {
list-style: none; padding: 10px; min-height: 60px;
margin: 10px 0;
box-shadow: inset 0 0.125rem 0.5rem rgba(0,0,0,2);
border-radius: 0.70rcap;
}
li {
padding: 8px; margin: 5px; background: #4caf50;
color: white; cursor: grab; border-radius: 6px;
}
.block {
padding: 8px;
margin: 5px;
background: #4caf50;
color: white;
cursor: grab;
border-radius: 6px;
}
.if-block {
background: #ff9800;
color: white;
padding: 10px;
border-radius: 6px;
margin: 8px 0;
cursor: grab;
}
.if-title {
font-weight: bold;
color: #004a99;
margin-bottom: 5px;
}
.branch {
border: 2px dashed #666;
padding: 8px;
min-height: 40px;
margin: 6px 0;
background: #fafafa;
}
.branch-label {
font-size: 12px;
font-weight: bold;
}
.container {
margin: 10px 2rem 10px 2rem;
border-radius: 1.125rem;
padding: 2.5rem clamp(1.75rem, 1vw, 25rem);
background:
linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.02)) padding-box,
radial-gradient(120% 140% at 100% 0%, rgba(224,133,0,.30), transparent 40%) padding-box,
radial-gradient(120% 140% at 0% 100%, rgba(0,95,163,.35), transparent 40%) padding-box;
box-shadow:
0 0.625rem 1.875rem rgba(0,0,0,.45),
inset 0 0.0625rem 0 rgba(255,255,255,.06);
backdrop-filter: blur(0.875rem) saturate(120%);
border: 0.0625rem solid rgba(255,255,255,.10);
overflow: auto; /* เพิ่มการเลื่อนภายใน container */
}
.btn_submitlogic {
--_ring: rgba(0,95,163,.38);
padding: 1.5rem 6.25rem;
border: 0;
border-radius: 0.75rem;
font: 700 1.625rem/1 "Inter", system-ui, sans-serif;
letter-spacing: 0.01em;
color: var(--white);
background: linear-gradient(90deg, var(--blue-600), var(--orange-500));
box-shadow:
0 0.5rem 1.5rem rgba(0,0,0,.45),
0 0 0 0 var(--_ring);
cursor: pointer;
transition: transform 0.06s ease, box-shadow 0.2s ease, filter 0.2s ease;
display: inline-flex;
align-items: center;
min-width: 360px;
gap: 0.625rem;
margin: 20px auto; /* เพิ่มระยะห่างและจัดให้อยู่ตรงกลาง */
}
.btn_submitlogic:hover { filter: saturate(115%); }
.btn_submitlogic:active { transform: translateY(0.0625rem); }
.btn_submitlogic:focus-visible {
box-shadow: 0 0.5rem 1.5rem rgba(0,0,0,.45), 0 0 0 0.375rem var(--_ring);
}
.result {
box-shadow: 0 0.125rem 0.5rem rgba(0,0,0,2);
border-radius: 0.70rem;
margin: 10px 0;
padding: 10px; min-height: 60px;
font-size: 1.25rem;
font-weight: bold;
}
.level-header {
text-align: center;
margin-bottom: 20px;
}
.level-select {
margin: 10px 0 20px 0;
padding: 8px;
border-radius: 6px;
border: 1px solid #ffffff;
font-size: 1rem;
}
4 changes: 3 additions & 1 deletion public/html/logic_game.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
<link rel="stylesheet" href="../css/logic_game.css">
<script src="https://cdn.jsdelivr.net/npm/sortablejs@1.15.0/Sortable.min.js"></script>
<script src="../dist/logic_game.js" defer></script>


<header class="brandbar" role="banner">
<h1>CAMT OPEN HOUSE 68<span class="cursor">_</span></h1>
<div><h2>Flowchart Puzzle Game!!!<span class="cursor">_</span></h2></div>
Expand Down Expand Up @@ -47,4 +49,4 @@ <h3>Flow หลัก</h3>
</div>
</div>
</body>
</html>
</html>
29 changes: 26 additions & 3 deletions src/logic_game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,23 +255,46 @@ function loadLevel(levelIndex: number) {
}
function checkAnswer() {
const level = levels[currentLevel];

// ดึงข้อมูลจาก Flow หลัก
const mainFlow = Array.from(
document.querySelectorAll("#dropzone > .block, #dropzone > .if-block")
).map((el) => (el as HTMLElement).innerText.split("\n")[0]); // แค่ชื่อบล็อก
).map((el) => {
const text = (el as HTMLElement).innerText.trim();
// ลบข้อความ TRUE และ FALSE branch ออกจากบล็อก IF
return text.includes("TRUE") || text.includes("FALSE")
? text.split("\n")[0] // แยกเฉพาะข้อความก่อน newline
: text;
});

// ดึงข้อมูลจาก TRUE branch
const trueBranch = Array.from(document.querySelectorAll(".branch-label"))
.filter((label) => (label as HTMLElement).innerText.includes("TRUE"))
.map((label) => label.nextElementSibling)
.filter((branch) => branch !== null)
.flatMap((branch) => Array.from(branch.querySelectorAll(".block")))
.map((el) => (el as HTMLElement).innerText.trim());

// ดึงข้อมูลจาก FALSE branch
const falseBranch = Array.from(document.querySelectorAll(".branch-label"))
.filter((label) => (label as HTMLElement).innerText.includes("FALSE"))
.map((label) => label.nextElementSibling)
.filter((branch) => branch !== null)
.flatMap((branch) => Array.from(branch.querySelectorAll(".block")))
.map((el) => (el as HTMLElement).innerText);
.map((el) => (el as HTMLElement).innerText.trim());

// Debug: แสดงข้อมูลที่ดึงมา
console.log("mainFlow:", mainFlow);
console.log("trueBranch:", trueBranch);
console.log("falseBranch:", falseBranch);
console.log("correctMain:", level.correctMain);
console.log("correctTrue:", level.correctTrue);
console.log("correctFalse:", level.correctFalse);

// ตรวจสอบผลลัพธ์
let result = document.getElementById("result");
if (!result) return;

if (
JSON.stringify(mainFlow) === JSON.stringify(level.correctMain) &&
JSON.stringify(trueBranch) === JSON.stringify(level.correctTrue) &&
Expand Down