{
"id": "291",
"prompt": "A club membership card: subscribed viewers get a green-trimmed MEMBER CARD showing the club size and a small LEAVE CLUB button; everyone else gets a NOT A MEMBER card with a big JOIN CLUB button. Joining needs a wallet - route identity-less viewers through request_identity() first - and a real join fires subscribe() plus a local notify() welcome. All taps edge-detected with the previous pointer_down in a slot.",
"solution_rl": "fn frame(t: i32) {\n host::display::clear(0x0c0e13);\n let has: i32 = host::agent::viewer_has_identity();\n let subbed: i32 = host::agent::is_subscribed();\n let count: i32 = host::agent::subscriber_count();\n let down: i32 = host::display::pointer_down();\n let prev: i32 = host::display::state_get(0);\n host::display::state_set(0, down);\n let mut click: i32 = 0;\n if down == 1 && prev == 0 {\n click = 1;\n }\n\n if subbed == 1 {\n host::display::fill_rect(76, 130, 360, 220, 0x152a1a);\n host::display::fill_rect(76, 130, 360, 8, 0x33ff88);\n host::display::draw_string(100, 170, \"MEMBER CARD\", 0x99ffbb, 3);\n host::display::draw_string(100, 240, \"CLUB SIZE\", 0x557766, 1);\n host::display::draw_number(190, 232, count, 0xffffff, 3);\n host::display::fill_rect(100, 300, 140, 34, 0x223328);\n host::display::draw_string(112, 310, \"LEAVE CLUB\", 0x88aa99, 1);\n if click == 1 {\n let px: i32 = host::display::pointer_x();\n let py: i32 = host::display::pointer_y();\n if px >= 100 && px < 240 && py >= 300 && py < 334 {\n host::agent::unsubscribe();\n }\n }\n } else {\n host::display::fill_rect(76, 130, 360, 220, 0x1a1e26);\n host::display::draw_string(100, 170, \"NOT A MEMBER\", 0x8899aa, 3);\n host::display::draw_string(100, 240, \"MEMBERS\", 0x556677, 1);\n host::display::draw_number(172, 232, count, 0xffffff, 3);\n host::display::fill_rect(100, 290, 200, 44, 0xdddddd);\n host::display::draw_string(128, 304, \"JOIN CLUB\", 0x000000, 2);\n if click == 1 {\n let px2: i32 = host::display::pointer_x();\n let py2: i32 = host::display::pointer_y();\n if px2 >= 100 && px2 < 300 && py2 >= 290 && py2 < 334 {\n if has == 0 {\n host::agent::request_identity();\n } else {\n host::agent::subscribe();\n host::agent::notify(\"Welcome to the club\", \"Your membership is live.\");\n }\n }\n }\n }\n host::display::present();\n}\n",
"tags": [
"agent",
"feed",
"notify"
]
}