require('dotenv').config(); const { Pool } = require('pg'); const pool = new Pool({ host: process.env.DB_HOST, port: process.env.DB_PORT, database: process.env.DB_NAME, user: process.env.DB_USER, password: process.env.DB_PASSWORD, }); const games = [ { title: "Star Catcher", description: "Catch falling stars while avoiding meteors! Move left and right to collect as many stars as you can.", code: ` Star Catcher
Score: 0
๐Ÿงบ

Game Over!

Final Score: 0

โ† โ†’ Arrow keys or touch to move
` }, { title: "Balloon Pop Frenzy", description: "Pop as many balloons as you can before they float away! Click or tap the balloons to pop them and score points.", code: ` Balloon Pop
Score: 0
Time: 30

Time's Up!

Score: 0

` }, { title: "Snake Classic", description: "The classic snake game! Eat the apples to grow longer but don't hit the walls or yourself. Use arrow keys or swipe to control.", code: ` Snake
Score: 0
Arrow keys or swipe to move

Game Over!

Score: 0

` }, { title: "Memory Match", description: "Test your memory! Flip cards to find matching pairs. Complete the game with as few moves as possible.", code: ` Memory Match

Memory Match

Moves: 0 | Pairs: 0/8

You Win!

Completed in 0 moves

` }, { title: "Whack-a-Mole", description: "Quick! Whack the moles before they hide! Test your reflexes in this classic arcade game.", code: ` Whack-a-Mole

Whack-a-Mole!

Score: 0Time: 30

Time's Up!

Final Score: 0

` }, { title: "Color Match", description: "Match the color to the word! But be careful - the colors are tricky. How fast can you react?", code: ` Color Match
Score: 0Time: 30
RED
Does the COLOR match the WORD?

Game Over!

Final Score: 0

` }, { title: "Fruit Ninja", description: "Slice the fruits as they fly across the screen! Avoid the bombs or it's game over.", code: ` Fruit Ninja
Score: 0
โค๏ธโค๏ธโค๏ธ

Game Over!

Final Score: 0

` }, { title: "Math Blaster", description: "Solve math problems as fast as you can! Each correct answer earns points, but wrong answers cost time.", code: ` Math Blaster
Score: 0Time: 60
5 + 3 = ?

Time's Up!

Final Score: 0

Problems Solved: 0

` }, { title: "Brick Breaker", description: "Classic brick breaking action! Bounce the ball to destroy all bricks. Don't let the ball fall!", code: ` Brick Breaker
Score: 0 | Lives: 3
โ† โ†’ or touch to move

Game Over

Score: 0

` }, { title: "Space Invaders", description: "Defend Earth from alien invaders! Shoot them down before they reach the bottom. Classic arcade action!", code: ` Space Invaders
SCORE: 0 | LIVES: 3
โ† โ†’ MOVE | SPACE FIRE | TAP TO SHOOT

GAME OVER

SCORE: 0

` } ]; async function insertGames() { const client = await pool.connect(); try { // Get admin user ID const adminResult = await client.query( "SELECT id FROM users WHERE role = 'admin' LIMIT 1" ); if (adminResult.rows.length === 0) { console.error('No admin user found!'); return; } const adminId = adminResult.rows[0].id; console.log('Using admin ID:', adminId); for (const game of games) { const result = await client.query( `INSERT INTO games (creator_id, title, description, game_code, status, published_at, play_count) VALUES ($1, $2, $3, $4, 'published', NOW(), $5) ON CONFLICT DO NOTHING RETURNING id, title`, [adminId, game.title, game.description, game.code, Math.floor(Math.random() * 100) + 10] ); if (result.rows[0]) { console.log('Created game:', result.rows[0].title); } } console.log('All games created successfully!'); } finally { client.release(); await pool.end(); } } insertGames().catch(console.error);