Repository Public License
1{2 "entrypoint": "play",3 "icon": {4 "background": {5 "angle": 135,6 "colors": [7 "#FF7AB6",8 "#8B6CFF"9 ],10 "pattern": "dots",11 "style": "linear"12 },13 "finish": "glass",14 "layers": [15 {16 "fill": "#FFFFFF",17 "height": 54,18 "rotation": -12,19 "shadow": true,20 "shape": "roundedRect",21 "width": 42,22 "x": 37,23 "y": 5224 },25 {26 "fill": "#FF4F9A",27 "rotation": -12,28 "size": 24,29 "symbol": "heart.fill",30 "x": 37,31 "y": 5232 },33 {34 "fill": {35 "angle": 135,36 "colors": [37 "#FFD84D",38 "#FF9F43"39 ]40 },41 "height": 54,42 "rotation": 12,43 "shadow": true,44 "shape": "roundedRect",45 "stroke": "#FFFFFF",46 "strokeWidth": 3,47 "width": 42,48 "x": 63,49 "y": 4850 },51 {52 "fill": "#FFFFFF",53 "rotation": 12,54 "size": 24,55 "symbol": "questionmark",56 "x": 63,57 "y": 4858 }59 ]60 },61 "id": "app_prj_tbl5mkmxwh",62 "name": "Memory Match",63 "objects": [64 {65 "id": "scores",66 "name": "Best Scores",67 "props": {68 "columns": [69 {70 "label": "Player",71 "name": "player",72 "required": true,73 "type": "text"74 },75 {76 "label": "Moves",77 "name": "moves",78 "required": true,79 "type": "integer"80 },81 {82 "label": "Date",83 "name": "played_on",84 "type": "date"85 }86 ],87 "seed": [88 {89 "moves": 11,90 "played_on": "2024-05-02",91 "player": "Mia"92 },93 {94 "moves": 14,95 "played_on": "2024-05-03",96 "player": "Leo"97 },98 {99 "moves": 17,100 "played_on": "2024-05-04",101 "player": "Ava"102 }103 ]104 },105 "provenance": {106 "source": "agent"107 },108 "schemaVersion": 1,109 "type": "prism.data.table",110 "version": 1111 },112 {113 "id": "game",114 "name": "Game logic",115 "props": {116 "source": "var EMOJI = [\"🐶\",\"🍕\",\"🚀\",\"🦄\",\"🐸\",\"🌈\",\"🍓\",\"⚽️\",\"🐱\",\"🍦\",\"🦋\",\"🐢\",\"🎈\",\"🍩\",\"🐙\",\"🌻\"];\n\nfunction shuffle(a) {\n for (var i = a.length - 1; i > 0; i--) {\n var j = Math.floor(Math.random() * (i + 1));\n var t = a[i]; a[i] = a[j]; a[j] = t;\n }\n return a;\n}\n\nfunction newGame() {\n var picks = shuffle(EMOJI.slice()).slice(0, 8);\n var deck = shuffle(picks.concat(picks));\n app.set(\"deck\", deck);\n app.set(\"flipped\", []);\n app.set(\"matched\", []);\n app.set(\"moves\", 0);\n app.set(\"miss\", 0);\n app.set(\"won\", false);\n return deck;\n}\n"117 },118 "provenance": {119 "generated": true,120 "source": "agent"121 },122 "schemaVersion": 1,123 "type": "prism.script",124 "version": 1125 },126 {127 "id": "memoryBoard",128 "name": "Memory board",129 "props": {130 "events": [131 "won"132 ],133 "props": [134 {135 "default": 96,136 "kind": "number",137 "name": "cardSize",138 "summary": "Card width and height in points."139 },140 {141 "default": "scores",142 "kind": "string",143 "name": "scoreTable",144 "summary": "Table that receives {player, moves, played_on} when a game is won."145 }146 ],147 "source": "function list(k) { var v = app.get(k); return Array.isArray(v) ? v : []; }\n\nfunction render(props) {\n var size = props.cardSize || 96;\n var deck = list(\"deck\");\n var flipped = list(\"flipped\");\n var matched = list(\"matched\");\n var cards = deck.map(function (emoji, i) {\n var isMatched = matched.indexOf(i) >= 0;\n var faceUp = isMatched || flipped.indexOf(i) >= 0;\n return {\n type: \"zstack\", id: \"card\" + i, width: size, height: size,\n cornerRadius: 18,\n background: faceUp ? (isMatched ? \"success\" : \"surface\") : { gradient: [\"#FF7AB6\", \"#8B6CFF\"], angle: 135 },\n borderColor: faceUp ? (isMatched ? \"success\" : \"accent\") : \"#FFFFFF\",\n borderWidth: 3,\n shadow: true,\n scale: isMatched ? 0.95 : 1,\n opacity: isMatched ? 0.85 : 1,\n onTap: { call: \"flip\", args: [i] },\n label: faceUp ? (\"Card \" + (i + 1) + \", \" + emoji + (isMatched ? \", matched\" : \"\")) : (\"Card \" + (i + 1) + \", face down\"),\n children: [ faceUp\n ? { type: \"text\", text: emoji, size: size * 0.5 }\n : { type: \"symbol\", name: \"questionmark\", size: size * 0.32, color: \"#FFFFFF\" } ]\n };\n });\n return { type: \"grid\", columns: 4, spacing: 12, animate: true, children: cards };\n}\n\nfunction flip(i, ev) {\n if (app.get(\"won\")) return;\n var deck = list(\"deck\");\n var flipped = list(\"flipped\").slice();\n var matched = list(\"matched\").slice();\n if (matched.indexOf(i) >= 0 || flipped.indexOf(i) >= 0) return;\n if (flipped.length >= 2) { flipped = []; app.set(\"miss\", 0); }\n flipped.push(i);\n if (flipped.length === 2) {\n var moves = (app.get(\"moves\") || 0) + 1;\n app.set(\"moves\", moves);\n if (deck[flipped[0]] === deck[flipped[1]]) {\n matched = matched.concat(flipped);\n flipped = [];\n app.set(\"matched\", matched);\n if (matched.length === deck.length) {\n app.set(\"won\", true);\n var name = (app.get(\"player\") || \"\").trim() || \"Player\";\n var table = (ev && ev.props && ev.props.scoreTable) || \"scores\";\n app.insert(table, { player: name, moves: moves, played_on: app.today() });\n app.notify(\"🎉 You found all pairs in \" + moves + \" moves!\", \"success\");\n app.emit(\"won\", moves);\n }\n } else {\n app.set(\"miss\", 1);\n }\n }\n app.set(\"flipped\", flipped);\n}\n\nfunction tick(props) {\n var m = app.get(\"miss\") || 0;\n if (m <= 0) return;\n if (m >= 3) { app.set(\"flipped\", []); app.set(\"miss\", 0); }\n else app.set(\"miss\", m + 1);\n}\n",148 "summary": "A 4×4 memory board: tap cards to flip two at a time; matched pairs stay up, misses flip back after a moment. Counts moves and saves a score when all pairs are found.",149 "tick": 0.5150 },151 "provenance": {152 "generated": true,153 "source": "agent"154 },155 "schemaVersion": 1,156 "type": "prism.component",157 "version": 1158 },159 {160 "children": [161 "root"162 ],163 "id": "play",164 "name": "Play",165 "props": {166 "icon": "square.grid.4x3.fill"167 },168 "provenance": {169 "source": "agent"170 },171 "schemaVersion": 1,172 "type": "prism.page",173 "version": 1174 },175 {176 "children": [177 "title",178 "win_alert",179 "main_row"180 ],181 "id": "root",182 "props": {183 "align": "stretch",184 "grow": true,185 "padding": 20,186 "spacing": 16187 },188 "provenance": {189 "source": "agent"190 },191 "schemaVersion": 1,192 "type": "prism.stack",193 "version": 1194 },195 {196 "id": "title",197 "props": {198 "level": 1,199 "text": "🧠 Memory Match"200 },201 "provenance": {202 "source": "agent"203 },204 "schemaVersion": 1,205 "type": "prism.heading",206 "version": 1207 },208 {209 "children": [210 "board_card",211 "side"212 ],213 "id": "main_row",214 "props": {215 "align": "leading",216 "direction": "horizontal",217 "grow": true,218 "spacing": 20219 },220 "provenance": {221 "source": "agent"222 },223 "schemaVersion": 1,224 "type": "prism.stack",225 "version": 1226 },227 {228 "children": [229 "board"230 ],231 "id": "board_card",232 "props": {233 "title": "Find the pairs!"234 },235 "provenance": {236 "source": "agent"237 },238 "schemaVersion": 1,239 "type": "prism.card",240 "version": 1241 },242 {243 "children": [244 "stats_row",245 "player_field",246 "new_game",247 "scores_heading",248 "scores_table"249 ],250 "id": "side",251 "props": {252 "align": "stretch",253 "grow": true,254 "spacing": 14255 },256 "provenance": {257 "source": "agent"258 },259 "schemaVersion": 1,260 "type": "prism.stack",261 "version": 1262 },263 {264 "id": "board",265 "props": {266 "accessibilityLabel": "Memory card board",267 "cardSize": 96,268 "scoreTable": "scores"269 },270 "provenance": {271 "source": "agent"272 },273 "schemaVersion": 1,274 "type": "custom.memoryBoard",275 "version": 1276 },277 {278 "children": [279 "moves_stat",280 "pairs_stat"281 ],282 "id": "stats_row",283 "props": {284 "align": "stretch",285 "direction": "horizontal",286 "height": 66,287 "spacing": 12288 },289 "provenance": {290 "source": "agent"291 },292 "schemaVersion": 1,293 "type": "prism.stack",294 "version": 1295 },296 {297 "id": "player_field",298 "props": {299 "label": "Your name",300 "value": {301 "$bind": "player"302 }303 },304 "provenance": {305 "source": "agent"306 },307 "schemaVersion": 1,308 "type": "prism.textField",309 "version": 1310 },311 {312 "events": {313 "click": [314 {315 "args": [],316 "function": "newGame",317 "type": "runScript"318 },319 {320 "message": "New game! Good luck 🍀",321 "tone": "info",322 "type": "showNotification"323 }324 ]325 },326 "id": "new_game",327 "props": {328 "accessibilityLabel": "Start a new game",329 "icon": "arrow.clockwise",330 "style": "primary",331 "title": "New Game"332 },333 "provenance": {334 "source": "agent"335 },336 "schemaVersion": 1,337 "type": "prism.button",338 "version": 1339 },340 {341 "id": "scores_heading",342 "props": {343 "level": 2,344 "text": "🏆 Best Scores"345 },346 "provenance": {347 "source": "agent"348 },349 "schemaVersion": 1,350 "type": "prism.heading",351 "version": 1352 },353 {354 "dependencies": [355 "scores"356 ],357 "id": "scores_table",358 "props": {359 "columns": [360 {361 "column": "player",362 "title": "Player"363 },364 {365 "align": "trailing",366 "column": "moves",367 "format": "number",368 "title": "Moves"369 },370 {371 "column": "played_on",372 "format": "date",373 "title": "Date"374 }375 ],376 "emptyMessage": "Finish a game to get on the board.",377 "emptyTitle": "No scores yet",378 "grow": true,379 "query": {380 "limit": 10,381 "sort": [382 {383 "column": "moves",384 "descending": false385 },386 {387 "column": "played_on",388 "descending": false389 }390 ],391 "table": "scores"392 },393 "sortable": false394 },395 "provenance": {396 "source": "agent"397 },398 "schemaVersion": 1,399 "type": "prism.table",400 "version": 1401 },402 {403 "id": "moves_stat",404 "props": {405 "grow": true,406 "icon": "hand.tap.fill",407 "label": "Moves",408 "tone": "accent",409 "value": {410 "$expr": "state.moves"411 }412 },413 "provenance": {414 "source": "agent"415 },416 "schemaVersion": 1,417 "type": "prism.aggregation",418 "version": 1419 },420 {421 "id": "pairs_stat",422 "props": {423 "format": "text",424 "grow": true,425 "icon": "star.fill",426 "label": "Pairs found",427 "tone": "success",428 "value": {429 "$expr": "concat(text(length(state.matched) / 2), ' / 8')"430 }431 },432 "provenance": {433 "source": "agent"434 },435 "schemaVersion": 1,436 "type": "prism.aggregation",437 "version": 1438 },439 {440 "id": "win_alert",441 "props": {442 "message": {443 "$expr": "concat('You found every pair in ', text(state.moves), ' moves. Your score was saved. Press New Game to play again!')"444 },445 "title": "🎉 You did it!",446 "tone": "success",447 "visible": {448 "$expr": "state.won"449 }450 },451 "provenance": {452 "source": "agent"453 },454 "schemaVersion": 1,455 "type": "prism.alert",456 "version": 1457 }458 ],459 "permissions": [460 "storage.local",461 "logic.scripts"462 ],463 "schemaVersion": 1,464 "state": {465 "deck": [466 "🐶",467 "🍕",468 "🚀",469 "🦄",470 "🐸",471 "🌈",472 "🍓",473 "⚽️",474 "🍕",475 "🐸",476 "🐶",477 "⚽️",478 "🦄",479 "🚀",480 "🍓",481 "🌈"482 ],483 "flipped": [],484 "matched": [],485 "miss": 0,486 "moves": 0,487 "player": "Player 1",488 "won": false489 },490 "summary": "A kids' memory card game: flip emoji cards two at a time on a 4×4 board, count moves, and keep best scores between sessions.",491 "theme": {492 "accent": "#8B6CFF",493 "backgroundGradient": [494 "#FFF0F7",495 "#EEE8FF"496 ],497 "font": "rounded",498 "headingFont": "rounded",499 "headingWeight": "heavy",500 "preset": "candy"501 },502 "version": 1503}