[ 'title' => 'اللعبة الترفيهية - العجلة، الجمل، والاختيار', 'spin' => 'دور العجلة!', 'history' => 'سجل النتائج', 'wheel_desc' => 'جرّب حظك! العجلة موزونة ويمكن تعديل الأوزان من الخادم.', 'camel_title' => 'ساعد الجمل على إيجاد الماء', 'camel_instructions' => 'اضغط على مربعات الصحراء للكشف — لديك عدد محدود من المحاولات.', 'camel_attempts' => 'المحاولات المتبقية', 'camel_restart' => 'أعد اللعب', 'match_title' => 'الفتاة تختار زوجاً', 'match_instructions' => 'اختاري من بين المرشّحين بناءً على الصفات — كل اختيار يُعطي نتيجة.', 'match_choose' => 'اختاري هذا المرشح', 'match_result' => 'نتيجة الاختيار', 'change_lang' => 'تغيير اللغة', 'more_features' => 'هل تريد ميزات إضافية؟ (حفظ في قاعدة بيانات، أصوات، تسجيل دخول)' ], 'en' => [ 'title' => 'Fun Hub - Wheel, Camel, & Match', 'spin' => 'Spin the Wheel!', 'history' => 'Results History', 'wheel_desc' => 'Try your luck! Wheel uses server-side weighted selection.', 'camel_title' => 'Help the Camel Find Water', 'camel_instructions' => 'Click desert tiles to uncover — limited attempts.', 'camel_attempts' => 'Attempts left', 'camel_restart' => 'Play Again', 'match_title' => 'Girl Chooses a Husband', 'match_instructions' => 'Pick among candidates based on attributes — choices produce a score.', 'match_choose' => 'Choose this candidate', 'match_result' => 'Selection result', 'change_lang' => 'Change language', 'more_features' => 'Want more features? (DB save, sounds, login)' ] ]; // --- الجوائز (wheel) مع ألوان $prizes = [ ['label_ar'=>'100 نقطة','label_en'=>'100 pts','color'=>'#f44336'], ['label_ar'=>'50 نقطة','label_en'=>'50 pts','color'=>'#e91e63'], ['label_ar'=>'خسارة','label_en'=>'Lose','color'=>'#9e9e9e'], ['label_ar'=>'200 نقطة','label_en'=>'200 pts','color'=>'#3f51b5'], ['label_ar'=>'محاولة إضافية','label_en'=>'Extra try','color'=>'#00bcd4'], ['label_ar'=>'500 نقطة','label_en'=>'500 pts','color'=>'#4caf50'], ['label_ar'=>'خسارة','label_en'=>'Lose','color'=>'#607d8b'], ['label_ar'=>'جائزة كبرى','label_en'=>'Grand Prize','color'=>'#ffc107'] ]; // تحويل للواجهة بناءً على اللغة function prize_label($p, $lang){ return $lang === 'ar' ? $p['label_ar'] : $p['label_en']; } // --- نقطة نهاية الخادم: طلب الدور (spin) if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'spin') { header('Content-Type: application/json; charset=utf-8'); // أوزان قابلة للتعديل — مثال متوازن $weights = [10,12,30,8,15,5,10,10]; if (count($weights) !== count($prizes)) $weights = array_fill(0, count($prizes), 1); $total = array_sum($weights); $r = mt_rand(1, $total); $acc = 0; $selected = 0; foreach ($weights as $i => $w) { $acc += $w; if ($r <= $acc) { $selected = $i; break; } } if (!isset($_SESSION['history'])) $_SESSION['history'] = []; $entry = [ 'time'=>date('Y-m-d H:i:s'), 'index'=>$selected, 'label_ar'=>$prizes[$selected]['label_ar'], 'label_en'=>$prizes[$selected]['label_en']]; $_SESSION['history'][] = $entry; echo json_encode(['ok'=>true,'index'=>$selected,'label_ar'=>$entry['label_ar'],'label_en'=>$entry['label_en']]); exit; } // --- إعداد لعبة الجمل (server-side seed for randomness) if (!isset($_SESSION['camel'])) { $_SESSION['camel'] = [ 'size' => 5, 'water' => [rand(0,4), rand(0,4)], 'attempts' => 6 ]; } // إعادة ضبط إذا طُلب if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'camel_reset'){ $_SESSION['camel'] = [ 'size'=>5, 'water'=>[rand(0,4), rand(0,4)], 'attempts'=>6]; header('Content-Type: application/json'); echo json_encode(['ok'=>true]); exit; } // معالجة طلبات أخرى (لا نستخدم السيرفر لاختيارات المواعدة هنا، يتم حسابها في العميل) // --- HTML + CSS + JS ?>
php -S localhost:8000